diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4e73779 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.idea/ +target/ +.vscode/ +*.iml +nb-configuration.xml +nbactions.xml +*.log diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..054ec78 --- /dev/null +++ b/pom.xml @@ -0,0 +1,588 @@ + + + 4.0.0 + + com.unicenta + unicentaopos + 5.0 + jar + + UTF-8 + 11 + 11 + + + + + org.xerial + sqlite-jdbc + 3.7.2 + + + + org.openjfx + javafx-base + 11 + + + org.openjfx + javafx-controls + 11 + + + org.openjfx + javafx-fxml + 11 + + + org.openjfx + javafx-graphics + 11 + + + org.openjfx + javafx-media + 11 + + + org.openjfx + javafx-swing + 11 + + + org.openjfx + javafx-web + 11 + + + org.mariadb.jdbc + mariadb-java-client + 2.7.0 + + + org.projectlombok + lombok + 1.18.6 + provided + + + ch.qos.logback + logback-classic + 1.2.2 + + + org.jfree + jcommon + 1.0.24 + + + org.jfree + jfreechart + 1.0.19 + + + + commons-beanutils + commons-beanutils + 1.9.3 + + + commons-digester + commons-digester + 2.1 + + + com.lowagie + itext + 2.1.7 + + + org.apache.poi + poi + 3.10.1 + + + net.sf.barcode4j + barcode4j + 2.1 + + + commons-codec + commons-codec + 1.10 + + + org.apache.velocity + velocity + 1.7 + + + oro + oro + 2.0.8 + + + commons-collections + commons-collections + 3.2.2 + + + commons-lang + commons-lang + 2.6 + + + org.beanshell + bsh + 2.0b4 + + + org.bidib.jbidib.org.qbang.rxtx + rxtxcomm + 2.2 + + + org.jpos + jpos + 2.0.10 + + + org.slf4j + slf4j-nop + + + org.slf4j + slf4j-api + + + + + + org.swinglabs.swingx + swingx-all + 1.6.5-1 + + + axis + axis + 1.4 + + + org.apache.axis + axis-jaxrpc + 1.4 + + + javax.xml.soap + saaj-api + 1.3.5 + + + axis + axis-wsdl4j + 1.5.1 + + + commons-discovery + commons-discovery + 0.5 + + + + org.swinglabs + swing-layout + 1.0.3 + + + net.sourceforge.javacsv + javacsv + 2.0 + + + org.netbeans.external + AbsoluteLayout + RELEASE82 + + + com.javapos + jpos + 1.13 + + + mysql + mysql-connector-java + 5.1.39 + + + org.apache.derby + derby + 10.14.2.0 + + + xml-apis + xml-apis + 1.0.b2 + + + + + org.apache.xmlgraphics + fop + 2.1 + + + net.sf.jasperreports + jasperreports + 6.4.0 + + + com.lowagie + itext + + + + + net.sf.jasperreports + jasperreports-fonts + 6.0.0 + + + ar.com.fdvs + DynamicJasper-core-fonts + 2.0 + + + + org.eclipse.jdt.core.compiler + ecj + 4.6.1 + + + + joda-time + joda-time + 2.9.7 + + + + + com.formdev + flatlaf-intellij-themes + 2.0.1 + + + + com.formdev + flatlaf + 1.6.5 + + + + com.formdev + flatlaf-swingx + 1.6.5 + + + org.reflections + reflections + 0.9.12 + + + + de.sciss + weblaf + 1.2.9 + + + org.slf4j + slf4j-nop + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-simple + + + + + com.unicenta + unicenta-plugins + 1.1 + + + uk.co.pos_apps + openbravo + 1.0-SNAPSHOT + + + com.gluonhq + charm-glisten + 6.2.2 + + + javax.xml.bind + jaxb-api + 2.3.0 + + + javax.persistence + persistence-api + 1.0.2 + + + com.dalsemi.onewire + OneWireAPI + 0.1 + + + + org.usb4java + usb4java + 1.2.0 + + + javax.usb + usb-api + 1.0.2 + + + org.jdatepicker + jdatepicker + 1.3.4 + + + + com.sleepycat + je + 5.0.73 + + + org.pushingpixels + trident + 1.4 + + + org.pushingpixels + substance + 7.1.00 + + + + org.postgresql + postgresql + 9.4.1208 + + + de.sciss + weblaf-ui + 2.1.3 + jar + + + + junit + junit + 4.12 + test + + + org.mockito + mockito-inline + 4.2.0 + + + org.mockito + mockito-junit-jupiter + 4.2.0 + test + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.10 + + + copy-dependencies + prepare-package + + copy-dependencies + + + ${project.build.directory}/lib + false + false + true + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + + true + lib/ + com.unicenta.pos.forms.StartPOS + + + unicenta-pos + ${project.version} + com.unicenta + unicenta.com + + + + + + maven-resources-plugin + 2.7 + + + copy-resources + validate + + copy-resources + + + ${project.build.directory} + + + ${basedir}/target/lib/Windows + ${basedir}/src/other/Windows + false + + + ${basedir}/target/lib/Linux + ${basedir}/src/other/Linux + false + + + ${basedir}/target/lib/Mac_OS_X + ${basedir}/src/other/Mac_OS_X + false + + + ${basedir}/target/ + ${basedir}/src/scripts + false + + + ${basedir}/target/Bonus + ${basedir}/src/other/Bonus + false + + + ${basedir}/target/Configs + ${basedir}/src/other/Configs + false + + + ${basedir}/target/Templates + ${basedir}/src/other/Templates + false + + + ${basedir}/target + ${basedir}/src/other/images + false + + + ${basedir}/target + ${basedir}/src/other/license + false + + + ${basedir}/target/reports/com + ${basedir}/src/main/resources/com + false + + + ${basedir}/target/locales + ${basedir}/src/main/resources + false + + com/** + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + true + true + + + + + + org.apache.maven.wagon + wagon-ftp + 2.10 + + + unicentaopos + + + + charm-glisten + charm-glisten Repository + https://nexus.gluonhq.com/nexus/content/repositories/releases/ + default + + + unicenta-repo + https://repo.unicenta.org/maven2/ + default + + + central + https://repo1.maven.org/maven2/ + default + + + + netbeans + NetBeans + https://netbeans.apidesign.org/maven2/ + + + + flatlaf + flatlaf + https://dev.webswing.org/public/nexus/repository/webswing-3rd-parties// + + + + + unicenta-repo + ftp://repo.unicenta.org/ + false + + + unicenta-opos + diff --git a/src/main/java/com/unicenta/basic/BasicException.java b/src/main/java/com/unicenta/basic/BasicException.java new file mode 100644 index 0000000..fed648f --- /dev/null +++ b/src/main/java/com/unicenta/basic/BasicException.java @@ -0,0 +1,58 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.basic; + +/** + * + * @author JG uniCenta + */ +public class BasicException extends java.lang.Exception { + + /** + * Creates a new instance of DataException without detail message. + */ + public BasicException() { + } + + /** + * + * @param msg + */ + public BasicException(String msg) { + super(msg); + } + + /** + * + * @param msg + * @param cause + */ + public BasicException(String msg, Throwable cause) { + super(msg, cause); + } + + /** + * + * @param cause + */ + public BasicException(Throwable cause) { + super(cause); + } +} diff --git a/src/main/java/com/unicenta/beans/DateUtils.java b/src/main/java/com/unicenta/beans/DateUtils.java new file mode 100644 index 0000000..c412f5d --- /dev/null +++ b/src/main/java/com/unicenta/beans/DateUtils.java @@ -0,0 +1,121 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +/** + * + * @author JG uniCenta + */ +public class DateUtils { + + /** Creates a new instance of DateUtils */ + private DateUtils() { + } + + /** + * + * @return + */ + public static Date getToday() { + // el dia de hoy sin horas ni nada. + return getToday(new Date()); + } + + /** + * + * @param d + * @return + */ + public static Date getToday(Date d) { + // el dia de hoy sin horas ni nada. + GregorianCalendar ddate = new GregorianCalendar(); + ddate.setTime(d); + GregorianCalendar ddateday = new GregorianCalendar(ddate.get(GregorianCalendar.YEAR), ddate.get(GregorianCalendar.MONTH), ddate.get(GregorianCalendar.DAY_OF_MONTH)); + return ddateday.getTime(); + } + + /** + * + * @return + */ + public static Date getTodayMinutes() { + // el dia de hoy sin horas ni nada. + return getTodayMinutes(new Date()); + } + + /** + * + * @param d + * @return + */ + public static Date getTodayMinutes(Date d) { + // el dia de hoy sin horas ni nada. + GregorianCalendar ddate = new GregorianCalendar(); + ddate.setTime(d); + GregorianCalendar ddateday = new GregorianCalendar(ddate.get(GregorianCalendar.YEAR), ddate.get(GregorianCalendar.MONTH), ddate.get(GregorianCalendar.DAY_OF_MONTH) + , ddate.get(GregorianCalendar.HOUR_OF_DAY), ddate.get(GregorianCalendar.MINUTE)); + return ddateday.getTime(); + } + + /** + * + * @param d + * @return + */ + public static Date getTodayHours(Date d) { + // el dia ajustado a las horeas + Calendar ddate = Calendar.getInstance(); + ddate.setTime(d); + + Calendar dNow = Calendar.getInstance(); + dNow.clear(); + dNow.set(ddate.get(Calendar.YEAR), ddate.get(Calendar.MONTH), ddate.get(Calendar.DAY_OF_MONTH) + , ddate.get(Calendar.HOUR_OF_DAY), 0, 0); + + return dNow.getTime(); + } + + /** + * + * @param day + * @param hour + * @return + */ + public static Date getDate(Date day, Date hour) { + + // Calculamos el dia actual con la hora escogida. + Calendar dDay = Calendar.getInstance(); + dDay.setTime(day); + Calendar dHour = Calendar.getInstance(); + dHour.setTime(hour); + + Calendar dNow = Calendar.getInstance(); + dNow.clear(); + dNow.set(dDay.get(Calendar.YEAR), dDay.get(Calendar.MONTH), dDay.get(Calendar.DAY_OF_MONTH) + , dHour.get(Calendar.HOUR_OF_DAY), dHour.get(Calendar.MINUTE), dHour.get(Calendar.SECOND)); + + return dNow.getTime(); + } + +} diff --git a/src/main/java/com/unicenta/beans/JCalendarDialog.form b/src/main/java/com/unicenta/beans/JCalendarDialog.form new file mode 100644 index 0000000..83063f6 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JCalendarDialog.form @@ -0,0 +1,118 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/beans/JCalendarDialog.java b/src/main/java/com/unicenta/beans/JCalendarDialog.java new file mode 100644 index 0000000..e170d87 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JCalendarDialog.java @@ -0,0 +1,274 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import java.awt.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import javax.swing.*; +import java.util.*; + +/** + * + * @author Adrian + */ +public class JCalendarDialog extends javax.swing.JDialog { + + // private static ResourceBundle m_Intl; + private static LocaleResources m_resources; + + private Date m_date; + private JCalendarPanel myCalendar = null; + private JTimePanel myTime = null; + + /** Creates new form JCalendarDialog + * @param parent + * @param modal */ + public JCalendarDialog(java.awt.Frame parent, boolean modal) { + super(parent, modal); + + if (m_resources == null) { + m_resources = new LocaleResources(); + m_resources.addBundleName("beans_messages"); + } else { + } + } + /** Creates new form JCalendarDialog + * @param parent + * @param modal */ + public JCalendarDialog(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + + if (m_resources != null) { + } else { + m_resources = new LocaleResources(); + m_resources.addBundleName("beans_messages"); + } + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window) parent; + } else { + return getWindow(parent.getParent()); + } + } + + /** + * + * @param parent + * @param date + * @return + */ + public static Date showCalendarTimeHours(Component parent, Date date) { + return internalCalendarTime(parent, date == null ? DateUtils.getToday() : date, true); + } + + /** + * + * @param parent + * @param date + * @return + */ + public static Date showCalendarTime(Component parent, Date date) { + return internalCalendarTime(parent, date == null ? DateUtils.getTodayMinutes() : date, true); + } + + /** + * + * @param parent + * @param date + * @return + */ + public static Date showCalendar(Component parent, Date date) { + return internalCalendarTime(parent, date == null ? DateUtils.getTodayMinutes() : date, false); + } + + private static Date internalCalendarTime(Component parent, Date date, boolean bTimePanel) { + + Window window = getWindow(parent); + + JCalendarDialog myMsg; + if (window instanceof Frame) { + myMsg = new JCalendarDialog((Frame) window, true); + } else { + myMsg = new JCalendarDialog((Dialog) window, true); + } + + myMsg.initComponents(); + + Date d = date; + int dialogwidth = 400; + + myMsg.myCalendar = new JCalendarPanel(d); + myMsg.myCalendar.addPropertyChangeListener("Date", new JPanelCalendarChange(myMsg)); + myMsg.jPanelGrid.add(myMsg.myCalendar); + + if (bTimePanel) { + myMsg.myTime = new JTimePanel(d); + myMsg.myTime.addPropertyChangeListener("Date", new JPanelTimeChange(myMsg)); + myMsg.jPanelGrid.add(myMsg.myTime); + dialogwidth += 400; + } + + myMsg.getRootPane().setDefaultButton(myMsg.jcmdOK); + + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + myMsg.setBounds((screenSize.width - dialogwidth) / 2, (screenSize.height - 359) / 2, dialogwidth, 359); + + //myMsg.show(); + myMsg.m_date = null; + myMsg.setVisible(true); + return myMsg.m_date; + } + + private static class JPanelTimeChange implements PropertyChangeListener { + private final JCalendarDialog m_me; + public JPanelTimeChange(JCalendarDialog me) { + m_me = me; + } + @Override + public void propertyChange(PropertyChangeEvent evt) { + m_me.myCalendar.setDate(m_me.myTime.getDate()); + } + } + + private static class JPanelCalendarChange implements PropertyChangeListener { + private final JCalendarDialog m_me; + public JPanelCalendarChange(JCalendarDialog me) { + m_me = me; + } + @Override + public void propertyChange(PropertyChangeEvent evt) { + m_me.myTime.setDate(m_me.myCalendar.getDate()); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jcmdOK = new javax.swing.JButton(); + jcmdCancel = new javax.swing.JButton(); + jPanel2 = new javax.swing.JPanel(); + jPanelGrid = new javax.swing.JPanel(); + + setTitle(m_resources.getString("title.calendar")); // NOI18N + setResizable(false); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + closeWindow(evt); + } + }); + + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setText(m_resources.getString("button.ok")); // NOI18N + jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel1.add(jcmdOK); + + jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setText(m_resources.getString("button.cancel")); // NOI18N + jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel1.add(jcmdCancel); + + getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH); + + jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel2.setLayout(new java.awt.BorderLayout()); + + jPanelGrid.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanelGrid.setLayout(new java.awt.GridLayout(1, 0, 5, 0)); + jPanel2.add(jPanelGrid, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER); + }// //GEN-END:initComponents + + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + GregorianCalendar dateresult; + + GregorianCalendar date1 = new GregorianCalendar(); + date1.setTime(myCalendar.getDate()); + + if (myTime == null) { + dateresult = new GregorianCalendar( + date1.get(GregorianCalendar.YEAR), + date1.get(GregorianCalendar.MONTH), + date1.get(GregorianCalendar.DAY_OF_MONTH)); + + } else { + GregorianCalendar date2 = new GregorianCalendar(); + date2.setTime(myTime.getDate()); + dateresult = new GregorianCalendar( + date1.get(GregorianCalendar.YEAR), + date1.get(GregorianCalendar.MONTH), + date1.get(GregorianCalendar.DAY_OF_MONTH), + date2.get(GregorianCalendar.HOUR_OF_DAY), + date2.get(GregorianCalendar.MINUTE)); + } + + m_date = dateresult.getTime(); + + setVisible(false); + dispose(); + }//GEN-LAST:event_jcmdOKActionPerformed + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + setVisible(false); + dispose(); + }//GEN-LAST:event_jcmdCancelActionPerformed + + private void closeWindow(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeWindow + + setVisible(false); + dispose(); + }//GEN-LAST:event_closeWindow + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanelGrid; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/beans/JCalendarPanel.form b/src/main/java/com/unicenta/beans/JCalendarPanel.form new file mode 100644 index 0000000..9aceef4 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JCalendarPanel.form @@ -0,0 +1,134 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/beans/JCalendarPanel.java b/src/main/java/com/unicenta/beans/JCalendarPanel.java new file mode 100644 index 0000000..e8bb895 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JCalendarPanel.java @@ -0,0 +1,376 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.*; +import java.util.*; +import javax.swing.*; +import javax.swing.border.LineBorder; + +/** + * + * @author JG uniCenta + */ +public class JCalendarPanel extends javax.swing.JPanel { + + // private static ResourceBundle m_Intl; + private static LocaleResources m_resources; + + private static GregorianCalendar m_CalendarHelper = new GregorianCalendar(); // solo de ayuda + + private Date m_date; + private JButtonDate[] m_ListDates; + private JLabel[] m_jDays; + + private JButtonDate m_jCurrent; + private JButtonDate m_jBtnMonthInc; + private JButtonDate m_jBtnMonthDec; + private JButtonDate m_jBtnYearInc; + private JButtonDate m_jBtnYearDec; + private JButtonDate m_jBtnToday; + + private DateFormat fmtMonthYear = new SimpleDateFormat("MMMMM yyyy"); + + /** Creates new form JCalendarPanel2 */ + public JCalendarPanel() { + this(new Date()); + } + + /** + * + * @param dDate + */ + public JCalendarPanel(Date dDate) { + + super(); + + if (m_resources == null) { + m_resources = new LocaleResources(); + m_resources.addBundleName("beans_messages"); + } + + initComponents(); + initComponents2(); + +// m_CalendarHelper = new GregorianCalendar(); +// m_CalendarHelper.setTime(dDate); + m_date = dDate; + + // pintamos + renderMonth(); + renderDay(); + } + + /** + * + * @param dNewDate + */ + public void setDate(Date dNewDate) { + + // cambiamos la fecha + Date dOldDate = m_date; + m_date = dNewDate; + + // pintamos + renderMonth(); + renderDay(); + + // decimos al mundo que ha cambiado la propiedad fecha + firePropertyChange("Date", dOldDate, dNewDate); + } + + /** + * + * @return + */ + public Date getDate() { + return m_date; + } + + public void setEnabled(boolean bValue) { + + super.setEnabled(bValue); + + // pintamos + renderMonth(); + renderDay(); + } + + private void renderMonth() { + +// GregorianCalendar oCalRender = new GregorianCalendar(); +// oCalRender.setTime(m_CalendarHelper.getTime()); + + for (int j = 0; j < 7; j++) { + m_jDays[j].setEnabled(isEnabled()); + } + + // Borramos todos los dias + for(int i = 0; i < 42; i++) { + JButtonDate jAux = m_ListDates[i]; + jAux.DateInf = null; + jAux.setEnabled(false); + jAux.setText(null); + jAux.setForeground((Color)UIManager.getDefaults().get("TextPane.foreground")); + jAux.setBackground((Color)UIManager.getDefaults().get("TextPane.background")); + jAux.setBorder(null); + } + + if (m_date == null) { + m_jLblMonth.setEnabled(isEnabled()); + m_jLblMonth.setText(null); + } else { + m_CalendarHelper.setTime(m_date); + + m_jLblMonth.setEnabled(isEnabled()); + m_jLblMonth.setText(fmtMonthYear.format(m_CalendarHelper.getTime())); + + int iCurrentMonth = m_CalendarHelper.get(Calendar.MONTH); + m_CalendarHelper.set(Calendar.DAY_OF_MONTH, 1); + + while(m_CalendarHelper.get(Calendar.MONTH) == iCurrentMonth) { + + JButtonDate jAux = getLabelByDate(m_CalendarHelper.getTime()); + jAux.DateInf = m_CalendarHelper.getTime(); + jAux.setEnabled(isEnabled()); + jAux.setText(String.valueOf(m_CalendarHelper.get(Calendar.DAY_OF_MONTH))); + + m_CalendarHelper.add(Calendar.DATE, 1); + } + } + + m_jCurrent = null; + } + + private void renderDay() { + + m_jBtnToday.setEnabled(isEnabled()); + + if (m_date == null) { + m_jBtnMonthDec.setEnabled(false); + m_jBtnMonthInc.setEnabled(isEnabled()); + m_jBtnYearDec.setEnabled(isEnabled()); + m_jBtnYearInc.setEnabled(isEnabled()); + } else { + m_CalendarHelper.setTime(m_date); + + m_CalendarHelper.add(Calendar.MONTH, -1); + m_jBtnMonthDec.DateInf = m_CalendarHelper.getTime(); + m_jBtnMonthDec.setEnabled(isEnabled()); + m_CalendarHelper.add(Calendar.MONTH, 2); + m_jBtnMonthInc.DateInf = m_CalendarHelper.getTime(); + m_jBtnMonthInc.setEnabled(isEnabled()); + + m_CalendarHelper.setTime(m_date); + m_CalendarHelper.add(Calendar.YEAR, -1); + m_jBtnYearDec.DateInf = m_CalendarHelper.getTime(); + m_jBtnYearDec.setEnabled(isEnabled()); + m_CalendarHelper.add(Calendar.YEAR, 2); + m_jBtnYearInc.DateInf = m_CalendarHelper.getTime(); + m_jBtnYearInc.setEnabled(isEnabled()); + + if(m_jCurrent != null) { + m_jCurrent.setForeground((Color)UIManager.getDefaults().get("TextPane.foreground")); + m_jCurrent.setBackground((Color)UIManager.getDefaults().get("TextPane.background")); + m_jCurrent.setBorder(null); + } + + JButtonDate jAux = getLabelByDate(m_date); + jAux.setBackground((Color)UIManager.getDefaults().get("TextPane.selectionBackground")); + jAux.setForeground((Color)UIManager.getDefaults().get("TextPane.selectionForeground")); + jAux.setBorder(new LineBorder((Color)UIManager.getDefaults().get("TitledBorder.titleColor"))); + m_jCurrent = jAux; + } + } + + private JButtonDate getLabelByDate(Date d) { + + GregorianCalendar oCalRender = new GregorianCalendar(); + oCalRender.setTime(d); + int iDayOfMonth = oCalRender.get(Calendar.DAY_OF_MONTH); + + oCalRender.set(Calendar.DAY_OF_MONTH, 1); + + int iCol = oCalRender.get(Calendar.DAY_OF_WEEK) - oCalRender.getFirstDayOfWeek(); + if (iCol < 0) { + iCol += 7; + } + return m_ListDates[iCol + iDayOfMonth - 1]; + } + + private class DateClick implements ActionListener { + + public void actionPerformed(ActionEvent e) { + JButtonDate oLbl = (JButtonDate)e.getSource(); + if(oLbl.DateInf != null) { + setDate(oLbl.DateInf); + } + } + } + + private static class JButtonDate extends JButton { + + public Date DateInf; + + public JButtonDate(ActionListener datehandler) { + super(); + initComponent(); + addActionListener(datehandler); + } + public JButtonDate(String sText, ActionListener datehandler) { + super(sText); + initComponent(); + addActionListener(datehandler); + } + public JButtonDate(Icon icon, ActionListener datehandler) { + super(icon); + initComponent(); + addActionListener(datehandler); + } + + private void initComponent() { + DateInf = null; + setRequestFocusEnabled(false); + setFocusPainted(false); + setFocusable(false); + } + } + + private void initComponents2() { + + ActionListener dateclick = new DateClick(); + + m_jBtnYearDec = new JButtonDate(new ImageIcon(getClass().getResource("/com/unicenta/images/2leftarrow.png")), dateclick); + m_jBtnMonthDec = new JButtonDate(new ImageIcon(getClass().getResource("/com/unicenta/images/1leftarrow.png")), dateclick); + m_jBtnToday = new JButtonDate(m_resources.getString("button.Today"), dateclick); + m_jBtnMonthInc = new JButtonDate(new ImageIcon(getClass().getResource("/com/unicenta/images/1rightarrow.png")), dateclick); + m_jBtnYearInc = new JButtonDate(new ImageIcon(getClass().getResource("/com/unicenta/images/2rightarrow.png")), dateclick); + + m_jBtnToday.DateInf = new Date(); + m_jActions.add(m_jBtnYearDec); + m_jActions.add(m_jBtnMonthDec); + m_jActions.add(m_jBtnToday); + m_jActions.add(m_jBtnMonthInc); + m_jActions.add(m_jBtnYearInc); + + m_ListDates = new JButtonDate[42]; + for(int i = 0; i < 42; i++) { + JButtonDate jAux = new JButtonDate(dateclick); + // jAux.setFont(new Font("Dialog", 1, 24)); + jAux.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jAux.setText(null); + jAux.setOpaque(true); + jAux.setForeground((Color)UIManager.getDefaults().get("TextPane.foreground")); + jAux.setBackground((Color)UIManager.getDefaults().get("TextPane.background")); + jAux.setBorder(null); + m_ListDates[i] = jAux; + m_jDates.add(jAux); + } + + m_jDays = new JLabel[7]; + for(int iHead = 0; iHead < 7; iHead++) { + JLabel JAuxHeader = new JLabel(); + //JAuxHeader.setFont(new Font("Dialog", 1, 24)); + JAuxHeader.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jDays[iHead] = JAuxHeader; + m_jWeekDays.add(JAuxHeader); + } + + DateFormat fmtWeekDay = new SimpleDateFormat("E"); + Calendar oCalRender = new GregorianCalendar(); + int iCol; + for (int j = 0; j < 7; j++) { + oCalRender.add(Calendar.DATE, 1); + iCol = oCalRender.get(Calendar.DAY_OF_WEEK) - oCalRender.getFirstDayOfWeek(); + if (iCol < 0) { + iCol += 7; + } + m_jDays[iCol].setText(fmtWeekDay.format(oCalRender.getTime())); + } + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + m_jMonth = new javax.swing.JPanel(); + m_jWeekDays = new javax.swing.JPanel(); + m_jDates = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + m_jLblMonth = new javax.swing.JLabel(); + jPanel3 = new javax.swing.JPanel(); + m_jActions = new javax.swing.JPanel(); + + setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + setLayout(new java.awt.BorderLayout()); + + jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + jPanel1.setLayout(new java.awt.BorderLayout()); + + m_jMonth.setLayout(new java.awt.BorderLayout()); + + m_jWeekDays.setLayout(new java.awt.GridLayout(1, 7)); + m_jMonth.add(m_jWeekDays, java.awt.BorderLayout.NORTH); + + m_jDates.setBackground(javax.swing.UIManager.getDefaults().getColor("TextPane.background")); + m_jDates.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jDates.setLayout(new java.awt.GridLayout(6, 7)); + m_jMonth.add(m_jDates, java.awt.BorderLayout.CENTER); + + jPanel1.add(m_jMonth, java.awt.BorderLayout.CENTER); + + m_jLblMonth.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N + jPanel2.add(m_jLblMonth); + + jPanel1.add(jPanel2, java.awt.BorderLayout.NORTH); + + add(jPanel1, java.awt.BorderLayout.CENTER); + + jPanel3.setLayout(new java.awt.BorderLayout()); + + m_jActions.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5)); + m_jActions.setLayout(new java.awt.GridLayout(0, 1, 0, 5)); + jPanel3.add(m_jActions, java.awt.BorderLayout.NORTH); + + add(jPanel3, java.awt.BorderLayout.LINE_END); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel m_jActions; + private javax.swing.JPanel m_jDates; + private javax.swing.JLabel m_jLblMonth; + private javax.swing.JPanel m_jMonth; + private javax.swing.JPanel m_jWeekDays; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/beans/JClockPanel.form b/src/main/java/com/unicenta/beans/JClockPanel.form new file mode 100644 index 0000000..5c32496 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JClockPanel.form @@ -0,0 +1,22 @@ + + +
+ + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/beans/JClockPanel.java b/src/main/java/com/unicenta/beans/JClockPanel.java new file mode 100644 index 0000000..8924fa4 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JClockPanel.java @@ -0,0 +1,252 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.RenderingHints; +import java.awt.geom.AffineTransform; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +/** + * + * @author JG uniCenta + */ +public class JClockPanel extends javax.swing.JPanel { + + private static Calendar m_calendar = new GregorianCalendar(); // solo de ayuda... + + private Date m_date; + private boolean m_bSeconds; + private long m_lPeriod; + + /** Creates new form JClockPanel */ + public JClockPanel() { + this(true); + } + + /** + * + * @param bSeconds + */ + public JClockPanel(boolean bSeconds) { + + initComponents(); + + m_bSeconds = bSeconds; + m_date = null; + m_lPeriod = 0L; + } + + /** + * + * @param bValue + */ + public void setSecondsVisible(boolean bValue) { + m_bSeconds = bValue; + repaint(); + } + + /** + * + * @return + */ + public boolean isSecondsVisible() { + return m_bSeconds; + } + + /** + * + * @param period + */ + public void setPeriod(long period) { + if (period >= 0L) { + m_lPeriod = period; + repaint(); + } + } + + /** + * + * @return + */ + public long getPeriod() { + return m_lPeriod; + } + + /** + * + * @param dDate + */ + public void setTime(Date dDate){ + m_date = dDate; + repaint(); + } + + /** + * + * @return + */ + public Date getTime() { + return m_date; + } + + @Override + public void paintComponent(Graphics g) { + + super.paintComponent(g); + + int width = getWidth(); + int height = getHeight(); + + double dhour = 0.0; + double dminute = 0.0; + double dsecond = 0.0; + + // Calculo los atributos de la hora que voy a pintar + if (m_date != null) { + m_calendar.setTime(m_date); + dhour = (double) m_calendar.get(Calendar.HOUR_OF_DAY); + dminute = (double) m_calendar.get(Calendar.MINUTE); + dsecond = (double) m_calendar.get(Calendar.SECOND); + } + + Graphics2D g2 = (Graphics2D) g; + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + // guardo los valores iniciales + Paint oldPainter = g2.getPaint(); + AffineTransform oldt = g2.getTransform(); + + // pinto el fondo +// g2.setPaint(new GradientPaint(0, 0, Color.WHITE, width, 0, Color.LIGHT_GRAY)); +// g2.fill(g2.getClip()); + + // Calculo el centro y el tamano del reloj + int icenterx = width / 2; + int icentery = height / 2; + int iradius = Math.min(icenterx, icentery); + + // Centro las coordenadas y ajusto la transformacion del tamano del reloj + g2.transform(AffineTransform.getTranslateInstance(icenterx, icentery)); + g2.transform(AffineTransform.getScaleInstance(iradius / 1100.0 , iradius / 1100.0)); + AffineTransform mytrans = g2.getTransform(); + + // Pinto la esfera del reloj; + g2.setPaint(this.isEnabled() + ? new GradientPaint(-1200, -1200, Color.BLUE, 1200, 1200, Color.CYAN) + : new GradientPaint(-1200, -1200, Color.GRAY, 1200, 1200, Color.LIGHT_GRAY)); + g2.fillOval(-1000, -1000, 2000, 2000); + g2.setPaint(this.isEnabled() + ? new GradientPaint(-1200, -1200, Color.CYAN, 1200, 1200, Color.BLUE) + : new GradientPaint(-1200, -1200, Color.LIGHT_GRAY, 1200, 1200, Color.GRAY)); + g2.fillOval(-900, -900, 1800, 1800); + g2.setColor(Color.BLACK); + g2.drawOval(-1000, -1000, 2000, 2000); + + // Pinto las marcas pequenas, los minutos + for (int i = 0; i < 60; i++) { + g2.setColor(Color.WHITE); + g2.fillRect(900, -5 , 50, 10); + g2.transform(AffineTransform.getRotateInstance(Math.PI / 30.0)); + } + + // Pinto las marcas grandes, las horas. + g2.setTransform(mytrans); + for (int i = 0; i < 12; i++) { + g2.setColor(Color.WHITE); + g2.fillRect(800, -15 , 150, 30); + // g2.setColor(Color.BLACK); + // g2.drawRect(800, -15 , 150, 30); + g2.transform(AffineTransform.getRotateInstance(Math.PI / 6.0)); + } + + if (m_date != null) { + // Aguja de las horas + g2.setTransform(mytrans); + g2.transform(AffineTransform.getRotateInstance((dhour + dminute / 60.0) * Math.PI / 6.0)); // Poner hora + + if (m_lPeriod > 0L) { // pintamos la marca del periodo... + // dibujo un arco con el periodo seleccionado... + int iArc = (int) (m_lPeriod / 120000L); + g2.setColor(new Color(255, 255, 255, 100)); + g2.fillArc(-1000, -1000, 2000, 2000, 90 - iArc, iArc); + g2.setColor(Color.DARK_GRAY); + g2.drawArc(-1000, -1000, 2000, 2000, 90 - iArc, iArc); + } else { + // la aguja de las horas + g2.setColor(Color.WHITE); + g2.fillPolygon(new int[]{0, -35, 0, 35}, new int[]{100, 0, -600, 0}, 4); + g2.setColor(Color.DARK_GRAY); + g2.drawPolygon(new int[]{0, -35, 0, 35}, new int[]{100, 0, -600, 0}, 4); + + // Aguja de los minutos + g2.setTransform(mytrans); + g2.transform(AffineTransform.getRotateInstance((dminute) * Math.PI / 30.0)); // Poner minutos + g2.setColor(Color.WHITE); + g2.fillPolygon(new int[]{0, -35, 0, 35}, new int[]{100, 0, -900, 0}, 4); + g2.setColor(Color.DARK_GRAY); + g2.drawPolygon(new int[]{0, -35, 0, 35}, new int[]{100, 0, -900, 0}, 4); + + // Aguja de los segundos + if (m_bSeconds) { + g2.setTransform(mytrans); + g2.transform(AffineTransform.getRotateInstance(dsecond * Math.PI / 30.0)); // Poner segundos + g2.setColor(Color.YELLOW); + g2.fillPolygon(new int[]{-15, 0, 15}, new int[]{200, -900, 200}, 3); + g2.setColor(Color.DARK_GRAY); + g2.drawPolygon(new int[]{-15, 0, 15}, new int[]{200, -900, 200}, 3); + + g2.setTransform(mytrans); + g2.setColor(Color.YELLOW); + g2.fillOval(-25, -25, 50, 50); + g2.setColor(Color.DARK_GRAY); + g2.drawOval(-25, -25, 50, 50); + } + } + } + + // Pinto el tornillo central + g2.setColor(Color.WHITE); + g2.fillOval(-10, -10, 20, 20); + g2.setColor(Color.BLACK); + g2.drawOval(-10, -10, 20, 20); + + // restauro los valores iniciales + g2.setTransform(oldt); + g2.setPaint(oldPainter); + } + + // //GEN-BEGIN:initComponents + private void initComponents() { + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/beans/JFlowPanel.java b/src/main/java/com/unicenta/beans/JFlowPanel.java new file mode 100644 index 0000000..c47a7f1 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JFlowPanel.java @@ -0,0 +1,214 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import java.awt.Component; +import java.awt.ComponentOrientation; +import java.awt.Dimension; +import java.awt.Rectangle; +import javax.swing.JPanel; +import javax.swing.JViewport; +import javax.swing.Scrollable; +import javax.swing.SwingConstants; + +/** + * + * @author JG uniCenta + */ +public class JFlowPanel extends JPanel implements Scrollable { + + private int hgap = 5; + private int vgap = 5; + + /** + * + */ + public JFlowPanel() { + this(5, 5); + } + + /** + * + * @param hgap + * @param vgap + */ + public JFlowPanel(int hgap, int vgap) { + this.hgap = hgap; + this.vgap = vgap; + } + + /** + * + * @param iValue + */ + public void setHorizontalGap(int iValue) { + hgap = iValue; + } + + /** + * + * @return + */ + public int getHorizontalGap() { + return hgap; + } + + /** + * + * @param iValue + */ + public void setVerticalGap(int iValue) { + vgap = iValue; + } + + /** + * + * @param iValue + * @return + */ + public int getVerticalGap(int iValue) { + return vgap; + } + + private Dimension calculateFlowLayout(boolean bDoChilds) { + Dimension dim = new Dimension(0, hgap); + + int maxWidth; + if (getParent() != null && getParent() instanceof JViewport) { + JViewport viewport = (JViewport) getParent(); + maxWidth = viewport.getExtentSize().width; + } else if (getParent() != null){ + maxWidth = getParent().getWidth(); + } else { + maxWidth = getWidth(); + } + + synchronized (getTreeLock()) { + int compCount = getComponentCount(); + int maxRowWidth = 0; + int maxRowHeight = 0; + int x = 0; + + for (int i = 0 ; i < compCount ; i++) { + Component m = getComponent(i); + if (m.isVisible()) { + Dimension d = m.getPreferredSize(); + if (x == 0 || (x + hgap + d.width + hgap) <= maxWidth) { + // continuamos con esta linea + x += hgap; + if (bDoChilds) { + m.setBounds(getPosition(x, maxWidth - d.width), dim.height, d.width, d.height); + } + x += d.width; + if (d.height > maxRowHeight) { + maxRowHeight = d.height; + } + } else { + // nueva linea + dim.height += maxRowHeight + vgap; + if (bDoChilds) { + m.setBounds(getPosition(hgap, maxWidth - d.width), dim.height, d.width, d.height); + } + if (x > maxRowWidth) { + maxRowWidth = x; + } + x = hgap + d.width; + maxRowHeight = d.height; + } + } + } + + // calculamos la ultima linea. + dim.height += maxRowHeight + vgap; + if (x > maxRowWidth) { + maxRowWidth = x; + } + dim.width = maxRowWidth; + } + return dim; + } + + private int getPosition(int x, int width) { + if (getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT) { + return width - x ; + } else { + return x; + } + } + + public Dimension getPreferredSize() { + return calculateFlowLayout(false); + } + public Dimension getMinimumSize() { + return calculateFlowLayout(false); + } + public Dimension getMaximumSize() { + return calculateFlowLayout(false); + } + public Dimension getPreferredScrollableViewportSize() { + return calculateFlowLayout(false); + } + + public void doLayout() { + calculateFlowLayout(true); + } + + public boolean getScrollableTracksViewportHeight() { + return (getParent().getHeight() > getPreferredSize().height); + } + + public boolean getScrollableTracksViewportWidth() { + return (getParent().getWidth() > getPreferredSize().width); + } + + public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { + if (getComponentCount() == 0) { + return orientation == SwingConstants.HORIZONTAL ? hgap : vgap; + } else { + return orientation == SwingConstants.HORIZONTAL + ? getComponent(0).getWidth() + hgap + : getComponent(0).getHeight() + vgap; + } + } + + public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { + if (getComponentCount() == 0) { + return orientation == SwingConstants.HORIZONTAL ? hgap : vgap; + } else { + if (orientation == SwingConstants.HORIZONTAL) { + int hunit = getComponent(0).getWidth() + hgap; + return (visibleRect.width / hunit) * hunit; + } else { + int vunit = getComponent(0).getHeight() + vgap; + return (visibleRect.width / vunit) * vunit; + } + } + } + + public void setEnabled(boolean value) { + synchronized (getTreeLock()) { + int compCount = getComponentCount(); + for (int i = 0 ; i < compCount ; i++) { + getComponent(i).setEnabled(value); + } + } + super.setEnabled(value); + } +} diff --git a/src/main/java/com/unicenta/beans/JGuestsPop.form b/src/main/java/com/unicenta/beans/JGuestsPop.form new file mode 100644 index 0000000..6aadfdc --- /dev/null +++ b/src/main/java/com/unicenta/beans/JGuestsPop.form @@ -0,0 +1,175 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/beans/JGuestsPop.java b/src/main/java/com/unicenta/beans/JGuestsPop.java new file mode 100644 index 0000000..5b4bfb0 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JGuestsPop.java @@ -0,0 +1,226 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta - joint with Jacinto Rodriguez +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import com.unicenta.basic.BasicException; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import java.awt.*; + +/** + * Jun 2018 + * @author Jack Gerrard uniCenta + */ +@Slf4j +public class JGuestsPop extends javax.swing.JDialog { + + private static LocaleResources m_resources; + + private Integer m_value; + + /** Creates new form JDinerPop + * @param parent + * @param modal */ + public JGuestsPop(java.awt.Frame parent, boolean modal) { + super(parent, modal); + init(); + } + + /** Creates new form JDinerPop + * @param parent + * @param modal */ + public JGuestsPop(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + init(); + } + + private void init() { + + if (m_resources == null) { + m_resources = new LocaleResources(); + m_resources.addBundleName("beans_messages"); + } + + initComponents(); + getRootPane().setDefaultButton(jcmdOK); + + m_jnumber.addEditorKeys(m_jKeys); + m_jnumber.reset(); + m_jnumber.setValueInteger(1); + m_jnumber.activate(); +// m_jnumber.setVisible(false); + + m_jPanelTitle.setBorder(RoundedBorder.createGradientBorder()); + + m_value = null; + } + + private void setTitle(String title, String message, Icon icon) { + setTitle(title); + m_lblMessage.setText(message); + m_lblMessage.setIcon(icon); + } + + public static Integer showEditNumber(Component parent, String title) { + return showEditNumber(parent, title, null, null); + } + public static Integer showEditNumber(Component parent, String title, String message) { + return showEditNumber(parent, title, message, null); + } + public static Integer showEditNumber(Component parent, String title, String message, Icon icon) { + + Window window = SwingUtilities.windowForComponent(parent); + + JGuestsPop myMsg; + if (window instanceof Frame) { + myMsg = new JGuestsPop((Frame) window, true); + } else { + myMsg = new JGuestsPop((Dialog) window, true); + } + + myMsg.setTitle(title, message, icon); + myMsg.setVisible(true); + return myMsg.m_value; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel2 = new javax.swing.JPanel(); + jPanelGrid = new javax.swing.JPanel(); + jPanel3 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel4 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + m_jnumber = new com.unicenta.editor.JEditorDoublePositive(); + jcmdOK = new javax.swing.JButton(); + m_jPanelTitle = new javax.swing.JPanel(); + m_lblMessage = new javax.swing.JLabel(); + + setResizable(false); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + formWindowClosing(evt); + } + }); + + jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel2.setLayout(new java.awt.BorderLayout()); + + jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS)); + jPanel3.add(m_jKeys); + + jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel4.setLayout(new java.awt.BorderLayout()); + + jPanel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + + m_jnumber.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jnumber.setPreferredSize(new java.awt.Dimension(130, 30)); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(m_jnumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(m_jnumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(20, Short.MAX_VALUE)) + ); + + jPanel4.add(jPanel1, java.awt.BorderLayout.LINE_START); + + jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdOK.setPreferredSize(new java.awt.Dimension(80, 45)); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel4.add(jcmdOK, java.awt.BorderLayout.CENTER); + + jPanel3.add(jPanel4); + + jPanelGrid.add(jPanel3); + + jPanel2.add(jPanelGrid, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER); + + m_jPanelTitle.setLayout(new java.awt.BorderLayout()); + + m_lblMessage.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPanelTitle.add(m_lblMessage, java.awt.BorderLayout.CENTER); + + getContentPane().add(m_jPanelTitle, java.awt.BorderLayout.NORTH); + + setSize(new java.awt.Dimension(328, 409)); + setLocationRelativeTo(null); + }// //GEN-END:initComponents + + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + try { + m_value = m_jnumber.getValueInteger(); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + setVisible(false); + dispose(); + + }//GEN-LAST:event_jcmdOKActionPerformed + + private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing + + setVisible(false); + dispose(); + + }//GEN-LAST:event_formWindowClosing + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanelGrid; + private javax.swing.JButton jcmdOK; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JPanel m_jPanelTitle; + private com.unicenta.editor.JEditorDoublePositive m_jnumber; + private javax.swing.JLabel m_lblMessage; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/beans/JNumberDialog.form b/src/main/java/com/unicenta/beans/JNumberDialog.form new file mode 100644 index 0000000..9169f94 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JNumberDialog.form @@ -0,0 +1,241 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/beans/JNumberDialog.java b/src/main/java/com/unicenta/beans/JNumberDialog.java new file mode 100644 index 0000000..25246e0 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JNumberDialog.java @@ -0,0 +1,300 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Window; +import javax.swing.Icon; +import javax.swing.SwingUtilities; + +/** + * + * @author adrian + */ +public class JNumberDialog extends javax.swing.JDialog { + + private static LocaleResources m_resources; + + private Double m_value; + + /** Creates new form JNumberDialog + * @param parent + * @param modal */ + public JNumberDialog(java.awt.Frame parent, boolean modal) { + super(parent, modal); + init(); + } + + /** Creates new form JNumberDialog + * @param parent + * @param modal */ + public JNumberDialog(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + init(); + } + + public JNumberDialog() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + private void init() { + + if (m_resources == null) { + m_resources = new LocaleResources(); + m_resources.addBundleName("beans_messages"); + } + + initComponents(); + getRootPane().setDefaultButton(jcmdOK); + + m_jnumber.addEditorKeys(m_jKeys); + m_jnumber.reset(); + m_jnumber.setDoubleValue(0.0); + m_jnumber.activate(); + + m_jPanelTitle.setBorder(RoundedBorder.createGradientBorder()); + + m_value = null; + } + + private void setTitle(String title, String message, Icon icon) { + setTitle(title); + m_lblMessage.setText(message); + m_lblMessage.setIcon(icon); + } + + /** + * + * @param parent + * @param title + * @return + */ + public static Double showEditNumber(Component parent, String title) { + return showEditNumber(parent, title, null, null); + } + + /** + * + * @param parent + * @param title + * @param message + * @return + */ + public static Double showEditNumber(Component parent, String title, String message) { + return showEditNumber(parent, title, message, null); + } + + /** + * + * @param parent + * @param title + * @param message + * @param icon + * @return + */ + public static Double showEditNumber(Component parent, String title, String message, Icon icon) { + + Window window = SwingUtilities.windowForComponent(parent); + + JNumberDialog myMsg; + if (window instanceof Frame) { + myMsg = new JNumberDialog((Frame) window, true); + } else { + myMsg = new JNumberDialog((Dialog) window, true); + } + + myMsg.setTitle(title, message, icon); + myMsg.setVisible(true); + return myMsg.m_value; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jcmdCancel = new javax.swing.JButton(); + jcmdOK = new javax.swing.JButton(); + jPanel2 = new javax.swing.JPanel(); + jPanelGrid = new javax.swing.JPanel(); + jPanel3 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel4 = new javax.swing.JPanel(); + m_jnumber = new com.unicenta.editor.JEditorDoublePositive(); + m_jPanelTitle = new javax.swing.JPanel(); + m_lblMessage = new javax.swing.JLabel(); + + setPreferredSize(new java.awt.Dimension(310, 410)); + setResizable(false); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + formWindowClosing(evt); + } + }); + + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setText(m_resources.getString("button.cancel")); // NOI18N + jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel1.add(jcmdCancel); + + jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setText(m_resources.getString("button.ok")); // NOI18N + jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel1.add(jcmdOK); + + jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel2.setLayout(new java.awt.BorderLayout()); + + jPanelGrid.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanelGrid.setPreferredSize(new java.awt.Dimension(300, 320)); + + jPanel3.setPreferredSize(new java.awt.Dimension(300, 350)); + jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS)); + + m_jKeys.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jKeys.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jKeysActionPerformed(evt); + } + }); + jPanel3.add(m_jKeys); + + jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel4.setMinimumSize(new java.awt.Dimension(110, 30)); + jPanel4.setPreferredSize(new java.awt.Dimension(142, 30)); + jPanel4.setLayout(new java.awt.BorderLayout()); + + m_jnumber.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jnumber.setMinimumSize(new java.awt.Dimension(100, 20)); + m_jnumber.setPreferredSize(new java.awt.Dimension(132, 20)); + jPanel4.add(m_jnumber, java.awt.BorderLayout.PAGE_START); + + jPanel3.add(jPanel4); + + javax.swing.GroupLayout jPanelGridLayout = new javax.swing.GroupLayout(jPanelGrid); + jPanelGrid.setLayout(jPanelGridLayout); + jPanelGridLayout.setHorizontalGroup( + jPanelGridLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanelGridLayout.createSequentialGroup() + .addGap(16, 16, 16) + .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + jPanelGridLayout.setVerticalGroup( + jPanelGridLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanelGridLayout.createSequentialGroup() + .addGap(5, 5, 5) + .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 331, Short.MAX_VALUE) + .addGap(0, 0, 0)) + ); + + jPanel2.add(jPanelGrid, java.awt.BorderLayout.CENTER); + + m_jPanelTitle.setLayout(new java.awt.BorderLayout()); + + m_lblMessage.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_lblMessage.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, java.awt.Color.darkGray), javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5))); + m_jPanelTitle.add(m_lblMessage, java.awt.BorderLayout.CENTER); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jPanelTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 342, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 342, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 342, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(m_jPanelTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + + setSize(new java.awt.Dimension(358, 479)); + setLocationRelativeTo(null); + }// //GEN-END:initComponents + + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + + m_value = m_jnumber.getDoubleValue(); + setVisible(false); + dispose(); + + + }//GEN-LAST:event_jcmdOKActionPerformed + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + setVisible(false); + dispose(); + + }//GEN-LAST:event_jcmdCancelActionPerformed + + private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing + + setVisible(false); + dispose(); + + }//GEN-LAST:event_formWindowClosing + + private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed + + }//GEN-LAST:event_m_jKeysActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanelGrid; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JPanel m_jPanelTitle; + private com.unicenta.editor.JEditorDoublePositive m_jnumber; + private javax.swing.JLabel m_lblMessage; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/beans/JNumberEvent.java b/src/main/java/com/unicenta/beans/JNumberEvent.java new file mode 100644 index 0000000..12458a3 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JNumberEvent.java @@ -0,0 +1,51 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import java.util.EventObject; + +/** + * + * @author adrianromero + * @version + */ +public class JNumberEvent extends EventObject { + + private char m_cKey; + + /** + * + * @param source + * @param cKey + */ + public JNumberEvent(Object source, char cKey) { + super(source); + m_cKey = cKey; + } + + /** + * + * @return + */ + public char getKey() { + return m_cKey; + } + +} diff --git a/src/main/java/com/unicenta/beans/JNumberEventListener.java b/src/main/java/com/unicenta/beans/JNumberEventListener.java new file mode 100644 index 0000000..268e064 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JNumberEventListener.java @@ -0,0 +1,35 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import java.util.EventListener; +/** + * + * @author adrian romero + * @version + */ +public interface JNumberEventListener extends EventListener { + + /** + * + * @param e + */ + public void keyPerformed(JNumberEvent e); +} diff --git a/src/main/java/com/unicenta/beans/JNumberKeys.form b/src/main/java/com/unicenta/beans/JNumberKeys.form new file mode 100644 index 0000000..4259836 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JNumberKeys.form @@ -0,0 +1,452 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/beans/JNumberKeys.java b/src/main/java/com/unicenta/beans/JNumberKeys.java new file mode 100644 index 0000000..83c5645 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JNumberKeys.java @@ -0,0 +1,501 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import java.awt.ComponentOrientation; +import java.util.Enumeration; +import java.util.Vector; + +/** + * + * @author JG uniCenta + */ +public class JNumberKeys extends javax.swing.JPanel { + + private Vector m_Listeners = new Vector(); + + private boolean minusenabled = true; + private boolean equalsenabled = true; + + /** Creates new form JNumberKeys */ + public JNumberKeys() { + initComponents (); + + m_jKey0.addActionListener(new MyKeyNumberListener('0')); + m_jKey1.addActionListener(new MyKeyNumberListener('1')); + m_jKey2.addActionListener(new MyKeyNumberListener('2')); + m_jKey3.addActionListener(new MyKeyNumberListener('3')); + m_jKey4.addActionListener(new MyKeyNumberListener('4')); + m_jKey5.addActionListener(new MyKeyNumberListener('5')); + m_jKey6.addActionListener(new MyKeyNumberListener('6')); + m_jKey7.addActionListener(new MyKeyNumberListener('7')); + m_jKey8.addActionListener(new MyKeyNumberListener('8')); + m_jKey9.addActionListener(new MyKeyNumberListener('9')); + m_jKeyDot.addActionListener(new MyKeyNumberListener('.')); + m_jMultiply.addActionListener(new MyKeyNumberListener('*')); + m_jCE.addActionListener(new MyKeyNumberListener('\u007f')); + m_jPlus.addActionListener(new MyKeyNumberListener('+')); + m_jMinus.addActionListener(new MyKeyNumberListener('-')); + m_jEquals.addActionListener(new MyKeyNumberListener('=')); + } + + /** + * + * @param value + */ + public void setNumbersOnly(boolean value) { + m_jEquals.setVisible(value); + m_jMinus.setVisible(value); + m_jPlus.setVisible(value); + m_jMultiply.setVisible(value); + } + + @Override + public void setEnabled(boolean b) { + super.setEnabled(b); + + m_jKey0.setEnabled(b); + m_jKey1.setEnabled(b); + m_jKey2.setEnabled(b); + m_jKey3.setEnabled(b); + m_jKey4.setEnabled(b); + m_jKey5.setEnabled(b); + m_jKey6.setEnabled(b); + m_jKey7.setEnabled(b); + m_jKey8.setEnabled(b); + m_jKey9.setEnabled(b); + m_jKeyDot.setEnabled(b); + m_jMultiply.setEnabled(b); + m_jCE.setEnabled(b); + m_jPlus.setEnabled(b); + m_jMinus.setEnabled(minusenabled && b); + m_jEquals.setEnabled(equalsenabled && b); + } + + @Override + public void setComponentOrientation(ComponentOrientation o) { + // Nothing to change + } + + /** + * + * @param b + */ + public void setMinusEnabled(boolean b) { + minusenabled = b; + m_jMinus.setEnabled(minusenabled && isEnabled()); + } + + /** + * + * @return + */ + public boolean isMinusEnabled() { + return minusenabled; + } + + /** + * + * @param b + */ + public void setEqualsEnabled(boolean b) { + equalsenabled = b; + m_jEquals.setEnabled(equalsenabled && isEnabled()); + } + + /** + * + * @return + */ + public boolean isEqualsEnabled() { + return equalsenabled; + } + + /** + * + * @param enabled + */ + public void dotIs00(boolean enabled) { + if (enabled) { + m_jKeyDot.setIcon(new javax.swing.ImageIcon(getClass() + .getResource("/com/unicenta/images/btn00.png"))); + } + } + + /** + * + * @return + */ + public boolean isNumbersOnly() { + return m_jEquals.isVisible(); + } + + /** + * + * @param listener + */ + public void addJNumberEventListener(JNumberEventListener listener) { + m_Listeners.add(listener); + } + + /** + * + * @param listener + */ + public void removeJNumberEventListener(JNumberEventListener listener) { + m_Listeners.remove(listener); + } + + private class MyKeyNumberListener implements java.awt.event.ActionListener { + + private final char m_cCad; + + public MyKeyNumberListener(char cCad){ + m_cCad = cCad; + } + @Override + public void actionPerformed(java.awt.event.ActionEvent evt) { + + JNumberEvent oEv = new JNumberEvent(JNumberKeys.this, m_cCad); + JNumberEventListener oListener; + + for (Enumeration e = m_Listeners.elements(); e.hasMoreElements();) { + oListener = (JNumberEventListener) e.nextElement(); + oListener.keyPerformed(oEv); + } + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the FormEditor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + m_jCE = new javax.swing.JButton(); + m_jMultiply = new javax.swing.JButton(); + m_jMinus = new javax.swing.JButton(); + m_jPlus = new javax.swing.JButton(); + m_jKey9 = new javax.swing.JButton(); + m_jKey8 = new javax.swing.JButton(); + m_jKey7 = new javax.swing.JButton(); + m_jKey4 = new javax.swing.JButton(); + m_jKey5 = new javax.swing.JButton(); + m_jKey6 = new javax.swing.JButton(); + m_jKey3 = new javax.swing.JButton(); + m_jKey2 = new javax.swing.JButton(); + m_jKey1 = new javax.swing.JButton(); + m_jKey0 = new javax.swing.JButton(); + m_jKeyDot = new javax.swing.JButton(); + m_jEquals = new javax.swing.JButton(); + + setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + setMinimumSize(new java.awt.Dimension(193, 200)); + setPreferredSize(new java.awt.Dimension(193, 200)); + setLayout(new java.awt.GridBagLayout()); + + m_jCE.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btnce.png"))); // NOI18N + m_jCE.setFocusPainted(false); + m_jCE.setFocusable(false); + m_jCE.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jCE.setMaximumSize(new java.awt.Dimension(66, 36)); + m_jCE.setMinimumSize(new java.awt.Dimension(66, 36)); + m_jCE.setPreferredSize(new java.awt.Dimension(66, 36)); + m_jCE.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.gridwidth = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0); + add(m_jCE, gridBagConstraints); + + m_jMultiply.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btnmult.png"))); // NOI18N + m_jMultiply.setFocusPainted(false); + m_jMultiply.setFocusable(false); + m_jMultiply.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jMultiply.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jMultiply.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jMultiply.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jMultiply.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0); + add(m_jMultiply, gridBagConstraints); + + m_jMinus.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btnminus.png"))); // NOI18N + m_jMinus.setFocusPainted(false); + m_jMinus.setFocusable(false); + m_jMinus.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jMinus.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jMinus.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jMinus.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jMinus.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 3; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 0); + add(m_jMinus, gridBagConstraints); + + m_jPlus.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btnplus.png"))); // NOI18N + m_jPlus.setFocusPainted(false); + m_jPlus.setFocusable(false); + m_jPlus.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jPlus.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jPlus.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 3; + gridBagConstraints.gridy = 1; + gridBagConstraints.gridheight = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); + add(m_jPlus, gridBagConstraints); + + m_jKey9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn9.png"))); // NOI18N + m_jKey9.setFocusPainted(false); + m_jKey9.setFocusable(false); + m_jKey9.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey9.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jKey9.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jKey9.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jKey9.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 3; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey9, gridBagConstraints); + + m_jKey8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn8.png"))); // NOI18N + m_jKey8.setFocusPainted(false); + m_jKey8.setFocusable(false); + m_jKey8.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey8.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jKey8.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jKey8.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jKey8.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 3; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey8, gridBagConstraints); + + m_jKey7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn7.png"))); // NOI18N + m_jKey7.setFocusPainted(false); + m_jKey7.setFocusable(false); + m_jKey7.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey7.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jKey7.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jKey7.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jKey7.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 3; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey7, gridBagConstraints); + + m_jKey4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn4.png"))); // NOI18N + m_jKey4.setFocusPainted(false); + m_jKey4.setFocusable(false); + m_jKey4.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey4.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jKey4.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jKey4.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jKey4.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey4, gridBagConstraints); + + m_jKey5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn5.png"))); // NOI18N + m_jKey5.setFocusPainted(false); + m_jKey5.setFocusable(false); + m_jKey5.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey5.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jKey5.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jKey5.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jKey5.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey5, gridBagConstraints); + + m_jKey6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn6.png"))); // NOI18N + m_jKey6.setFocusPainted(false); + m_jKey6.setFocusable(false); + m_jKey6.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey6.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jKey6.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jKey6.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jKey6.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey6, gridBagConstraints); + + m_jKey3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn3.png"))); // NOI18N + m_jKey3.setFocusPainted(false); + m_jKey3.setFocusable(false); + m_jKey3.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey3.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jKey3.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jKey3.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jKey3.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey3, gridBagConstraints); + + m_jKey2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn2.png"))); // NOI18N + m_jKey2.setFocusPainted(false); + m_jKey2.setFocusable(false); + m_jKey2.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey2.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jKey2.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jKey2.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jKey2.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey2, gridBagConstraints); + + m_jKey1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn1.png"))); // NOI18N + m_jKey1.setFocusPainted(false); + m_jKey1.setFocusable(false); + m_jKey1.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey1.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jKey1.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jKey1.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jKey1.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey1, gridBagConstraints); + + m_jKey0.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn0.png"))); // NOI18N + m_jKey0.setFocusPainted(false); + m_jKey0.setFocusable(false); + m_jKey0.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey0.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jKey0.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jKey0.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jKey0.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 4; + gridBagConstraints.gridwidth = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); + add(m_jKey0, gridBagConstraints); + + m_jKeyDot.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btndot.png"))); // NOI18N + m_jKeyDot.setFocusPainted(false); + m_jKeyDot.setFocusable(false); + m_jKeyDot.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKeyDot.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jKeyDot.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jKeyDot.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jKeyDot.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 4; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0); + add(m_jKeyDot, gridBagConstraints); + + m_jEquals.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btnequals.png"))); // NOI18N + m_jEquals.setFocusPainted(false); + m_jEquals.setFocusable(false); + m_jEquals.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jEquals.setPreferredSize(new java.awt.Dimension(42, 36)); + m_jEquals.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 3; + gridBagConstraints.gridy = 3; + gridBagConstraints.gridheight = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); + add(m_jEquals, gridBagConstraints); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton m_jCE; + private javax.swing.JButton m_jEquals; + private javax.swing.JButton m_jKey0; + private javax.swing.JButton m_jKey1; + private javax.swing.JButton m_jKey2; + private javax.swing.JButton m_jKey3; + private javax.swing.JButton m_jKey4; + private javax.swing.JButton m_jKey5; + private javax.swing.JButton m_jKey6; + private javax.swing.JButton m_jKey7; + private javax.swing.JButton m_jKey8; + private javax.swing.JButton m_jKey9; + private javax.swing.JButton m_jKeyDot; + private javax.swing.JButton m_jMinus; + private javax.swing.JButton m_jMultiply; + private javax.swing.JButton m_jPlus; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/beans/JNumberPop.form b/src/main/java/com/unicenta/beans/JNumberPop.form new file mode 100644 index 0000000..d8b98d9 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JNumberPop.form @@ -0,0 +1,175 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/beans/JNumberPop.java b/src/main/java/com/unicenta/beans/JNumberPop.java new file mode 100644 index 0000000..c51224f --- /dev/null +++ b/src/main/java/com/unicenta/beans/JNumberPop.java @@ -0,0 +1,237 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta - joint with Jacinto Rodriguez +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import com.unicenta.basic.BasicException; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import java.awt.*; + +/** + * Dec 2017 + * @author Jack Gerarrd uniCenta + */ +@Slf4j +public class JNumberPop extends javax.swing.JDialog { + + private static LocaleResources m_resources; + + private Integer m_value; + + /** Creates new form JNumberDialog + * @param parent + * @param modal */ + public JNumberPop(java.awt.Frame parent, boolean modal) { + super(parent, modal); + init(); + } + + /** Creates new form JNumberDialog + * @param parent + * @param modal */ + public JNumberPop(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + init(); + } + + private void init() { + + if (m_resources == null) { + m_resources = new LocaleResources(); + m_resources.addBundleName("beans_messages"); + } + + initComponents(); + getRootPane().setDefaultButton(jcmdOK); + + m_jnumber.addEditorKeys(m_jKeys); + m_jnumber.reset(); + m_jnumber.setValueInteger(1); + m_jnumber.activate(); + m_jnumber.setVisible(false); + + m_jPanelTitle.setBorder(RoundedBorder.createGradientBorder()); + + m_value = null; + } + + private void setTitle(String title, String message, Icon icon) { + setTitle(title); + m_lblMessage.setText(message); + m_lblMessage.setIcon(icon); + } + + public static Integer showEditNumber(Component parent, String title) { + return showEditNumber(parent, title, null, null); + } + public static Integer showEditNumber(Component parent, String title, String message) { + return showEditNumber(parent, title, message, null); + } + public static Integer showEditNumber(Component parent, String title, String message, Icon icon) { + + Window window = SwingUtilities.windowForComponent(parent); + + JNumberPop myMsg; + if (window instanceof Frame) { + myMsg = new JNumberPop((Frame) window, true); + } else { + myMsg = new JNumberPop((Dialog) window, true); + } + + myMsg.setTitle(title, message, icon); + myMsg.setVisible(true); + return myMsg.m_value; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel2 = new javax.swing.JPanel(); + jPanelGrid = new javax.swing.JPanel(); + jPanel3 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel4 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + m_jnumber = new com.unicenta.editor.JEditorDoublePositive(); + jcmdOK = new javax.swing.JButton(); + m_jPanelTitle = new javax.swing.JPanel(); + m_lblMessage = new javax.swing.JLabel(); + + setResizable(false); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + formWindowClosing(evt); + } + }); + + jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel2.setLayout(new java.awt.BorderLayout()); + + jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS)); + + m_jKeys.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jKeysActionPerformed(evt); + } + }); + jPanel3.add(m_jKeys); + + jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel4.setLayout(new java.awt.BorderLayout()); + + jPanel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + + m_jnumber.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(m_jnumber, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(95, 95, 95)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(m_jnumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(20, Short.MAX_VALUE)) + ); + + jPanel4.add(jPanel1, java.awt.BorderLayout.LINE_START); + + jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdOK.setPreferredSize(new java.awt.Dimension(80, 45)); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel4.add(jcmdOK, java.awt.BorderLayout.CENTER); + + jPanel3.add(jPanel4); + + jPanelGrid.add(jPanel3); + + jPanel2.add(jPanelGrid, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER); + + m_jPanelTitle.setLayout(new java.awt.BorderLayout()); + + m_lblMessage.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPanelTitle.add(m_lblMessage, java.awt.BorderLayout.CENTER); + + getContentPane().add(m_jPanelTitle, java.awt.BorderLayout.NORTH); + + setSize(new java.awt.Dimension(328, 409)); + setLocationRelativeTo(null); + }// //GEN-END:initComponents + + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + + try { + m_value = m_jnumber.getValueInteger(); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + setVisible(false); + dispose(); + + + }//GEN-LAST:event_jcmdOKActionPerformed + + private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing + + setVisible(false); + dispose(); + + }//GEN-LAST:event_formWindowClosing + + private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed + + }//GEN-LAST:event_m_jKeysActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanelGrid; + private javax.swing.JButton jcmdOK; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JPanel m_jPanelTitle; + private com.unicenta.editor.JEditorDoublePositive m_jnumber; + private javax.swing.JLabel m_lblMessage; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/beans/JPasswordDialog.form b/src/main/java/com/unicenta/beans/JPasswordDialog.form new file mode 100644 index 0000000..6a3e437 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JPasswordDialog.form @@ -0,0 +1,204 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/beans/JPasswordDialog.java b/src/main/java/com/unicenta/beans/JPasswordDialog.java new file mode 100644 index 0000000..4ca0d60 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JPasswordDialog.java @@ -0,0 +1,266 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import java.awt.*; +import javax.swing.*; + +public class JPasswordDialog extends javax.swing.JDialog { + + private static LocaleResources m_resources; + + private String m_sPassword; + + /** Creates new form JPasswordDialog + * @param parent + * @param modal */ + public JPasswordDialog(java.awt.Frame parent, boolean modal) { + super(parent, modal); + init(); + } + /** Creates new form JPasswordDialog + * @param parent + * @param modal */ + public JPasswordDialog(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + init(); + } + + private void init() { + + if (m_resources == null) { + m_resources = new LocaleResources(); + m_resources.addBundleName("beans_messages"); + } + + initComponents(); + getRootPane().setDefaultButton(jcmdOK); + + m_jpassword.addEditorKeys(m_jKeys); + m_jpassword.reset(); + m_jpassword.activate(); + + m_jPanelTitle.setBorder(RoundedBorder.createGradientBorder()); + + m_sPassword = null; + } + + private void setTitle(String title, String message, Icon icon) { + setTitle(title); + m_lblMessage.setText(message); + m_lblMessage.setIcon(icon); + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window) parent; + } else { + return getWindow(parent.getParent()); + } + } + + /** + * + * @param parent + * @param title + * @return + */ + public static String showEditPassword(Component parent, String title) { + return showEditPassword(parent, title, null, null); + } + + /** + * + * @param parent + * @param title + * @param message + * @return + */ + public static String showEditPassword(Component parent, String title, String message) { + return showEditPassword(parent, title, message, null); + } + + /** + * + * @param parent + * @param title + * @param message + * @param icon + * @return + */ + public static String showEditPassword(Component parent, String title, String message, Icon icon) { + + Window window = getWindow(parent); + + JPasswordDialog myMsg; + if (window instanceof Frame) { + myMsg = new JPasswordDialog((Frame) window, true); + } else { + myMsg = new JPasswordDialog((Dialog) window, true); + } + + myMsg.setTitle(title, message, icon); + myMsg.setVisible(true); + return myMsg.m_sPassword; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jcmdCancel = new javax.swing.JButton(); + jcmdOK = new javax.swing.JButton(); + jPanel2 = new javax.swing.JPanel(); + jPanelGrid = new javax.swing.JPanel(); + jPanel3 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel4 = new javax.swing.JPanel(); + m_jpassword = new com.unicenta.editor.JEditorPassword(); + m_jPanelTitle = new javax.swing.JPanel(); + m_lblMessage = new javax.swing.JLabel(); + + setPreferredSize(new java.awt.Dimension(320, 450)); + setResizable(false); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + closeWindow(evt); + } + }); + + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdCancel.setPreferredSize(new java.awt.Dimension(80, 45)); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel1.add(jcmdCancel); + + jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdOK.setPreferredSize(new java.awt.Dimension(80, 45)); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel1.add(jcmdOK); + + getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH); + + jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel2.setPreferredSize(new java.awt.Dimension(320, 390)); + jPanel2.setLayout(new java.awt.BorderLayout()); + + jPanelGrid.setPreferredSize(new java.awt.Dimension(310, 380)); + + jPanel3.setPreferredSize(new java.awt.Dimension(300, 350)); + jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.Y_AXIS)); + + m_jKeys.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jKeysActionPerformed(evt); + } + }); + jPanel3.add(m_jKeys); + + jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel4.setPreferredSize(new java.awt.Dimension(120, 30)); + jPanel4.setLayout(new java.awt.BorderLayout()); + + m_jpassword.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jpassword.setPreferredSize(new java.awt.Dimension(110, 30)); + jPanel4.add(m_jpassword, java.awt.BorderLayout.CENTER); + + jPanel3.add(jPanel4); + + jPanelGrid.add(jPanel3); + + jPanel2.add(jPanelGrid, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER); + + m_jPanelTitle.setLayout(new java.awt.BorderLayout()); + + m_lblMessage.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, java.awt.Color.darkGray), javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5))); + m_jPanelTitle.add(m_lblMessage, java.awt.BorderLayout.CENTER); + + getContentPane().add(m_jPanelTitle, java.awt.BorderLayout.NORTH); + + setSize(new java.awt.Dimension(308, 489)); + setLocationRelativeTo(null); + }// //GEN-END:initComponents + + private void jNumberKeys21KeyPerformed(com.unicenta.beans.JNumberEvent evt) {//GEN-FIRST:event_jNumberKeys21KeyPerformed + + }//GEN-LAST:event_jNumberKeys21KeyPerformed + + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + m_sPassword = m_jpassword.getPassword(); + setVisible(false); + dispose(); + + }//GEN-LAST:event_jcmdOKActionPerformed + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + setVisible(false); + dispose(); + + }//GEN-LAST:event_jcmdCancelActionPerformed + + private void closeWindow(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeWindow + + setVisible(false); + dispose(); + + }//GEN-LAST:event_closeWindow + + private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed + }//GEN-LAST:event_m_jKeysActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanelGrid; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JPanel m_jPanelTitle; + private com.unicenta.editor.JEditorPassword m_jpassword; + private javax.swing.JLabel m_lblMessage; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/beans/JTimePanel.form b/src/main/java/com/unicenta/beans/JTimePanel.form new file mode 100644 index 0000000..8257d83 --- /dev/null +++ b/src/main/java/com/unicenta/beans/JTimePanel.form @@ -0,0 +1,92 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/beans/JTimePanel.java b/src/main/java/com/unicenta/beans/JTimePanel.java new file mode 100644 index 0000000..d03776c --- /dev/null +++ b/src/main/java/com/unicenta/beans/JTimePanel.java @@ -0,0 +1,387 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JButton; + +/** + * + * @author JG uniCenta + */ +public class JTimePanel extends javax.swing.JPanel { + + /** + * + */ + public final static int BUTTONS_ALL = 3; + + /** + * + */ + public final static int BUTTONS_HOUR = 1; + + /** + * + */ + public final static int BUTTONS_MINUTE = 2; + + private DateFormat fmtTime = DateFormat.getTimeInstance(DateFormat.SHORT); + + private JClockPanel m_jclock; + private Date m_dMinDate; + private Date m_dMaxDate; + + private JButtonDate m_jbtnplushour = null; + private JButtonDate m_jbtnminushour = null; + private JButtonDate m_jbtnplusfifteen = null; + private JButtonDate m_jbtnminusfifteen = null; + private JButtonDate m_jbtnplusminute = null; + private JButtonDate m_jbtnminusminute = null; + + /** Creates new form JTimePanel */ + public JTimePanel() { + this(null, BUTTONS_ALL); + } + + /** + * + * @param dDate + */ + public JTimePanel(Date dDate) { + this(dDate, BUTTONS_ALL); + } + + /** + * + * @param dDate + * @param iButtons + */ + public JTimePanel(Date dDate, int iButtons) { + super(); + + initComponents(); + + m_jclock = new JClockPanel(false); + jPanel2.add(m_jclock, BorderLayout.CENTER); + + + GregorianCalendar c; + DateFormat f = new SimpleDateFormat("H:mm"); + + ActionListener dateclick = new DateClick(); + + if ((iButtons & BUTTONS_HOUR) > 0) { + c = new GregorianCalendar(1900, 0, 0, 1, 0); + m_jbtnplushour = new JButtonDate(f.format(c.getTime()), new ImageIcon(getClass().getResource("/com/unicenta/images/2rightarrow.png")), dateclick); + m_jactions.add(m_jbtnplushour); + } + + if ((iButtons & BUTTONS_MINUTE) > 0) { + c = new GregorianCalendar(1900, 0, 0, 0, 15); + m_jbtnplusfifteen = new JButtonDate(f.format(c.getTime()), new ImageIcon(getClass().getResource("/com/unicenta/images/1rightarrow.png")), dateclick); + m_jactions.add(m_jbtnplusfifteen); + } + + if ((iButtons & BUTTONS_MINUTE) > 0) { + c = new GregorianCalendar(1900, 0, 0, 0, 1); + m_jbtnplusminute = new JButtonDate(f.format(c.getTime()), new ImageIcon(getClass().getResource("/com/unicenta/images/1rightarrow.png")), dateclick); + m_jactions.add(m_jbtnplusminute); + } +// c = new GregorianCalendar(1900, 0, 0, 0, 0); +// m_jbtnmidnight = new JButtonDate(f.format(c.getTime()), dateclick); +// m_jactions.add(m_jbtnmidnight); + + if ((iButtons & BUTTONS_MINUTE) > 0) { + c = new GregorianCalendar(1900, 0, 0, 0, 1); + m_jbtnminusminute = new JButtonDate(f.format(c.getTime()), new ImageIcon(getClass().getResource("/com/unicenta/images/1leftarrow.png")), dateclick); + m_jactions.add(m_jbtnminusminute); + } + + if ((iButtons & BUTTONS_MINUTE) > 0) { + c = new GregorianCalendar(1900, 0, 0, 0, 15); + m_jbtnminusfifteen = new JButtonDate(f.format(c.getTime()), new ImageIcon(getClass().getResource("/com/unicenta/images/1leftarrow.png")), dateclick); + m_jactions.add(m_jbtnminusfifteen); + } + + if ((iButtons & BUTTONS_HOUR) > 0) { + c = new GregorianCalendar(1900, 0, 0, 1, 0); + m_jbtnminushour = new JButtonDate(f.format(c.getTime()), new ImageIcon(getClass().getResource("/com/unicenta/images/2leftarrow.png")), dateclick); + m_jactions.add(m_jbtnminushour); + } + + m_dMinDate = null; + m_dMaxDate = null; + m_jclock.setTime(dDate); + renderTime(); + } + + /** + * + */ + public void setDateMidNight() { + setDate(new GregorianCalendar(1900, 0, 0, 0, 0).getTime()); + } + + /** + * + * @param dNewDate + */ + public void setDate(Date dNewDate) { + + Date dOldDate = m_jclock.getTime(); + if (((dNewDate == null && dOldDate != null) || (dNewDate != null && !dNewDate.equals(dOldDate))) + && checkDates(dNewDate)) { + m_jclock.setTime(dNewDate); + renderTime(); + firePropertyChange("Date", dOldDate, dNewDate); // decimos al mundo que ha cambiado la propiedad fecha + } + } + + private boolean checkDates(Date dDate) { + return dDate == null || (m_dMaxDate == null || m_dMaxDate.compareTo(dDate) > 0) && (m_dMinDate == null || m_dMinDate.compareTo(dDate) <= 0); + } + + /** + * + * @return + */ + public Date getDate() { + return m_jclock.getTime(); + } + + /** + * + * @param dMinDate + * @param dMaxDate + */ + public void setCheckDates(Date dMinDate, Date dMaxDate) { + + m_dMinDate = dMinDate; + m_dMaxDate = dMaxDate; + setDate(null); + renderTime(); // este quiza sobra. + } + + @Override + public void setEnabled(boolean bValue) { + + super.setEnabled(bValue); + renderTime(); + } + + /** + * + * @param period + */ + public void setPeriod(long period) { + m_jclock.setPeriod(period); + renderTime(); + } + + private void renderTime() { + + Date dDate = m_jclock.getTime(); + if (dDate == null) { + if (m_jbtnplushour != null) { + m_jbtnplushour.setEnabled(false); + } + if (m_jbtnminushour != null) { + m_jbtnminushour.setEnabled(false); + } + if (m_jbtnplusfifteen != null) { + m_jbtnplusfifteen.setEnabled(false); + } + if (m_jbtnminusfifteen != null) { + m_jbtnminusfifteen.setEnabled(false); + } + if (m_jbtnplusminute != null) { + m_jbtnplusminute.setEnabled(false); + } + if (m_jbtnminusminute != null) { + m_jbtnminusminute.setEnabled(false); + } + m_jlblTime.setText(" "); + m_jlblSeparator.setVisible(false); + m_jlblTime2.setVisible(false); + m_jtime.revalidate(); + } else { + GregorianCalendar oCalRender = new GregorianCalendar(); + oCalRender.setTime(dDate); + // int iDay = oCalRender.get(Calendar.DAY_OF_MONTH); + + oCalRender.add(Calendar.HOUR_OF_DAY, 1); + if (m_jbtnplushour != null) { + m_jbtnplushour.DateInf = oCalRender.getTime(); + m_jbtnplushour.setEnabled(isEnabled() && checkDates(oCalRender.getTime())); + } + oCalRender.add(Calendar.HOUR_OF_DAY, -2); + if (m_jbtnminushour != null) { + m_jbtnminushour.DateInf = oCalRender.getTime(); + m_jbtnminushour.setEnabled(isEnabled() && checkDates(oCalRender.getTime())); + } + + oCalRender.setTime(dDate); + + oCalRender.add(Calendar.MINUTE, 15); + if (m_jbtnplusfifteen != null) { + m_jbtnplusfifteen.DateInf = oCalRender.getTime(); + m_jbtnplusfifteen.setEnabled(isEnabled() && checkDates(oCalRender.getTime())); + } + oCalRender.add(Calendar.MINUTE, -30); + if (m_jbtnminusfifteen != null) { + m_jbtnminusfifteen.DateInf = oCalRender.getTime(); + m_jbtnminusfifteen.setEnabled(isEnabled() && checkDates(oCalRender.getTime())); + } + oCalRender.setTime(dDate); + + oCalRender.add(Calendar.MINUTE, 1); + if (m_jbtnplusminute != null) { + m_jbtnplusminute.DateInf = oCalRender.getTime(); + m_jbtnplusminute.setEnabled(isEnabled() && checkDates(oCalRender.getTime())); + } + oCalRender.add(Calendar.MINUTE, -2); + if (m_jbtnminusminute != null) { + m_jbtnminusminute.DateInf = oCalRender.getTime(); + m_jbtnminusminute.setEnabled(isEnabled() && checkDates(oCalRender.getTime())); + } + + if (m_jclock.getPeriod() > 0L) { + // damos el periodo + m_jlblTime.setText(fmtTime.format(dDate)); + m_jlblTime2.setText(fmtTime.format(new Date(dDate.getTime() + m_jclock.getPeriod()))); + m_jlblSeparator.setVisible(true); + m_jlblTime2.setVisible(true); + m_jtime.revalidate(); + } else { + // es una hora normal + m_jlblTime.setText(fmtTime.format(dDate)); + m_jlblSeparator.setVisible(false); + m_jlblTime2.setVisible(false); + m_jtime.revalidate(); + } + } + + m_jclock.setEnabled(isEnabled()); + } + + private class DateClick implements ActionListener { + + @Override + public void actionPerformed(ActionEvent e) { + JButtonDate oLbl = (JButtonDate)e.getSource(); + if(oLbl.DateInf != null) { + setDate(oLbl.DateInf); + } + } + } + + private static class JButtonDate extends JButton { + + public Date DateInf; + + public JButtonDate(ActionListener datehandler) { + super(); + initComponent(); + addActionListener(datehandler); + } + + public JButtonDate(String sText, ActionListener datehandler) { + super(sText); + initComponent(); + addActionListener(datehandler); + } + + public JButtonDate(String sText, Icon ico, ActionListener datehandler) { + super(sText, ico); + initComponent(); + addActionListener(datehandler); + } + + private void initComponent() { + DateInf = null; + setRequestFocusEnabled(false); + setFocusPainted(false); + setFocusable(false); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + m_jactions = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + m_jtime = new javax.swing.JPanel(); + m_jlblTime = new javax.swing.JLabel(); + m_jlblSeparator = new javax.swing.JLabel(); + m_jlblTime2 = new javax.swing.JLabel(); + + setLayout(new java.awt.BorderLayout()); + + jPanel1.setLayout(new java.awt.BorderLayout()); + + m_jactions.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5)); + m_jactions.setLayout(new java.awt.GridLayout(0, 1, 0, 5)); + jPanel1.add(m_jactions, java.awt.BorderLayout.NORTH); + + add(jPanel1, java.awt.BorderLayout.LINE_END); + + jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + jPanel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel2.setLayout(new java.awt.BorderLayout()); + + m_jtime.add(m_jlblTime); + + m_jlblSeparator.setText(" - "); + m_jtime.add(m_jlblSeparator); + m_jtime.add(m_jlblTime2); + + jPanel2.add(m_jtime, java.awt.BorderLayout.NORTH); + + add(jPanel2, java.awt.BorderLayout.CENTER); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel m_jactions; + private javax.swing.JLabel m_jlblSeparator; + private javax.swing.JLabel m_jlblTime; + private javax.swing.JLabel m_jlblTime2; + private javax.swing.JPanel m_jtime; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/beans/LocaleResources.java b/src/main/java/com/unicenta/beans/LocaleResources.java new file mode 100644 index 0000000..71bb28d --- /dev/null +++ b/src/main/java/com/unicenta/beans/LocaleResources.java @@ -0,0 +1,127 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.text.MessageFormat; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * + * @author adrian + */ +public class LocaleResources { + + private List m_resources; + private ClassLoader m_localeloader; + + /** Creates a new instance of LocaleResources */ + public LocaleResources() { +// m_resources = new LinkedList(); + m_resources = new LinkedList<>(); + + File fuserdir = new File(System.getProperty("user.dir")); + File fresources = new File(fuserdir, "locales"); + try { + m_localeloader = URLClassLoader.newInstance( + new URL[] { fresources.toURI().toURL() }, + Thread.currentThread().getContextClassLoader()); + } catch (MalformedURLException e) { + m_localeloader = Thread.currentThread().getContextClassLoader(); + } + } + + public ResourceBundle getBundle(String bundlename) { + return ResourceBundle.getBundle(bundlename, Locale.getDefault(), m_localeloader); + } + + /** + * + * @param bundlename + */ + + public void addBundleName(String bundlename) { +// m_resources.add(getBundle(bundlename)); + m_resources.add(ResourceBundle.getBundle(bundlename)); + } + + /** + * + * @param sKey + * @return + */ + public String getString(String sKey) { + + if (sKey == null) { + return null; + } else { + for (ResourceBundle r : m_resources) { + try { + return r.getString(sKey); + } catch (MissingResourceException e) { + // Next + } + } + + // MissingResourceException in all ResourceBundle + return "** " + sKey + " **"; + } + } + + /** + * + * @param sKey + * @param sValues + * @return + */ + public String getString(String sKey, Object ... sValues) { + + if (sKey == null) { + return null; + } else { + for (ResourceBundle r : m_resources) { + try { + return MessageFormat.format(r.getString(sKey), sValues); + } catch (MissingResourceException e) { + // Next + } + } + + // MissingResourceException in all ResourceBundle + StringBuilder sreturn = new StringBuilder(); + sreturn.append("** "); + sreturn.append(sKey); + for (Object value : sValues) { + sreturn.append(" < "); + sreturn.append(value.toString()); + } + sreturn.append("** "); + + return sreturn.toString(); + } + } +} diff --git a/src/main/java/com/unicenta/beans/RoundedBorder.java b/src/main/java/com/unicenta/beans/RoundedBorder.java new file mode 100644 index 0000000..92560b4 --- /dev/null +++ b/src/main/java/com/unicenta/beans/RoundedBorder.java @@ -0,0 +1,268 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.beans; + +import java.awt.*; +import javax.swing.border.AbstractBorder; +import javax.swing.border.Border; + +/** + * + * @author JG uniCenta + */ +public class RoundedBorder extends AbstractBorder { + + private static Border blackLine; + private static Border grayLine; + private static Border gradientBorder; + + /** + * + */ + protected Color colorBorder; + + /** + * + */ + protected Color colorgradient; + + /** + * + */ + protected int roundedRadius; + + /** + * + */ + protected float thickness; + + /** + * + */ + protected boolean filled; + + private float ftop; + private float fbottom; + private float ftopinset; + private float fbottominset; + + /** + * + * @return + */ + public static Border createBlackLineBorder() { + if (blackLine == null) { + blackLine = new RoundedBorder(Color.BLACK); + } + return blackLine; + } + + /** + * + * @return + */ + public static Border createGrayLineBorder() { + if (grayLine == null) { + grayLine = new RoundedBorder(Color.GRAY); + } + return grayLine; + } + + /** + * + * @return + */ + public static Border createGradientBorder() { + if (gradientBorder == null) { + gradientBorder = new RoundedBorder(Color.GRAY, 0f, 8, false, false); + } + return gradientBorder; + } + + /** + * + * @param colorBorder + */ + public RoundedBorder(Color colorBorder) { + this(colorBorder, Color.WHITE, 1f, 0, true, true); + } + + /** + * + * @param colorBorder + * @param thickness + */ + public RoundedBorder(Color colorBorder, float thickness) { + this(colorBorder, Color.WHITE, thickness, 0, true, true); + } + + /** + * + * @param colorBorder + * @param thickness + * @param roundedRadius + */ + public RoundedBorder(Color colorBorder, float thickness, int roundedRadius) { + this(colorBorder, Color.WHITE, thickness, roundedRadius, true, true); + } + + /** + * + * @param colorBorder + * @param thickness + * @param roundedRadius + * @param btopborder + * @param bbottomborder + */ + public RoundedBorder(Color colorBorder, float thickness, int roundedRadius, boolean btopborder, boolean bbottomborder) { + this(colorBorder, Color.WHITE, thickness, roundedRadius, btopborder, bbottomborder); + } + + /** + * + * @param colorBorder + * @param colorgradient + * @param thickness + * @param roundedRadius + * @param btopborder + * @param bbottomborder + */ + public RoundedBorder(Color colorBorder, Color colorgradient, float thickness, int roundedRadius, boolean btopborder, boolean bbottomborder) { + + this.colorBorder = colorBorder; + this.colorgradient = colorgradient; + this.thickness = thickness; + this.roundedRadius = roundedRadius; + this.filled = true; + + ftop = btopborder ? 0f : thickness + roundedRadius; + fbottom = bbottomborder ? 0f : thickness + roundedRadius; + ftopinset = btopborder ? 0f : thickness; // para los bordes a derecha e izquierda + fbottominset = bbottomborder ? 0f : thickness; // para los bordes a derecha e izquierda + } + + @Override + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + + Graphics2D g2d = (Graphics2D) g; + + Object oldAntialias = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING); + Stroke oldStroke = g2d.getStroke(); + Paint oldColor = g2d.getPaint(); + + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + float imedium = thickness; + + if (filled) { + if (c.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT) { + g2d.setPaint(new GradientPaint(0, 0, c.getBackground(), width, 0, colorgradient)); + } else { + g2d.setPaint(new GradientPaint(0, 0, colorgradient, width, 0, c.getBackground())); + } + g2d.fillRoundRect( + (int) (x + thickness), + (int) (y + thickness - ftop), + (int) (width - thickness - thickness), + (int) (height - thickness - thickness + ftop + fbottom), + (int) (roundedRadius * 2 - imedium), + (int) (roundedRadius * 2 - imedium)); + } + + if (thickness > 0f) { + g2d.setStroke(new BasicStroke(thickness)); + g2d.setPaint(colorBorder); + g2d.drawRoundRect( + (int) (x), + (int) (y - ftop), + (int) (width- thickness), + (int) (height - thickness + ftop + fbottom), + roundedRadius * 2, + roundedRadius * 2); + } + + g2d.setPaint(oldColor); + g2d.setStroke(oldStroke); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialias); + } + + @Override + public Insets getBorderInsets(Component c) { + +// // Los bordes estan arriba y abajo +// return new Insets( +// (int)(0.5 + thickness + roundedRadius - ftop), +// (int)(0.5 + thickness), +// (int)(0.5 + thickness + roundedRadius - fbottom), +// (int)(0.5 + thickness)); + + // Los bordes estan a derecha y a izquierda + return new Insets( + (int)(0.5 + thickness - ftopinset), + (int)(0.5 + thickness + roundedRadius), + (int)(0.5 + thickness - fbottominset), + (int)(0.5 + thickness + roundedRadius)); + } + + @Override + public Insets getBorderInsets(Component c, Insets insets) { + +// insets.top = (int)(0.5 + thickness + roundedRadius - ftop); +// insets.left =(int)(0.5 + thickness); +// insets.bottom = (int)(0.5 + thickness + roundedRadius - fbottom); +// insets.right = (int)(0.5 + thickness); + + insets.top = (int)(0.5 + thickness - ftopinset); + insets.left =(int)(0.5 + thickness + roundedRadius); + insets.bottom = (int)(0.5 + thickness - fbottominset); + insets.right = (int)(0.5 + thickness + roundedRadius); + + return insets; + } + + /** + * + * @return + */ + public Color getLineColor() { + return colorBorder; + } + + /** + * + * @return + */ + public float getThickness() { + return thickness; + } + + /** + * + * @return + */ + public boolean isFilled() { + return filled; + } + + @Override + public boolean isBorderOpaque() { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/data/gui/ComboBoxValModel.java b/src/main/java/com/unicenta/data/gui/ComboBoxValModel.java new file mode 100644 index 0000000..c24a661 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/ComboBoxValModel.java @@ -0,0 +1,184 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import com.unicenta.data.loader.IKeyGetter; +import com.unicenta.data.loader.KeyGetterBuilder; +import java.util.*; +import javax.swing.*; + +/** + * + * @author adrian + */ +public class ComboBoxValModel extends AbstractListModel implements ComboBoxModel { + + private List m_aData; + private IKeyGetter m_keygetter; + private Object m_selected; + + /** Creates a new instance of ComboBoxValModel + * @param aData + * @param keygetter */ + public ComboBoxValModel(List aData, IKeyGetter keygetter) { + m_aData = aData; + m_keygetter = keygetter; + m_selected = null; + } + + /** + * + * @param aData + */ + public ComboBoxValModel(List aData) { + this(aData, KeyGetterBuilder.INSTANCE); + } + + /** + * + * @param keygetter + */ + public ComboBoxValModel(IKeyGetter keygetter) { + this(new ArrayList(), keygetter); + } + + /** + * + */ + public ComboBoxValModel() { + this(new ArrayList(), KeyGetterBuilder.INSTANCE); + } + + /** + * + * @param c + */ + public void add(Object c) { + m_aData.add(c); + } + + /** + * + * @param c + */ + public void del(Object c) { + m_aData.remove(c); + } + + /** + * + * @param index + * @param c + */ + public void add(int index, Object c) { + m_aData.add(index, c); + } + + /** + * + * @param aData + */ + public void refresh(List aData) { + m_aData = aData; + m_selected = null; + } + + /** + * + * @return + */ + public Object getSelectedKey() { + if (m_selected == null) { + return null; + } else { + return m_keygetter.getKey(m_selected); // Si casca, excepcion parriba + } + } + + /** + * + * @return + */ + public String getSelectedText() { + if (m_selected == null) { + return null; + } else { + return m_selected.toString(); + } + } + + /** + * + * @param aKey + */ + public void setSelectedKey(Object aKey) { + setSelectedItem(getElementByKey(aKey)); + } + + /** + * + */ + public void setSelectedFirst() { + m_selected = (m_aData.isEmpty()) ? null : m_aData.get(0); + } + + /** + * + * @param aKey + * @return + */ + public Object getElementByKey(Object aKey) { + if (aKey != null) { + Iterator it = m_aData.iterator(); + while (it.hasNext()) { + Object value = it.next(); + if (aKey.equals(m_keygetter.getKey(value))) { + return value; + } + } + } + return null; + } + + @Override + public Object getElementAt(int index) { + return m_aData.get(index); + } + + @Override + public Object getSelectedItem() { + return m_selected; + } + + @Override + public int getSize() { + return m_aData.size(); + } + + @Override + public void setSelectedItem(Object anItem) { + + if ((m_selected != null && !m_selected.equals(anItem)) || m_selected == null && anItem != null) { + m_selected = anItem; + fireContentsChanged(this, -1, -1); + } + } + +} diff --git a/src/main/java/com/unicenta/data/gui/CompoundIcon.java b/src/main/java/com/unicenta/data/gui/CompoundIcon.java new file mode 100644 index 0000000..b69f1e6 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/CompoundIcon.java @@ -0,0 +1,57 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import javax.swing.Icon; + +/** + * + * @author adrian + */ +public class CompoundIcon implements Icon { + + private Icon m_icon1; + private Icon m_icon2; + + /** Creates a new instance of CompoundIcon + * @param icon1 + * @param icon2 */ + public CompoundIcon(Icon icon1, Icon icon2) { + m_icon1 = icon1; + m_icon2 = icon2; + } + + @Override + public int getIconHeight() { + return Math.max(m_icon1.getIconHeight(), m_icon2.getIconHeight()); + } + + @Override + public int getIconWidth() { + return m_icon1.getIconWidth() + m_icon2.getIconWidth(); + } + + @Override + public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y) { + m_icon1.paintIcon(c, g, x, y); + m_icon2.paintIcon(c, g, x + m_icon1.getIconWidth(), y); + } + +} diff --git a/src/main/java/com/unicenta/data/gui/FindInfo.java b/src/main/java/com/unicenta/data/gui/FindInfo.java new file mode 100644 index 0000000..4d63f09 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/FindInfo.java @@ -0,0 +1,149 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.Finder; +import java.util.regex.*; + +/** + * + * @author JG uniCenta + */ +public class FindInfo implements Finder { + + /** + * + */ + public static final int MATCH_STARTFIELD = 0; + public static final int MATCH_WHOLEFIELD = 1; + public static final int MATCH_ANYPARTFIELD = 2; + public static final int MATCH_REGEXP = 3; + + private String m_sTextCompare; + private Pattern m_TextPattern; + + private String m_sText; // Texto a buscar + private int m_iField; // Campo de busqueda + private int m_iMatch; // Tipo de busqueda + private boolean m_bMatchCase; // Mayusculas / Minusculas + + private Vectorer m_vec; + + /** Creates a new instance of FindInfo + * @param vec + * @param sText + * @param iField + * @param iMatch + * @param bMatchCase */ + public FindInfo(Vectorer vec, String sText, int iField, boolean bMatchCase, int iMatch) { + m_vec = vec; + m_sText = sText; + m_iField = iField; + m_bMatchCase = bMatchCase; + m_iMatch = iMatch; + + if (iMatch == MATCH_REGEXP) { + m_TextPattern = m_bMatchCase + ? Pattern.compile(m_sText) + : Pattern.compile(m_sText, Pattern.CASE_INSENSITIVE); + } else { + m_sTextCompare = m_bMatchCase + ? m_sText + : m_sText.toUpperCase(); + } + } + + /** Creates a new instance of FindInfo + * @param vec */ + public FindInfo(Vectorer vec) { + this(vec, "", 0, true, MATCH_ANYPARTFIELD); + } + + /** + * + * @return + */ + public Vectorer getVectorer() { + return m_vec; + } + + /** + * + * @return + */ + public String getText() { + return m_sText; + } + + /** + * + * @return + */ + public int getField() { + return m_iField; + } + + /** + * + * @return + */ + public boolean isMatchCase() { + return m_bMatchCase; + } + + /** + * + * @return + */ + public int getMatch() { + return m_iMatch; + } + + /** + * + * @param obj + * @return + * @throws BasicException + */ + public boolean match(Object obj) throws BasicException { + + String[] v = m_vec.getValues(obj); + + String sField = m_bMatchCase + ? v[m_iField] + : v[m_iField].toUpperCase(); + + switch (m_iMatch) { + case MATCH_STARTFIELD: + return sField.startsWith(m_sTextCompare); + case MATCH_WHOLEFIELD: + return sField.equals(m_sTextCompare); + case MATCH_ANYPARTFIELD: + return sField.contains(m_sTextCompare); + case MATCH_REGEXP: + return m_TextPattern.matcher(sField).matches(); + default: + return false; + } + } + +} diff --git a/src/main/java/com/unicenta/data/gui/JCounter.form b/src/main/java/com/unicenta/data/gui/JCounter.form new file mode 100644 index 0000000..e3aa037 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JCounter.form @@ -0,0 +1,60 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/data/gui/JCounter.java b/src/main/java/com/unicenta/data/gui/JCounter.java new file mode 100644 index 0000000..06e25cf --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JCounter.java @@ -0,0 +1,104 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import javax.swing.*; +import com.unicenta.format.Formats; +import com.unicenta.data.user.BrowseListener; +import com.unicenta.data.user.BrowsableEditableData; +import com.unicenta.data.user.StateListener; + +/** + * + * @author adrianromero + */ +public class JCounter extends JPanel implements BrowseListener, StateListener { + + /** Creates new form JCounter + * @param bd */ + public JCounter(BrowsableEditableData bd) { + initComponents(); + bd.addBrowseListener(this); + bd.addStateListener(this); + } + + /** + * + * @param iState + */ + public void updateState(int iState) { + if (iState == BrowsableEditableData.ST_INSERT) { + // Insert + jlblIndex.setText("*"); + } + } + + /** + * + * @param iIndex + * @param iCounter + */ + public void updateIndex(int iIndex, int iCounter) { + + if (iIndex >= 0 && iIndex < iCounter) { + jlblIndex.setText(Formats.INT.formatValue(new Integer(iIndex + 1))); + } else { + jlblIndex.setText("-"); + } + jlblCounter.setText(Formats.INT.formatValue(new Integer(iCounter))); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jlblIndex = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jlblCounter = new javax.swing.JLabel(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setMaximumSize(new java.awt.Dimension(80, 20)); + setMinimumSize(new java.awt.Dimension(80, 20)); + setPreferredSize(new java.awt.Dimension(80, 20)); + + jlblIndex.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jlblIndex.setText("XX"); + add(jlblIndex); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText("/"); + add(jLabel2); + + jlblCounter.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jlblCounter.setText("XX"); + add(jlblCounter); + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jlblCounter; + private javax.swing.JLabel jlblIndex; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/data/gui/JFind.form b/src/main/java/com/unicenta/data/gui/JFind.form new file mode 100644 index 0000000..ed48e25 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JFind.form @@ -0,0 +1,232 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/data/gui/JFind.java b/src/main/java/com/unicenta/data/gui/JFind.java new file mode 100644 index 0000000..e10c4f6 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JFind.java @@ -0,0 +1,269 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.LocalRes; +import com.unicenta.data.loader.Vectorer; +import java.awt.*; +import javax.swing.*; + +/** + * + * @author JG uniCenta + */ +public class JFind extends JDialog { + + private FindInfo m_FindInfo; + private Vectorer m_vec; + + /** Creates new form JFind */ + private JFind(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + /** Creates new form JFind */ + private JFind(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + private FindInfo init(FindInfo lastFindInfo) throws BasicException { + + initComponents(); + + getRootPane().setDefaultButton(jcmdOK); + + // El texto + m_jFind.setText(lastFindInfo.getText()); + // Pinto la caja + m_jWhere.removeAllItems(); + for (int i = 0; i < lastFindInfo.getVectorer().getHeaders().length; i++) { + m_jWhere.addItem(lastFindInfo.getVectorer().getHeaders()[i]); + } + m_jWhere.setSelectedIndex(lastFindInfo.getField()); + // El Match + m_jMatch.removeAllItems(); + m_jMatch.addItem(LocalRes.getIntString("list.startfield")); + m_jMatch.addItem(LocalRes.getIntString("list.wholefield")); + m_jMatch.addItem(LocalRes.getIntString("list.anypart")); + m_jMatch.addItem(LocalRes.getIntString("list.re")); + m_jMatch.setSelectedIndex(lastFindInfo.getMatch()); + // El case + m_jMatchCase.setSelected(lastFindInfo.isMatchCase()); + + m_vec = lastFindInfo.getVectorer(); + + m_FindInfo = null; + + //show(); + setVisible(true); + + return m_FindInfo; + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window)parent; + } else { + return getWindow(parent.getParent()); + } + } + + /** + * + * @param parent + * @param lastFindInfo + * @return + * @throws BasicException + */ + public static FindInfo showMessage(Component parent, FindInfo lastFindInfo) throws BasicException { + + Window window = getWindow(parent); + + JFind myMsg; + if (window instanceof Frame) { + myMsg = new JFind((Frame) window, true); + } else { + myMsg = new JFind((Dialog) window, true); + } + return myMsg.init(lastFindInfo); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + m_jFind = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + m_jWhere = new javax.swing.JComboBox(); + jLabel3 = new javax.swing.JLabel(); + m_jMatch = new javax.swing.JComboBox(); + m_jMatchCase = new javax.swing.JCheckBox(); + jPanel2 = new javax.swing.JPanel(); + jcmdCancel = new javax.swing.JButton(); + jcmdOK = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(LocalRes.getIntString("title.find")); // NOI18N + setResizable(false); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(LocalRes.getIntString("label.findwhat")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jFind.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jFind.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(LocalRes.getIntString("label.where")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jWhere.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jWhere.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(LocalRes.getIntString("label.match")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jMatch.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jMatch.setPreferredSize(new java.awt.Dimension(250, 30)); + + m_jMatchCase.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jMatchCase.setText(LocalRes.getIntString("label.casesensitive")); // NOI18N + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addComponent(m_jFind, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addComponent(m_jWhere, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jMatchCase, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jMatch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jFind, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jWhere, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jMatch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jMatchCase) + .addContainerGap()) + ); + + getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); + + jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setText(LocalRes.getIntString("button.cancel")); // NOI18N + jcmdCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel2.add(jcmdCancel); + + jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setText(LocalRes.getIntString("button.OK")); // NOI18N + jcmdOK.setMaximumSize(new java.awt.Dimension(65, 33)); + jcmdOK.setMinimumSize(new java.awt.Dimension(65, 33)); + jcmdOK.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel2.add(jcmdOK); + + getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); + + setSize(new java.awt.Dimension(434, 251)); + setLocationRelativeTo(null); + }// //GEN-END:initComponents + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_jcmdCancelActionPerformed + + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + m_FindInfo = new FindInfo(m_vec, + m_jFind.getText(), + m_jWhere.getSelectedIndex(), + m_jMatchCase.isSelected(), + m_jMatch.getSelectedIndex()); + + dispose(); + + }//GEN-LAST:event_jcmdOKActionPerformed + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + private javax.swing.JTextField m_jFind; + private javax.swing.JComboBox m_jMatch; + private javax.swing.JCheckBox m_jMatchCase; + private javax.swing.JComboBox m_jWhere; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/data/gui/JImageEditor.form b/src/main/java/com/unicenta/data/gui/JImageEditor.form new file mode 100644 index 0000000..d423fbf --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JImageEditor.form @@ -0,0 +1,184 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/data/gui/JImageEditor.java b/src/main/java/com/unicenta/data/gui/JImageEditor.java new file mode 100644 index 0000000..2bac7e7 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JImageEditor.java @@ -0,0 +1,444 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import com.unicenta.data.loader.LocalRes; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import javax.imageio.ImageIO; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileFilter; + +/** + * + * @author JG uniCenta + */ +public class JImageEditor extends javax.swing.JPanel { + + private Dimension m_maxsize; + private ZoomIcon m_icon; + private BufferedImage m_Img = null; + + private static File m_fCurrentDirectory = null; + private static NumberFormat m_percentformat = new DecimalFormat("#,##0.##%"); + + /** Creates new form JImageEditor */ + public JImageEditor() { + initComponents(); + + m_Img = null; + m_maxsize = null; + m_icon = new ZoomIcon(); + m_jImage.setIcon(m_icon); + m_jPercent.setText(m_percentformat.format(m_icon.getZoom())); + privateSetEnabled(isEnabled()); + } + + /** + * + * @param size + */ + public void setMaxDimensions(Dimension size) { + m_maxsize = size; + } + + /** + * + * @return + */ + public Dimension getMaxDimensions() { + return m_maxsize; + } + + @Override + public void setEnabled(boolean value) { + + privateSetEnabled(value); + super.setEnabled(value); + } + + private void privateSetEnabled(boolean value) { + m_jbtnopen.setEnabled(value); + m_jbtnclose.setEnabled(value && (m_Img != null)); + m_jbtnzoomin.setEnabled(value && (m_Img != null)); + m_jbtnzoomout.setEnabled(value && (m_Img != null)); + m_jPercent.setEnabled(value && (m_Img != null)); + m_jScr.setEnabled(value && (m_Img != null)); + } + + /** + * + * @param img + */ + public void setImage(BufferedImage img) { + BufferedImage oldimg = m_Img; + m_Img = img; + m_icon.setIcon(m_Img == null ? null : new ImageIcon(m_Img)); + + m_jPercent.setText(m_percentformat.format(m_icon.getZoom())); + + m_jImage.revalidate(); + m_jScr.revalidate(); + m_jScr.repaint(); + + privateSetEnabled(isEnabled()); + + firePropertyChange("image", oldimg, m_Img); + } + + /** + * + * @return + */ + public BufferedImage getImage() { + return m_Img; + } + + /** + * + * @return + */ + public double getZoom() { + return m_icon.getZoom(); + } + + /** + * + * @param zoom + */ + public void setZoom(double zoom) { + double oldzoom = m_icon.getZoom(); + m_icon.setZoom(zoom); + + m_jPercent.setText(m_percentformat.format(m_icon.getZoom())); + + m_jImage.revalidate(); + m_jScr.revalidate(); + m_jScr.repaint(); + + firePropertyChange("zoom", oldzoom, zoom); + } + + /** + * + */ + public void incZoom() { + double zoom = m_icon.getZoom(); + setZoom(zoom > 4.0 ? 8.0 : zoom * 2.0); + } + + /** + * + */ + public void decZoom() { + double zoom = m_icon.getZoom(); + setZoom(zoom < 0.5 ? 0.25 : zoom / 2.0); + } + + /** + * + */ + public void doLoad() { + JFileChooser fc = new JFileChooser(m_fCurrentDirectory); + + fc.addChoosableFileFilter(new ExtensionsFilter(LocalRes.getIntString("label.imagefiles"), "png", "gif", "jpg", "jpeg", "bmp")); + + if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + try { + BufferedImage img = ImageIO.read(fc.getSelectedFile()); + if (img != null) { + // compruebo que no exceda el tamano maximo. + if (m_maxsize != null && (img.getHeight() > m_maxsize.height || img.getWidth() > m_maxsize.width)) { + if (JOptionPane.showConfirmDialog(this, + LocalRes.getIntString("message.resizeimage"), + LocalRes.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { + // Redimensionamos la imagen para que se ajuste + img = resizeImage(img); + } + } + setImage(img); + m_fCurrentDirectory = fc.getCurrentDirectory(); + } + } catch (IOException eIO) { + } + } + } + + private BufferedImage resizeImage(BufferedImage img) { + + int myheight = img.getHeight(); + int mywidth = img.getWidth(); + + if (myheight > m_maxsize.height) { + mywidth = (int) (mywidth * m_maxsize.height / myheight); + myheight = m_maxsize.height; + } + if (mywidth > m_maxsize.width) { + myheight = (int) (myheight * m_maxsize.width / mywidth); + mywidth = m_maxsize.width; + } + + BufferedImage thumb = new BufferedImage(mywidth, myheight, BufferedImage.TYPE_4BYTE_ABGR); + + double scalex = (double) mywidth / (double) img.getWidth(null); + double scaley = (double) myheight / (double) img.getHeight(null); + + Graphics2D g2d = thumb.createGraphics(); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + //g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + + g2d.setColor(new Color(0, 0, 0, 0)); // Transparent + + g2d.fillRect(0, 0, mywidth, myheight); + if (scalex < scaley) { + g2d.drawImage(img, 0,(int) ((myheight - img.getHeight(null) * scalex) / 2.0) + , mywidth, (int) (img.getHeight(null) * scalex), null); + } else { + g2d.drawImage(img, (int) ((mywidth - img.getWidth(null) * scaley) / 2.0), 0 + , (int) (img.getWidth(null) * scaley), myheight, null); + } + g2d.dispose(); + + return thumb; + } + + private static class ZoomIcon implements Icon { + + private Icon ico; + private double zoom; + + public ZoomIcon() { + this.ico = null; + this.zoom = 1.0; + } + @Override + public int getIconHeight() { + return ico == null ? 0 : (int) (zoom * ico.getIconHeight()); + } + @Override + public int getIconWidth() { + return ico == null ? 0 : (int) (zoom * ico.getIconWidth()); + } + @Override + public void paintIcon(Component c, Graphics g, int x, int y) { + if (ico != null) { + Graphics2D g2d = (Graphics2D) g; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + AffineTransform oldt = g2d.getTransform(); + g2d.transform(AffineTransform.getScaleInstance(zoom, zoom)); + ico.paintIcon(c, g2d, (int) (x / zoom), (int) (y / zoom)); + g2d.setTransform(oldt); + } + } + public void setIcon(Icon ico) { + this.ico = ico; + this.zoom = 1.0; + } + public void setZoom(double zoom) { + this.zoom = zoom; + } + public double getZoom() { + return zoom; + } + } + private static class ExtensionsFilter extends FileFilter { + + private String message; + private String[] extensions; + + public ExtensionsFilter(String message, String... extensions) { + this.message = message; + this.extensions = extensions; + } + + @Override + public boolean accept(java.io.File f) { + if (f.isDirectory()) { + return true; + } else { + String sFileName = f.getName(); + int ipos = sFileName.lastIndexOf('.'); + if (ipos >= 0) { + String sExt = sFileName.substring(ipos + 1); + for(String s : extensions) { + if (s.equalsIgnoreCase(sExt)) { + return true; + } + } + } + return false; + } + } + + @Override + public String getDescription() { + return message; + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + m_jScr = new javax.swing.JScrollPane(); + m_jImage = new javax.swing.JLabel(); + jPanel1 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + m_jbtnopen = new javax.swing.JButton(); + m_jbtnclose = new javax.swing.JButton(); + m_jbtnzoomin = new javax.swing.JButton(); + m_jPercent = new javax.swing.JLabel(); + m_jbtnzoomout = new javax.swing.JButton(); + + setBackground(new java.awt.Color(255, 255, 255)); + setOpaque(false); + setLayout(new java.awt.BorderLayout()); + + m_jScr.setBackground(new java.awt.Color(255, 255, 255)); + m_jScr.setOpaque(false); + + m_jImage.setBackground(new java.awt.Color(255, 255, 255)); + m_jImage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/no_photo.png"))); // NOI18N + m_jImage.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + m_jScr.setViewportView(m_jImage); + + add(m_jScr, java.awt.BorderLayout.CENTER); + + jPanel1.setBackground(new java.awt.Color(255, 255, 255)); + jPanel1.setOpaque(false); + jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jPanel2.setBackground(new java.awt.Color(255, 255, 255)); + jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5)); + jPanel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel2.setOpaque(false); + jPanel2.setLayout(new java.awt.GridLayout(0, 1, 0, 2)); + + m_jbtnopen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/camera.png"))); // NOI18N + m_jbtnopen.setToolTipText("Open Folder"); + m_jbtnopen.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jbtnopen.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnopenActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnopen); + + m_jbtnclose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/fileclose.png"))); // NOI18N + m_jbtnclose.setToolTipText("Remove Picture"); + m_jbtnclose.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jbtnclose.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtncloseActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnclose); + + m_jbtnzoomin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/viewmag+.png"))); // NOI18N + m_jbtnzoomin.setToolTipText("Zoom In"); + m_jbtnzoomin.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jbtnzoomin.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnzoominActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnzoomin); + + m_jPercent.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jPercent.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jPercent.setOpaque(true); + m_jPercent.setPreferredSize(new java.awt.Dimension(10, 30)); + jPanel2.add(m_jPercent); + + m_jbtnzoomout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/viewmag-.png"))); // NOI18N + m_jbtnzoomout.setToolTipText("Zoom Out"); + m_jbtnzoomout.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jbtnzoomout.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnzoomoutActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnzoomout); + + jPanel1.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1)); + + add(jPanel1, java.awt.BorderLayout.LINE_END); + }// //GEN-END:initComponents + + private void m_jbtnzoomoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnzoomoutActionPerformed + + decZoom(); + + }//GEN-LAST:event_m_jbtnzoomoutActionPerformed + + private void m_jbtnzoominActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnzoominActionPerformed + + incZoom(); + + }//GEN-LAST:event_m_jbtnzoominActionPerformed + + private void m_jbtncloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtncloseActionPerformed + + setImage(null); + + }//GEN-LAST:event_m_jbtncloseActionPerformed + + private void m_jbtnopenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnopenActionPerformed + + doLoad(); + + }//GEN-LAST:event_m_jbtnopenActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JLabel m_jImage; + private javax.swing.JLabel m_jPercent; + private javax.swing.JScrollPane m_jScr; + private javax.swing.JButton m_jbtnclose; + private javax.swing.JButton m_jbtnopen; + private javax.swing.JButton m_jbtnzoomin; + private javax.swing.JButton m_jbtnzoomout; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/data/gui/JImageViewerCustomer.form b/src/main/java/com/unicenta/data/gui/JImageViewerCustomer.form new file mode 100644 index 0000000..c5e4fcd --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JImageViewerCustomer.form @@ -0,0 +1,131 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/data/gui/JImageViewerCustomer.java b/src/main/java/com/unicenta/data/gui/JImageViewerCustomer.java new file mode 100644 index 0000000..77a17f7 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JImageViewerCustomer.java @@ -0,0 +1,395 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import com.unicenta.data.loader.LocalRes; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import javax.imageio.ImageIO; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileFilter; + +/** + * + * @author JG uniCenta + */ +public class JImageViewerCustomer extends javax.swing.JPanel { + + private Dimension m_maxsize; + private final ZoomIcon m_icon; + private BufferedImage m_Img = null; + + private static File m_fCurrentDirectory = null; + private static final NumberFormat m_percentformat = new DecimalFormat("#,##0.##%"); + + public JImageViewerCustomer() { + initComponents(); + + m_Img = null; + m_maxsize = null; + m_icon = new ZoomIcon(); + m_jImage.setIcon(m_icon); + m_jPercent.setText(m_percentformat.format(m_icon.getZoom())); + privateSetEnabled(isEnabled()); + } + + /** + * + * @param size + */ + public void setMaxDimensions(Dimension size) { + m_maxsize = size; + } + + /** + * + * @return + */ + public Dimension getMaxDimensions() { + return m_maxsize; + } + + @Override + public void setEnabled(boolean value) { + + privateSetEnabled(value); + super.setEnabled(value); + } + + private void privateSetEnabled(boolean value) { + m_jbtnzoomin.setEnabled(value && (m_Img != null)); + m_jbtnzoomout.setEnabled(value && (m_Img != null)); + m_jPercent.setEnabled(value && (m_Img != null)); + m_jScr.setEnabled(value && (m_Img != null)); + } + + /** + * + * @param img + */ + public void setImage(BufferedImage img) { + BufferedImage oldimg = m_Img; + m_Img = img; + m_icon.setIcon(m_Img == null ? null : new ImageIcon(m_Img)); + + m_jPercent.setText(m_percentformat.format(m_icon.getZoom())); + + m_jImage.revalidate(); + m_jScr.revalidate(); + m_jScr.repaint(); + + privateSetEnabled(isEnabled()); + + firePropertyChange("image", oldimg, m_Img); + } + + /** + * + * @return + */ + public BufferedImage getImage() { + return m_Img; + } + + /** + * + * @return + */ + public double getZoom() { + return m_icon.getZoom(); + } + + /** + * + * @param zoom + */ + public void setZoom(double zoom) { + double oldzoom = m_icon.getZoom(); + m_icon.setZoom(zoom); + + m_jPercent.setText(m_percentformat.format(m_icon.getZoom())); + + m_jImage.revalidate(); + m_jScr.revalidate(); + m_jScr.repaint(); + + firePropertyChange("zoom", oldzoom, zoom); + } + + /** + * + */ + public void incZoom() { + double zoom = m_icon.getZoom(); + setZoom(zoom > 4.0 ? 8.0 : zoom * 2.0); + } + + /** + * + */ + public void decZoom() { + double zoom = m_icon.getZoom(); + setZoom(zoom < 0.5 ? 0.25 : zoom / 2.0); + } + + /** + * + */ + public void doLoad() { + JFileChooser fc = new JFileChooser(m_fCurrentDirectory); + + fc.addChoosableFileFilter(new ExtensionsFilter( + LocalRes.getIntString("label.imagefiles"), "png", "gif", "jpg", "jpeg", "bmp")); + + if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + try { + BufferedImage img = ImageIO.read(fc.getSelectedFile()); + if (img != null) { + // compruebo que no exceda el tamano maximo. + if (m_maxsize != null && (img.getHeight() > m_maxsize.height || img.getWidth() > m_maxsize.width)) { + if (JOptionPane.showConfirmDialog(this, + LocalRes.getIntString("message.resizeimage"), + LocalRes.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { + // Redimensionamos la imagen para que se ajuste + img = resizeImage(img); + } + } + setImage(img); + m_fCurrentDirectory = fc.getCurrentDirectory(); + } + } catch (IOException eIO) { + } + } + } + + private BufferedImage resizeImage(BufferedImage img) { + + int myheight = img.getHeight(); + int mywidth = img.getWidth(); + + if (myheight > m_maxsize.height) { + mywidth = (int) (mywidth * m_maxsize.height / myheight); + myheight = m_maxsize.height; + } + if (mywidth > m_maxsize.width) { + myheight = (int) (myheight * m_maxsize.width / mywidth); + mywidth = m_maxsize.width; + } + + BufferedImage thumb = new BufferedImage(mywidth, myheight, BufferedImage.TYPE_4BYTE_ABGR); + + double scalex = (double) mywidth / (double) img.getWidth(null); + double scaley = (double) myheight / (double) img.getHeight(null); + + Graphics2D g2d = thumb.createGraphics(); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + + g2d.setColor(new Color(0, 0, 0, 0)); + + g2d.fillRect(0, 0, mywidth, myheight); + if (scalex < scaley) { + g2d.drawImage(img, 0,(int) ((myheight - img.getHeight(null) * scalex) / 2.0) + , mywidth, (int) (img.getHeight(null) * scalex), null); + } else { + g2d.drawImage(img, (int) ((mywidth - img.getWidth(null) * scaley) / 2.0), 0 + , (int) (img.getWidth(null) * scaley), myheight, null); + } + g2d.dispose(); + + return thumb; + } + + private static class ZoomIcon implements Icon { + + private Icon ico; + private double zoom; + + public ZoomIcon() { + this.ico = null; + this.zoom = 1.0; + } + @Override + public int getIconHeight() { + return ico == null ? 0 : (int) (zoom * ico.getIconHeight()); + } + @Override + public int getIconWidth() { + return ico == null ? 0 : (int) (zoom * ico.getIconWidth()); + } + @Override + public void paintIcon(Component c, Graphics g, int x, int y) { + if (ico != null) { + Graphics2D g2d = (Graphics2D) g; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + AffineTransform oldt = g2d.getTransform(); + g2d.transform(AffineTransform.getScaleInstance(zoom, zoom)); + ico.paintIcon(c, g2d, (int) (x / zoom), (int) (y / zoom)); + g2d.setTransform(oldt); + } + } + public void setIcon(Icon ico) { + this.ico = ico; + this.zoom = 1.0; + } + public void setZoom(double zoom) { + this.zoom = zoom; + } + public double getZoom() { + return zoom; + } + } + private static class ExtensionsFilter extends FileFilter { + + private final String message; + private final String[] extensions; + + public ExtensionsFilter(String message, String... extensions) { + this.message = message; + this.extensions = extensions; + } + + @Override + public boolean accept(java.io.File f) { + if (f.isDirectory()) { + return true; + } else { + String sFileName = f.getName(); + int ipos = sFileName.lastIndexOf('.'); + if (ipos >= 0) { + String sExt = sFileName.substring(ipos + 1); + for(String s : extensions) { + if (s.equalsIgnoreCase(sExt)) { + return true; + } + } + } + return false; + } + } + + @Override + public String getDescription() { + return message; + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + m_jScr = new javax.swing.JScrollPane(); + m_jImage = new javax.swing.JLabel(); + jPanel1 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + m_jbtnzoomin = new javax.swing.JButton(); + m_jPercent = new javax.swing.JLabel(); + m_jbtnzoomout = new javax.swing.JButton(); + + setLayout(new java.awt.BorderLayout()); + + m_jImage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/no_photo.png"))); // NOI18N + m_jImage.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + m_jScr.setViewportView(m_jImage); + + add(m_jScr, java.awt.BorderLayout.CENTER); + + jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5)); + jPanel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel2.setLayout(new java.awt.GridLayout(0, 1, 0, 2)); + + m_jbtnzoomin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/viewmag+.png"))); // NOI18N + m_jbtnzoomin.setToolTipText("Zoom In"); + m_jbtnzoomin.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jbtnzoomin.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnzoominActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnzoomin); + + m_jPercent.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jPercent.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jPercent.setOpaque(true); + m_jPercent.setPreferredSize(new java.awt.Dimension(10, 30)); + jPanel2.add(m_jPercent); + + m_jbtnzoomout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/viewmag-.png"))); // NOI18N + m_jbtnzoomout.setToolTipText("Zoom Out"); + m_jbtnzoomout.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jbtnzoomout.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnzoomoutActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnzoomout); + + jPanel1.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1)); + + add(jPanel1, java.awt.BorderLayout.LINE_END); + }// //GEN-END:initComponents + + private void m_jbtnzoomoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnzoomoutActionPerformed + + decZoom(); + + }//GEN-LAST:event_m_jbtnzoomoutActionPerformed + + private void m_jbtnzoominActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnzoominActionPerformed + + incZoom(); + + }//GEN-LAST:event_m_jbtnzoominActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JLabel m_jImage; + private javax.swing.JLabel m_jPercent; + private javax.swing.JScrollPane m_jScr; + private javax.swing.JButton m_jbtnzoomin; + private javax.swing.JButton m_jbtnzoomout; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/data/gui/JImageViewerProduct.form b/src/main/java/com/unicenta/data/gui/JImageViewerProduct.form new file mode 100644 index 0000000..c5e4fcd --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JImageViewerProduct.form @@ -0,0 +1,131 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/data/gui/JImageViewerProduct.java b/src/main/java/com/unicenta/data/gui/JImageViewerProduct.java new file mode 100644 index 0000000..c0029ef --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JImageViewerProduct.java @@ -0,0 +1,395 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import com.unicenta.data.loader.LocalRes; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import javax.imageio.ImageIO; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileFilter; + +/** + * + * @author JG uniCenta + */ +public class JImageViewerProduct extends javax.swing.JPanel { + + private Dimension m_maxsize; + private final ZoomIcon m_icon; + private BufferedImage m_Img = null; + + private static File m_fCurrentDirectory = null; + private static final NumberFormat m_percentformat = new DecimalFormat("#,##0.##%"); + + public JImageViewerProduct() { + initComponents(); + + m_Img = null; + m_maxsize = null; + m_icon = new ZoomIcon(); + m_jImage.setIcon(m_icon); + m_jPercent.setText(m_percentformat.format(m_icon.getZoom())); + privateSetEnabled(isEnabled()); + } + + /** + * + * @param size + */ + public void setMaxDimensions(Dimension size) { + m_maxsize = size; + } + + /** + * + * @return + */ + public Dimension getMaxDimensions() { + return m_maxsize; + } + + @Override + public void setEnabled(boolean value) { + + privateSetEnabled(value); + super.setEnabled(value); + } + + private void privateSetEnabled(boolean value) { + m_jbtnzoomin.setEnabled(value && (m_Img != null)); + m_jbtnzoomout.setEnabled(value && (m_Img != null)); + m_jPercent.setEnabled(value && (m_Img != null)); + m_jScr.setEnabled(value && (m_Img != null)); + } + + /** + * + * @param img + */ + public void setImage(BufferedImage img) { + BufferedImage oldimg = m_Img; + m_Img = img; + m_icon.setIcon(m_Img == null ? null : new ImageIcon(m_Img)); + + m_jPercent.setText(m_percentformat.format(m_icon.getZoom())); + + m_jImage.revalidate(); + m_jScr.revalidate(); + m_jScr.repaint(); + + privateSetEnabled(isEnabled()); + + firePropertyChange("image", oldimg, m_Img); + } + + /** + * + * @return + */ + public BufferedImage getImage() { + return m_Img; + } + + /** + * + * @return + */ + public double getZoom() { + return m_icon.getZoom(); + } + + /** + * + * @param zoom + */ + public void setZoom(double zoom) { + double oldzoom = m_icon.getZoom(); + m_icon.setZoom(zoom); + + m_jPercent.setText(m_percentformat.format(m_icon.getZoom())); + + m_jImage.revalidate(); + m_jScr.revalidate(); + m_jScr.repaint(); + + firePropertyChange("zoom", oldzoom, zoom); + } + + /** + * + */ + public void incZoom() { + double zoom = m_icon.getZoom(); + setZoom(zoom > 4.0 ? 8.0 : zoom * 2.0); + } + + /** + * + */ + public void decZoom() { + double zoom = m_icon.getZoom(); + setZoom(zoom < 0.5 ? 0.25 : zoom / 2.0); + } + + /** + * + */ + public void doLoad() { + JFileChooser fc = new JFileChooser(m_fCurrentDirectory); + + fc.addChoosableFileFilter(new ExtensionsFilter( + LocalRes.getIntString("label.imagefiles"), "png", "gif", "jpg", "jpeg", "bmp")); + + if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + try { + BufferedImage img = ImageIO.read(fc.getSelectedFile()); + if (img != null) { + // compruebo que no exceda el tamano maximo. + if (m_maxsize != null && (img.getHeight() > m_maxsize.height || img.getWidth() > m_maxsize.width)) { + if (JOptionPane.showConfirmDialog(this, + LocalRes.getIntString("message.resizeimage"), + LocalRes.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { + // Redimensionamos la imagen para que se ajuste + img = resizeImage(img); + } + } + setImage(img); + m_fCurrentDirectory = fc.getCurrentDirectory(); + } + } catch (IOException eIO) { + } + } + } + + private BufferedImage resizeImage(BufferedImage img) { + + int myheight = img.getHeight(); + int mywidth = img.getWidth(); + + if (myheight > m_maxsize.height) { + mywidth = (int) (mywidth * m_maxsize.height / myheight); + myheight = m_maxsize.height; + } + if (mywidth > m_maxsize.width) { + myheight = (int) (myheight * m_maxsize.width / mywidth); + mywidth = m_maxsize.width; + } + + BufferedImage thumb = new BufferedImage(mywidth, myheight, BufferedImage.TYPE_4BYTE_ABGR); + + double scalex = (double) mywidth / (double) img.getWidth(null); + double scaley = (double) myheight / (double) img.getHeight(null); + + Graphics2D g2d = thumb.createGraphics(); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + + g2d.setColor(new Color(0, 0, 0, 0)); + + g2d.fillRect(0, 0, mywidth, myheight); + if (scalex < scaley) { + g2d.drawImage(img, 0,(int) ((myheight - img.getHeight(null) * scalex) / 2.0) + , mywidth, (int) (img.getHeight(null) * scalex), null); + } else { + g2d.drawImage(img, (int) ((mywidth - img.getWidth(null) * scaley) / 2.0), 0 + , (int) (img.getWidth(null) * scaley), myheight, null); + } + g2d.dispose(); + + return thumb; + } + + private static class ZoomIcon implements Icon { + + private Icon ico; + private double zoom; + + public ZoomIcon() { + this.ico = null; + this.zoom = 1.0; + } + @Override + public int getIconHeight() { + return ico == null ? 0 : (int) (zoom * ico.getIconHeight()); + } + @Override + public int getIconWidth() { + return ico == null ? 0 : (int) (zoom * ico.getIconWidth()); + } + @Override + public void paintIcon(Component c, Graphics g, int x, int y) { + if (ico != null) { + Graphics2D g2d = (Graphics2D) g; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + AffineTransform oldt = g2d.getTransform(); + g2d.transform(AffineTransform.getScaleInstance(zoom, zoom)); + ico.paintIcon(c, g2d, (int) (x / zoom), (int) (y / zoom)); + g2d.setTransform(oldt); + } + } + public void setIcon(Icon ico) { + this.ico = ico; + this.zoom = 1.0; + } + public void setZoom(double zoom) { + this.zoom = zoom; + } + public double getZoom() { + return zoom; + } + } + private static class ExtensionsFilter extends FileFilter { + + private final String message; + private final String[] extensions; + + public ExtensionsFilter(String message, String... extensions) { + this.message = message; + this.extensions = extensions; + } + + @Override + public boolean accept(java.io.File f) { + if (f.isDirectory()) { + return true; + } else { + String sFileName = f.getName(); + int ipos = sFileName.lastIndexOf('.'); + if (ipos >= 0) { + String sExt = sFileName.substring(ipos + 1); + for(String s : extensions) { + if (s.equalsIgnoreCase(sExt)) { + return true; + } + } + } + return false; + } + } + + @Override + public String getDescription() { + return message; + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + m_jScr = new javax.swing.JScrollPane(); + m_jImage = new javax.swing.JLabel(); + jPanel1 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + m_jbtnzoomin = new javax.swing.JButton(); + m_jPercent = new javax.swing.JLabel(); + m_jbtnzoomout = new javax.swing.JButton(); + + setLayout(new java.awt.BorderLayout()); + + m_jImage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/no_photo.png"))); // NOI18N + m_jImage.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + m_jScr.setViewportView(m_jImage); + + add(m_jScr, java.awt.BorderLayout.CENTER); + + jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5)); + jPanel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel2.setLayout(new java.awt.GridLayout(0, 1, 0, 2)); + + m_jbtnzoomin.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/viewmag+.png"))); // NOI18N + m_jbtnzoomin.setToolTipText("Zoom In"); + m_jbtnzoomin.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jbtnzoomin.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnzoominActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnzoomin); + + m_jPercent.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jPercent.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jPercent.setOpaque(true); + m_jPercent.setPreferredSize(new java.awt.Dimension(10, 30)); + jPanel2.add(m_jPercent); + + m_jbtnzoomout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/viewmag-.png"))); // NOI18N + m_jbtnzoomout.setToolTipText("Zoom Out"); + m_jbtnzoomout.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jbtnzoomout.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnzoomoutActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnzoomout); + + jPanel1.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1)); + + add(jPanel1, java.awt.BorderLayout.LINE_END); + }// //GEN-END:initComponents + + private void m_jbtnzoomoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnzoomoutActionPerformed + + decZoom(); + + }//GEN-LAST:event_m_jbtnzoomoutActionPerformed + + private void m_jbtnzoominActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnzoominActionPerformed + + incZoom(); + + }//GEN-LAST:event_m_jbtnzoominActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JLabel m_jImage; + private javax.swing.JLabel m_jPercent; + private javax.swing.JScrollPane m_jScr; + private javax.swing.JButton m_jbtnzoomin; + private javax.swing.JButton m_jbtnzoomout; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/data/gui/JLabelDirty.java b/src/main/java/com/unicenta/data/gui/JLabelDirty.java new file mode 100644 index 0000000..5f5af25 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JLabelDirty.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import com.unicenta.data.user.DirtyListener; +import com.unicenta.data.user.DirtyManager; +import javax.swing.*; + +/** + * + * @author JG uniCenta + */ +public class JLabelDirty extends JLabel { + + private static Icon m_IconModif = null; + private static Icon m_IconNull = null; + + /** Creates a new instance of JDirtyPicture + * @param dm */ + public JLabelDirty(DirtyManager dm) { + + if (m_IconModif == null) { + m_IconModif = new ImageIcon(getClass().getResource("/com/unicenta/images/edit.png")); + } + if (m_IconNull == null) { + m_IconNull = new NullIcon(16, 16); + } + + dm.addDirtyListener(new DirtyListener() { + public void changedDirty(boolean bDirty) { + setIcon(bDirty ? m_IconModif : m_IconNull); + } + }); + } +} diff --git a/src/main/java/com/unicenta/data/gui/JListData.form b/src/main/java/com/unicenta/data/gui/JListData.form new file mode 100644 index 0000000..41b5032 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JListData.form @@ -0,0 +1,117 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/data/gui/JListData.java b/src/main/java/com/unicenta/data/gui/JListData.java new file mode 100644 index 0000000..f9f5de0 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JListData.java @@ -0,0 +1,175 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import java.util.*; + +/** + * + * @author JG uniCenta + */ +public class JListData extends javax.swing.JDialog { + + private Object m_selected; + + /** Creates new form JListData + * @param parent */ + public JListData(java.awt.Frame parent) { + super(parent, true); + initComponents(); + + getRootPane().setDefaultButton(m_jOK); + } + + /** + * + * @param data + * @return + */ + public Object showList(List data) { + + return showList(new MyListData(data)); + } + + /** + * + * @param model + * @return + */ + public Object showList(javax.swing.ListModel model) { + + m_jData.setModel(model); + m_selected = null; + + setVisible(true); + //show(); + + return m_selected; + } + + private static class MyListData extends javax.swing.AbstractListModel { + + private List m_data; + + public MyListData(List data) { + m_data = data; + } + + @Override + public Object getElementAt(int index) { + return m_data.get(index); + } + + @Override + public int getSize() { + return m_data.size(); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + m_jOK = new javax.swing.JButton(); + m_jCancel = new javax.swing.JButton(); + jScrollPane1 = new javax.swing.JScrollPane(); + m_jData = new javax.swing.JList(); + jToolBar1 = new javax.swing.JToolBar(); + jButton1 = new javax.swing.JButton(); + jButton2 = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + m_jOK.setText("Accept"); + m_jOK.setMaximumSize(new java.awt.Dimension(65, 33)); + m_jOK.setMinimumSize(new java.awt.Dimension(65, 33)); + m_jOK.setPreferredSize(new java.awt.Dimension(65, 33)); + m_jOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jOKActionPerformed(evt); + } + }); + jPanel1.add(m_jOK); + + m_jCancel.setText("Cancel"); + m_jCancel.setMaximumSize(new java.awt.Dimension(65, 33)); + m_jCancel.setMinimumSize(new java.awt.Dimension(65, 33)); + m_jCancel.setPreferredSize(new java.awt.Dimension(65, 33)); + m_jCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jCancelActionPerformed(evt); + } + }); + jPanel1.add(m_jCancel); + + getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH); + + m_jData.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jData.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + jScrollPane1.setViewportView(m_jData); + + getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER); + + jToolBar1.setFloatable(false); + + jButton1.setText("jButton1"); + jToolBar1.add(jButton1); + + jButton2.setText("jButton2"); + jToolBar1.add(jButton2); + + getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH); + + setSize(new java.awt.Dimension(264, 337)); + setLocationRelativeTo(null); + }// //GEN-END:initComponents + + private void m_jCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jCancelActionPerformed + + dispose(); + }//GEN-LAST:event_m_jCancelActionPerformed + + private void m_jOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jOKActionPerformed + + m_selected = m_jData.getSelectedValue(); + + dispose(); + }//GEN-LAST:event_m_jOKActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JPanel jPanel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JToolBar jToolBar1; + private javax.swing.JButton m_jCancel; + private javax.swing.JList m_jData; + private javax.swing.JButton m_jOK; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/data/gui/JListNavigator.form b/src/main/java/com/unicenta/data/gui/JListNavigator.form new file mode 100644 index 0000000..c80ac1e --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JListNavigator.form @@ -0,0 +1,54 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/data/gui/JListNavigator.java b/src/main/java/com/unicenta/data/gui/JListNavigator.java new file mode 100644 index 0000000..10822dc --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JListNavigator.java @@ -0,0 +1,150 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import java.awt.Dimension; +import java.awt.Rectangle; +import javax.swing.ListCellRenderer; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.LocalRes; +import com.unicenta.data.user.BrowsableEditableData; +import com.unicenta.data.user.BrowseListener; + +/** + * + * @author JG uniCenta + */ +public class JListNavigator extends javax.swing.JPanel implements BrowseListener, ListSelectionListener { + + /** + * + */ + protected BrowsableEditableData m_bd; + + /** Creates new form JListBrowse + * @param bd */ + public JListNavigator(BrowsableEditableData bd) { + this(bd, false); + } + + /** + * + * @param bd + * @param bTouchable + */ + public JListNavigator(BrowsableEditableData bd, boolean bTouchable) { + + m_bd = bd; + + initComponents(); + +// if (bTouchable) { + jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); + jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(35, 35)); + jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); +// } + + + m_jlist.addListSelectionListener(this); + m_jlist.setModel(m_bd.getListModel()); + + m_bd.addBrowseListener(this); + } + + /** + * + * @param cellRenderer + */ + public void setCellRenderer(ListCellRenderer cellRenderer) { + m_jlist.setCellRenderer(cellRenderer); + } + + /** + * + * @param iIndex + * @param iCounter + */ + @Override + public void updateIndex(int iIndex, int iCounter) { + + if (iIndex >= 0 && iIndex < iCounter) { + m_jlist.setSelectedIndex(iIndex); + } else { + m_jlist.setSelectedIndex(-1); + } + } + + @Override + public void valueChanged(ListSelectionEvent evt) { + + if (!evt.getValueIsAdjusting()) { + int i = m_jlist.getSelectedIndex(); + if (i >= 0) { + if (!m_bd.isAdjusting()) { + + try { + m_bd.moveTo(i); + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nomove"), eD); + msg.show(this); + } + } + Rectangle oRect = m_jlist.getCellBounds(i, i); + m_jlist.scrollRectToVisible(oRect); + } + } + } + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + m_jlist = new javax.swing.JList(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setPreferredSize(new java.awt.Dimension(300, 2)); + setLayout(new java.awt.BorderLayout()); + + jScrollPane1.setAutoscrolls(true); + jScrollPane1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + m_jlist.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jlist.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + m_jlist.setFocusable(false); + m_jlist.setRequestFocusEnabled(false); + jScrollPane1.setViewportView(m_jlist); + + add(jScrollPane1, java.awt.BorderLayout.CENTER); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JList m_jlist; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/data/gui/JMessageDialog.form b/src/main/java/com/unicenta/data/gui/JMessageDialog.form new file mode 100644 index 0000000..1c4d13d --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JMessageDialog.form @@ -0,0 +1,180 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/data/gui/JMessageDialog.java b/src/main/java/com/unicenta/data/gui/JMessageDialog.java new file mode 100644 index 0000000..2b2fbe6 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JMessageDialog.java @@ -0,0 +1,249 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import com.unicenta.data.loader.LocalRes; +import java.awt.*; +import javax.swing.*; +/** + * + * @author adrian + */ +public class JMessageDialog extends javax.swing.JDialog { + + /** Creates new form JMessageDialog */ + private JMessageDialog(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + /** Creates new form JMessageDialog */ + private JMessageDialog(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window) parent; + } else { + return getWindow(parent.getParent()); + } + } + + /** + * + * @param parent + * @param inf + */ + public static void showMessage(Component parent, MessageInf inf) { + + Window window = getWindow(parent); + + JMessageDialog myMsg; + if (window instanceof Frame) { + myMsg = new JMessageDialog((Frame) window, true); + } else { + myMsg = new JMessageDialog((Dialog) window, true); + } + + myMsg.initComponents(); + myMsg.applyComponentOrientation(parent.getComponentOrientation()); + myMsg.jscrException.setVisible(false); + myMsg.getRootPane().setDefaultButton(myMsg.jcmdOK); + + myMsg.jlblIcon.setIcon(inf.getSignalWordIcon()); + myMsg.jlblErrorCode.setText(inf.getErrorCodeMsg()); + myMsg.jlblMessage.setText("" + inf.getMessageMsg()); + + // Capturamos el texto de la excepcion... + if (inf.getCause() == null) { + myMsg.jtxtException.setText(null); + } else { + StringBuilder sb = new StringBuilder(); + + if (inf.getCause() instanceof Throwable) { + Throwable t = (Throwable) inf.getCause(); + while (t != null) { + sb.append(t.getClass().getName()); + sb.append(": \n"); + sb.append(t.getMessage()); + sb.append("\n\n"); + t = t.getCause(); + } + } else if (inf.getCause() instanceof Throwable[]) { + Throwable[] m_aExceptions = (Throwable[]) inf.getCause(); + for (int i = 0; i < m_aExceptions.length; i++) { + sb.append(m_aExceptions[i].getClass().getName()); + sb.append(": \n"); + sb.append(m_aExceptions[i].getMessage()); + sb.append("\n\n"); + } + } else if (inf.getCause() instanceof Object[]) { + Object [] m_aObjects = (Object []) inf.getCause(); + for (int i = 0; i < m_aObjects.length; i++) { + sb.append(m_aObjects[i].toString()); + sb.append("\n\n"); + } + } else if (inf.getCause() instanceof String) { + sb.append(inf.getCause().toString()); + } else { + sb.append(inf.getCause().getClass().getName()); + sb.append(": \n"); + sb.append(inf.getCause().toString()); + } + myMsg.jtxtException.setText(sb.toString()); + } + myMsg.jtxtException.setCaretPosition(0); + + //myMsg.show(); + myMsg.setVisible(true); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel4 = new javax.swing.JPanel(); + jlblErrorCode = new javax.swing.JLabel(); + jlblMessage = new javax.swing.JLabel(); + jscrException = new javax.swing.JScrollPane(); + jtxtException = new javax.swing.JTextArea(); + jlblIcon = new javax.swing.JLabel(); + jPanel3 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + jcmdOK = new javax.swing.JButton(); + jcmdMore = new javax.swing.JButton(); + + setTitle(LocalRes.getIntString("title.message")); // NOI18N + setResizable(false); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + closeDialog(evt); + } + }); + + jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS)); + + jlblErrorCode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jlblErrorCode.setText("jlblErrorCode"); + jPanel4.add(jlblErrorCode); + + jlblMessage.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jlblMessage.setText("jlblMessage"); + jlblMessage.setVerticalAlignment(javax.swing.SwingConstants.TOP); + jlblMessage.setMinimumSize(new java.awt.Dimension(200, 100)); + jlblMessage.setPreferredSize(new java.awt.Dimension(200, 100)); + jPanel4.add(jlblMessage); + + jscrException.setAlignmentX(0.0F); + + jtxtException.setEditable(false); + jtxtException.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jscrException.setViewportView(jtxtException); + + jPanel4.add(jscrException); + + getContentPane().add(jPanel4, java.awt.BorderLayout.CENTER); + + jlblIcon.setVerticalAlignment(javax.swing.SwingConstants.TOP); + jlblIcon.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10)); + getContentPane().add(jlblIcon, java.awt.BorderLayout.LINE_START); + + jPanel3.setLayout(new java.awt.BorderLayout()); + + jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdOK.setText(LocalRes.getIntString("button.OK")); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jcmdOK.setActionCommand(bundle.getString("button.OK")); // NOI18N + jcmdOK.setMaximumSize(new java.awt.Dimension(65, 33)); + jcmdOK.setMinimumSize(new java.awt.Dimension(65, 33)); + jcmdOK.setPreferredSize(new java.awt.Dimension(65, 33)); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel2.add(jcmdOK); + + jcmdMore.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdMore.setText(LocalRes.getIntString("button.information")); // NOI18N + jcmdMore.setMaximumSize(new java.awt.Dimension(65, 33)); + jcmdMore.setMinimumSize(new java.awt.Dimension(65, 33)); + jcmdMore.setPreferredSize(new java.awt.Dimension(65, 33)); + jcmdMore.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdMoreActionPerformed(evt); + } + }); + jPanel2.add(jcmdMore); + + jPanel3.add(jPanel2, java.awt.BorderLayout.LINE_END); + + getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH); + + setSize(new java.awt.Dimension(455, 277)); + setLocationRelativeTo(null); + }// //GEN-END:initComponents + + private void jcmdMoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdMoreActionPerformed + + // Add your handling code here: + jcmdMore.setEnabled(false); + jscrException.setVisible(true); + setSize(getWidth(), 310); +// JG 25 May 2013 change for JDK 7 + validate(); +// validateTree(); + + }//GEN-LAST:event_jcmdMoreActionPerformed + + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + // Add your handling code here: + setVisible(false); + dispose(); + }//GEN-LAST:event_jcmdOKActionPerformed + + /** Closes the dialog */ + private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog + setVisible(false); + dispose(); + }//GEN-LAST:event_closeDialog + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JButton jcmdMore; + private javax.swing.JButton jcmdOK; + private javax.swing.JLabel jlblErrorCode; + private javax.swing.JLabel jlblIcon; + private javax.swing.JLabel jlblMessage; + private javax.swing.JScrollPane jscrException; + private javax.swing.JTextArea jtxtException; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/data/gui/JNavigator.form b/src/main/java/com/unicenta/data/gui/JNavigator.form new file mode 100644 index 0000000..e30e205 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JNavigator.form @@ -0,0 +1,22 @@ + + +
+ + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/data/gui/JNavigator.java b/src/main/java/com/unicenta/data/gui/JNavigator.java new file mode 100644 index 0000000..8251719 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JNavigator.java @@ -0,0 +1,372 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import java.util.*; +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.LocalRes; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.BrowseListener; +import com.unicenta.data.user.BrowsableEditableData; +import com.unicenta.data.user.StateListener; + +/** + * + * @author JG uniCenta + */ +public class JNavigator extends javax.swing.JPanel implements BrowseListener, StateListener { + + /** + * + */ + public final static int BUTTONS_ALL = 0; + + /** + * + */ + public final static int BUTTONS_NONAVIGATE = 1; + + /** + * + */ + protected BrowsableEditableData m_bd; + + /** + * + */ + protected ComparatorCreator m_cc; + + /** + * + */ + protected FindInfo m_LastFindInfo; + + private javax.swing.JButton jbtnFind = null; + private javax.swing.JButton jbtnSort = null; + private javax.swing.JButton jbtnFirst = null; + private javax.swing.JButton jbtnLast = null; + private javax.swing.JButton jbtnNext = null; + private javax.swing.JButton jbtnPrev = null; + private javax.swing.JButton jbtnRefresh = null; + private javax.swing.JButton jbtnReload = null; + + /** Creates new form JNavigator + * @param bd + * @param vec + * @param cc + * @param iButtons */ + public JNavigator(BrowsableEditableData bd, Vectorer vec, ComparatorCreator cc, int iButtons) { + + initComponents(); + + if (iButtons == BUTTONS_ALL) { + jbtnFirst = new javax.swing.JButton(); + jbtnFirst.setPreferredSize(new java.awt.Dimension(60,45)); + jbtnFirst.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/2leftarrow.png"))); + jbtnFirst.setMargin(new java.awt.Insets(2, 2, 2, 2)); + jbtnFirst.setFocusPainted(false); + jbtnFirst.setFocusable(false); + jbtnFirst.setRequestFocusEnabled(false); + jbtnFirst.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnFirstActionPerformed(evt); + } + }); + add(jbtnFirst); + } + + if (iButtons == BUTTONS_ALL) { + jbtnPrev = new javax.swing.JButton(); + jbtnPrev.setPreferredSize(new java.awt.Dimension(60,45)); + jbtnPrev.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/1leftarrow.png"))); + jbtnPrev.setMargin(new java.awt.Insets(2, 2, 2, 2)); + jbtnPrev.setFocusPainted(false); + jbtnPrev.setFocusable(false); + jbtnPrev.setRequestFocusEnabled(false); + jbtnPrev.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnPrevActionPerformed(evt); + } + }); + add(jbtnPrev); + } + + jbtnRefresh = new javax.swing.JButton(); + jbtnRefresh.setPreferredSize(new java.awt.Dimension(60,45)); + jbtnRefresh.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/1downarrow.png"))); + jbtnRefresh.setMargin(new java.awt.Insets(2, 2, 2, 2)); + jbtnRefresh.setFocusPainted(false); + jbtnRefresh.setFocusable(false); + jbtnRefresh.setRequestFocusEnabled(false); + jbtnRefresh.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnRefreshActionPerformed(evt); + } + }); + add(jbtnRefresh); + + if (iButtons == BUTTONS_ALL) { + jbtnNext = new javax.swing.JButton(); + jbtnNext.setPreferredSize(new java.awt.Dimension(60,45)); + jbtnNext.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/1rightarrow.png"))); + jbtnNext.setMargin(new java.awt.Insets(2, 2, 2, 2)); + jbtnNext.setFocusPainted(false); + jbtnNext.setFocusable(false); + jbtnNext.setRequestFocusEnabled(false); + jbtnNext.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnNextActionPerformed(evt); + } + }); + add(jbtnNext); + } + + if (iButtons == BUTTONS_ALL) { + jbtnLast = new javax.swing.JButton(); + jbtnLast.setPreferredSize(new java.awt.Dimension(60,45)); + jbtnLast.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/2rightarrow.png"))); + jbtnLast.setMargin(new java.awt.Insets(2, 2, 2, 2)); + jbtnLast.setFocusPainted(false); + jbtnLast.setFocusable(false); + jbtnLast.setRequestFocusEnabled(false); + jbtnLast.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnLastActionPerformed(evt); + } + }); + add(jbtnLast); + } + + add(new javax.swing.JSeparator()); + + if (bd.canLoadData()) { + jbtnReload = new javax.swing.JButton(); + jbtnReload.setPreferredSize(new java.awt.Dimension(60,45)); + jbtnReload.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); + jbtnReload.setMargin(new java.awt.Insets(2, 2, 2, 2)); + jbtnReload.setFocusPainted(false); + jbtnReload.setFocusable(false); + jbtnReload.setRequestFocusEnabled(false); + jbtnReload.addActionListener(new java.awt.event.ActionListener() { + @Override + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnReloadActionPerformed(evt); + } + }); + add(jbtnReload); + + add(new javax.swing.JSeparator()); + } + + if (vec == null) { + m_LastFindInfo = null; + } else { + m_LastFindInfo = new FindInfo(vec); + jbtnFind = new javax.swing.JButton(); + jbtnFind.setPreferredSize(new java.awt.Dimension(60,45)); + jbtnFind.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/search24.png"))); + jbtnFind.setMargin(new java.awt.Insets(2, 2, 2, 2)); + jbtnFind.setFocusPainted(false); + jbtnFind.setFocusable(false); + jbtnFind.setRequestFocusEnabled(false); + jbtnFind.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnFindActionPerformed(evt); + } + }); + add(jbtnFind); + } + + m_cc = cc; + if (m_cc != null) { + jbtnSort = new javax.swing.JButton(); + jbtnSort.setPreferredSize(new java.awt.Dimension(60,45)); + jbtnSort.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sort_incr.png"))); + jbtnSort.setMargin(new java.awt.Insets(2, 2, 2, 2)); + jbtnSort.setFocusPainted(false); + jbtnSort.setFocusable(false); + jbtnSort.setRequestFocusEnabled(false); + jbtnSort.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnSortActionPerformed(evt); + } + }); + add(jbtnSort); + } + + m_bd = bd; + bd.addBrowseListener(this); + bd.addStateListener(this); + } + + /** + * + * @param bd + */ + public JNavigator(BrowsableEditableData bd) { + this(bd, null, null, BUTTONS_ALL); + } + + /** + * + * @param bd + * @param vec + * @param cc + */ + public JNavigator(BrowsableEditableData bd, Vectorer vec, ComparatorCreator cc) { + this(bd, vec, cc, BUTTONS_ALL); + } + + /** + * + * @param iState + */ + public void updateState(int iState) { + if (iState == BrowsableEditableData.ST_INSERT || iState == BrowsableEditableData.ST_DELETE) { + // Insert o Delete + if (jbtnFirst != null) jbtnFirst.setEnabled(false); + if (jbtnPrev != null) jbtnPrev.setEnabled(false); + if (jbtnNext != null) jbtnNext.setEnabled(false); + if (jbtnLast != null) jbtnLast.setEnabled(false); + if (jbtnRefresh != null) jbtnRefresh.setEnabled(true); + } + } + + /** + * + * @param iIndex + * @param iCounter + */ + public void updateIndex(int iIndex, int iCounter) { + + if (iIndex >= 0 && iIndex < iCounter) { + // Reposicionamiento + if (jbtnFirst != null) jbtnFirst.setEnabled(iIndex > 0); + if (jbtnPrev != null) jbtnPrev.setEnabled(iIndex > 0); + if (jbtnNext != null) jbtnNext.setEnabled(iIndex < iCounter - 1); + if (jbtnLast != null) jbtnLast.setEnabled(iIndex < iCounter - 1); + if (jbtnRefresh != null) jbtnRefresh.setEnabled(true); + } else { + // EOF + if (jbtnFirst != null) jbtnFirst.setEnabled(false); + if (jbtnPrev != null) jbtnPrev.setEnabled(false); + if (jbtnNext != null) jbtnNext.setEnabled(false); + if (jbtnLast != null) jbtnLast.setEnabled(false); + if (jbtnRefresh != null) jbtnRefresh.setEnabled(false); + } + } + + private void jbtnSortActionPerformed(java.awt.event.ActionEvent evt) { + try { + Comparator c = JSort.showMessage(this, m_cc); + if (c != null) { + m_bd.sort(c); + } + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nolistdata"), eD); + msg.show(this); + } + } + + private void jbtnFindActionPerformed(java.awt.event.ActionEvent evt) { + + try { + FindInfo newFindInfo = JFind.showMessage(this, m_LastFindInfo); + if (newFindInfo != null) { + m_LastFindInfo = newFindInfo; + + int index = m_bd.findNext(newFindInfo); + if (index < 0) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.norecord")); + msg.show(this); + } else { + m_bd.moveTo(index); + } + } + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nolistdata"), eD); + msg.show(this); + } + } + + private void jbtnRefreshActionPerformed(java.awt.event.ActionEvent evt) { + + m_bd.actionReloadCurrent(this); + } + + private void jbtnReloadActionPerformed(java.awt.event.ActionEvent evt) { + + try { + m_bd.actionLoad(); + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.noreload"), eD); + msg.show(this); + } + } + + private void jbtnLastActionPerformed(java.awt.event.ActionEvent evt) { + + try { + m_bd.moveLast(); + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nomove"), eD); + msg.show(this); + } + } + + private void jbtnFirstActionPerformed(java.awt.event.ActionEvent evt) { + + try{ + m_bd.moveFirst(); + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nomove"), eD); + msg.show(this); + } + } + + private void jbtnPrevActionPerformed(java.awt.event.ActionEvent evt) { + try { + m_bd.movePrev(); + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nomove"), eD); + msg.show(this); + } + } + + private void jbtnNextActionPerformed(java.awt.event.ActionEvent evt) { + try { + m_bd.moveNext(); + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nomove"), eD); + msg.show(this); + } + } + + // //GEN-BEGIN:initComponents + private void initComponents() { + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + }// //GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/data/gui/JSaver.form b/src/main/java/com/unicenta/data/gui/JSaver.form new file mode 100644 index 0000000..5dc9645 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JSaver.form @@ -0,0 +1,106 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/unicenta/data/gui/JSaver.java b/src/main/java/com/unicenta/data/gui/JSaver.java new file mode 100644 index 0000000..95daaaa --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JSaver.java @@ -0,0 +1,189 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import java.util.*; +import javax.swing.*; +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.LocalRes; +import com.unicenta.data.user.BrowsableEditableData; +import com.unicenta.data.user.StateListener; + +/** + * + * @author JG uniCenta + */ +public class JSaver extends JPanel implements StateListener { + + /** + * + */ + protected BrowsableEditableData m_bd; + + /** Creates new form JSaver + * @param bd */ + public JSaver(BrowsableEditableData bd) { + + initComponents(); + + m_bd = bd; + + // m_bd.addBrowseListener(this); + m_bd.addStateListener(this); + } + + /** + * + * @param iState + */ + @Override + public void updateState(int iState) { + switch (iState) { + case BrowsableEditableData.ST_INSERT: + jbtnNew.setEnabled(m_bd.canInsertData()); + jbtnDelete.setEnabled(false); + jbtnSave.setEnabled(m_bd.canInsertData()); + break; + case BrowsableEditableData.ST_DELETE: + jbtnNew.setEnabled(m_bd.canInsertData()); + jbtnDelete.setEnabled(false); + jbtnSave.setEnabled(m_bd.canDeleteData()); + break; + case BrowsableEditableData.ST_NORECORD: + jbtnNew.setEnabled(m_bd.canInsertData()); + jbtnDelete.setEnabled(false); + jbtnSave.setEnabled(false); + break; + case BrowsableEditableData.ST_UPDATE: + jbtnNew.setEnabled(m_bd.canInsertData()); + jbtnDelete.setEnabled(m_bd.canDeleteData()); + jbtnSave.setEnabled(m_bd.canUpdateData()); + break; + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jbtnNew = new javax.swing.JButton(); + jbtnDelete = new javax.swing.JButton(); + jbtnSave = new javax.swing.JButton(); + + jbtnNew.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/editnew.png"))); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jbtnNew.setToolTipText(bundle.getString("tooltip.addnew")); // NOI18N + jbtnNew.setFocusPainted(false); + jbtnNew.setFocusable(false); + jbtnNew.setMargin(new java.awt.Insets(2, 2, 2, 2)); + jbtnNew.setPreferredSize(new java.awt.Dimension(60, 45)); + jbtnNew.setRequestFocusEnabled(false); + jbtnNew.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnNewActionPerformed(evt); + } + }); + + jbtnDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_delete.png"))); // NOI18N + jbtnDelete.setToolTipText(bundle.getString("tooltip.delete")); // NOI18N + jbtnDelete.setFocusPainted(false); + jbtnDelete.setFocusable(false); + jbtnDelete.setMargin(new java.awt.Insets(2, 2, 2, 2)); + jbtnDelete.setPreferredSize(new java.awt.Dimension(60, 45)); + jbtnDelete.setRequestFocusEnabled(false); + jbtnDelete.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnDeleteActionPerformed(evt); + } + }); + + jbtnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/filesave.png"))); // NOI18N + jbtnSave.setToolTipText(bundle.getString("tooltip.save")); // NOI18N + jbtnSave.setFocusPainted(false); + jbtnSave.setFocusable(false); + jbtnSave.setMargin(new java.awt.Insets(2, 2, 2, 2)); + jbtnSave.setPreferredSize(new java.awt.Dimension(60, 45)); + jbtnSave.setRequestFocusEnabled(false); + jbtnSave.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnSaveActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jbtnNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jbtnDelete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jbtnSave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jbtnNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnDelete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnSave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + }// //GEN-END:initComponents + + private void jbtnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSaveActionPerformed + try { + m_bd.saveData(); + + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nosave"), eD); + msg.show(this); + } + }//GEN-LAST:event_jbtnSaveActionPerformed + + private void jbtnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnDeleteActionPerformed + try { + m_bd.actionDelete(); + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nodelete"), eD); + msg.show(this); + } + }//GEN-LAST:event_jbtnDeleteActionPerformed + + private void jbtnNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnNewActionPerformed + try { + m_bd.actionInsert(); + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nonew"), eD); + msg.show(this); + } + }//GEN-LAST:event_jbtnNewActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jbtnDelete; + private javax.swing.JButton jbtnNew; + private javax.swing.JButton jbtnSave; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/data/gui/JSort.form b/src/main/java/com/unicenta/data/gui/JSort.form new file mode 100644 index 0000000..98593ac --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JSort.form @@ -0,0 +1,221 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/data/gui/JSort.java b/src/main/java/com/unicenta/data/gui/JSort.java new file mode 100644 index 0000000..dc3456a --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/JSort.java @@ -0,0 +1,270 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import javax.swing.*; +import java.awt.*; +import java.util.Comparator; +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.LocalRes; + +/** + * + * @author JG uniCenta + */ +public class JSort extends JDialog { + + private ComparatorCreator m_cc; + private Comparator m_Comparator; + + private JSort(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + + private JSort(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + private Comparator init(ComparatorCreator cc) throws BasicException { + + initComponents(); + + getRootPane().setDefaultButton(jcmdOK); + + m_cc = cc; + + String[] sHeaders = m_cc.getHeaders(); + + m_jSort1.removeAllItems(); + m_jSort1.addItem(""); + for (int i = 0; i < sHeaders.length; i++) { + m_jSort1.addItem(sHeaders[i]); + } + m_jSort1.setSelectedItem(0); + + m_jSort2.removeAllItems(); + m_jSort2.addItem(""); + for (int i = 0; i < sHeaders.length; i++) { + m_jSort2.addItem(sHeaders[i]); + } + m_jSort2.setSelectedItem(0); + + m_jSort3.removeAllItems(); + m_jSort3.addItem(""); + for (int i = 0; i < sHeaders.length; i++) { + m_jSort3.addItem(sHeaders[i]); + } + m_jSort3.setSelectedItem(0); + + m_Comparator = null; + setVisible(true); + return m_Comparator; + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window)parent; + } else { + return getWindow(parent.getParent()); + } + } + + /** + * + * @param parent + * @param cc + * @return + * @throws BasicException + */ + public static Comparator showMessage(Component parent, ComparatorCreator cc) throws BasicException { + + Window window = getWindow(parent); + + JSort myMsg; + if (window instanceof Frame) { + myMsg = new JSort((Frame) window, true); + } else { + myMsg = new JSort((Dialog) window, true); + } + return myMsg.init(cc); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLabel2 = new javax.swing.JLabel(); + m_jSort1 = new javax.swing.JComboBox(); + jLabel3 = new javax.swing.JLabel(); + m_jSort2 = new javax.swing.JComboBox(); + jLabel4 = new javax.swing.JLabel(); + m_jSort3 = new javax.swing.JComboBox(); + jPanel2 = new javax.swing.JPanel(); + jcmdCancel = new javax.swing.JButton(); + jcmdOK = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(LocalRes.getIntString("caption.sort")); // NOI18N + setResizable(false); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(LocalRes.getIntString("label.sortby")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jSort1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSort1.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(LocalRes.getIntString("label.andby")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jSort2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSort2.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(LocalRes.getIntString("label.andby")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jSort3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSort3.setPreferredSize(new java.awt.Dimension(200, 30)); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(10, 10, 10) + .addComponent(m_jSort1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(10, 10, 10) + .addComponent(m_jSort2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(10, 10, 10) + .addComponent(m_jSort3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSort1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSort2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jSort3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + ); + + getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); + + jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setText(LocalRes.getIntString("button.cancel")); // NOI18N + jcmdCancel.setMaximumSize(new java.awt.Dimension(65, 33)); + jcmdCancel.setMinimumSize(new java.awt.Dimension(65, 33)); + jcmdCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel2.add(jcmdCancel); + + jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setText(LocalRes.getIntString("button.OK")); // NOI18N + jcmdOK.setMaximumSize(new java.awt.Dimension(65, 33)); + jcmdOK.setMinimumSize(new java.awt.Dimension(65, 33)); + jcmdOK.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel2.add(jcmdOK); + + getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); + + setSize(new java.awt.Dimension(396, 234)); + setLocationRelativeTo(null); + }// //GEN-END:initComponents + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_jcmdCancelActionPerformed + + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + int iSort1 = m_jSort1.getSelectedIndex(); + int iSort2 = m_jSort2.getSelectedIndex(); + int iSort3 = m_jSort3.getSelectedIndex(); + + if (iSort1 > 0 && iSort2 == 0 && iSort3 == 0) { + m_Comparator = m_cc.createComparator(new int[] {iSort1 - 1}); + dispose(); + } else if (iSort1 > 0 && iSort2 > 0 && iSort3 == 0) { + m_Comparator = m_cc.createComparator(new int[] {iSort1 - 1, iSort2 - 1}); + dispose(); + } else if (iSort1 > 0 && iSort2 > 0 && iSort3 > 0) { + m_Comparator = m_cc.createComparator(new int[] {iSort1 - 1, iSort2 - 1, iSort3 - 1}); + dispose(); + } else { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, LocalRes.getIntString("message.nosort")); + msg.show(this); + } + + }//GEN-LAST:event_jcmdOKActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + private javax.swing.JComboBox m_jSort1; + private javax.swing.JComboBox m_jSort2; + private javax.swing.JComboBox m_jSort3; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/data/gui/ListCellRendererBasic.java b/src/main/java/com/unicenta/data/gui/ListCellRendererBasic.java new file mode 100644 index 0000000..8b591bc --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/ListCellRendererBasic.java @@ -0,0 +1,49 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import com.unicenta.data.loader.IRenderString; +import java.awt.*; +import javax.swing.*; + +/** + * + * @author JG uniCenta + */ +public class ListCellRendererBasic extends DefaultListCellRenderer { + + private IRenderString m_renderer; + + /** Creates a new instance of ListCellRendererBasic + * @param renderer */ + public ListCellRendererBasic(IRenderString renderer) { + m_renderer = renderer; + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, null, index, isSelected, cellHasFocus); + + String s = m_renderer.getRenderString(value); + setText((s == null || s.equals("")) ? " " : s); // Un espacio en caso de nulo para que no deja la celda chiquitita. + return this; + } + +} diff --git a/src/main/java/com/unicenta/data/gui/ListKeyed.java b/src/main/java/com/unicenta/data/gui/ListKeyed.java new file mode 100644 index 0000000..b0e412f --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/ListKeyed.java @@ -0,0 +1,55 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import com.unicenta.data.loader.IKeyed; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author adrianromero + * @param + */ +public class ListKeyed extends ArrayList { + + /** + * + * @param list + */ + public ListKeyed(List list) { + this.addAll(list); + } + + /** + * + * @param key + * @return + */ + public K get(Object key) { + + for (K elem : this) { + if ((key == null && elem.getKey() == null) || (key != null && key.equals(elem.getKey()))) { + return elem; + } + } + return null; + } +} diff --git a/src/main/java/com/unicenta/data/gui/ListQBFModelNumber.java b/src/main/java/com/unicenta/data/gui/ListQBFModelNumber.java new file mode 100644 index 0000000..ae3f2b4 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/ListQBFModelNumber.java @@ -0,0 +1,141 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + + +package com.unicenta.data.gui; + +import com.unicenta.data.loader.QBFCompareEnum; +import javax.swing.AbstractListModel; +import javax.swing.ComboBoxModel; +/** + * + * @author adrian + */ +public class ListQBFModelNumber extends AbstractListModel implements ComboBoxModel { + +private Object[] m_items; +private Object m_sel; + +/** Creates a new instance of ListQBFModelNumber + * @param items */ +// public ListQBFModelNumber() { +// private ListQBFModelNumber(Object... items) { + public ListQBFModelNumber(Object... items) { + m_items = items; + m_sel = m_items[0]; + } + +// m_items = new Object[] { + + /** + * + * @return + */ + public static ListQBFModelNumber getMandatoryString() { + return new ListQBFModelNumber( + QBFCompareEnum.COMP_NONE, + QBFCompareEnum.COMP_EQUALS, + QBFCompareEnum.COMP_RE, + QBFCompareEnum.COMP_DISTINCT, +// QBFCompareEnum.COMP_GREATER, + QBFCompareEnum.COMP_GREATER, + QBFCompareEnum.COMP_LESS, +// QBFCompareEnum.COMP_GREATEROREQUALS, + QBFCompareEnum.COMP_GREATEROREQUALS, + QBFCompareEnum.COMP_LESSOREQUALS + ); + } + + /** + * + * @return + */ + public static ListQBFModelNumber getMandatoryNumber() { + return new ListQBFModelNumber( + QBFCompareEnum.COMP_NONE, + QBFCompareEnum.COMP_EQUALS, + QBFCompareEnum.COMP_DISTINCT, + QBFCompareEnum.COMP_GREATER, + QBFCompareEnum.COMP_LESS, + QBFCompareEnum.COMP_GREATEROREQUALS, + QBFCompareEnum.COMP_LESSOREQUALS + ); + } + + /** + * + * @return + */ + public static ListQBFModelNumber getNonMandatoryString() { + return new ListQBFModelNumber( + QBFCompareEnum.COMP_NONE, + QBFCompareEnum.COMP_EQUALS, + QBFCompareEnum.COMP_RE, + QBFCompareEnum.COMP_DISTINCT, + QBFCompareEnum.COMP_GREATER, + QBFCompareEnum.COMP_LESS, + QBFCompareEnum.COMP_GREATEROREQUALS, + QBFCompareEnum.COMP_LESSOREQUALS, + QBFCompareEnum.COMP_ISNULL, +// QBFCompareEnum.COMP_ISNOTNULL, +// }; +// m_sel = m_items[0]; + QBFCompareEnum.COMP_ISNOTNULL + ); + } + + /** + * + * @return + */ + public static ListQBFModelNumber getNonMandatoryNumber() { + return new ListQBFModelNumber( + QBFCompareEnum.COMP_NONE, + QBFCompareEnum.COMP_EQUALS, + QBFCompareEnum.COMP_DISTINCT, + QBFCompareEnum.COMP_GREATER, + QBFCompareEnum.COMP_LESS, + QBFCompareEnum.COMP_GREATEROREQUALS, + QBFCompareEnum.COMP_LESSOREQUALS, + QBFCompareEnum.COMP_ISNULL, + QBFCompareEnum.COMP_ISNOTNULL + ); + } + + @Override + public Object getElementAt(int index) { + + return m_items[index]; + } + + @Override + public int getSize() { + return m_items.length; + } + + @Override + public Object getSelectedItem() { + return m_sel; + } + + @Override + public void setSelectedItem(Object anItem) { + m_sel = anItem; + } +} diff --git a/src/main/java/com/unicenta/data/gui/MessageInf.java b/src/main/java/com/unicenta/data/gui/MessageInf.java new file mode 100644 index 0000000..11b4db6 --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/MessageInf.java @@ -0,0 +1,224 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import com.unicenta.data.loader.LocalRes; +import java.awt.*; +import javax.swing.*; + +/** + * + * @author JG uniCenta + */ +public class MessageInf { + + // SIGNAL_WORD'S + + /** + * + */ + public final static int SGN_DANGER = 0xFF000000; // Death or serious injury will occur + + /** + * + */ + public final static int SGN_WARNING = 0xFE000000; // Death or serious injury may occur + + /** + * + */ + public final static int SGN_CAUTION = 0xFD000000; // Minor or moderate injury may occur + + /** + * + */ + public final static int SGN_NOTICE = 0xFC000000; // Damage to property may occur + + /** + * + */ + public final static int SGN_IMPORTANT = 0xFA000000; // Operating or maintenance instructions or additional information + + /** + * + */ + public final static int SGN_SUCCESS = 0xFB000000; + + // ERROR_CLASS'ES + + /** + * + */ + public final static int CLS_GENERIC = 0x00000000; + + // ERROR_CODE'S + + // VARIABLES + private int m_iMsgNumber; // = SIGNAL_WORD (0xFF000000) | ERROR_CLASS (0x00FF0000) | ERROR_CODE (0x0000FFFF) + private String m_sHazard; + private String m_sConsequences; + private String m_sAvoiding; + + // CAUSE + private Object m_eCause; + + /** Creates a new instance of MessageInf + * @param iSignalWord + * @param sHazard + * @param e */ + public MessageInf(int iSignalWord, String sHazard, Object e) { +// m_iMsgNumber = iSignalWord | CLS_GENERIC; + m_iMsgNumber = iSignalWord; + m_sHazard = sHazard; + m_sConsequences = ""; + m_sAvoiding = ""; + m_eCause = e; + } + /** Creates a new instance of MessageInf + * @param iSignalWord + * @param sHazard */ + public MessageInf(int iSignalWord, String sHazard) { + this (iSignalWord, sHazard, null); + } + + /** Creates a new instance of MessageInf + * @param e */ + public MessageInf(Throwable e) { + this(SGN_WARNING, e.getLocalizedMessage(), e); + } + + /** + * + * @param parent + */ + public void show(Component parent) { + JMessageDialog.showMessage(parent, this); + } + + /** + * + * @return + */ + public Object getCause() { + return m_eCause; + } + + /** + * + * @return + */ + public int getSignalWord() { + return m_iMsgNumber & 0xFF000000; + } + + /** + * + * @return + */ + public Icon getSignalWordIcon() { + int iSignalWord = getSignalWord(); + if (iSignalWord == SGN_DANGER) { + return UIManager.getIcon("OptionPane.errorIcon"); + } else if (iSignalWord == SGN_WARNING) { + return UIManager.getIcon("OptionPane.warningIcon"); + } else if (iSignalWord == SGN_CAUTION) { + return UIManager.getIcon("OptionPane.warningIcon"); + } else if (iSignalWord == SGN_NOTICE) { + return UIManager.getIcon("OptionPane.informationIcon"); + } else if (iSignalWord == SGN_IMPORTANT) { + return UIManager.getIcon("OptionPane.informationIcon"); + } else if (iSignalWord == SGN_SUCCESS) { + return UIManager.getIcon("OptionPane.informationIcon"); + } else { + return UIManager.getIcon("OptionPane.questionIcon"); + } + } + + /** + * + * @return + */ + public String getErrorCodeMsg() { + + StringBuilder sb = new StringBuilder(); + int iSignalWord = getSignalWord(); + if (iSignalWord == SGN_DANGER) { + sb.append("DNG_"); + } else if (iSignalWord == SGN_WARNING) { + sb.append("WRN_"); + } else if (iSignalWord == SGN_CAUTION) { + sb.append("CAU_"); + } else if (iSignalWord == SGN_NOTICE) { + sb.append("NOT_"); + } else if (iSignalWord == SGN_IMPORTANT) { + sb.append("IMP_"); + } else if (iSignalWord == SGN_SUCCESS) { + sb.append("INF_"); + } else { + sb.append("UNK_"); + } + sb.append(toHex((m_iMsgNumber & 0x00FF0000) >> 16, 2)); + sb.append('_'); + sb.append(toHex(m_iMsgNumber & 0x0000FFFF, 4)); + return sb.toString(); + } + + private String toHex(int i, int iChars) { + String s = Integer.toHexString(i); + return s.length() >= iChars ? s : fillString(iChars - s.length()) + s; + } + + private String fillString(int iChars) { + char[] aStr = new char[iChars]; + for (int i = 0; i < aStr.length; i++) { + aStr[i] = '0'; + } + return new String(aStr); + } + + /** + * + * @return + */ + public String getMessageMsg() { + + StringBuilder sb = new StringBuilder(); + int iSignalWord = getSignalWord(); + if (iSignalWord == SGN_DANGER) { + sb.append(LocalRes.getIntString("sgn.danger")); + } else if (iSignalWord == SGN_WARNING) { + sb.append(LocalRes.getIntString("sgn.warning")); + } else if (iSignalWord == SGN_CAUTION) { + sb.append(LocalRes.getIntString("sgn.caution")); + } else if (iSignalWord == SGN_NOTICE) { + sb.append(LocalRes.getIntString("sgn.notice")); + } else if (iSignalWord == SGN_IMPORTANT) { + sb.append(LocalRes.getIntString("sgn.important")); + } else if (iSignalWord == SGN_SUCCESS) { + sb.append(LocalRes.getIntString("sgn.success")); + } else { + sb.append(LocalRes.getIntString("sgn.unknown")); + } + sb.append(m_sHazard); + sb.append(m_sConsequences); + sb.append(m_sAvoiding); + return sb.toString(); + } +} diff --git a/src/main/java/com/unicenta/data/gui/NullIcon.java b/src/main/java/com/unicenta/data/gui/NullIcon.java new file mode 100644 index 0000000..1599c9d --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/NullIcon.java @@ -0,0 +1,55 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import javax.swing.Icon; + +/** + * + * @author adrian + */ +public class NullIcon implements Icon { + + private int m_iWidth; + private int m_iHeight; + + /** Creates a new instance of NullIcon + * @param width + * @param height */ + public NullIcon(int width, int height) { + m_iWidth = width; + m_iHeight = height; + } + + @Override + public int getIconHeight() { + return m_iHeight; + } + + @Override + public int getIconWidth() { + return m_iWidth; + } + + @Override + public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y) { + } + +} diff --git a/src/main/java/com/unicenta/data/gui/TableRendererBasic.java b/src/main/java/com/unicenta/data/gui/TableRendererBasic.java new file mode 100644 index 0000000..925180f --- /dev/null +++ b/src/main/java/com/unicenta/data/gui/TableRendererBasic.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.gui; + +import com.unicenta.format.Formats; +import java.awt.Component; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; + +/** + * + * @author JG uniCenta + */ +public class TableRendererBasic extends DefaultTableCellRenderer { + + private Formats[] m_aFormats; + + /** Creates a new instance of TableRendererBasic + * @param aFormats */ + public TableRendererBasic(Formats[] aFormats) { + m_aFormats = aFormats; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){ + + JLabel aux = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column); + + aux.setText(m_aFormats[column].formatValue(value)); + aux.setHorizontalAlignment(m_aFormats[column].getAlignment()); + + return aux; + } +} diff --git a/src/main/java/com/unicenta/data/loader/BaseSentence.java b/src/main/java/com/unicenta/data/loader/BaseSentence.java new file mode 100644 index 0000000..1993f2e --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/BaseSentence.java @@ -0,0 +1,275 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public abstract class BaseSentence implements SentenceList, SentenceFind, SentenceExec { + + // Funciones de bajo nivel + + /** + * + * @param params + * @return + * @throws BasicException + */ + public abstract DataResultSet openExec(Object params) throws BasicException; + + /** + * + * @return + * @throws BasicException + */ + public abstract DataResultSet moreResults() throws BasicException; + + /** + * + * @throws BasicException + */ + public abstract void closeExec() throws BasicException; + + // Funciones + + /** + * + * @return + * @throws BasicException + */ + @Override + public final int exec() throws BasicException { + return exec((Object) null); + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + @Override + public final int exec(Object... params) throws BasicException { + return exec((Object) params); + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + @Override + public final int exec(Object params) throws BasicException { + DataResultSet SRS = openExec(params); + if (SRS == null) { + throw new BasicException(LocalRes.getIntString("exception.noupdatecount")); + } + int iResult = SRS.updateCount(); + SRS.close(); + closeExec(); + return iResult; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public final List list() throws BasicException { + return list((Object) null); + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + @Override + public final List list(Object... params) throws BasicException { + return list((Object) params); + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + @Override + public final List list(Object params) throws BasicException { + // En caso de error o lanza un pepinazo en forma de DataException + DataResultSet SRS = openExec(params); + List aSO = fetchAll(SRS); + SRS.close(); + closeExec(); + return aSO; + } + + /** + * + * @param offset + * @param length + * @return + * @throws BasicException + */ + @Override + public final List listPage(int offset, int length) throws BasicException { + return listPage(null, offset, length); + } + + /** + * + * @param params + * @param offset + * @param length + * @return + * @throws BasicException + */ + @Override + public final List listPage(Object params, int offset, int length) throws BasicException { + // En caso de error o lanza un pepinazo en forma de DataException + DataResultSet SRS = openExec(params); + List aSO = fetchPage(SRS, offset, length); + SRS.close(); + closeExec(); + return aSO; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public final Object find() throws BasicException { + return find((Object) null); + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + @Override + public final Object find(Object... params) throws BasicException { + return find((Object) params); + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + @Override + public final Object find(Object params) throws BasicException { + // En caso de error o lanza un pepinazo en forma de SQLException + DataResultSet SRS = openExec(params); + Object obj = fetchOne(SRS); + SRS.close(); + closeExec(); + return obj; + } + + // Utilidades + + /** + * + * @param SRS + * @return + * @throws BasicException + */ + public final List fetchAll(DataResultSet SRS) throws BasicException { + if (SRS == null) { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + List aSO = new ArrayList(); + while (SRS.next()) { + aSO.add(SRS.getCurrent()); + } + return aSO; + } + + // Utilidades + + /** + * + * @param SRS + * @param offset + * @param length + * @return + * @throws BasicException + */ + public final List fetchPage(DataResultSet SRS, int offset, int length) throws BasicException { + + if (SRS == null) { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + if (offset < 0 || length < 0) { + throw new BasicException(LocalRes.getIntString("exception.nonegativelimits")); + } + + // Skip los primeros que no me importan + while (offset > 0 && SRS.next()) { + offset--; + } + + // me traigo tantos como me han dicho + List aSO = new ArrayList(); + if (offset == 0) { + while (length > 0 && SRS.next()) { + length--; + aSO.add(SRS.getCurrent()); + } + } + return aSO; + } + + /** + * + * @param SRS + * @return + * @throws BasicException + */ + public final Object fetchOne(DataResultSet SRS) throws BasicException { + + if (SRS == null) { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + if (SRS.next()) { + return SRS.getCurrent(); + } else { + return null; + } + } + + } diff --git a/src/main/java/com/unicenta/data/loader/BasicSentenceEnum.java b/src/main/java/com/unicenta/data/loader/BasicSentenceEnum.java new file mode 100644 index 0000000..4e18085 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/BasicSentenceEnum.java @@ -0,0 +1,89 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author adrian + */ +public class BasicSentenceEnum implements SentenceEnum { + + BaseSentence sent; + DataResultSet SRS; + + /** Creates a new instance of AbstractSentenceEnum + * @param sent */ + public BasicSentenceEnum(BaseSentence sent) { + this.sent = sent; + this.SRS = null; + } + + /** + * + * @throws BasicException + */ + public void load() throws BasicException { + load(null); + } + + /** + * + * @param params + * @throws BasicException + */ + public void load(Object params) throws BasicException { + SRS = sent.openExec(params); + } + + /** + * + * @return + * @throws BasicException + */ + public Object getCurrent() throws BasicException { + if (SRS == null) { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + return SRS.getCurrent(); + } + + /** + * + * @return + * @throws BasicException + */ + public boolean next() throws BasicException { + if (SRS == null) { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + if (SRS.next()) { + return true; + } else { + SRS.close(); + SRS = null; + sent.closeExec(); + return false; + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/BatchSentence.java b/src/main/java/com/unicenta/data/loader/BatchSentence.java new file mode 100644 index 0000000..8eb9d7f --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/BatchSentence.java @@ -0,0 +1,345 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Reader; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * + * @author JG uniCenta + */ +public abstract class BatchSentence extends BaseSentence { + + /** + * + */ + protected Session m_s; + + /** + * + */ + protected HashMap m_parameters; + + /** Creates a new instance of BatchSentence + * @param s */ + public BatchSentence(Session s) { + m_s = s; + m_parameters = new HashMap<>(); + } + + /** + * + * @param name + * @param replacement + */ + public void putParameter(String name, String replacement) { + m_parameters.put(name, replacement); + } + + /** + * + * @return + * @throws BasicException + */ + protected abstract Reader getReader() throws BasicException; + + /** + * + */ + public class ExceptionsResultSet implements DataResultSet { + + List l; + int m_iIndex; + + /** + * + * @param l + */ + public ExceptionsResultSet(List l) { + this.l = l; + m_iIndex = -1; + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + @Override + public Integer getInt(int columnIndex) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + @Override + public String getString(int columnIndex) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + @Override + public Double getDouble(int columnIndex) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + @Override + public Boolean getBoolean(int columnIndex) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + @Override + public java.util.Date getTimestamp(int columnIndex) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + //public java.io.InputStream getBinaryStream(int columnIndex) throws DataException; + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + @Override + public byte[] getBytes(int columnIndex) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + @Override + public Object getObject(int columnIndex) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + // public int getColumnCount() throws DataException; + + /** + * + * @return + * @throws BasicException + */ + @Override + public DataField[] getDataField() throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object getCurrent() throws BasicException { + if (m_iIndex < 0 || m_iIndex >= l.size()) { + throw new BasicException(LocalRes.getIntString("exception.outofbounds")); + } else { + return l.get(m_iIndex); + } + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public boolean next() throws BasicException { + return ++m_iIndex < l.size(); + } + + /** + * + * @throws BasicException + */ + @Override + public void close() throws BasicException { + } + + /** + * + * @return + */ + @Override + public int updateCount() { + return 0; + } + } + + /** + * + * @throws BasicException + */ + @Override + public final void closeExec() throws BasicException { + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public final DataResultSet moreResults() throws BasicException { + return null; + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + @Override + public DataResultSet openExec(Object params) throws BasicException { + + BufferedReader br = new BufferedReader(getReader()); + + String sLine; + StringBuffer sSentence = new StringBuffer(); + List aExceptions = new ArrayList(); + + try { + while ((sLine = br.readLine()) != null) { + sLine = sLine.trim(); + if (!sLine.equals("") && !sLine.startsWith("--")) { + // No es un comentario ni linea vacia + if (sLine.endsWith(";")) { + // ha terminado la sentencia + sSentence.append(sLine.substring(0, sLine.length() - 1)); + + // File parameters + Pattern pattern = Pattern.compile("\\$(\\w+)\\{([^}]*)\\}"); + Matcher matcher = pattern.matcher(sSentence.toString()); + List paramlist = new ArrayList(); + + // Replace all occurrences of pattern in input + StringBuffer buf = new StringBuffer(); + while (matcher.find()) { + if ("FILE".equals(matcher.group(1))) { + paramlist.add(ImageUtils.getBytesFromResource(matcher.group(2))); + matcher.appendReplacement(buf, "?"); + } else { + String replacement = m_parameters.get(matcher.group(1)); + if (replacement == null) { + matcher.appendReplacement(buf, Matcher.quoteReplacement(matcher.group(0))); + } else { + paramlist.add(replacement); + matcher.appendReplacement(buf, "?"); + } + } + } + matcher.appendTail(buf); + + // La disparo + try { + BaseSentence sent; + if (paramlist.isEmpty()) { + sent = new StaticSentence(m_s, buf.toString()); + sent.exec(); + } else { + sent = new PreparedSentence(m_s, buf.toString(), SerializerWriteBuilder.INSTANCE); + sent.exec(new VarParams(paramlist)); + } + } catch (BasicException eD) { + aExceptions.add(eD); + } + sSentence = new StringBuffer(); + + } else { + // la sentencia continua en la linea siguiente + sSentence.append(sLine); + } + } + } + + br.close(); + + } catch (IOException eIO) { + throw new BasicException(LocalRes.getIntString("exception.noreadfile"), eIO); + } + + if (sSentence.length() > 0) { + // ha quedado una sentencia inacabada + aExceptions.add(new BasicException(LocalRes.getIntString("exception.nofinishedfile"))); + } + + return new ExceptionsResultSet(aExceptions); + } + + private static class VarParams implements SerializableWrite { + + private List l; + + public VarParams(List l) { + this.l = l; + } + + @Override + public void writeValues(DataWrite dp) throws BasicException { + for (int i = 0; i < l.size(); i++) { + Object v = l.get(i); + if (v instanceof String) { + dp.setString(i + 1, (String) v); + } else if (v instanceof byte[]) { + dp.setBytes(i + 1, (byte[]) l.get(i)); + } else { + dp.setObject(i + 1, v); + } + } + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/BatchSentenceResource.java b/src/main/java/com/unicenta/data/loader/BatchSentenceResource.java new file mode 100644 index 0000000..0027584 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/BatchSentenceResource.java @@ -0,0 +1,63 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import com.unicenta.basic.BasicException; +import java.io.UnsupportedEncodingException; + +/** + * + * @author adrianromero + */ +public class BatchSentenceResource extends BatchSentence { + + private String m_sResScript; + + /** Creates a new instance of BatchSentenceResource + * @param s + * @param resscript */ + public BatchSentenceResource(Session s, String resscript) { + super(s); + m_sResScript = resscript; + } + + /** + * + * @return + * @throws BasicException + */ + protected Reader getReader() throws BasicException { + + InputStream in = BatchSentenceResource.class.getResourceAsStream(m_sResScript); + + if (in == null) { + throw new BasicException(LocalRes.getIntString("exception.nosentencesfile")); + } else { + try { + return new InputStreamReader(in, "UTF-8"); + } catch (UnsupportedEncodingException ex) { + throw new BasicException(LocalRes.getIntString("exception.nosentencesfile"), ex); + } + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/BatchSentenceScript.java b/src/main/java/com/unicenta/data/loader/BatchSentenceScript.java new file mode 100644 index 0000000..b0ea0e2 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/BatchSentenceScript.java @@ -0,0 +1,51 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + + +package com.unicenta.data.loader; + +import java.io.Reader; +import com.unicenta.basic.BasicException; + +/** + * + * @author adrianromero + */ +public class BatchSentenceScript extends BatchSentence { + + private String m_sScript; + + /** Creates a new instance of BatchSentenceScript + * @param s + * @param script */ + public BatchSentenceScript(Session s, String script) { + super(s); + m_sScript = script; + } + + /** + * + * @return + * @throws BasicException + */ + protected Reader getReader() throws BasicException { + + return new java.io.StringReader(m_sScript); + } +} diff --git a/src/main/java/com/unicenta/data/loader/CompanyDetails.java b/src/main/java/com/unicenta/data/loader/CompanyDetails.java new file mode 100644 index 0000000..71c0ce0 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/CompanyDetails.java @@ -0,0 +1,63 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + + +import com.unicenta.pos.forms.AppConfig; +import java.io.*; + +/** + * + * @author JG uniCenta + */ +public class CompanyDetails { + private String db_url; + private String db_user; + private String db_password; + private File m_config; + private Session session; + + /** + * + */ + public CompanyDetails() { + + AppConfig config = new AppConfig(m_config); +} + + /** + * + * @param config + */ + public void loadProperties(AppConfig config) { + + db_url=(config.getProperty("db.url")); + db_user=(config.getProperty("db_user")); + db_password=(config.getProperty("db.password")); +} + + /** + * + * @return + */ + public String getUser() { + return db_user; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/data/loader/ComparatorCreator.java b/src/main/java/com/unicenta/data/loader/ComparatorCreator.java new file mode 100644 index 0000000..b760a10 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/ComparatorCreator.java @@ -0,0 +1,42 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import java.util.Comparator; + +/** + * + * @author JG uniCenta + */ +public interface ComparatorCreator { + + /** + * + * @return + */ + public String[] getHeaders(); + + /** + * + * @param index + * @return + */ + public Comparator createComparator(int[] index); +} diff --git a/src/main/java/com/unicenta/data/loader/ComparatorCreatorBasic.java b/src/main/java/com/unicenta/data/loader/ComparatorCreatorBasic.java new file mode 100644 index 0000000..e179cb4 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/ComparatorCreatorBasic.java @@ -0,0 +1,117 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import java.util.Comparator; + +/** + * + * @author JG uniCenta + */ +public class ComparatorCreatorBasic implements ComparatorCreator { + + private String[] m_sHeaders; + private Datas[] m_aDatas; + private int[] m_iAvailableIndexes; + + /** Creates a new instance of ComparatorCreatorBasic + * @param sHeaders + * @param aDatas + * @param iAvailableIndexes */ + public ComparatorCreatorBasic(String[] sHeaders, Datas[] aDatas, int[] iAvailableIndexes) { + + m_sHeaders = sHeaders; + m_aDatas = aDatas; + m_iAvailableIndexes = iAvailableIndexes; + } + + /** + * + * @param sHeaders + * @param aDatas + */ + public ComparatorCreatorBasic(String[] sHeaders, Datas[] aDatas) { + m_sHeaders = sHeaders; + m_aDatas = aDatas; + m_iAvailableIndexes = new int[aDatas.length]; + for (int i = 0; i < aDatas.length; i++) { + m_iAvailableIndexes[i] = i; + } + } + + /** + * + * @return + */ + public String[] getHeaders() { + + String[] sTempHeaders = new String[m_iAvailableIndexes.length]; + + for (int i = 0; i < m_iAvailableIndexes.length; i++) { + sTempHeaders[i] = m_sHeaders[m_iAvailableIndexes[i]]; + } + return sTempHeaders; + } + + /** + * + * @param aiOrderBy + * @return + */ + public Comparator createComparator(int[] aiOrderBy) { + return new ComparatorBasic(aiOrderBy); + } + + /** + * + */ + public class ComparatorBasic implements Comparator { + + private int[] m_aiOrderBy; + + /** Creates a new instance of ComparatorBasic + * @param aiOrderBy */ + public ComparatorBasic(int[] aiOrderBy) { + m_aiOrderBy = aiOrderBy; + } + public int compare(Object o1, Object o2) { + if (o1 == null) { + if (o2 == null) { + return 0; + } else { + return -1; + } + } else if (o2 == null) { + return +1; + } else { + // ninguno de los dos es nulo... + Object[] ao1 = (Object[]) o1; + Object[] ao2 = (Object[]) o2; + for (int i = 0; i < m_aiOrderBy.length; i++) { + int result = m_aDatas[m_iAvailableIndexes[m_aiOrderBy[i]]].compare(ao1[m_iAvailableIndexes[m_aiOrderBy[i]]], ao2[m_iAvailableIndexes[m_aiOrderBy[i]]]); + if (result != 0) { + return result; + } + } + return 0; + } + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/DataField.java b/src/main/java/com/unicenta/data/loader/DataField.java new file mode 100644 index 0000000..ddf1ce8 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/DataField.java @@ -0,0 +1,46 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author JG uniCenta + */ +public class DataField { + + /** Creates a new instance of DataField */ + public DataField() { + } + + /** + * + */ + public String Name; + + /** + * + */ + public int Size; + + /** + * + */ + public int Type; +} diff --git a/src/main/java/com/unicenta/data/loader/DataParams.java b/src/main/java/com/unicenta/data/loader/DataParams.java new file mode 100644 index 0000000..68f33e8 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/DataParams.java @@ -0,0 +1,121 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; +import java.util.Date; + +/** + * + * @author adrianromero + */ +public abstract class DataParams implements DataWrite { + + /** + * + */ + protected DataWrite dw; + + /** + * + * @throws BasicException + */ + public abstract void writeValues() throws BasicException; + + /** + * + * @param paramIndex + * @param iValue + * @throws BasicException + */ + public void setInt(int paramIndex, Integer iValue) throws BasicException { + dw.setInt(paramIndex, iValue); + } + + public void setString(int paramIndex, String sValue) throws BasicException { + dw.setString(paramIndex, sValue); + } + + /** + * + * @param paramIndex + * @param dValue + * @throws BasicException + */ + public void setDouble(int paramIndex, Double dValue) throws BasicException { + dw.setDouble(paramIndex, dValue); + } + + /** + * + * @param paramIndex + * @param bValue + * @throws BasicException + */ + public void setBoolean(int paramIndex, Boolean bValue) throws BasicException { + dw.setBoolean(paramIndex, bValue); + } + + /** + * + * @param paramIndex + * @param dValue + * @throws BasicException + */ + public void setTimestamp(int paramIndex, Date dValue) throws BasicException { + dw.setTimestamp(paramIndex, dValue); + } + + /** + * + * @param paramIndex + * @param value + * @throws BasicException + */ + public void setBytes(int paramIndex, byte[] value) throws BasicException { + dw.setBytes(paramIndex, value); + } + + /** + * + * @param paramIndex + * @param value + * @throws BasicException + */ + public void setObject(int paramIndex, Object value) throws BasicException { + dw.setObject(paramIndex, value); + } + + /** + * + * @return + */ + public DataWrite getDataWrite() { + return dw; + } + + /** + * + * @param dw + */ + public void setDataWrite(DataWrite dw) { + this.dw = dw; + } +} diff --git a/src/main/java/com/unicenta/data/loader/DataRead.java b/src/main/java/com/unicenta/data/loader/DataRead.java new file mode 100644 index 0000000..a80fa96 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/DataRead.java @@ -0,0 +1,96 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author adrian + */ +public interface DataRead { + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public Integer getInt(int columnIndex) throws BasicException; + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public String getString(int columnIndex) throws BasicException; + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public Double getDouble(int columnIndex) throws BasicException; + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public Boolean getBoolean(int columnIndex) throws BasicException; + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public java.util.Date getTimestamp(int columnIndex) throws BasicException; + + //public java.io.InputStream getBinaryStream(int columnIndex) throws DataException; + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public byte[] getBytes(int columnIndex) throws BasicException; + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public Object getObject(int columnIndex) throws BasicException ; + +// public int getColumnCount() throws DataException; + + /** + * + * @return + * @throws BasicException + */ + public DataField[] getDataField() throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/DataResultSet.java b/src/main/java/com/unicenta/data/loader/DataResultSet.java new file mode 100644 index 0000000..cca22f3 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/DataResultSet.java @@ -0,0 +1,56 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public interface DataResultSet extends DataRead { + + /** + * + * @return + * @throws BasicException + */ + public Object getCurrent() throws BasicException; + + /** + * + * @return + * @throws BasicException + */ + public boolean next() throws BasicException; + + /** + * + * @throws BasicException + */ + public void close() throws BasicException; + + /** + * + * @return + * @throws BasicException + */ + public int updateCount() throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/DataWrite.java b/src/main/java/com/unicenta/data/loader/DataWrite.java new file mode 100644 index 0000000..606d6bb --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/DataWrite.java @@ -0,0 +1,86 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author adrian + */ +public interface DataWrite { + + /** + * + * @param paramIndex + * @param iValue + * @throws BasicException + */ + public void setInt(int paramIndex, Integer iValue) throws BasicException; + /** + * + * @param paramIndex + * @param sValue + * @throws BasicException + */ + public void setString(int paramIndex, String sValue) throws BasicException; + + /** + * + * @param paramIndex + * @param dValue + * @throws BasicException + */ + public void setDouble(int paramIndex, Double dValue) throws BasicException; + + /** + * + * @param paramIndex + * @param bValue + * @throws BasicException + */ + public void setBoolean(int paramIndex, Boolean bValue) throws BasicException; + + /** + * + * @param paramIndex + * @param dValue + * @throws BasicException + */ + public void setTimestamp(int paramIndex, java.util.Date dValue) throws BasicException; + + //public void setBinaryStream(int paramIndex, java.io.InputStream in, int length) throws DataException; + + /** + * + * @param paramIndex + * @param value + * @throws BasicException + */ + public void setBytes(int paramIndex, byte[] value) throws BasicException; + + /** + * + * @param paramIndex + * @param value + * @throws BasicException + */ + public void setObject(int paramIndex, Object value) throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/DataWriteUtils.java b/src/main/java/com/unicenta/data/loader/DataWriteUtils.java new file mode 100644 index 0000000..faaa098 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/DataWriteUtils.java @@ -0,0 +1,156 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import java.sql.Timestamp; +import java.util.Date; +import java.text.DateFormat; +import java.text.SimpleDateFormat; + +/** + * + * @author adrian + */ +public class DataWriteUtils { + + + /** Creates a new instance of DataWriteUtils */ + public DataWriteUtils() { + } + + /** + * + * @param obj + * @return + */ + public static String getSQLValue(Object obj) { + if (obj == null) { + return "NULL"; + } else if (obj instanceof Double) { + return getSQLValue((Double) obj); + } else if (obj instanceof Integer) { + return getSQLValue((Integer) obj); + } else if (obj instanceof Boolean) { + return getSQLValue((Boolean) obj); + } else if (obj instanceof String) { + return getSQLValue((String) obj); + } else if (obj instanceof Date) { + return getSQLValue((Date) obj); + } else { + return getSQLValue(obj.toString()); + } + } + + /** + * + * @param iValue + * @return + */ + public static String getSQLValue(Integer iValue) { + if (iValue == null) { + return "NULL"; + } else { + return iValue.toString(); + } + } + + /** + * + * @param dValue + * @return + */ + public static String getSQLValue(Double dValue) { + if (dValue == null) { + return "NULL"; + } else { + return dValue.toString(); + } + } + + /** + * + * @param bValue + * @return + */ + public static String getSQLValue(Boolean bValue) { + if (bValue == null) { + return "NULL"; + } else { + return bValue.booleanValue() ? "TRUE" : "FALSE"; + } + } + + /** + * + * @param sValue + * @return + */ + public static String getSQLValue(String sValue) { + if (sValue == null) { + return "NULL"; + } else { + return '\'' + getEscaped(sValue) + '\''; + } + } + + /** + * + * @param dValue + * @return + */ + public static String getSQLValue(Date dValue) { + if (dValue == null) { + return "NULL"; + } else { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String date = sdf.format(dValue); + return "'"+date+"'"; + } + } + + /** + * + * @param sValue + * @return + */ + public static String getEscaped(String sValue) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < sValue.length(); i++) { + switch (sValue.charAt(i)) { + case '\\': + sb.append("\\\\"); + break; + case '\'': + sb.append("\\'"); + break; + case '\n': + sb.append("\\n"); + break; + case '\r': + sb.append("\\r"); + break; + default: + sb.append(sValue.charAt(i)); + break; + } + } + return sb.toString(); + } + } diff --git a/src/main/java/com/unicenta/data/loader/Datas.java b/src/main/java/com/unicenta/data/loader/Datas.java new file mode 100644 index 0000000..81db461 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/Datas.java @@ -0,0 +1,388 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; + +/** + * @author JG uniCenta + */ +public abstract class Datas { + + /** + * + */ + public final static Datas INT = new DatasINT(); + + /** + * + */ + public final static Datas STRING = new DatasSTRING(); + + /** + * + */ + public final static Datas DOUBLE = new DatasDOUBLE(); + + /** + * + */ + public final static Datas BOOLEAN = new DatasBOOLEAN(); + + /** + * + */ + public final static Datas TIMESTAMP = new DatasTIMESTAMP(); + + /** + * + */ + public final static Datas BYTES = new DatasBYTES(); + + /** + * + */ + public final static Datas IMAGE = new DatasIMAGE(); + //public final static Datas INPUTSTREAM = new DatasINPUTSTREAM(); + + /** + * + */ + public final static Datas OBJECT = new DatasOBJECT(); + + /** + * + */ + public final static Datas SERIALIZABLE = new DatasSERIALIZABLE(); + + /** + * + */ + public final static Datas NULL = new DatasNULL(); + + private static DateFormat tsf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + + /** + * Creates a new instance of Datas + */ + private Datas() { + } + + /** + * @param dr + * @param i + * @return + * @throws BasicException + */ + public abstract Object getValue(DataRead dr, int i) throws BasicException; + + /** + * @param dw + * @param i + * @param value + * @throws BasicException + */ + public abstract void setValue(DataWrite dw, int i, Object value) throws BasicException; + + /** + * @return + */ + public abstract Class getClassValue(); + + /** + * @param value + * @return + */ + protected abstract String toStringAbstract(Object value); + + /** + * @param o1 + * @param o2 + * @return + */ + protected abstract int compareAbstract(Object o1, Object o2); + + /** + * @param value + * @return + */ + public String toString(Object value) { + if (value == null) { + return "null"; + } else { + return toStringAbstract(value); + } + } + + /** + * @param o1 + * @param o2 + * @return + */ + public int compare(Object o1, Object o2) { + if (o1 == null) { + if (o2 == null) { + return 0; + } else { + return -1; + } + } else if (o2 == null) { + return +1; + } else { + return compareAbstract(o1, o2); + } + } + + private static final class DatasINT extends Datas { + public Object getValue(DataRead dr, int i) throws BasicException { + return dr.getInt(i); + } + + public void setValue(DataWrite dw, int i, Object value) throws BasicException { + dw.setInt(i, (Integer) value); + } + + public Class getClassValue() { + return java.lang.Integer.class; + } + + protected String toStringAbstract(Object value) { + return ((Integer) value).toString(); + } + + protected int compareAbstract(Object o1, Object o2) { + return ((Integer) o1).compareTo((Integer) o2); + } + } + + private static final class DatasSTRING extends Datas { + public Object getValue(DataRead dr, int i) throws BasicException { + return dr.getString(i); + } + + public void setValue(DataWrite dw, int i, Object value) throws BasicException { + dw.setString(i, (String) value); + } + + public Class getClassValue() { + return java.lang.String.class; + } + + protected String toStringAbstract(Object value) { + return "\'" + DataWriteUtils.getEscaped((String) value) + "\'"; + } + + protected int compareAbstract(Object o1, Object o2) { + return ((String) o1).compareTo((String) o2); + } + } + + private static final class DatasDOUBLE extends Datas { + public Object getValue(DataRead dr, int i) throws BasicException { + return dr.getDouble(i); + } + + public void setValue(DataWrite dw, int i, Object value) throws BasicException { + dw.setDouble(i, (Double) value); + } + + public Class getClassValue() { + return java.lang.Double.class; + } + + protected String toStringAbstract(Object value) { + return ((Double) value).toString(); + } + + protected int compareAbstract(Object o1, Object o2) { + return ((Double) o1).compareTo((Double) o2); + } + } + + private static final class DatasBOOLEAN extends Datas { + public Object getValue(DataRead dr, int i) throws BasicException { + return dr.getBoolean(i); + } + + public void setValue(DataWrite dw, int i, Object value) throws BasicException { + dw.setBoolean(i, (Boolean) value); + } + + public Class getClassValue() { + return java.lang.Boolean.class; + } + + protected String toStringAbstract(Object value) { + return ((Boolean) value).toString(); + } + + protected int compareAbstract(Object o1, Object o2) { + return ((Boolean) o1).compareTo((Boolean) o2); + } + } + + private static final class DatasTIMESTAMP extends Datas { + public Object getValue(DataRead dr, int i) throws BasicException { + return dr.getTimestamp(i); + } + + public void setValue(DataWrite dw, int i, Object value) throws BasicException { + dw.setTimestamp(i, (java.util.Date) value); + } + + public Class getClassValue() { + return java.util.Date.class; + } + + protected String toStringAbstract(Object value) { + return tsf.format(value); + } + + protected int compareAbstract(Object o1, Object o2) { + return ((java.util.Date) o1).compareTo((java.util.Date) o2); + } + } + + private static final class DatasBYTES extends Datas { + public Object getValue(DataRead dr, int i) throws BasicException { + return dr.getBytes(i); + } + + public void setValue(DataWrite dw, int i, Object value) throws BasicException { + dw.setBytes(i, (byte[]) value); + } + + public Class getClassValue() { + return byte[].class; + } + + protected String toStringAbstract(Object value) { + return "0x" + ImageUtils.bytes2hex((byte[]) value); + } + + protected int compareAbstract(Object o1, Object o2) { + throw new UnsupportedOperationException(); + } + } + + private static final class DatasIMAGE extends Datas { + @Override + public Object getValue(DataRead dr, int i) throws BasicException { + return ImageUtils.readImage(dr.getBytes(i)); + } + + @Override + public void setValue(DataWrite dw, int i, Object value) throws BasicException { + dw.setBytes(i, ImageUtils.writeImage((java.awt.image.BufferedImage) value)); + } + + @Override + public Class getClassValue() { + return java.awt.image.BufferedImage.class; + } + + @Override + protected String toStringAbstract(Object value) { + return "0x" + ImageUtils.bytes2hex(ImageUtils.writeImage((java.awt.image.BufferedImage) value)); + } + + @Override + protected int compareAbstract(Object o1, Object o2) { + throw new UnsupportedOperationException(); + } + } + + // private static final class DatasINPUTSTREAM extends Datas { +// public Object getValue(DataRead dr, int i) throws DataException { +// byte[] b = dr.getBytes(i); +// return b == null ? null : new java.io.ByteArrayInputStream(b); +// } +// public void setValue(DataWrite dw, int i, Object value) throws DataException { +// } +// } + private static final class DatasOBJECT extends Datas { + public Object getValue(DataRead dr, int i) throws BasicException { + return dr.getObject(i); + } + + public void setValue(DataWrite dw, int i, Object value) throws BasicException { + dw.setObject(i, value); + } + + public Class getClassValue() { + return java.lang.Object.class; + } + + protected String toStringAbstract(Object value) { + return "0x" + ImageUtils.bytes2hex(ImageUtils.writeSerializable(value)); + } + + protected int compareAbstract(Object o1, Object o2) { + throw new UnsupportedOperationException(); + } + } + + private static final class DatasSERIALIZABLE extends Datas { + public Object getValue(DataRead dr, int i) throws BasicException { + return ImageUtils.readSerializable(dr.getBytes(i)); + } + + public void setValue(DataWrite dw, int i, Object value) throws BasicException { + dw.setBytes(i, ImageUtils.writeSerializable(value)); + } + + public Class getClassValue() { + return java.lang.Object.class; + } + + protected String toStringAbstract(Object value) { + return "0x" + ImageUtils.bytes2hex(ImageUtils.writeSerializable(value)); + } + + protected int compareAbstract(Object o1, Object o2) { + throw new UnsupportedOperationException(); + } + } + + private static final class DatasNULL extends Datas { + public Object getValue(DataRead dr, int i) throws BasicException { + return null; + } + + public void setValue(DataWrite dw, int i, Object value) throws BasicException { + // No asigno null, no asigno nada. + } + + public Class getClassValue() { + return java.lang.Object.class; + } + + protected String toStringAbstract(Object value) { + return "null"; + } + + protected int compareAbstract(Object o1, Object o2) { + throw new UnsupportedOperationException(); + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/IKeyGetter.java b/src/main/java/com/unicenta/data/loader/IKeyGetter.java new file mode 100644 index 0000000..f24cc1b --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/IKeyGetter.java @@ -0,0 +1,34 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author JG uniCenta + */ +public interface IKeyGetter { + + /** + * + * @param value + * @return + */ + public Object getKey(Object value); +} diff --git a/src/main/java/com/unicenta/data/loader/IKeyed.java b/src/main/java/com/unicenta/data/loader/IKeyed.java new file mode 100644 index 0000000..b7f7431 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/IKeyed.java @@ -0,0 +1,35 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author adrianromero + * Created on 27 de febrero de 2007, 22:08 + * + */ +public interface IKeyed { + + /** + * + * @return + */ + public Object getKey(); +} diff --git a/src/main/java/com/unicenta/data/loader/IRenderString.java b/src/main/java/com/unicenta/data/loader/IRenderString.java new file mode 100644 index 0000000..f656c8f --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/IRenderString.java @@ -0,0 +1,34 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author JG uniCenta + */ +public interface IRenderString { + + /** + * + * @param value + * @return + */ + public String getRenderString(Object value); +} diff --git a/src/main/java/com/unicenta/data/loader/ISQLBuilderStatic.java b/src/main/java/com/unicenta/data/loader/ISQLBuilderStatic.java new file mode 100644 index 0000000..6d17064 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/ISQLBuilderStatic.java @@ -0,0 +1,38 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public interface ISQLBuilderStatic { + + /** + * + * @param sw + * @param params + * @return + * @throws BasicException + */ + public String getSQL(SerializerWrite sw, Object params) throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/ImageUtils.java b/src/main/java/com/unicenta/data/loader/ImageUtils.java new file mode 100644 index 0000000..ab9cbef --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/ImageUtils.java @@ -0,0 +1,245 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import java.io.*; +import javax.imageio.ImageIO; +import java.awt.image.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.util.Properties; + +/** + * + * @author JG uniCenta + */ +public class ImageUtils { + + private static char[] HEXCHARS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + + /** Creates a new instance of ImageUtils */ + private ImageUtils() { + } + + private static byte[] readStream(InputStream in) throws IOException { + byte[] buffer = new byte[1024]; + byte[] resource = new byte[0]; + int n; + + while ((n = in.read(buffer)) != -1) { + byte[] b = new byte[resource.length + n]; + System.arraycopy(resource, 0, b, 0, resource.length); + System.arraycopy(buffer, 0, b, resource.length, n); + resource = b; + } + return resource; + } + + /** + * + * @param file + * @return + */ + public static byte[] getBytesFromResource(String file) { + + InputStream in = ImageUtils.class.getResourceAsStream(file); + + if (in == null) { + return null; + } else { + try { + return ImageUtils.readStream(in); + } catch (IOException e) { + return new byte[0]; + } finally { + try { + in.close(); + } catch (IOException e) { + } + } + } + } + + /** + * + * @param file + * @return + */ + public static BufferedImage readImageFromResource(String file) { + return readImage(getBytesFromResource(file)); + } + + /** + * + * @param url + * @return + */ + public static BufferedImage readImage(String url) { + try { + return readImage(new URL(url)); + } catch (MalformedURLException e) { + return null; + } + } + + /** + * + * @param url + * @return + */ + public static BufferedImage readImage(URL url) { + + InputStream in = null; + + try { + URLConnection urlConnection = url.openConnection(); + in = urlConnection.getInputStream(); + return readImage(readStream(in)); + } catch (IOException e) { + return null; + } finally { + try { + if (in != null) { + in.close(); + } + } catch (IOException e) { + } + } + } + + /** + * + * @param b + * @return + */ + public static BufferedImage readImage(byte[] b) { + if (b == null) { + return null; + } else { + try { + return ImageIO.read(new ByteArrayInputStream(b)); + } catch(IOException e) { + return null; + } + } + } + + /** + * + * @param img + * @return + */ + public static byte[] writeImage(BufferedImage img) { + if (img == null) { + return null; + } else { + try { + ByteArrayOutputStream b = new ByteArrayOutputStream(); + ImageIO.write(img, "png", b); + b.flush(); + b.close(); + return b.toByteArray(); + } catch(IOException e) { + return null; + } + } + } + + /** + * + * @param b + * @return + */ + public static Object readSerializable(byte[] b) { + if (b == null) { + return null; + } else { + try { + ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(b)); + Object obj = in.readObject(); + in.close(); + return obj; + } catch (ClassNotFoundException eCNF) { + //logger.error("Cannot create lists object", eCNF); + return null; + } catch (IOException eIO) { + //logger.error("Cannot load lists file", eIO); + return null; + } + } + } + + /** + * + * @param o + * @return + */ + public static byte[] writeSerializable(Object o) { + + if (o == null) { + return null; + } else { + try { + ByteArrayOutputStream b = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(b); + out.writeObject(o); + out.flush(); + out.close(); + return b.toByteArray(); + } catch (IOException eIO) { + eIO.printStackTrace(); + return null; + } + } + } + + /** + * + * @param b + * @return + */ + public static Properties readProperties(byte b[]) { + Properties prop = new Properties(); + try { + if (b != null) { + prop.loadFromXML(new ByteArrayInputStream(b)); + } + } catch (IOException e) { + } + return prop; + } + + /** + * + * @param binput + * @return + */ + public static String bytes2hex(byte[] binput) { + + StringBuilder s = new StringBuilder(binput.length *2); + for (int i = 0; i < binput.length; i++) { + byte b = binput[i]; + s.append(HEXCHARS[(b & 0xF0) >> 4]); + s.append(HEXCHARS[b & 0x0F]); + } + return s.toString(); + } +} diff --git a/src/main/java/com/unicenta/data/loader/ImportSentence.java b/src/main/java/com/unicenta/data/loader/ImportSentence.java new file mode 100644 index 0000000..0c96b4f --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/ImportSentence.java @@ -0,0 +1,62 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author adrian + */ +public class ImportSentence extends BaseSentence { + + /** Creates a new instance of ImportSentence */ + public ImportSentence() { + } + + /** + * + * @throws BasicException + */ + @Override + public void closeExec() throws BasicException { + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public DataResultSet moreResults() throws BasicException { + return null; + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + @Override + public DataResultSet openExec(Object params) throws BasicException { + return null; + } +} diff --git a/src/main/java/com/unicenta/data/loader/JDBCSentence.java b/src/main/java/com/unicenta/data/loader/JDBCSentence.java new file mode 100644 index 0000000..f399909 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/JDBCSentence.java @@ -0,0 +1,236 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; +import java.sql.*; + +/** + * + * @author JG uniCenta + */ +public abstract class JDBCSentence extends BaseSentence { + + // Conexion + // protected Connection m_c; + + /** + * + */ + protected Session session; + + /** Creates a new instance of BaseSentence + * @param session */ + public JDBCSentence(Session session) { + super(); + this.session = session; + } + + /** + * + */ + protected static final class JDBCDataResultSet implements DataResultSet { + + private ResultSet m_rs; + private SerializerRead m_serread; +// private int m_iColumnCount; + + /** + * + * @param rs + * @param serread + */ + public JDBCDataResultSet(ResultSet rs, SerializerRead serread) { + m_rs = rs; + m_serread = serread; +// m_iColumnCount = -1; + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public Integer getInt(int columnIndex) throws BasicException { + try { + int iValue = m_rs.getInt(columnIndex); + return m_rs.wasNull() ? null : new Integer(iValue); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public String getString(int columnIndex) throws BasicException { + try { + return m_rs.getString(columnIndex); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public Double getDouble(int columnIndex) throws BasicException { + try { + double dValue = m_rs.getDouble(columnIndex); + return m_rs.wasNull() ? null : new Double(dValue); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public Boolean getBoolean(int columnIndex) throws BasicException { + try { + boolean bValue = m_rs.getBoolean(columnIndex); + return m_rs.wasNull() ? null : new Boolean(bValue); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public java.util.Date getTimestamp(int columnIndex) throws BasicException { + try { + java.sql.Timestamp ts = m_rs.getTimestamp(columnIndex); + return ts == null ? null : new java.util.Date(ts.getTime()); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public byte[] getBytes(int columnIndex) throws BasicException { + try { + return m_rs.getBytes(columnIndex); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public Object getObject(int columnIndex) throws BasicException { + try { + return m_rs.getObject(columnIndex); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + + /** + * + * @return + * @throws BasicException + */ + public DataField[] getDataField() throws BasicException { + try { + ResultSetMetaData md = m_rs.getMetaData(); + DataField[] df = new DataField[md.getColumnCount()]; + for (int i = 0; i < df.length; i++) { + df[i] = new DataField(); + df[i].Name = md.getColumnName(i + 1); + df[i].Size = md.getColumnDisplaySize(i + 1); + df[i].Type = md.getColumnType(i + 1); + } + return df; + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object getCurrent() throws BasicException { + return m_serread.readValues(this); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public boolean next() throws BasicException { + try { + return m_rs.next(); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + + /** + * + * @throws BasicException + */ + @Override + public void close() throws BasicException { + try { + m_rs.close(); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public int updateCount() throws BasicException { + return -1; // es decir somos datos. + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/KeyGetterBasic.java b/src/main/java/com/unicenta/data/loader/KeyGetterBasic.java new file mode 100644 index 0000000..3f63b95 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/KeyGetterBasic.java @@ -0,0 +1,54 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + + +package com.unicenta.data.loader; + +/** + * + * @author adrian + */ +public class KeyGetterBasic implements IKeyGetter { + + private int [] m_aElems; + + /** Creates a new instance of KeyGetterBasic + * @param aElems */ + public KeyGetterBasic(int[] aElems) { + m_aElems = aElems; + } + + /** + * + * @param value + * @return + */ + public Object getKey(Object value) { + if (value == null) { + return null; + } else { + Object[] avalue = (Object []) value; + Object[] akey = new Object[m_aElems.length]; + for (int i = 0; i < m_aElems.length; i++) { + akey[i] = avalue[m_aElems[i]]; + } + return akey; + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/KeyGetterBuilder.java b/src/main/java/com/unicenta/data/loader/KeyGetterBuilder.java new file mode 100644 index 0000000..b0c78fe --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/KeyGetterBuilder.java @@ -0,0 +1,51 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author adrianromero + * Created on 27 de febrero de 2007, 22:09 + * + */ +public class KeyGetterBuilder implements IKeyGetter { + + /** + * + */ + public final static IKeyGetter INSTANCE = new KeyGetterBuilder(); + + /** Creates a new instance of KeyGetterBuilder */ + public KeyGetterBuilder() { + } + + /** + * + * @param value + * @return + */ + @Override + public Object getKey(Object value) { + + return (value == null) + ? null + : ((IKeyed) value).getKey(); + } +} diff --git a/src/main/java/com/unicenta/data/loader/KeyGetterFirst.java b/src/main/java/com/unicenta/data/loader/KeyGetterFirst.java new file mode 100644 index 0000000..444c98c --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/KeyGetterFirst.java @@ -0,0 +1,50 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author adrian + */ +public class KeyGetterFirst implements IKeyGetter { + + private final int [] m_aElems; + + /** Creates a new instance of KeyGetterBasic + * @param aElems */ + public KeyGetterFirst(int[] aElems) { + m_aElems = aElems; + } + + /** + * + * @param value + * @return + */ + @Override + public Object getKey(Object value) { + if (value == null) { + return null; + } else { + Object[] avalue = (Object []) value; + return avalue[m_aElems[0]]; + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/LocalRes.java b/src/main/java/com/unicenta/data/loader/LocalRes.java new file mode 100644 index 0000000..5d8fa67 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/LocalRes.java @@ -0,0 +1,51 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import java.util.MissingResourceException; +import com.unicenta.beans.LocaleResources; + +/** + * + * @author JG uniCenta + */ +public class LocalRes { + + // private static ResourceBundle m_Intl; + private static LocaleResources m_resources; + + static { + m_resources = new LocaleResources(); + m_resources.addBundleName("data_messages"); + } + + /** Creates a new instance of LocalRes */ + private LocalRes() { + } + + /** + * + * @param sKey + * @return + */ + public static String getIntString(String sKey) { + return m_resources.getString(sKey); + } +} diff --git a/src/main/java/com/unicenta/data/loader/MetaSentence.java b/src/main/java/com/unicenta/data/loader/MetaSentence.java new file mode 100644 index 0000000..20b3abd --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/MetaSentence.java @@ -0,0 +1,212 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import java.sql.*; +import java.util.*; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class MetaSentence extends JDBCSentence { + + private String m_sSentence; + + /** + * + */ + protected SerializerRead m_SerRead = null; + + /** + * + */ + protected SerializerWrite m_SerWrite = null; + + /** Creates a new instance of MetaDataSentence + * @param s + * @param sSentence + * @param serwrite + * @param serread */ + public MetaSentence(Session s, String sSentence, SerializerWrite serwrite, SerializerRead serread) { + super(s); + m_sSentence = sSentence; + m_SerWrite = serwrite; + m_SerRead = serread; + } + + /** + * + * @param s + * @param sSentence + * @param serread + */ + public MetaSentence(Session s, String sSentence, SerializerRead serread) { + this(s, sSentence, null, serread); + } + + private static class MetaParameter implements DataWrite { + + private ArrayList m_aParams; + + /** Creates a new instance of MetaParameter */ + public MetaParameter() { + m_aParams = new ArrayList(); + } + + public void setDouble(int paramIndex, Double dValue) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.noparamtype")); + } + public void setBoolean(int paramIndex, Boolean bValue) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.noparamtype")); + } + public void setInt(int paramIndex, Integer iValue) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.noparamtype")); + } + public void setString(int paramIndex, String sValue) throws BasicException { + ensurePlace(paramIndex - 1); + m_aParams.set(paramIndex - 1, sValue); + } + public void setTimestamp(int paramIndex, java.util.Date dValue) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.noparamtype")); + } +// public void setBinaryStream(int paramIndex, java.io.InputStream in, int length) throws DataException { +// throw new DataException("Param type not allowed"); +// } + public void setBytes(int paramIndex, byte[] value) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.noparamtype")); + } + public void setObject(int paramIndex, Object value) throws BasicException { + setString(paramIndex, (value == null) ? null : value.toString()); + } + + public String getString(int index) { + return (String) m_aParams.get(index); + } + + private void ensurePlace(int i) { + m_aParams.ensureCapacity(i); + while (i >= m_aParams.size()){ + m_aParams.add(null); + } + } + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + public DataResultSet openExec(Object params) throws BasicException { + + closeExec(); + + try { + DatabaseMetaData db = session.getConnection().getMetaData(); + + MetaParameter mp = new MetaParameter(); + if (params != null) { + // si m_SerWrite fuera null deberiamos cascar + m_SerWrite.writeValues(mp, params); + } + + // Catalogs Has Schemas Has Objects + + // Lo generico de la base de datos + if ("getCatalogs".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getCatalogs(), m_SerRead); + } else if ("getSchemas".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getSchemas(), m_SerRead); + } else if ("getTableTypes".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getTableTypes(), m_SerRead); + } else if ("getTypeInfo".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getTypeInfo(), m_SerRead); + + // Los objetos por catalogo, esquema + + // Los tipos definidos por usuario + } else if ("getUDTs".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getUDTs(mp.getString(0), mp.getString(1), null, null), m_SerRead); + } else if ("getSuperTypes".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getSuperTypes(mp.getString(0), mp.getString(1), mp.getString(2)), m_SerRead); + + // Los atributos + } else if ("getAttributes".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getAttributes(mp.getString(0), mp.getString(1), null, null), m_SerRead); + + // Las Tablas y sus objetos relacionados + } else if ("getTables".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getTables(mp.getString(0), mp.getString(1), null, null), m_SerRead); + } else if ("getSuperTables".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getSuperTables(mp.getString(0), mp.getString(1), mp.getString(2)), m_SerRead); + } else if ("getTablePrivileges".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getTablePrivileges(mp.getString(0), mp.getString(1), mp.getString(2)), m_SerRead); + } else if ("getBestRowIdentifier".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getBestRowIdentifier(mp.getString(0), mp.getString(1), mp.getString(2), 0, true), m_SerRead); + } else if ("getPrimaryKeys".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getPrimaryKeys(mp.getString(0), mp.getString(1), mp.getString(2)), m_SerRead); + } else if ("getColumnPrivileges".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getColumnPrivileges(mp.getString(0), mp.getString(1), mp.getString(2), null), m_SerRead); + } else if ("getColumns".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getColumns(mp.getString(0), mp.getString(1), mp.getString(2), null), m_SerRead); + } else if ("getVersionColumns".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getVersionColumns(mp.getString(0), mp.getString(1), mp.getString(2)), m_SerRead); + } else if ("getIndexInfo".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getIndexInfo(mp.getString(0), mp.getString(1), mp.getString(2), false, false), m_SerRead); + } else if ("getExportedKeys".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getExportedKeys(mp.getString(0), mp.getString(1), mp.getString(2)), m_SerRead); + } else if ("getImportedKeys".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getImportedKeys(mp.getString(0), mp.getString(1), mp.getString(2)), m_SerRead); + } else if ("getCrossReference".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getCrossReference(mp.getString(0), mp.getString(1), mp.getString(2), null, null, null), m_SerRead); + + // Los procedimientos y sus objetos relacionados + } else if ("getProcedures".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getProcedures(mp.getString(0), mp.getString(1), null), m_SerRead); + } else if ("getProcedureColumns".equals(m_sSentence)) { + return new JDBCDataResultSet(db.getProcedureColumns(mp.getString(0), mp.getString(1), mp.getString(2), null), m_SerRead); + + } else { + return null; + } + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + + /** + * + * @throws BasicException + */ + public void closeExec() throws BasicException { + } + + /** + * + * @return + * @throws BasicException + */ + public DataResultSet moreResults() throws BasicException { + return null; + } +} diff --git a/src/main/java/com/unicenta/data/loader/NormalBuilder.java b/src/main/java/com/unicenta/data/loader/NormalBuilder.java new file mode 100644 index 0000000..9c1dbc4 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/NormalBuilder.java @@ -0,0 +1,136 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import java.util.*; +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class NormalBuilder implements ISQLBuilderStatic { + + public String sentence; + + /** Creates a new instance of NormalBuilder + * @param sSentence */ + public NormalBuilder(String sSentence) { + sentence = sSentence; + } + + /** + * + * @param write + * @param params + * @return + * @throws BasicException + */ + @Override + public String getSQL(SerializerWrite write, Object params) throws BasicException { + + NormalParameter normalParameter = new NormalParameter(sentence); + if (write != null) { + write.writeValues(normalParameter, params); + } + return normalParameter.getSentence(); + } + private static class NormalParameter implements DataWrite { + + private String m_sSentence; + private ArrayList m_aParams; // of String + + public NormalParameter(String sSentence) { + m_sSentence = sSentence; + m_aParams = new ArrayList(); + } + + @Override + public void setDouble(int paramIndex, Double dValue) throws BasicException { + ensurePlace(paramIndex - 1); + m_aParams.set(paramIndex - 1, DataWriteUtils.getSQLValue(dValue)); + } + + @Override + public void setBoolean(int paramIndex, Boolean bValue) throws BasicException { + ensurePlace(paramIndex - 1); + m_aParams.set(paramIndex - 1, DataWriteUtils.getSQLValue(bValue)); + } + @Override + public void setInt(int paramIndex, Integer iValue) throws BasicException { + ensurePlace(paramIndex - 1); + m_aParams.set(paramIndex - 1, DataWriteUtils.getSQLValue(iValue)); + } + + @Override + public void setString(int paramIndex, String sValue) throws BasicException { + ensurePlace(paramIndex - 1); + m_aParams.set(paramIndex - 1, DataWriteUtils.getSQLValue(sValue)); + } + + @Override + public void setTimestamp(int paramIndex, java.util.Date dValue) throws BasicException { + ensurePlace(paramIndex - 1); + m_aParams.set(paramIndex - 1, DataWriteUtils.getSQLValue(dValue)); + } +// public void setBinaryStream(int paramIndex, java.io.InputStream in, int length) throws DataException{ +// throw new DataException("Param type not allowed"); +// } + @Override + public void setBytes(int paramIndex, byte[] value) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.noparamtype")); + } + @Override + public void setObject(int paramIndex, Object value) throws BasicException { + ensurePlace(paramIndex - 1); + m_aParams.set(paramIndex - 1, DataWriteUtils.getSQLValue(value)); + } + + private void ensurePlace(int i) { + m_aParams.ensureCapacity(i); + while (i >= m_aParams.size()){ + m_aParams.add(null); + } + } + + public String getSentence() { + + StringBuilder sNewSentence = new StringBuilder(); + int iCount = 0; + int iPos; + int iLast = 0; + while ((iPos = m_sSentence.indexOf('?', iLast)) > 0) { + sNewSentence.append(m_sSentence.substring(iLast, iPos)); + if (iCount < m_aParams.size() && m_aParams.get(iCount) != null) { + // el valor que viene + sNewSentence.append(m_aParams.get(iCount)); + } else { + // nulo + sNewSentence.append(DataWriteUtils.getSQLValue((Object) null)); + } + iCount++; + iLast = iPos + 1; + } + sNewSentence.append(m_sSentence.substring(iLast)); + + return sNewSentence.toString(); // sustituida + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/PreparedSentence.java b/src/main/java/com/unicenta/data/loader/PreparedSentence.java new file mode 100644 index 0000000..4d870c1 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/PreparedSentence.java @@ -0,0 +1,250 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; +import lombok.extern.slf4j.Slf4j; + +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.sql.Types; + +/** + * + * @author adrianromero + */ +@Slf4j +public class PreparedSentence extends JDBCSentence { + + + private String m_sentence; + + /** + * + */ + protected SerializerWrite m_SerWrite = null; + + /** + * + */ + protected SerializerRead m_SerRead = null; + + // Estado + private PreparedStatement m_Stmt; + + /** + * + * @param s + * @param sentence + * @param serwrite + * @param serread + */ + public PreparedSentence(Session s, String sentence, SerializerWrite serwrite, SerializerRead serread) { + super(s); + m_sentence = sentence; + m_SerWrite = serwrite; + m_SerRead = serread; + m_Stmt = null; + } + + /** + * + * @param s + * @param sentence + * @param serwrite + */ + public PreparedSentence(Session s, String sentence, SerializerWrite serwrite) { + this(s, sentence, serwrite, null); + } + + /** + * + * @param s + * @param sentence + */ + public PreparedSentence(Session s, String sentence) { + this(s, sentence, null, null); + } + + private static final class PreparedSentencePars implements DataWrite { + + private PreparedStatement m_ps; + + /** Creates a new instance of SQLParameter */ + PreparedSentencePars(PreparedStatement ps) { + m_ps = ps; + } + + @Override + public void setInt(int paramIndex, Integer iValue) throws BasicException { + try { + m_ps.setObject(paramIndex, iValue, Types.INTEGER); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + @Override + public void setString(int paramIndex, String sValue) throws BasicException { + try { + m_ps.setString(paramIndex, sValue); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + @Override + public void setDouble(int paramIndex, Double dValue) throws BasicException { + try { + m_ps.setObject(paramIndex, dValue, Types.DOUBLE); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + @Override + public void setBoolean(int paramIndex, Boolean bValue) throws BasicException { + try { + if (bValue == null) { + m_ps.setObject(paramIndex, null); + } else { + m_ps.setBoolean(paramIndex, bValue.booleanValue()); + } + // m_ps.setObject(paramIndex, bValue, Types.BOOLEAN); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + @Override + public void setTimestamp(int paramIndex, java.util.Date dValue) throws BasicException { + try { + m_ps.setObject(paramIndex, dValue == null ? null : new Timestamp(dValue.getTime()), Types.TIMESTAMP); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } +// public void setBinaryStream(int paramIndex, java.io.InputStream in, int length) throws DataException { +// try { +// m_ps.setBinaryStream(paramIndex, in, length); +// } catch (SQLException eSQL) { +// throw new DataException(eSQL); +// } +// } + @Override + public void setBytes(int paramIndex, byte[] value) throws BasicException { + try { + m_ps.setBytes(paramIndex, value); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + @Override + public void setObject(int paramIndex, Object value) throws BasicException { + try { + m_ps.setObject(paramIndex, value); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + @Override + public DataResultSet openExec(Object params) throws BasicException { + // true -> un resultset + // false -> un updatecount (si -1 entonces se acabo) + + closeExec(); + + try { + log.debug("Executing prepared SQL: {}", m_sentence); + + m_Stmt = session.getConnection().prepareStatement(m_sentence); + + if (m_SerWrite != null) { + // si m_SerWrite fuera null deberiamos cascar. + PreparedSentencePars preparedSentencePars = new PreparedSentencePars(m_Stmt); + m_SerWrite.writeValues(preparedSentencePars, params); + } + + if (m_Stmt.execute()) { + return new JDBCDataResultSet(m_Stmt.getResultSet(), m_SerRead); + } else { + int iUC = m_Stmt.getUpdateCount(); + if (iUC < 0) { + return null; + } else { + return new SentenceUpdateResultSet(iUC); + } + } + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public final DataResultSet moreResults() throws BasicException { + // true -> un resultset + // false -> un updatecount (si -1 entonces se acabo) + + try { + if (m_Stmt.getMoreResults()){ + // tenemos resultset + return new JDBCDataResultSet(m_Stmt.getResultSet(), m_SerRead); + } else { + // tenemos updatecount o si devuelve -1 ya no hay mas + int iUC = m_Stmt.getUpdateCount(); + if (iUC < 0) { + return null; + } else { + return new SentenceUpdateResultSet(iUC); + } + } + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + + /** + * + * @throws BasicException + */ + @Override + public final void closeExec() throws BasicException { + + if (m_Stmt != null) { + try { + m_Stmt.close(); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } finally { + m_Stmt = null; + } + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/QBFBuilder.java b/src/main/java/com/unicenta/data/loader/QBFBuilder.java new file mode 100644 index 0000000..621b18b --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/QBFBuilder.java @@ -0,0 +1,201 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author adrian + */ +public class QBFBuilder implements ISQLBuilderStatic { + + private final String m_sSentNullFilter; // la sentencia que se devuelve cuando el filtro es vacio + private final String m_sSentBeginPart; // La sentencia que se devuelve es m_sSentBeginPart + ( filtro ) + m_sSentEndPart + private final String m_sSentEndPart; + + private final String[] m_asFindFields; + +// /** Creates a new instance of QBFBuilder */ +// public QBFBuilder(TableDefinition tb, String[] asFindFields) { +// StringBuilder sent = new StringBuilder(); +// sent.append("select "); +// for (int i = 0; i < tb.getFields().length; i ++) { +// if (i > 0) { +// sent.append(", "); +// } +// sent.append(tb.getFields()[i]); +// } +// sent.append(" from "); +// sent.append(tb.getTableName()); +// m_sSentNullFilter = sent.toString(); +// sent.append(" where "); +// m_sSentBeginPart = sent.toString(); +// m_sSentEndPart = ""; +// m_asFindFields = asFindFields; +// } + + /** + * + * @param sSentence + * @param asFindFields + */ + public QBFBuilder(String sSentence, String[] asFindFields) { + int iPos = sSentence.indexOf("?(QBF_FILTER)"); + if (iPos < 0) { + m_sSentBeginPart = sSentence; + m_sSentEndPart = ""; + m_sSentNullFilter = sSentence; + } else { + m_sSentBeginPart = sSentence.substring(0, iPos); + m_sSentEndPart = sSentence.substring(iPos + 13); + m_sSentNullFilter = m_sSentBeginPart + "(1=1)" + m_sSentEndPart; + } + m_asFindFields = asFindFields; + } + + /** + * + * @param sw + * @param params + * @return + * @throws BasicException + */ + @Override + public String getSQL(SerializerWrite sw, Object params) throws BasicException { + + QBFParameter mydw = new QBFParameter(m_asFindFields); + if (sw == null || params == null) { + return m_sSentNullFilter; + } else { + sw.writeValues(mydw, params); + String sFilter = mydw.getFilter(); + if (sFilter.length() == 0) { + return m_sSentNullFilter; // no hay filtro + } else { + return m_sSentBeginPart + "(" + sFilter + ")" + m_sSentEndPart; // incluimos el filtro + } + } + } + + private static class QBFParameter implements DataWrite { + + private final String[] m_asFindFields; + private final QBFCompareEnum[] m_aiCondFields; + private final String[] m_aParams; + + public QBFParameter(String[] asFindFields) { + m_asFindFields = asFindFields; + m_aiCondFields = new QBFCompareEnum[asFindFields.length]; + m_aParams = new String[asFindFields.length]; + + for( int i = 0; i < m_aParams.length; i++) { + m_aParams[i] = DataWriteUtils.getSQLValue((Object) null); + } + } + + @Override + public void setDouble(int paramIndex, Double dValue) throws BasicException { + if ((paramIndex - 1) % 2 == 0) { + throw new BasicException(LocalRes.getIntString("exception.nocompare")); + } else { + m_aParams[(paramIndex - 1) / 2] = DataWriteUtils.getSQLValue(dValue); + } + } + @Override + public void setBoolean(int paramIndex, Boolean bValue) throws BasicException { + if ((paramIndex - 1) % 2 == 0) { + throw new BasicException(LocalRes.getIntString("exception.nocompare")); + } else { + m_aParams[(paramIndex - 1) / 2] = DataWriteUtils.getSQLValue(bValue); + } + } + @Override + public void setInt(int paramIndex, Integer iValue) throws BasicException { + if ((paramIndex - 1) % 2 == 0) { + throw new BasicException(LocalRes.getIntString("exception.nocompare")); + } else { + m_aParams[(paramIndex - 1) / 2] = DataWriteUtils.getSQLValue(iValue); + } + } + @Override + public void setString(int paramIndex, String sValue) throws BasicException { + if ((paramIndex - 1) % 2 == 0) { + throw new BasicException(LocalRes.getIntString("exception.nocompare")); + } else { + m_aParams[(paramIndex - 1) / 2] = DataWriteUtils.getSQLValue(sValue); + } + } + @Override + public void setTimestamp(int paramIndex, java.util.Date dValue) throws BasicException { + if ((paramIndex - 1) % 2 == 0) { + throw new BasicException(LocalRes.getIntString("exception.nocompare")); + } else { + m_aParams[(paramIndex - 1) / 2] = DataWriteUtils.getSQLValue(dValue); + } + } +// public void setBinaryStream(int paramIndex, java.io.InputStream in, int length) throws DataException{ +// if ((paramIndex - 1) % 2 == 0) { +// throw new DataException("Expected comparator for QBF"); +// } else { +// throw new DataException("Param type not allowed"); +// } +// } + @Override + public void setBytes(int paramIndex, byte[] value) throws BasicException { + if ((paramIndex - 1) % 2 == 0) { + throw new BasicException(LocalRes.getIntString("exception.nocompare")); + } else { + throw new BasicException("Param type not allowed"); + } + } + @Override + public void setObject(int paramIndex, Object value) throws BasicException { + if ((paramIndex - 1) % 2 == 0) { + if (value instanceof QBFCompareEnum) { + m_aiCondFields[(paramIndex - 1) / 2] = (QBFCompareEnum) value; + } else { + throw new BasicException(LocalRes.getIntString("exception.nocompare")); + } + } else { + m_aParams[(paramIndex - 1) / 2] = DataWriteUtils.getSQLValue(value); + } + } + + public String getFilter() { + // El retorno debe ser siempre una expresion valida puesto que no se donde sera insertada. + + StringBuilder sFilter = new StringBuilder(); + + String sItem; + for (int i = 0; i < m_asFindFields.length; i ++) { + sItem = m_aiCondFields[i].getExpression(m_asFindFields[i], m_aParams[i]); + if (sItem != null) { + if (sFilter.length() > 0) { + sFilter.append(" AND "); + } + sFilter.append(sItem); + } + } + + return sFilter.toString(); + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/QBFCompareEnum.java b/src/main/java/com/unicenta/data/loader/QBFCompareEnum.java new file mode 100644 index 0000000..34cd421 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/QBFCompareEnum.java @@ -0,0 +1,140 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author adrian + */ +public abstract class QBFCompareEnum { + + /** + * + */ + public final static QBFCompareEnum COMP_NONE = new QBFCompareEnum(0, "qbf.none") { + @Override + public String getExpression(String sField, String sSQLValue) { return null; } + }; + + /** + * + */ + public final static QBFCompareEnum COMP_ISNULL = new QBFCompareEnum(1, "qbf.null") { + @Override + public String getExpression(String sField, String sSQLValue) { return sField + " IS NULL"; } + }; + + /** + * + */ + public final static QBFCompareEnum COMP_ISNOTNULL = new QBFCompareEnum(2, "qbf.notnull") { + @Override + public String getExpression(String sField, String sSQLValue) { return sField + " IS NOT NULL"; } + }; + + /** + * + */ + public final static QBFCompareEnum COMP_RE = new QBFCompareEnum(3, "qbf.re") { + @Override + public String getExpression(String sField, String sSQLValue) { return sField + " LIKE " + sSQLValue; } + }; + + /** + * + */ + public final static QBFCompareEnum COMP_EQUALS = new QBFCompareEnum(3, "qbf.equals") { + @Override + public String getExpression(String sField, String sSQLValue) { return sField + " = " + sSQLValue; } + }; + + /** + * + */ + public final static QBFCompareEnum COMP_DISTINCT = new QBFCompareEnum(4, "qbf.distinct") { + @Override + public String getExpression(String sField, String sSQLValue) { return sField + " <> " + sSQLValue; } + }; + + /** + * + */ + public final static QBFCompareEnum COMP_GREATER = new QBFCompareEnum(5, "qbf.greater") { + @Override + public String getExpression(String sField, String sSQLValue) { return sField + " > " + sSQLValue; } + }; + + /** + * + */ + public final static QBFCompareEnum COMP_LESS = new QBFCompareEnum(6, "qbf.less") { + @Override + public String getExpression(String sField, String sSQLValue) { return sField + " < " + sSQLValue; } + }; + + /** + * + */ + public final static QBFCompareEnum COMP_GREATEROREQUALS = new QBFCompareEnum(7, "qbf.greaterequals") { + @Override + public String getExpression(String sField, String sSQLValue) { return sField + " >= " + sSQLValue; } + }; + + /** + * + */ + public final static QBFCompareEnum COMP_LESSOREQUALS = new QBFCompareEnum(8, "qbf.lessequals") { + @Override + public String getExpression(String sField, String sSQLValue) { return sField + " <= " + sSQLValue; } + }; +// public final static QBFCompareEnum COMP_STARTSWITH = new QBFCompareEnum(9, "qbf.startswith") { +// public String getExpression(String sField, String sSQLValue) { return sField + " LIKE " ... + sSQLValue; } +// }; +// public final static int COMP_ENDSWITH = 12; +// public final static int COMP_CONTAINS = 13; + + private final int m_iValue; + private final String m_sKey; + + private QBFCompareEnum(int iValue, String sKey) { + m_iValue = iValue; + m_sKey = sKey; + } + + /** + * + * @return + */ + public int getCompareInt() { + return m_iValue; + } + @Override + public String toString() { + return LocalRes.getIntString(m_sKey); + } + + /** + * + * @param sField + * @param sSQLValue + * @return + */ + public abstract String getExpression(String sField, String sSQLValue); +} diff --git a/src/main/java/com/unicenta/data/loader/RenderStringBasic.java b/src/main/java/com/unicenta/data/loader/RenderStringBasic.java new file mode 100644 index 0000000..3e905d8 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/RenderStringBasic.java @@ -0,0 +1,65 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.format.Formats; + +/** + * + * @author adrian + */ +public class RenderStringBasic implements IRenderString { + + private Formats[] m_aFormats; + private int[] m_aiIndex; + + /** Creates a new instance of StringnizerBasic + * @param fmts + * @param aiIndex */ + public RenderStringBasic(Formats[] fmts, int[] aiIndex) { + m_aFormats = fmts; + m_aiIndex = aiIndex; + } + + /** + * + * @param value + * @return + */ + public String getRenderString(Object value) { + + if (value == null) { + return null; + } else { + Object [] avalue = (Object[]) value; + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < m_aiIndex.length; i++) { + if (i > 0) { + sb.append(" - "); + } + sb.append(m_aFormats[m_aiIndex[i]].formatValue(avalue[m_aiIndex[i]])); + } + + return sb.toString(); + } + } + +} diff --git a/src/main/java/com/unicenta/data/loader/SentenceEnum.java b/src/main/java/com/unicenta/data/loader/SentenceEnum.java new file mode 100644 index 0000000..158c898 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SentenceEnum.java @@ -0,0 +1,56 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public interface SentenceEnum { + + /** + * + * @throws BasicException + */ + public void load() throws BasicException; + + /** + * + * @param params + * @throws BasicException + */ + public void load(Object params) throws BasicException; + + /** + * + * @return + * @throws BasicException + */ + public Object getCurrent() throws BasicException; + + /** + * + * @return + * @throws BasicException + */ + public boolean next() throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/SentenceExec.java b/src/main/java/com/unicenta/data/loader/SentenceExec.java new file mode 100644 index 0000000..c12f57b --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SentenceExec.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public interface SentenceExec { + + /** + * + * @return + * @throws BasicException + */ + public int exec() throws BasicException; + + /** + * + * @param params + * @return + * @throws BasicException + */ + public int exec(Object params) throws BasicException; + + /** + * + * @param params + * @return + * @throws BasicException + */ + public int exec(Object... params) throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/SentenceExecAdapter.java b/src/main/java/com/unicenta/data/loader/SentenceExecAdapter.java new file mode 100644 index 0000000..4443b0b --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SentenceExecAdapter.java @@ -0,0 +1,56 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public abstract class SentenceExecAdapter implements SentenceExec { + + /** + * + * @return + * @throws BasicException + */ + public int exec() throws BasicException { + return exec((Object) null); + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + public int exec(Object... params) throws BasicException { + return exec((Object) params); + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + public abstract int exec(Object params) throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/SentenceExecTransaction.java b/src/main/java/com/unicenta/data/loader/SentenceExecTransaction.java new file mode 100644 index 0000000..dfc164c --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SentenceExecTransaction.java @@ -0,0 +1,86 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author adrianromero + * Created on February 6, 2007, 4:06 PM + * + */ +public abstract class SentenceExecTransaction implements SentenceExec { + + private Session m_s; + + /** + * + * @param s + */ + public SentenceExecTransaction(Session s) { + m_s = s; + } + + /** + * + * @return + * @throws BasicException + */ + public final int exec() throws BasicException { + return exec((Object) null); + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + public final int exec(Object... params) throws BasicException { + return exec((Object) params); + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + public final int exec(final Object params) throws BasicException { + + Transaction t = new Transaction(m_s) { + public Integer transact() throws BasicException{ + return execInTransaction(params); + } + }; + + return t.execute(); + } + + /** + * + * @param params + * @return + * @throws BasicException + */ + protected abstract int execInTransaction(Object params) throws BasicException; +} + diff --git a/src/main/java/com/unicenta/data/loader/SentenceFind.java b/src/main/java/com/unicenta/data/loader/SentenceFind.java new file mode 100644 index 0000000..c18e880 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SentenceFind.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public interface SentenceFind { + + /** + * + * @return + * @throws BasicException + */ + public Object find() throws BasicException; + + /** + * + * @param params + * @return + * @throws BasicException + */ + public Object find(Object params) throws BasicException; + + /** + * + * @param params + * @return + * @throws BasicException + */ + public Object find(Object... params) throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/SentenceList.java b/src/main/java/com/unicenta/data/loader/SentenceList.java new file mode 100644 index 0000000..edd7ab0 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SentenceList.java @@ -0,0 +1,72 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public interface SentenceList { + + /** + * + * @return + * @throws BasicException + */ + public List list() throws BasicException; + + /** + * + * @param params + * @return + * @throws BasicException + */ + public List list(Object... params) throws BasicException; + + /** + * + * @param params + * @return + * @throws BasicException + */ + public List list(Object params) throws BasicException; + + /** + * + * @param offset + * @param length + * @return + * @throws BasicException + */ + public List listPage(int offset, int length) throws BasicException; + + /** + * + * @param params + * @param offset + * @param length + * @return + * @throws BasicException + */ + public List listPage(Object params, int offset, int length) throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/SentenceUpdateResultSet.java b/src/main/java/com/unicenta/data/loader/SentenceUpdateResultSet.java new file mode 100644 index 0000000..8d4847b --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SentenceUpdateResultSet.java @@ -0,0 +1,154 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author adrian + */ +public class SentenceUpdateResultSet implements DataResultSet { + + private int m_iUpdateCount; + + /** Creates a new instance of UpdateResultSet + * @param iUpdateCount */ + public SentenceUpdateResultSet(int iUpdateCount) { + m_iUpdateCount = iUpdateCount; + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public Integer getInt(int columnIndex) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public String getString(int columnIndex) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public Double getDouble(int columnIndex) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public Boolean getBoolean(int columnIndex) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public java.util.Date getTimestamp(int columnIndex) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + //public java.io.InputStream getBinaryStream(int columnIndex) throws DataException; + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public byte[] getBytes(int columnIndex) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + /** + * + * @param columnIndex + * @return + * @throws BasicException + */ + public Object getObject(int columnIndex) throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + +// public int getColumnCount() throws DataException; + + /** + * + * @return + * @throws BasicException + */ + public DataField[] getDataField() throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + /** + * + * @return + * @throws BasicException + */ + public Object getCurrent() throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + /** + * + * @return + * @throws BasicException + */ + public boolean next() throws BasicException { + throw new BasicException(LocalRes.getIntString("exception.nodataset")); + } + + /** + * + * @throws BasicException + */ + public void close() throws BasicException { + } + + /** + * + * @return + * @throws BasicException + */ + public int updateCount() throws BasicException { + return m_iUpdateCount; + } +} diff --git a/src/main/java/com/unicenta/data/loader/SequenceForDerby.java b/src/main/java/com/unicenta/data/loader/SequenceForDerby.java new file mode 100644 index 0000000..719f1c7 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SequenceForDerby.java @@ -0,0 +1,75 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class SequenceForDerby extends BaseSentence { + + private BaseSentence sent1; + private BaseSentence sent2; + + /** Creates a new instance of SequenceForMySQL + * @param s + * @param sSeqTable */ + public SequenceForDerby(Session s, String sSeqTable) { + + sent1 = new StaticSentence(s, "UPDATE " + sSeqTable + " SET ID = (SELECT ID FROM "+ sSeqTable +")+1 "); + sent2 = new StaticSentence(s, "SELECT ID from PICKUP_NUMBER", null, SerializerReadInteger.INSTANCE); + } + + + // Funciones de bajo nivel + + /** + * + * @param params + * @return + * @throws BasicException + */ + @Override + public DataResultSet openExec(Object params) throws BasicException { + sent1.exec(); + return sent2.openExec(null); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public DataResultSet moreResults() throws BasicException { + return sent2.moreResults(); + } + + /** + * + * @throws BasicException + */ + @Override + public void closeExec() throws BasicException { + sent2.closeExec(); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SequenceForMySQL.java b/src/main/java/com/unicenta/data/loader/SequenceForMySQL.java new file mode 100644 index 0000000..b6d2092 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SequenceForMySQL.java @@ -0,0 +1,71 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class SequenceForMySQL extends BaseSentence { + + private BaseSentence sent1; + private BaseSentence sent2; + + /** Creates a new instance of SequenceForMySQL + * @param s + * @param sSeqTable */ + public SequenceForMySQL(Session s, String sSeqTable) { + + sent1 = new StaticSentence(s, "UPDATE " + sSeqTable + " SET ID = LAST_INSERT_ID(ID + 1)"); + sent2 = new StaticSentence(s, "SELECT LAST_INSERT_ID()", null, SerializerReadInteger.INSTANCE); + } + + // Funciones de bajo nivel + + /** + * + * @param params + * @return + * @throws BasicException + */ + public DataResultSet openExec(Object params) throws BasicException { + sent1.exec(); + return sent2.openExec(null); + } + + /** + * + * @return + * @throws BasicException + */ + public DataResultSet moreResults() throws BasicException { + return sent2.moreResults(); + } + + /** + * + * @throws BasicException + */ + public void closeExec() throws BasicException { + sent2.closeExec(); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SequenceForSQLite.java b/src/main/java/com/unicenta/data/loader/SequenceForSQLite.java new file mode 100644 index 0000000..30202e6 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SequenceForSQLite.java @@ -0,0 +1,48 @@ +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +public class SequenceForSQLite extends BaseSentence { + + private BaseSentence sent1; + private BaseSentence sent2; + + /** Creates a new instance of SequenceForMySQL + * @param s + * @param sSeqTable */ + public SequenceForSQLite(Session s, String sSeqTable) { + + sent1 = new StaticSentence(s, "UPDATE " + sSeqTable + " SET ID = last_insert_rowid()+1"); + sent2 = new StaticSentence(s, "SELECT last_insert_rowid()", null, SerializerReadInteger.INSTANCE); + } + + // Funciones de bajo nivel + + /** + * + * @param params + * @return + * @throws BasicException + */ + public DataResultSet openExec(Object params) throws BasicException { + sent1.exec(); + return sent2.openExec(null); + } + + /** + * + * @return + * @throws BasicException + */ + public DataResultSet moreResults() throws BasicException { + return sent2.moreResults(); + } + + /** + * + * @throws BasicException + */ + public void closeExec() throws BasicException { + sent2.closeExec(); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SerializableBuilder.java b/src/main/java/com/unicenta/data/loader/SerializableBuilder.java new file mode 100644 index 0000000..a3e8003 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializableBuilder.java @@ -0,0 +1,33 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author JG uniCenta + */ +public interface SerializableBuilder { + + /** + * + * @return + */ + public SerializableRead createNew(); +} diff --git a/src/main/java/com/unicenta/data/loader/SerializableRead.java b/src/main/java/com/unicenta/data/loader/SerializableRead.java new file mode 100644 index 0000000..2a5e706 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializableRead.java @@ -0,0 +1,36 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public interface SerializableRead { + + /** + * + * @param dr + * @throws BasicException + */ + public void readValues(DataRead dr) throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/SerializableWrite.java b/src/main/java/com/unicenta/data/loader/SerializableWrite.java new file mode 100644 index 0000000..05c45cb --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializableWrite.java @@ -0,0 +1,36 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public interface SerializableWrite { + + /** + * + * @param dp + * @throws BasicException + */ + public void writeValues(DataWrite dp) throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerRead.java b/src/main/java/com/unicenta/data/loader/SerializerRead.java new file mode 100644 index 0000000..5a981f6 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerRead.java @@ -0,0 +1,37 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author adrian + */ +public interface SerializerRead { + + /** + * + * @param dr + * @return + * @throws BasicException + */ + public Object readValues(DataRead dr) throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadBasic.java b/src/main/java/com/unicenta/data/loader/SerializerReadBasic.java new file mode 100644 index 0000000..ecabb83 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerReadBasic.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class SerializerReadBasic implements SerializerRead { + + private Datas[] m_classes; + + /** Creates a new instance of SerializerReadBasic + * @param classes */ + public SerializerReadBasic(Datas[] classes) { + m_classes = classes; + } + + /** + * + * @param dr + * @return + * @throws BasicException + */ + public Object readValues(DataRead dr) throws BasicException { + + Object[] m_values = new Object[m_classes.length]; + for (int i = 0; i < m_classes.length; i++) { + m_values[i] = m_classes[i].getValue(dr, i + 1); + } + return m_values; + } +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadBuilder.java b/src/main/java/com/unicenta/data/loader/SerializerReadBuilder.java new file mode 100644 index 0000000..c403ca5 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerReadBuilder.java @@ -0,0 +1,50 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author adrian + */ +public class SerializerReadBuilder implements SerializerRead { + + private SerializableBuilder m_sb; + + /** Creates a new instance of SerializerReadBuilder + * @param sb */ + public SerializerReadBuilder(SerializableBuilder sb) { + m_sb = sb; + } + + /** + * + * @param dr + * @return + * @throws BasicException + */ + public Object readValues(DataRead dr) throws BasicException { + SerializableRead sr = m_sb.createNew(); + sr.readValues(dr); + return sr; + } + +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadBytes.java b/src/main/java/com/unicenta/data/loader/SerializerReadBytes.java new file mode 100644 index 0000000..9ea2561 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerReadBytes.java @@ -0,0 +1,48 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author Adrian + */ +public class SerializerReadBytes implements SerializerRead { + + /** + * + */ + public static final SerializerRead INSTANCE = new SerializerReadBytes(); + + /** Creates a new instance of SerializerReadBytes */ + private SerializerReadBytes() { + } + + /** + * + * @param dr + * @return + * @throws BasicException + */ + public Object readValues(DataRead dr) throws BasicException { + return Datas.BYTES.getValue(dr,1); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadClass.java b/src/main/java/com/unicenta/data/loader/SerializerReadClass.java new file mode 100644 index 0000000..13e64ef --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerReadClass.java @@ -0,0 +1,55 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class SerializerReadClass implements SerializerRead { + + private final Class m_clazz; + + /** Creates a new instance of DefaultSerializerRead + * @param clazz */ + public SerializerReadClass(Class clazz) { + m_clazz = clazz; + } + + /** + * + * @param dr + * @return + * @throws BasicException + */ + @Override + public Object readValues(DataRead dr) throws BasicException { + try { + SerializableRead sr = (SerializableRead) m_clazz.newInstance(); + sr.readValues(dr); + return sr; +// JG 16 May 12 use multicatch + } catch (java.lang.InstantiationException | IllegalAccessException | ClassCastException eIns) { + return null; + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadDate.java b/src/main/java/com/unicenta/data/loader/SerializerReadDate.java new file mode 100644 index 0000000..eafada8 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerReadDate.java @@ -0,0 +1,50 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author James Bolongan + */ + +public class SerializerReadDate implements SerializerRead { + + /** + * + */ + public static final SerializerRead INSTANCE = new SerializerReadDate(); + + /** Creates a new instance of SerializerReadImage */ + private SerializerReadDate() { + } + + /** + * + * @param dr + * @return + * @throws BasicException + */ + @Override + public Object readValues(DataRead dr) throws BasicException { + return Datas.TIMESTAMP.getValue(dr, 1); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadDouble.java b/src/main/java/com/unicenta/data/loader/SerializerReadDouble.java new file mode 100644 index 0000000..359961a --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerReadDouble.java @@ -0,0 +1,48 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class SerializerReadDouble implements SerializerRead { + + /** + * + */ + public static final SerializerRead INSTANCE = new SerializerReadDouble(); + + /** Creates a new instance of SerializerReadInteger */ + public SerializerReadDouble() { + } + + /** + * + * @param dr + * @return + * @throws BasicException + */ + public Object readValues(DataRead dr) throws BasicException { + return Datas.DOUBLE.getValue(dr,1); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadImage.java b/src/main/java/com/unicenta/data/loader/SerializerReadImage.java new file mode 100644 index 0000000..9b01377 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerReadImage.java @@ -0,0 +1,49 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class SerializerReadImage implements SerializerRead { + + /** + * + */ + public static final SerializerRead INSTANCE = new SerializerReadImage(); + + /** Creates a new instance of SerializerReadImage */ + private SerializerReadImage() { + } + + /** + * + * @param dr + * @return + * @throws BasicException + */ + public Object readValues(DataRead dr) throws BasicException { + return Datas.IMAGE.getValue(dr,1); + } + +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadInteger.java b/src/main/java/com/unicenta/data/loader/SerializerReadInteger.java new file mode 100644 index 0000000..ad990aa --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerReadInteger.java @@ -0,0 +1,48 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class SerializerReadInteger implements SerializerRead { + + /** + * + */ + public static final SerializerRead INSTANCE = new SerializerReadInteger(); + + /** Creates a new instance of SerializerReadInteger */ + private SerializerReadInteger() { + } + + /** + * + * @param dr + * @return + * @throws BasicException + */ + public Object readValues(DataRead dr) throws BasicException { + return Datas.INT.getValue(dr,1); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadString.java b/src/main/java/com/unicenta/data/loader/SerializerReadString.java new file mode 100644 index 0000000..2730d82 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerReadString.java @@ -0,0 +1,48 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class SerializerReadString implements SerializerRead { + + /** + * + */ + public static final SerializerRead INSTANCE = new SerializerReadString(); + + /** Creates a new instance of SerializerReadImage */ + private SerializerReadString() { + } + + /** + * + * @param dr + * @return + * @throws BasicException + */ + public Object readValues(DataRead dr) throws BasicException { + return Datas.STRING.getValue(dr,1); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerReadUTF8.java b/src/main/java/com/unicenta/data/loader/SerializerReadUTF8.java new file mode 100644 index 0000000..3c18f82 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerReadUTF8.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class SerializerReadUTF8 implements SerializerRead { + + /** + * + */ + public static final SerializerRead INSTANCE = new SerializerReadUTF8(); + + /** Creates a new instance of SerializerReadImage */ + private SerializerReadUTF8() { + } + + /** + * + * @param dr + * @return + * @throws BasicException + */ + public Object readValues(DataRead dr) throws BasicException { + try { + return new String((byte[]) Datas.BYTES.getValue(dr,1), "UTF-8"); + } catch (java.io.UnsupportedEncodingException e) { + return null; + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerWrite.java b/src/main/java/com/unicenta/data/loader/SerializerWrite.java new file mode 100644 index 0000000..7e1f21e --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerWrite.java @@ -0,0 +1,38 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + * @param + */ +public interface SerializerWrite { + + /** + * + * @param dp + * @param obj + * @throws BasicException + */ + public void writeValues(DataWrite dp, T obj) throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerWriteBasic.java b/src/main/java/com/unicenta/data/loader/SerializerWriteBasic.java new file mode 100644 index 0000000..8a36fd3 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerWriteBasic.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class SerializerWriteBasic implements SerializerWrite { + + private Datas[] m_classes; + + /** Creates a new instance of SerializerWriteBasic + * @param classes */ + public SerializerWriteBasic(Datas... classes) { + m_classes = classes; + } + + /** + * + * @param dp + * @param obj + * @throws BasicException + */ + @Override + public void writeValues(DataWrite dp, Object[] obj) throws BasicException { + + for (int i = 0; i < m_classes.length; i++) { + m_classes[i].setValue(dp, i + 1, obj[i]); + } + } + +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerWriteBasicComposed.java b/src/main/java/com/unicenta/data/loader/SerializerWriteBasicComposed.java new file mode 100644 index 0000000..fc15519 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerWriteBasicComposed.java @@ -0,0 +1,55 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class SerializerWriteBasicComposed implements SerializerWrite { + + private Datas[][] m_classes; + + /** Creates a new instance of SerializerWriteComposed + * @param classes */ + public SerializerWriteBasicComposed(Datas[]... classes) { + m_classes = classes; + } + + /** + * + * @param dp + * @param obj + * @throws BasicException + */ + public void writeValues(DataWrite dp, Object[] obj) throws BasicException { + + int index = 0; + for (int i = 0; i < m_classes.length; i++) { + Object[] val = (Object[]) obj[i]; + for (int j = 0; j < m_classes[i].length; j++) { + index++; + m_classes[i][j].setValue(dp, index, val[j]); + } + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerWriteBasicExt.java b/src/main/java/com/unicenta/data/loader/SerializerWriteBasicExt.java new file mode 100644 index 0000000..1c3e4bb --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerWriteBasicExt.java @@ -0,0 +1,55 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class SerializerWriteBasicExt implements SerializerWrite { + + private Datas[] m_classes; + private int[] m_index; + + /** Creates a new instance of SerializerWriteBasic + * @param classes + * @param index */ + public SerializerWriteBasicExt(Datas[] classes, int[] index) { + m_classes = classes; + m_index = index; + } + + /** + * + * @param dp + * @param obj + * @throws BasicException + */ + @Override + public void writeValues(DataWrite dp, Object[] obj) throws BasicException { + + for (int i = 0; i < m_index.length; i++) { + m_classes[m_index[i]].setValue(dp, i + 1, obj[m_index[i]]); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/data/loader/SerializerWriteBuilder.java b/src/main/java/com/unicenta/data/loader/SerializerWriteBuilder.java new file mode 100644 index 0000000..fdac78c --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerWriteBuilder.java @@ -0,0 +1,48 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class SerializerWriteBuilder implements SerializerWrite { + + /** + * + */ + public static final SerializerWrite INSTANCE = new SerializerWriteBuilder(); + + /** Creates a new instance of SerializerWriteBuilder */ + private SerializerWriteBuilder() { + } + + /** + * + * @param dp + * @param obj + * @throws BasicException + */ + public void writeValues(DataWrite dp, SerializableWrite obj) throws BasicException { + obj.writeValues(dp); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerWriteComposed.java b/src/main/java/com/unicenta/data/loader/SerializerWriteComposed.java new file mode 100644 index 0000000..95a5b27 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerWriteComposed.java @@ -0,0 +1,115 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public class SerializerWriteComposed implements SerializerWrite { + + private List serwrites = new ArrayList(); + + /** Creates a new instance of SerializerWriteComposed */ + public SerializerWriteComposed() { + } + + /** + * + * @param sw + */ + public void add(SerializerWrite sw) { + serwrites.add(sw); + } + + /** + * + * @param dp + * @param obj + * @throws BasicException + */ + public void writeValues(DataWrite dp, Object obj) throws BasicException { + + Object[] a = (Object[]) obj; + DataWriteComposed dpc = new DataWriteComposed(dp); + + int i = 0; + for (SerializerWrite sw : serwrites) { + dpc.next(); + sw.writeValues(dpc, a[i++]); + } + } + + private static class DataWriteComposed implements DataWrite { + + private DataWrite dp; + private int offset = 0; + private int max = 0; + + public DataWriteComposed(DataWrite dp) { + this.dp = dp; + } + + public void next() { + offset = max; + } + + public void setInt(int paramIndex, Integer iValue) throws BasicException { + dp.setInt(offset + paramIndex, iValue); + max = Math.max(max, offset + paramIndex); + } + + public void setString(int paramIndex, String sValue) throws BasicException { + dp.setString(offset + paramIndex, sValue); + max = Math.max(max, offset + paramIndex); + } + + public void setDouble(int paramIndex, Double dValue) throws BasicException { + dp.setDouble(offset + paramIndex, dValue); + max = Math.max(max, offset + paramIndex); + } + + public void setBoolean(int paramIndex, Boolean bValue) throws BasicException { + dp.setBoolean(offset + paramIndex, bValue); + max = Math.max(max, offset + paramIndex); + } + + public void setTimestamp(int paramIndex, Date dValue) throws BasicException { + dp.setTimestamp(offset + paramIndex, dValue); + max = Math.max(max, offset + paramIndex); + } + + public void setBytes(int paramIndex, byte[] value) throws BasicException { + dp.setBytes(offset + paramIndex, value); + max = Math.max(max, offset + paramIndex); + } + + public void setObject(int paramIndex, Object value) throws BasicException { + dp.setObject(offset + paramIndex, value); + max = Math.max(max, offset + paramIndex); + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/data/loader/SerializerWriteInteger.java b/src/main/java/com/unicenta/data/loader/SerializerWriteInteger.java new file mode 100644 index 0000000..e994774 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerWriteInteger.java @@ -0,0 +1,48 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class SerializerWriteInteger implements SerializerWrite { + + /** + * + */ + public static final SerializerWrite INSTANCE = new SerializerWriteInteger(); + + /** Creates a new instance of SerializerWriteInteger */ + private SerializerWriteInteger() { + } + + /** + * + * @param dp + * @param obj + * @throws BasicException + */ + public void writeValues(DataWrite dp, Integer obj) throws BasicException { + Datas.INT.setValue(dp, 1, obj); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/data/loader/SerializerWriteParams.java b/src/main/java/com/unicenta/data/loader/SerializerWriteParams.java new file mode 100644 index 0000000..0cc800b --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerWriteParams.java @@ -0,0 +1,47 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author adrianromero + */ +public class SerializerWriteParams implements SerializerWrite{ + + /** + * + */ + public static final SerializerWrite INSTANCE = new SerializerWriteParams(); + + /** + * + * @param dp + * @param obj + * @throws BasicException + */ + @Override + public void writeValues(DataWrite dp, DataParams obj) throws BasicException { + obj.setDataWrite(dp); + obj.writeValues(); + obj.setDataWrite(null); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SerializerWriteString.java b/src/main/java/com/unicenta/data/loader/SerializerWriteString.java new file mode 100644 index 0000000..43766d8 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SerializerWriteString.java @@ -0,0 +1,58 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +import java.lang.reflect.Array; + +/** + * + * @author JG uniCenta + */ +public class SerializerWriteString implements SerializerWrite { + + /** + * + */ + public static final SerializerWrite INSTANCE = new SerializerWriteString(); + + /** Creates a new instance of SerializerWriteString */ + private SerializerWriteString() { + } + + /** + * + * @param dp + * @param obj + * @throws BasicException + */ + public void writeValues(DataWrite dp, Object obj) throws BasicException { + if (obj instanceof Object[]){ + for (int i = 0 ; i < ((Object[]) obj).length ; i++) { + Datas.STRING.setValue(dp, i+1, ((Object[]) obj)[i]); + } + } + else { + Datas.STRING.setValue(dp, 1, obj); + } + + } +} diff --git a/src/main/java/com/unicenta/data/loader/Session.java b/src/main/java/com/unicenta/data/loader/Session.java new file mode 100644 index 0000000..e743796 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/Session.java @@ -0,0 +1,213 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright © 2009-2020 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +/** + * + * @author adrianromero + * Created on February 6, 2007, 4:06 PM + * + */ +public final class Session { + + private final String m_surl; + private final String m_sappuser; + private final String m_spassword; + + private Connection m_c; + private boolean m_bInTransaction; + + /** + * + */ + public final SessionDB DB; + + /** Creates a new instance of Session + * @param url + * @param user + * @param password + * @throws java.sql.SQLException */ + public Session(String url, String user, String password) throws SQLException { + m_surl = url; + m_sappuser = user; + m_spassword = password; + + m_c = null; + m_bInTransaction = false; + + connect(); // no lazy connection + + DB = getDiff(); + } + + /** + * + * @throws SQLException + */ + public void connect() throws SQLException { + + // primero cerramos si no estabamos cerrados + close(); + + // creamos una nueva conexion. + m_c = (m_sappuser == null && m_spassword == null) + ? DriverManager.getConnection(m_surl) + : DriverManager.getConnection(m_surl, m_sappuser, m_spassword); + m_c.setAutoCommit(true); + m_bInTransaction = false; + } + + /** + * + */ + public void close() { + + if (m_c != null) { + try { + if (m_bInTransaction) { + m_bInTransaction = false; // lo primero salimos del estado + m_c.rollback(); + m_c.setAutoCommit(true); + } + m_c.close(); + } catch (SQLException e) { + // me la como + } finally { + m_c = null; + } + } + } + + /** + * + * @return + * @throws SQLException + */ + public Connection getConnection() throws SQLException { + + if (!m_bInTransaction) { + ensureConnection(); + } + return m_c; + } + + /** + * + * @throws SQLException + */ + public void begin() throws SQLException { + + if (m_bInTransaction) { + throw new SQLException("Already in transaction"); + } else { + ensureConnection(); + m_c.setAutoCommit(false); + m_bInTransaction = true; + } + } + + /** + * + * @throws SQLException + */ + public void commit() throws SQLException { + if (m_bInTransaction) { + m_bInTransaction = false; // lo primero salimos del estado + m_c.commit(); + m_c.setAutoCommit(true); + } else { + throw new SQLException("Transaction not started"); + } + } + + /** + * + * @throws SQLException + */ + public void rollback() throws SQLException { + if (m_bInTransaction) { + m_bInTransaction = false; // lo primero salimos del estado + m_c.rollback(); + m_c.setAutoCommit(true); + } else { + throw new SQLException("Transaction not started"); + } + } + + /** + * + * @return + */ + public boolean isTransaction() { + return m_bInTransaction; + } + + private void ensureConnection() throws SQLException { + // solo se invoca si isTransaction == false + + boolean bclosed; + try { + bclosed = m_c == null || m_c.isClosed(); + } catch (SQLException e) { + bclosed = true; + } + + // reconnect if closed + if (bclosed) { + connect(); + } + } + + /** + * + * @return + * @throws SQLException + */ + public String getURL() throws SQLException { + return getConnection().getMetaData().getURL(); + } + + private SessionDB getDiff() throws SQLException { + + String sdbmanager = getConnection().getMetaData().getDatabaseProductName(); + switch (sdbmanager) { + case "SQLite": + return new SessionDBSQLite(); + case "MariaDB": + return new SessionDBMariaDB(); + case "HSQL Database Engine": + return new SessionDBHSQLDB(); + case "MySQL": + return new SessionDBMySQL(); + case "PostgreSQL": + return new SessionDBPostgreSQL(); + case "Oracle": + return new SessionDBOracle(); + case "Apache Derby": + return new SessionDBDerby(); + default: + return new SessionDBGeneric(sdbmanager); + } + } +} diff --git a/src/main/java/com/unicenta/data/loader/SessionDB.java b/src/main/java/com/unicenta/data/loader/SessionDB.java new file mode 100644 index 0000000..ffce53c --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SessionDB.java @@ -0,0 +1,76 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author adrianromero + */ +public interface SessionDB { + + /** + * + * @return + */ + public String TRUE(); + + /** + * + * @return + */ + public String FALSE(); + + /** + * + * @return + */ + public String INTEGER_NULL(); + + /** + * + * @return + */ + public String CHAR_NULL(); + + /** + * + * @return + */ + public String getName(); + + /** + * + * @param s + * @param sequence + * @return + */ + public SentenceFind getSequenceSentence(Session s, String sequence); + + /** + * + * @param s + * @param sequence + * @return + */ + public SentenceFind resetSequenceSentence(Session s, String sequence); + +} + + diff --git a/src/main/java/com/unicenta/data/loader/SessionDBDerby.java b/src/main/java/com/unicenta/data/loader/SessionDBDerby.java new file mode 100644 index 0000000..2a4e7ac --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SessionDBDerby.java @@ -0,0 +1,94 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author adrianromero + */ +public class SessionDBDerby implements SessionDB { + + /** + * + * @return + */ + @Override + public String TRUE() { + return "1"; + } + + /** + * + * @return + */ + @Override + public String FALSE() { + return "0"; + } + + /** + * + * @return + */ + @Override + public String INTEGER_NULL() { + return "CAST(NULL AS INTEGER)"; + } + + /** + * + * @return + */ + @Override + public String CHAR_NULL() { + return "CAST(NULL AS CHAR)"; + } + + /** + * + * @return + */ + @Override + public String getName() { + return "Derby"; + } + + /** + * + * @param s + * @param sequence + * @return + */ + @Override + public SentenceFind getSequenceSentence(Session s, String sequence) { + return new SequenceForDerby(s, sequence); + } + + /** + * + * @param s + * @param sequence + * @return + */ + @Override + public SentenceFind resetSequenceSentence(Session s, String sequence) { + return new SequenceForDerby(s, sequence); +} +} diff --git a/src/main/java/com/unicenta/data/loader/SessionDBGeneric.java b/src/main/java/com/unicenta/data/loader/SessionDBGeneric.java new file mode 100644 index 0000000..831c593 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SessionDBGeneric.java @@ -0,0 +1,97 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author adrianromero + */ +public class SessionDBGeneric implements SessionDB { + + private String name; + + /** + * + * @param name + */ + public SessionDBGeneric(String name) { + this.name = name; + } + + /** + * + * @return + */ + public String TRUE() { + return "TRUE"; + } + + /** + * + * @return + */ + public String FALSE() { + return "FALSE"; + } + + /** + * + * @return + */ + public String INTEGER_NULL() { + return "CAST(NULL AS INTEGER)"; + } + + /** + * + * @return + */ + public String CHAR_NULL() { + return "CAST(NULL AS CHAR)"; + } + + /** + * + * @return + */ + public String getName() { + return name; + } + + /** + * + * @param s + * @param sequence + * @return + */ + public SentenceFind getSequenceSentence(Session s, String sequence) { + return new StaticSentence(s, "SELECT NEXTVAL('" + sequence + "')", null, SerializerReadInteger.INSTANCE); + } + + /** + * + * @param s + * @param sequence + * @return + */ + public SentenceFind resetSequenceSentence(Session s, String sequence){ + return new StaticSentence(s, "ALTER SEQUENCE " + sequence + " RESTART WITH 0", null, SerializerReadInteger.INSTANCE); +} +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/data/loader/SessionDBHSQLDB.java b/src/main/java/com/unicenta/data/loader/SessionDBHSQLDB.java new file mode 100644 index 0000000..bae03b6 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SessionDBHSQLDB.java @@ -0,0 +1,94 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author adrianromero + */ +public class SessionDBHSQLDB implements SessionDB { + + /** + * + * @return + */ + @Override + public String TRUE() { + return "TRUE"; + } + + /** + * + * @return + */ + @Override + public String FALSE() { + return "FALSE"; + } + + /** + * + * @return + */ + @Override + public String INTEGER_NULL() { + return "CAST(NULL AS INTEGER)"; + } + + /** + * + * @return + */ + @Override + public String CHAR_NULL() { + return "CAST(NULL AS CHAR)"; + } + + /** + * + * @return + */ + @Override + public String getName() { + return "HSQLDB"; + } + + /** + * + * @param s + * @param sequence + * @return + */ + @Override + public SentenceFind getSequenceSentence(Session s, String sequence) { + return new StaticSentence(s, "CALL NEXT VALUE FOR " + sequence, null, SerializerReadInteger.INSTANCE); + } + + /** + * + * @param s + * @param sequence + * @return + */ + @Override + public SentenceFind resetSequenceSentence(Session s, String sequence) { + return new StaticSentence(s, "CALL NEXT VALUE FOR " + sequence, null, SerializerReadInteger.INSTANCE); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SessionDBMariaDB.java b/src/main/java/com/unicenta/data/loader/SessionDBMariaDB.java new file mode 100644 index 0000000..62e1a1e --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SessionDBMariaDB.java @@ -0,0 +1,89 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author adrianromero + */ +public class SessionDBMariaDB implements SessionDB { + + /** + * + * @return + */ + public String TRUE() { + return "TRUE"; + } + + /** + * + * @return + */ + public String FALSE() { + return "FALSE"; + } + + /** + * + * @return + */ + public String INTEGER_NULL() { + return "CAST(NULL AS UNSIGNED INTEGER)"; + } + + /** + * + * @return + */ + public String CHAR_NULL() { + return "CAST(NULL AS CHAR)"; + } + + /** + * + * @return + */ + public String getName() { + return "MariaDB"; + } + + /** + * + * @param s + * @param sequence + * @return + */ + @Override + public SentenceFind getSequenceSentence(Session s, String sequence) { + return new SequenceForMySQL(s, sequence); + } + + /** + * + * @param s + * @param sequence + * @return + */ + @Override + public SentenceFind resetSequenceSentence(Session s, String sequence) { + return new SequenceForMySQL(s, "UPDATE pickup_number SET ID=1"); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SessionDBMySQL.java b/src/main/java/com/unicenta/data/loader/SessionDBMySQL.java new file mode 100644 index 0000000..0ca7aa6 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SessionDBMySQL.java @@ -0,0 +1,89 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author adrianromero + */ +public class SessionDBMySQL implements SessionDB { + + /** + * + * @return + */ + public String TRUE() { + return "TRUE"; + } + + /** + * + * @return + */ + public String FALSE() { + return "FALSE"; + } + + /** + * + * @return + */ + public String INTEGER_NULL() { + return "CAST(NULL AS UNSIGNED INTEGER)"; + } + + /** + * + * @return + */ + public String CHAR_NULL() { + return "CAST(NULL AS CHAR)"; + } + + /** + * + * @return + */ + public String getName() { + return "MySQL"; + } + + /** + * + * @param s + * @param sequence + * @return + */ + @Override + public SentenceFind getSequenceSentence(Session s, String sequence) { + return new SequenceForMySQL(s, sequence); + } + + /** + * + * @param s + * @param sequence + * @return + */ + @Override + public SentenceFind resetSequenceSentence(Session s, String sequence) { + return new SequenceForMySQL(s, "UPDATE pickup_number SET ID=1"); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SessionDBOracle.java b/src/main/java/com/unicenta/data/loader/SessionDBOracle.java new file mode 100644 index 0000000..475f4eb --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SessionDBOracle.java @@ -0,0 +1,87 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author adrianromero + */ +public class SessionDBOracle implements SessionDB { + + /** + * + * @return + */ + public String TRUE() { + return "1"; + } + + /** + * + * @return + */ + public String FALSE() { + return "0"; + } + + /** + * + * @return + */ + public String INTEGER_NULL() { + return "CAST(NULL AS INTEGER)"; + } + + /** + * + * @return + */ + public String CHAR_NULL() { + return "CAST(NULL AS CHAR)"; + } + + /** + * + * @return + */ + public String getName() { + return "Oracle"; + } + + /** + * + * @param s + * @param sequence + * @return + */ + public SentenceFind getSequenceSentence(Session s, String sequence) { + return new StaticSentence(s, "SELECT " + sequence + ".NEXTVAL FROM DUAL", null, SerializerReadInteger.INSTANCE); + } + + /** + * + * @param s + * @param sequence + * @return + */ + public SentenceFind resetSequenceSentence(Session s, String sequence) { + return new StaticSentence(s, "SELECT " + sequence + ".NEXTVAL FROM DUAL", null, SerializerReadInteger.INSTANCE); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/data/loader/SessionDBPostgreSQL.java b/src/main/java/com/unicenta/data/loader/SessionDBPostgreSQL.java new file mode 100644 index 0000000..ca589b2 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SessionDBPostgreSQL.java @@ -0,0 +1,94 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +/** + * + * @author adrianromero + */ +public class SessionDBPostgreSQL implements SessionDB { + + /** + * + * @return + */ + @Override + public String TRUE() { + return "True"; + } + + /** + * + * @return + */ + @Override + public String FALSE() { + return "False"; + } + + /** + * + * @return + */ + @Override + public String INTEGER_NULL() { + return "CAST(NULL AS INTEGER)"; + } + + /** + * + * @return + */ + @Override + public String CHAR_NULL() { + return "CAST(NULL AS CHAR)"; + } + + /** + * + * @return + */ + @Override + public String getName() { + return "PostgreSQL"; + } + + /** + * + * @param s + * @param sequence + * @return + */ + @Override + public SentenceFind getSequenceSentence(Session s, String sequence) { + return new StaticSentence(s, "SELECT NEXTVAL('" + sequence + "')", null, SerializerReadInteger.INSTANCE); + } + + /** + * + * @param s + * @param sequence + * @return + */ + @Override + public SentenceFind resetSequenceSentence(Session s, String sequence){ + return new StaticSentence(s, "ALTER SEQUENCE " + sequence + " RESTART WITH '0'", null, SerializerReadInteger.INSTANCE); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SessionDBSQLite.java b/src/main/java/com/unicenta/data/loader/SessionDBSQLite.java new file mode 100644 index 0000000..34d6ce1 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SessionDBSQLite.java @@ -0,0 +1,70 @@ +package com.unicenta.data.loader; + +/** + * + * @author adrianromero + */ +public class SessionDBSQLite implements SessionDB { + + /** + * + * @return + */ + public String TRUE() { + return "1"; + } + + /** + * + * @return + */ + public String FALSE() { + return "0"; + } + + /** + * + * @return + */ + public String INTEGER_NULL() { + return "CAST(NULL AS UNSIGNED INTEGER)"; + } + + /** + * + * @return + */ + public String CHAR_NULL() { + return "CAST(NULL AS CHAR)"; + } + + /** + * + * @return + */ + public String getName() { + return "SQLite"; + } + + /** + * + * @param s + * @param sequence + * @return + */ + @Override + public SentenceFind getSequenceSentence(Session s, String sequence) { + return new SequenceForSQLite(s, sequence); + } + + /** + * + * @param s + * @param sequence + * @return + */ + @Override + public SentenceFind resetSequenceSentence(Session s, String sequence) { + return new SequenceForSQLite(s, "UPDATE pickup_number SET ID=1"); + } +} diff --git a/src/main/java/com/unicenta/data/loader/SimpleBuilder.java b/src/main/java/com/unicenta/data/loader/SimpleBuilder.java new file mode 100644 index 0000000..a116eca --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/SimpleBuilder.java @@ -0,0 +1,49 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author adrian + */ +public class SimpleBuilder implements ISQLBuilderStatic { + + private String m_sSentence; + + /** Creates a new instance of SimpleBuilder + * @param sSentence */ + public SimpleBuilder(String sSentence) { + m_sSentence = sSentence; + } + + /** + * + * @param sw + * @param params + * @return + * @throws BasicException + */ + public String getSQL(SerializerWrite sw, Object params) throws BasicException { + return m_sSentence; + } + +} diff --git a/src/main/java/com/unicenta/data/loader/StaticSentence.java b/src/main/java/com/unicenta/data/loader/StaticSentence.java new file mode 100644 index 0000000..e7661d0 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/StaticSentence.java @@ -0,0 +1,224 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; +import lombok.extern.slf4j.Slf4j; + +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Arrays; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author adrianromero + */ +@Slf4j +public class StaticSentence extends JDBCSentence { + + + private ISQLBuilderStatic iSQLBuilder; + + /** + * + */ + protected SerializerWrite m_SerWrite = null; + + /** + * + */ + protected SerializerRead m_SerRead = null; + + // Estado + private Statement statement; + + /** + * Creates a new instance of StaticSentence + * + * @param s + * @param sentence + * @param serread + * @param serwrite + */ + public StaticSentence(Session s, ISQLBuilderStatic sentence, SerializerWrite serwrite, SerializerRead serread) { + super(s); + iSQLBuilder = sentence; + m_SerWrite = serwrite; + m_SerRead = serread; + statement = null; + } + + /** + * Creates a new instance of StaticSentence + * + * @param s + * @param sentence + */ + public StaticSentence(Session s, ISQLBuilderStatic sentence) { + this(s, sentence, null, null); + } + + /** + * Creates a new instance of StaticSentence + * + * @param s + * @param sentence + * @param serwrite + */ + public StaticSentence(Session s, ISQLBuilderStatic sentence, SerializerWrite serwrite) { + this(s, sentence, serwrite, null); + } + + /** + * Creates a new instance of StaticSentence + * + * @param s + * @param sentence + * @param serread + * @param serwrite + */ + public StaticSentence(Session s, String sentence, SerializerWrite serwrite, SerializerRead serread) { + this(s, new NormalBuilder(sentence), serwrite, serread); + } + + /** + * Creates a new instance of StaticSentence + * + * @param s + * @param sentence + * @param serwrite + */ + public StaticSentence(Session s, String sentence, SerializerWrite serwrite) { + this(s, new NormalBuilder(sentence), serwrite, null); + } + + /** + * Creates a new instance of StaticSentence + * + * @param s + * @param sentence + */ + public StaticSentence(Session s, String sentence) { + this(s, new NormalBuilder(sentence), null, null); + } + + public String fixSqliteDate(String sql) { + + try { + if (session.getURL().contains("sqlite") && sql.contains("{ts '")) { + StringBuilder sqliteSQL = new StringBuilder(); + + Pattern date = Pattern.compile("(?<=ts ).*(?=})"); + Matcher matchPattern = date.matcher(sql); + + if (matchPattern.find()) { + sqliteSQL.append(sql.replaceAll("\\{.*}", matchPattern.group(0))); + } + + return sqliteSQL.toString(); + } + + } + catch (Exception e) { + log.error("Error fixing sql for sqlite {}", e.getMessage()); + return sql; + } + return sql; + } + /** + * @param params + * @return + * @throws BasicException + */ + @Override + public DataResultSet openExec(Object params) throws BasicException { + // true -> un resultset + // false -> un updatecount (si -1 entonces se acabo) + + closeExec(); + + try { + + String sentence = fixSqliteDate(iSQLBuilder.getSQL(m_SerWrite, params)); + //String sentence = iSQLBuilder.getSQL(m_SerWrite, params); + + statement = session.getConnection().createStatement(); + + log.debug("Executing static SQL: {}", sentence); + + if (statement.execute(sentence)) { + return new JDBCDataResultSet(statement.getResultSet(), m_SerRead); + } else { + int iUC = statement.getUpdateCount(); + if (iUC < 0) { + return null; + } else { + return new SentenceUpdateResultSet(iUC); + } + } + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + + /** + * @throws BasicException + */ + @Override + public void closeExec() throws BasicException { + + if (statement != null) { + try { + statement.close(); + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } finally { + statement = null; + } + } + } + + /** + * @return + * @throws BasicException + */ + @Override + public DataResultSet moreResults() throws BasicException { + + try { + if (statement.getMoreResults()) { + // tenemos resultset + return new JDBCDataResultSet(statement.getResultSet(), m_SerRead); + } else { + // tenemos updatecount o si devuelve -1 ya no hay mas + int iUC = statement.getUpdateCount(); + if (iUC < 0) { + return null; + } else { + return new SentenceUpdateResultSet(iUC); + } + } + } catch (SQLException eSQL) { + throw new BasicException(eSQL); + } + } + +} diff --git a/src/main/java/com/unicenta/data/loader/TableDefinition.java b/src/main/java/com/unicenta/data/loader/TableDefinition.java new file mode 100644 index 0000000..4bde5f8 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/TableDefinition.java @@ -0,0 +1,349 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.format.Formats; + +/** + * + * @author JG uniCenta + */ +public class TableDefinition { + + private Session m_s; + private String tablename; + + private String[] fieldname; + private String[] fieldtran; + private Datas[] fielddata; + private Formats[] fieldformat; + + private int[] idinx; + + + /** Creates a new instance of TableDefinition + * @param s + * @param fieldformat + * @param tablename + * @param fieldname + * @param fieldtran + * @param idinx + * @param fielddata */ + public TableDefinition( + Session s, + String tablename, + String[] fieldname, String[] fieldtran, Datas[] fielddata, Formats[] fieldformat, + int[] idinx) { + + m_s = s; + this.tablename = tablename; + + this.fieldname = fieldname; + this.fieldtran = fieldtran; + this.fielddata = fielddata; + this.fieldformat = fieldformat; + + this.idinx = idinx; + } + + /** + * + * @param s + * @param tablename + * @param fieldname + * @param fielddata + * @param fieldformat + * @param idinx + */ + public TableDefinition( + Session s, + String tablename, + String[] fieldname, Datas[] fielddata, Formats[] fieldformat, + int[] idinx) { + this(s, tablename, fieldname, fieldname, fielddata, fieldformat, idinx); + } + + /** + * + * @return + */ + public String getTableName() { + return tablename; + } + + /** + * + * @return + */ + public String[] getFields() { + return fieldname; + } + + /** + * + * @param aiFields + * @return + */ + public Vectorer getVectorerBasic(int[] aiFields) { + return new VectorerBasic(fieldtran, fieldformat, aiFields); + } + + /** + * + * @param aiFields + * @return + */ + public IRenderString getRenderStringBasic(int[] aiFields) { + return new RenderStringBasic(fieldformat, aiFields); + } + + /** + * + * @param aiOrders + * @return + */ + public ComparatorCreator getComparatorCreator(int [] aiOrders) { + return new ComparatorCreatorBasic(fieldtran, fielddata, aiOrders); + } + + /** + * + * @return + */ + public IKeyGetter getKeyGetterBasic() { + if (idinx.length == 1) { + return new KeyGetterFirst(idinx); + } else { + return new KeyGetterBasic(idinx); + } + } + + /** + * + * @return + */ + public SerializerRead getSerializerReadBasic() { + return new SerializerReadBasic(fielddata); + } + + /** + * + * @param fieldindx + * @return + */ + public SerializerWrite getSerializerInsertBasic(int[] fieldindx) { + return new SerializerWriteBasicExt(fielddata, fieldindx); + } + + /** + * + * @return + */ + public SerializerWrite getSerializerDeleteBasic() { + return new SerializerWriteBasicExt(fielddata, idinx); + } + + /** + * + * @param fieldindx + * @return + */ + public SerializerWrite getSerializerUpdateBasic(int[] fieldindx) { + + int[] aindex = new int[fieldindx.length + idinx.length]; + + for (int i = 0; i < fieldindx.length; i++) { + aindex[i] = fieldindx[i]; + } + for (int i = 0; i < idinx.length; i++) { + aindex[i + fieldindx.length] = idinx[i]; + } + + return new SerializerWriteBasicExt(fielddata, aindex); + } + + /** + * + * @return + */ + public SentenceList getListSentence() { + return getListSentence(getSerializerReadBasic()); + } + + /** + * + * @param sr + * @return + */ + public SentenceList getListSentence(SerializerRead sr) { + return new PreparedSentence(m_s, getListSQL(), null, sr); + } + + /** + * + * @return + */ + public String getListSQL() { + + StringBuilder sent = new StringBuilder(); + sent.append("select "); + + for (int i = 0; i < fieldname.length; i ++) { + if (i > 0) { + sent.append(", "); + } + sent.append(fieldname[i]); + } + + sent.append(" from "); + sent.append(tablename); + + return sent.toString(); + } + + /** + * + * @return + */ + public SentenceExec getDeleteSentence() { + return getDeleteSentence(getSerializerDeleteBasic()); + } + + /** + * + * @param sw + * @return + */ + public SentenceExec getDeleteSentence(SerializerWrite sw) { + return new PreparedSentence(m_s, getDeleteSQL(), sw, null); + } + + /** + * + * @return + */ + public String getDeleteSQL() { + + StringBuilder sent = new StringBuilder(); + sent.append("delete from "); + sent.append(tablename); + + for (int i = 0; i < idinx.length; i ++) { + sent.append((i == 0) ? " where " : " and "); + sent.append(fieldname[idinx[i]]); + sent.append(" = ?"); + } + + return sent.toString(); + } + + /** + * + * @return + */ + public SentenceExec getInsertSentence() { + return getInsertSentence(getAllFields()); + } + + /** + * + * @param fieldindx + * @return + */ + public SentenceExec getInsertSentence(int[] fieldindx) { + return new PreparedSentence(m_s, getInsertSQL(fieldindx), getSerializerInsertBasic(fieldindx), null); + } + + private String getInsertSQL(int[] fieldindx) { + + StringBuilder sent = new StringBuilder(); + StringBuilder values = new StringBuilder(); + + sent.append("insert into "); + sent.append(tablename); + sent.append(" ("); + + for (int i = 0; i < fieldindx.length; i ++) { + if (i > 0) { + sent.append(", "); + values.append(", "); + } + sent.append(fieldname[fieldindx[i]]); + values.append("?"); + } + + sent.append(") values ("); + sent.append(values.toString()); + sent.append(")"); + + return sent.toString(); + } + + private int[] getAllFields() { + + int[] fieldindx = new int[fieldname.length]; + for (int i = 0; i < fieldname.length; i++) { + fieldindx[i] = i; + } + return fieldindx; + } + + /** + * + * @return + */ + public SentenceExec getUpdateSentence() { + return getUpdateSentence(getAllFields()); + } + + /** + * + * @param fieldindx + * @return + */ + public SentenceExec getUpdateSentence(int[] fieldindx) { + return new PreparedSentence(m_s, getUpdateSQL(fieldindx), getSerializerUpdateBasic(fieldindx), null); + } + + private String getUpdateSQL(int[] fieldindx) { + + StringBuilder sent = new StringBuilder(); + + sent.append("update "); + sent.append(tablename); + sent.append(" set "); + + for (int i = 0; i < fieldindx.length; i ++) { + if (i > 0) { + sent.append(", "); + } + sent.append(fieldname[fieldindx[i]]); + sent.append(" = ?"); + } + + for (int i = 0; i < idinx.length; i ++) { + sent.append((i == 0) ? " where " : " and "); + sent.append(fieldname[idinx[i]]); + sent.append(" = ?"); + } + + return sent.toString(); + } +} diff --git a/src/main/java/com/unicenta/data/loader/TicketFooter.java b/src/main/java/com/unicenta/data/loader/TicketFooter.java new file mode 100644 index 0000000..a3f33ad --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/TicketFooter.java @@ -0,0 +1,83 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2013 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; +import com.unicenta.pos.forms.AppViewConnection; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.data.loader.Session; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import java.io.*; + +public class TicketFooter { + private String footer_line1; + private String footer_line2; + private String footer_line3; + private String footer_line4; + private String footer_line5; + private String footer_line6; + private File m_config; + private Session session; + + public TicketFooter() { + AppConfig config = new AppConfig(m_config); + // AppViewConnection Session = new AppViewConnection(); + + } + + public void loadProperties(AppConfig config) { + footer_line1=(config.getProperty("till.footer1")); + footer_line2=(config.getProperty("till.footer2")); + footer_line3=(config.getProperty("till.footer3")); + footer_line4=(config.getProperty("till.footer4")); + footer_line5=(config.getProperty("till.footer5")); + footer_line6=(config.getProperty("till.footer6")); + } + + public String getTicketFooterLine1() { + return footer_line1; + } + + public String getTicketFooterLine2() { + return footer_line2; + } + + public String getTicketFooterLine3() { + return footer_line3; + } + + public String getTicketFooterLine4() { + return footer_line4; + } + + public String getTicketFooterLine5() { + return footer_line5; + } + + public String getTicketFooterLine6() { + return footer_line6; + } +} + + + + + diff --git a/src/main/java/com/unicenta/data/loader/TicketHeader.java b/src/main/java/com/unicenta/data/loader/TicketHeader.java new file mode 100644 index 0000000..ed64301 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/TicketHeader.java @@ -0,0 +1,83 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2013 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; +import com.unicenta.pos.forms.AppViewConnection; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.data.loader.Session; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import java.io.*; + +public class TicketHeader { + private String header_line1; + private String header_line2; + private String header_line3; + private String header_line4; + private String header_line5; + private String header_line6; + private File m_config; + private Session session; + + public TicketHeader() { + AppConfig config = new AppConfig(m_config); + // AppViewConnection Session = new AppViewConnection(); + + } + + public void loadProperties(AppConfig config) { + header_line1=(config.getProperty("till.header1")); + header_line2=(config.getProperty("till.header2")); + header_line3=(config.getProperty("till.header3")); + header_line4=(config.getProperty("till.header4")); + header_line5=(config.getProperty("till.header5")); + header_line6=(config.getProperty("till.header6")); + } + + public String getTicketHeaderLine1() { + return header_line1; + } + + public String getTicketHeaderLine2() { + return header_line2; + } + + public String getTicketHeaderLine3() { + return header_line3; + } + + public String getTicketHeaderLine4() { + return header_line4; + } + + public String getTicketHeaderLine5() { + return header_line5; + } + + public String getTicketHeaderLine6() { + return header_line6; + } +} + + + + + diff --git a/src/main/java/com/unicenta/data/loader/Transaction.java b/src/main/java/com/unicenta/data/loader/Transaction.java new file mode 100644 index 0000000..6db4506 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/Transaction.java @@ -0,0 +1,74 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; +import java.sql.SQLException; + +/** + * + * @author adrianromero + * Created on 26 de febrero de 2007, 21:50 + * @param + * + */ +public abstract class Transaction { + + private Session s; + + /** Creates a new instance of Transaction + * @param s */ + public Transaction(Session s) { + this.s = s; + } + + /** + * + * @return + * @throws BasicException + */ + public final T execute() throws BasicException { + + if (s.isTransaction()) { + return transact(); + } else { + try { + try { + s.begin(); + T result = transact(); + s.commit(); + return result; + } catch (BasicException e) { + s.rollback(); + throw e; + } + } catch (SQLException eSQL) { + throw new BasicException("Transaction error", eSQL); + } + } + } + + /** + * + * @return + * @throws BasicException + */ + protected abstract T transact() throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/Vectorer.java b/src/main/java/com/unicenta/data/loader/Vectorer.java new file mode 100644 index 0000000..09ec818 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/Vectorer.java @@ -0,0 +1,46 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public interface Vectorer { + + // public int size(); + + /** + * + * @return + * @throws BasicException + */ + public String[] getHeaders() throws BasicException; + + /** + * + * @param obj + * @return + * @throws BasicException + */ + public String[] getValues(Object obj) throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/loader/VectorerBasic.java b/src/main/java/com/unicenta/data/loader/VectorerBasic.java new file mode 100644 index 0000000..95d7beb --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/VectorerBasic.java @@ -0,0 +1,77 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import com.unicenta.format.Formats; +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class VectorerBasic implements Vectorer { + + private int[] m_aiIndex; + private String[] m_asHeaders; + private Formats[] m_aFormats; + + /** + * + * @param asHeaders + * @param aFormats + * @param aiIndex + */ + public VectorerBasic(String[] asHeaders, Formats[] aFormats, int[] aiIndex) { + m_asHeaders = asHeaders; + m_aFormats = aFormats; + m_aiIndex = aiIndex; + } + + /** + * + * @return + * @throws BasicException + */ + public String[] getHeaders() throws BasicException { + + String[] asvalues = new String[m_aiIndex.length]; + for (int i = 0; i < m_aiIndex.length; i++) { + asvalues[i] = m_asHeaders[m_aiIndex[i]]; + } + + return asvalues; + } + + /** + * + * @param obj + * @return + * @throws BasicException + */ + public String[] getValues(Object obj) throws BasicException { + Object[] avalues = (Object[]) obj; + String[] asvalues = new String[m_aiIndex.length]; + for (int i = 0; i < m_aiIndex.length; i++) { + asvalues[i] = m_aFormats[m_aiIndex[i]].formatValue(avalues[m_aiIndex[i]]); + } + + return asvalues; + } +} diff --git a/src/main/java/com/unicenta/data/loader/VectorerBuilder.java b/src/main/java/com/unicenta/data/loader/VectorerBuilder.java new file mode 100644 index 0000000..ee6f8d3 --- /dev/null +++ b/src/main/java/com/unicenta/data/loader/VectorerBuilder.java @@ -0,0 +1,108 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.loader; + +import java.util.*; +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public abstract class VectorerBuilder implements Vectorer { + + /** Creates a new instance of VectorerBuilder */ + public VectorerBuilder() { + } + + /** + * + * @return + * @throws BasicException + */ + public abstract String[] getHeaders() throws BasicException; + + /** + * + * @param obj + * @return + * @throws BasicException + */ + public String[] getValues(Object obj) throws BasicException { + + SerializableToArray s2a = new SerializableToArray(); + ((SerializableWrite) obj).writeValues(s2a); + return s2a.getValues(); + } + + private static class SerializableToArray implements DataWrite { + + private ArrayList m_aParams; + + /** Creates a new instance of MetaParameter */ + public SerializableToArray() { + m_aParams = new ArrayList(); + } + + public void setDouble(int paramIndex, Double dValue) throws BasicException { + ensurePlace(paramIndex - 1); + m_aParams.set(paramIndex - 1, dValue.toString()); + } + public void setBoolean(int paramIndex, Boolean bValue) throws BasicException { + ensurePlace(paramIndex - 1); + m_aParams.set(paramIndex - 1, bValue.toString()); + } + public void setInt(int paramIndex, Integer iValue) throws BasicException { + ensurePlace(paramIndex - 1); + m_aParams.set(paramIndex - 1, iValue.toString()); + } + public void setString(int paramIndex, String sValue) throws BasicException { + ensurePlace(paramIndex - 1); + m_aParams.set(paramIndex - 1, sValue); + } + public void setTimestamp(int paramIndex, java.util.Date dValue) throws BasicException { + ensurePlace(paramIndex - 1); + m_aParams.set(paramIndex - 1, dValue.toString()); + } +// public void setBinaryStream(int paramIndex, java.io.InputStream in, int length) throws DataException { +// ensurePlace(paramIndex -1); +// // m_aParams.set(paramIndex - 1, value.toString()); // quiza un uuencode o algo asi +// } + public void setBytes(int paramIndex, byte[] value) throws BasicException { + ensurePlace(paramIndex -1); + m_aParams.set(paramIndex - 1, value.toString()); // quiza un uuencode o algo asi + } + public void setObject(int paramIndex, Object value) throws BasicException { + ensurePlace(paramIndex - 1); + m_aParams.set(paramIndex - 1, value.toString()); + } + + private void ensurePlace(int i) { + m_aParams.ensureCapacity(i); + while (i >= m_aParams.size()){ + m_aParams.add(null); + } + } + + public String[] getValues() { + return (String[]) m_aParams.toArray(new String[m_aParams.size()]); + } + } +} diff --git a/src/main/java/com/unicenta/data/model/Column.java b/src/main/java/com/unicenta/data/model/Column.java new file mode 100644 index 0000000..095c8d7 --- /dev/null +++ b/src/main/java/com/unicenta/data/model/Column.java @@ -0,0 +1,53 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.model; + +/** + * + * @author adrian + */ +public class Column { + + private String name; + + /** + * + * @param name + */ + public Column(String name) { + this.name = name; + } + + /** + * + * @return + */ + public String getName() { + return name; + } + + /** + * + * @return + */ + public boolean isPK() { + return false; + } +} diff --git a/src/main/java/com/unicenta/data/model/Field.java b/src/main/java/com/unicenta/data/model/Field.java new file mode 100644 index 0000000..2034375 --- /dev/null +++ b/src/main/java/com/unicenta/data/model/Field.java @@ -0,0 +1,114 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.model; + +import com.unicenta.data.loader.Datas; +import com.unicenta.format.Formats; + +/** + * + * @author adrian + */ +public class Field { + + private String label; + private Datas data; + private Formats format; + + private boolean searchable; + private boolean comparable; + private boolean title; + + /** + * + * @param label + * @param data + * @param format + * @param title + * @param searchable + * @param comparable + */ + public Field(String label, Datas data, Formats format, boolean title, boolean searchable, boolean comparable) { + this.label = label; + this.data = data; + this.format = format; + this.title = title; + this.searchable = searchable; + this.comparable = comparable; + } + + /** + * + * @param label + * @param data + * @param format + */ + public Field(String label, Datas data, Formats format) { + this(label, data, format, false, false, false); + } + + /** + * + * @return + */ + public String getLabel() { + return label; + } + + /** + * + * @return + */ + public Formats getFormat() { + return format; + } + + /** + * + * @return + */ + public Datas getData() { + return data; + } + + /** + * + * @return + */ + public boolean isSearchable() { + return searchable; + } + + /** + * + * @return + */ + public boolean isComparable() { + return comparable; + } + + /** + * + * @return + */ + public boolean isTitle() { + return title; + } +} diff --git a/src/main/java/com/unicenta/data/model/PrimaryKey.java b/src/main/java/com/unicenta/data/model/PrimaryKey.java new file mode 100644 index 0000000..a9ede17 --- /dev/null +++ b/src/main/java/com/unicenta/data/model/PrimaryKey.java @@ -0,0 +1,44 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.model; + +/** + * + * @author adrian + */ +public class PrimaryKey extends Column { + + /** + * + * @param name + */ + public PrimaryKey(String name) { + super(name); + } + + /** + * + * @return + */ + @Override + public boolean isPK() { + return true; + } +} diff --git a/src/main/java/com/unicenta/data/model/Row.java b/src/main/java/com/unicenta/data/model/Row.java new file mode 100644 index 0000000..418774a --- /dev/null +++ b/src/main/java/com/unicenta/data/model/Row.java @@ -0,0 +1,358 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.model; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.DataWrite; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.IRenderString; +import com.unicenta.data.loader.PreparedSentence; +import com.unicenta.data.loader.SentenceExec; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.SerializerRead; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.Session; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.FilterEditorCreator; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import javax.swing.ListCellRenderer; + +/** + * + * @author adrian + */ +public class Row { + + private Field[] fields; + + /** + * + * @param fields + */ + public Row(Field... fields) { + this.fields = fields; + } + + /** + * + * @return + */ + public Vectorer getVectorer() { + return new RowVectorer(); + } + + /** + * + * @return + */ + public IRenderString getRenderString() { + return new RowRenderString(); + } + + /** + * + * @return + */ + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(new RowRenderString()); + } + + /** + * + * @return + */ + public ComparatorCreator getComparatorCreator() { + return new RowComparatorCreator(); + } + + /** + * + * @param s + * @param sql + * @param indexes + * @return + */ + public SentenceExec getExecSentence(Session s, String sql, final int... indexes) { + return new PreparedSentence(s, sql, + new SerializerWrite() { + @Override + public void writeValues(DataWrite dp, Object[] obj) throws BasicException { + for (int i = 0; i < indexes.length; i++) { + fields[indexes[i]].getData().setValue(dp, i + 1, obj[indexes[i]]); + } + } + } + ); + } + + /** + * + * @param s + * @param t + * @return + */ + public ListProvider getListProvider(Session s, Table t) { + return new ListProviderCreator(getListSentence(s, t)); + } + + /** + * + * @param s + * @param t + * @return + */ + public SaveProvider getSaveProvider(Session s, Table t) { + return new SaveProvider(getUpdateSentence(s, t), getInsertSentence(s, t), getDeleteSentence(s, t)); + } + + /** + * + * @param s + * @param sql + * @param sw + * @return + */ + public SentenceList getListSentence(Session s, String sql, SerializerWrite sw) { + return new PreparedSentence(s, sql, sw, new RowSerializerRead()); + } + + /** + * + * @param s + * @param sql + * @param filter + * @return + */ + public ListProvider getListProvider(Session s, String sql, FilterEditorCreator filter) { + return new ListProviderCreator(getListSentence(s, sql, filter.getSerializerWrite()), filter); + } + + /** + * + * @param s + * @param t + * @return + */ + public SentenceList getListSentence(Session s, Table t) { + return getListSentence(s, t.getListSQL(), null); + } + + /** + * + * @param s + * @param t + * @return + */ + public SentenceExec getInsertSentence(Session s, final Table t) { + return new PreparedSentence(s, t.getInsertSQL(), + new SerializerWrite() { + @Override + public void writeValues(DataWrite dp, Object[] obj) throws BasicException { + for (int i = 0; i < t.getColumns().length; i++) { + fields[i].getData().setValue(dp, i + 1, obj[i]); + } + } + } + ); + } + + /** + * + * @param s + * @param t + * @return + */ + public SentenceExec getDeleteSentence(Session s, final Table t) { + return new PreparedSentence(s, t.getDeleteSQL(), + new SerializerWrite() { + @Override + public void writeValues(DataWrite dp, Object[] obj) throws BasicException { + int index = 1; + for (int i = 0; i < t.getColumns().length; i++) { + if (t.getColumns()[i].isPK()) { + fields[i].getData().setValue(dp, index++, obj[i]); + } + } + } + } + ); + } + + /** + * + * @param s + * @param t + * @return + */ + public SentenceExec getUpdateSentence(Session s, final Table t) { + return new PreparedSentence(s, t.getUpdateSQL(), + new SerializerWrite() { + @Override + public void writeValues(DataWrite dp, Object[] obj) throws BasicException { + int index = 1; + for (int i = 0; i < t.getColumns().length; i++) { + if (!t.getColumns()[i].isPK()) { + fields[i].getData().setValue(dp, index++, obj[i]); + } + } + for (int i = 0; i < t.getColumns().length; i++) { + if (t.getColumns()[i].isPK()) { + fields[i].getData().setValue(dp, index++, obj[i]); + } + } + } + } + ); + } + + /** + * + * @return + */ + public Datas[] getDatas() { + Datas[] d = new Datas[fields.length]; + for (int i = 0; i < fields.length; i++) { + d[i] = fields[i].getData(); + } + return d; + } + + /** + * + * @return + */ + public SerializerRead getSerializerRead() { + return new RowSerializerRead(); + } + + private class RowSerializerRead implements SerializerRead { + @Override + public Object readValues(DataRead dr) throws BasicException { + Object[] m_values = new Object[fields.length]; + for (int i = 0; i < fields.length; i++) { + m_values[i] = fields[i].getData().getValue(dr, i + 1); + } + return m_values; + } + } + + private class RowVectorer implements Vectorer { + @Override + public String[] getHeaders() throws BasicException { +// JG Aug 2013 use Diamon Inference + List l = new ArrayList<>(); + for (Field f : fields) { + if (f.isSearchable()) { + l.add(f.getLabel()); + } + } + return l.toArray(new String[l.size()]); + } + @Override + public String[] getValues(Object obj) throws BasicException { + Object[] values = (Object[]) obj; +// JG Aug 2013 use Diamon Inference + List l = new ArrayList<>(); + for (int i = 0; i < fields.length; i++) { + if (fields[i].isSearchable()) { + l.add(fields[i].getFormat().formatValue(values[i])); + } + } + return l.toArray(new String[l.size()]); + } + } + + private class RowRenderString implements IRenderString { + @Override + public String getRenderString(Object value) { + Object[] values = (Object[]) value; + StringBuilder s = new StringBuilder(); + for (int i = 0; i < fields.length; i++) { + if (fields[i].isTitle()) { + if (s.length() > 0) { + s.append(" - "); + } + s.append(fields[i].getFormat().formatValue(values[i])); + } + } + return s.toString(); + } + } + + private class RowComparatorCreator implements ComparatorCreator { + + private List comparablefields = new ArrayList<>(); + + public RowComparatorCreator() { + for (int i = 0; i < fields.length; i++) { + if (fields[i].isComparable()) { + comparablefields.add(i); + } + } + } + + @Override + public String[] getHeaders() { + String [] headers = new String [comparablefields.size()]; + for (int i = 0; i < comparablefields.size(); i++) { + headers[i] = fields[comparablefields.get(i)].getLabel(); + } + return headers; + } + + @Override + public Comparator createComparator(final int[] orderby) { + return new Comparator() { + @Override + public int compare(Object o1, Object o2) { + if (o1 == null) { + if (o2 == null) { + return 0; + } else { + return -1; + } + } else if (o2 == null) { + return +1; + } else { + Object[] ao1 = (Object[]) o1; + Object[] ao2 = (Object[]) o2; + for (int i = 0; i < orderby.length; i++) { + int result = fields[comparablefields.get(orderby[i])].getData().compare( + ao1[comparablefields.get(orderby[i])], + ao2[comparablefields.get(orderby[i])]); + if (result != 0) { + return result; + } + } + return 0; + } + } + }; + } + } +} diff --git a/src/main/java/com/unicenta/data/model/Table.java b/src/main/java/com/unicenta/data/model/Table.java new file mode 100644 index 0000000..818b55a --- /dev/null +++ b/src/main/java/com/unicenta/data/model/Table.java @@ -0,0 +1,159 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.model; + +/** + * + * @author adrian + */ +public class Table { + + private String name; + private Column[] columns; + + /** + * + * @param name + * @param columns + */ + public Table(String name, Column... columns) { + this.name = name; + this.columns = columns; + } + + /** + * + * @return + */ + public String getName() { + return name; + } + + /** + * + * @return + */ + public Column[] getColumns() { + return columns; + } + + /** + * + * @return + */ + public String getListSQL() { + StringBuilder sent = new StringBuilder(); + sent.append("select "); + + for (int i = 0; i < columns.length; i ++) { + if (i > 0) { + sent.append(", "); + } + sent.append(columns[i].getName()); + } + + sent.append(" from "); + sent.append(name); + + return sent.toString(); + } + + /** + * + * @return + */ + public String getInsertSQL() { + + StringBuilder sent = new StringBuilder(); + StringBuilder values = new StringBuilder(); + + sent.append("insert into "); + sent.append(name); + sent.append(" ("); + + for (int i = 0; i < columns.length; i ++) { + if (i > 0) { + sent.append(", "); + values.append(", "); + } + sent.append(columns[i].getName()); + values.append("?"); + } + + sent.append(") values ("); + sent.append(values.toString()); + sent.append(")"); + + return sent.toString(); + } + + /** + * + * @return + */ + public String getUpdateSQL() { + + StringBuilder values = new StringBuilder(); + StringBuilder filter = new StringBuilder(); + + for (int i = 0; i < columns.length; i ++) { + if (columns[i].isPK()) { + if (filter.length() == 0) { + filter.append(" where "); + } else { + filter.append(" and "); + } + filter.append(columns[i].getName()); + filter.append(" = ?"); + } else { + if (values.length() > 0) { + values.append(", "); + } + values.append(columns[i].getName()); + values.append(" = ?"); + } + } + + return "update " + name + " set " + values + filter; + } + + /** + * + * @return + */ + public String getDeleteSQL() { + + StringBuilder filter = new StringBuilder(); + + for (int i = 0; i < columns.length; i ++) { + if (columns[i].isPK()) { + if (filter.length() == 0) { + filter.append(" where "); + } else { + filter.append(" and "); + } + filter.append(columns[i].getName()); + filter.append(" = ?"); + } + } + + return "delete from " + name + filter; + } +} diff --git a/src/main/java/com/unicenta/data/user/BrowsableData.java b/src/main/java/com/unicenta/data/user/BrowsableData.java new file mode 100644 index 0000000..6200c4d --- /dev/null +++ b/src/main/java/com/unicenta/data/user/BrowsableData.java @@ -0,0 +1,410 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.LocalRes; +import java.util.*; +import javax.swing.ListModel; +import javax.swing.event.EventListenerList; +import javax.swing.event.ListDataEvent; +import javax.swing.event.ListDataListener; + +/** + * + * @author JG uniCenta + */ +public class BrowsableData implements ListModel { + + /** + * + */ + protected EventListenerList listeners = new EventListenerList(); + private boolean m_bIsAdjusting; + + private ListProvider m_dataprov; + private SaveProvider m_saveprov; + + private List m_aData; // List + + private Comparator m_comparer; + + /** Creates a new instance of BrowsableData + * @param dataprov + * @param saveprov + * @param c */ + public BrowsableData(ListProvider dataprov, SaveProvider saveprov, Comparator c) { + m_dataprov = dataprov; + m_saveprov = saveprov; + m_comparer = c; + m_bIsAdjusting = false; + + m_aData = new ArrayList(); + } + + /** + * + * @param dataprov + * @param saveprov + */ + public BrowsableData(ListProvider dataprov, SaveProvider saveprov) { + this(dataprov, saveprov, null); + } + + /** + * + * @param dataprov + */ + public BrowsableData(ListProvider dataprov) { + this(dataprov, null, null); + } + + public final void addListDataListener(ListDataListener l) { + listeners.add(ListDataListener.class, l); + } + public final void removeListDataListener(ListDataListener l) { + listeners.remove(ListDataListener.class, l); + } + + // Metodos de acceso + public final Object getElementAt(int index) { + return m_aData.get(index); + } + + public final int getSize() { + return m_aData.size(); + } + + /** + * + * @return + */ + public final boolean isAdjusting() { + return m_bIsAdjusting; + } + + /** + * + * @param index0 + * @param index1 + */ + protected void fireDataIntervalAdded(int index0, int index1) { + m_bIsAdjusting = true; + EventListener[] l = listeners.getListeners(ListDataListener.class); + ListDataEvent e = null; + for (int i = 0; i < l.length; i++) { + if (e == null) { + e = new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, index0, index1); + } + ((ListDataListener) l[i]).intervalAdded(e); + } + m_bIsAdjusting = false; + } + + /** + * + * @param index0 + * @param index1 + */ + protected void fireDataContentsChanged(int index0, int index1) { + m_bIsAdjusting = true; + EventListener[] l = listeners.getListeners(ListDataListener.class); + ListDataEvent e = null; + for (int i = 0; i < l.length; i++) { + if (e == null) { + e = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, index0, index1); + } + ((ListDataListener) l[i]).contentsChanged(e); + } + m_bIsAdjusting = false; + } + + /** + * + * @param index0 + * @param index1 + */ + protected void fireDataIntervalRemoved(int index0, int index1) { + m_bIsAdjusting = true; + EventListener[] l = listeners.getListeners(ListDataListener.class); + ListDataEvent e = null; + for (int i = 0; i < l.length; i++) { + if (e == null) { + e = new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, index0, index1); + } + ((ListDataListener) l[i]).intervalRemoved(e); + } + m_bIsAdjusting = false; + } + + /** + * + * @throws BasicException + */ + public void refreshData() throws BasicException { + + putNewData(m_dataprov == null + ? null + : m_dataprov.refreshData()); + } + + /** + * + * @throws BasicException + */ + public void loadData() throws BasicException { + + putNewData(m_dataprov == null + ? null + : m_dataprov.loadData()); + } + + /** + * + * @throws BasicException + */ + public void unloadData() throws BasicException { + putNewData(null); + } + + /** + * + * @param l + */ + public void loadList(List l) { + putNewData(l); + } + + /** + * + * @param c + * @throws BasicException + */ + public void sort(Comparator c) throws BasicException { + + Collections.sort(m_aData, c); + putNewData(m_aData); + } + + /** + * + * @return + */ + public final boolean canLoadData() { + return m_dataprov != null; + } + + /** + * + * @return + */ + public boolean canInsertData() { + return m_saveprov != null && m_saveprov.canInsert(); + } + + /** + * + * @return + */ + public boolean canDeleteData() { + return m_saveprov != null && m_saveprov.canDelete(); + } + + /** + * + * @return + */ + public boolean canUpdateData() { + return m_saveprov != null && m_saveprov.canUpdate(); + } + + /** + * + * @param index + * @param f + * @return + * @throws BasicException + */ + public final int findNext(int index, Finder f) throws BasicException { + int i = index + 1; + + // search up to the end of the recordset + while (i < m_aData.size()) { + if (f.match(this.getElementAt(i))) { + return i; + } + i++; + } + // search from the begining + i = 0; + while (i < index) { + if (f.match(this.getElementAt(i))) { + return i; + } + i++; + } + + // No se ha encontrado + return -1; + } + + /** + * + * @param index + * @return + * @throws BasicException + */ + public final int removeRecord(int index) throws BasicException { + if (canDeleteData() && index >= 0 && index < m_aData.size()) { + if (m_saveprov.deleteData(getElementAt(index)) > 0) { + // borramos el elemento indicado + m_aData.remove(index); + // disparamos los eventos + fireDataIntervalRemoved(index, index); + + int newindex; + if (index < m_aData.size()) { + newindex = index; + } else { + newindex = m_aData.size() - 1; + } + return newindex; + } else { + throw new BasicException(LocalRes.getIntString("exception.nodelete")); + } + } else { + // indice no valido + throw new BasicException(LocalRes.getIntString("exception.nodelete")); + } + } + + /** + * + * @param index + * @param value + * @return + * @throws BasicException + */ + public final int updateRecord(int index, Object value) throws BasicException { + + if (canUpdateData() && index >= 0 && index < m_aData.size()) { + if (m_saveprov.updateData(value) > 0) { + // Modificamos el elemento indicado + int newindex; + if (m_comparer == null) { + newindex = index; + m_aData.set(newindex, value); + } else { + // lo movemos + newindex = insertionPoint(value); + if (newindex == index + 1) { + newindex = index; + m_aData.set(newindex, value); + } else if (newindex > index + 1) { + m_aData.remove(index); + newindex --; + m_aData.add(newindex, value); + } else { + m_aData.remove(index); + m_aData.add(newindex, value); + } + } + + if (newindex >= index) { + fireDataContentsChanged(index, newindex); + } else { + fireDataContentsChanged(newindex, index); + } + return newindex; + } else { + // fallo la actualizacion + throw new BasicException(LocalRes.getIntString("exception.noupdate")); + } + } else { + // registro invalido + throw new BasicException(LocalRes.getIntString("exception.noupdate")); + } + } + + /** + * + * @param value + * @return + * @throws BasicException + */ + public final int insertRecord(Object value) throws BasicException { + + if (canInsertData() && m_saveprov.insertData(value) > 0) { + int newindex; + if (m_comparer == null) { + // Anadimos el elemento indicado al final... + newindex = m_aData.size(); + } else { + // lo insertamos en el lugar adecuado + newindex = insertionPoint(value); + } + m_aData.add(newindex, value); + + // Disparamos la inserccion + fireDataIntervalAdded(newindex, newindex); + return newindex; + } else { + throw new BasicException(LocalRes.getIntString("exception.noinsert")); + } + } + + private final void putNewData(List aData) { + + int oldSize = m_aData.size(); + m_aData = (aData == null) ? new ArrayList() : aData; + int newSize = m_aData.size(); + + // Ordeno si es un Browsabledata ordenado + if (m_comparer != null) { + Collections.sort(m_aData, m_comparer); + } + + fireDataContentsChanged(0, newSize - 1); + if (oldSize > newSize) { + fireDataIntervalRemoved(newSize, oldSize - 1); + } else if (oldSize < newSize) { + fireDataIntervalAdded(oldSize, newSize - 1); + } + } + + private final int insertionPoint(Object value) { + + int low = 0; + int high = m_aData.size() - 1; + + while (low <= high) { + int mid = (low + high) >> 1; + Object midVal = m_aData.get(mid); + int cmp = m_comparer.compare(midVal, value); + + if (cmp <= 0) { + low = mid + 1; + } else { + high = mid - 1; + } + } + return low; + } +} diff --git a/src/main/java/com/unicenta/data/user/BrowsableEditableData.java b/src/main/java/com/unicenta/data/user/BrowsableEditableData.java new file mode 100644 index 0000000..00dc1ad --- /dev/null +++ b/src/main/java/com/unicenta/data/user/BrowsableEditableData.java @@ -0,0 +1,595 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2015 uniCenta & previous Openbravo POS works +// http://www.unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +import java.util.*; +import javax.swing.*; +import java.awt.Component; +import javax.swing.event.EventListenerList; +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.LocalRes; +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.customers.CustomerInfoGlobal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSystem; +import com.unicenta.pos.scripting.ScriptEngine; +import com.unicenta.pos.scripting.ScriptFactory; + +/** + * + * @author JG uniCenta + */ +public class BrowsableEditableData { + + /** + * Ticket Type = Debit + */ + public static final int ST_NORECORD = 0; + + /** + * Ticket Type = Credit (Refund) + */ + public static final int ST_UPDATE = 1; + + /** + * Payment Type = Debit (On Account) + */ + public static final int ST_DELETE = 2; + + /** + * Payment Type = Credit (On Account) + */ + public static final int ST_INSERT = 3; + + private final static int INX_EOF = -1; + + private BrowsableData m_bd; + + protected EventListenerList listeners = new EventListenerList(); + + private EditorRecord m_editorrecord; + private DirtyManager m_Dirty; + private int m_iState; // vinculado siempre al m_editorrecord +// private DocumentLoader m_keyvalue; + private int m_iIndex; + private boolean m_bIsAdjusting; + + private boolean iseditable = true; + + /** + * Creates a new instance of BrowsableEditableData + * @param bd + * @param ed + * @param dirty + */ + public BrowsableEditableData(BrowsableData bd, EditorRecord ed, DirtyManager dirty) { + m_bd = bd; + + m_editorrecord = ed; + m_Dirty = dirty; + m_iState = ST_NORECORD; + m_iIndex = INX_EOF; // En EOF + m_bIsAdjusting = false; +// m_keyvalue = DocumentLoaderBasic.INSTANCE; + + // Inicializo ? + m_editorrecord.writeValueEOF(); + m_Dirty.setDirty(false); + } + + /** + * Check Ticket Dirty state + * @param dataprov + * @param saveprov + * @param c + * @param ed + * @param dirty + */ + public BrowsableEditableData(ListProvider dataprov, SaveProvider saveprov, Comparator c, EditorRecord ed, DirtyManager dirty) { + this(new BrowsableData(dataprov, saveprov, c), ed, dirty); + } + + /** + * Ticket Dirty state + * @param dataprov + * @param saveprov + * @param ed + * @param dirty + */ + public BrowsableEditableData(ListProvider dataprov, SaveProvider saveprov, EditorRecord ed, DirtyManager dirty) { + this(new BrowsableData(dataprov, saveprov, null), ed, dirty); + } + + /** + * Ticket data for list + * @return + */ + public final ListModel getListModel() { + return m_bd; + } + + /** + * Value Changes + * @return + */ + public final boolean isAdjusting() { + return m_bIsAdjusting || m_bd.isAdjusting(); + } + + private Object getCurrentElement() { + return (m_iIndex >= 0 && m_iIndex < m_bd.getSize()) ? m_bd.getElementAt(m_iIndex) : null; + } + + /** + * Return index + * @return + */ + public final int getIndex() { + return m_iIndex; + } + + /** + * Add to State listener + * @param l + */ + public final void addStateListener(StateListener l) { + listeners.add(StateListener.class, l); + } + + /** + * Delete from State listener + * @param l + */ + public final void removeStateListener(StateListener l) { + listeners.remove(StateListener.class, l); + } + + /** + * Edit State listener + * @param l + */ + public final void addEditorListener(EditorListener l) { + listeners.add(EditorListener.class, l); + } + + /** + * Delete from State listener + * @param l + */ + public final void removeEditorListener(EditorListener l) { + listeners.remove(EditorListener.class, l); + } + + /** + * Add to browse listener + * @param l + */ + public final void addBrowseListener(BrowseListener l) { + listeners.add(BrowseListener.class, l); + } + + /** + * Delete from browse listener + * @param l + */ + public final void removeBrowseListener(BrowseListener l) { + listeners.remove(BrowseListener.class, l); + } + + /** + * Return State + * @return + */ + public int getState() { + return m_iState; + } + + private void fireStateUpdate() { + EventListener[] l = listeners.getListeners(StateListener.class); + int iState = getState(); + for (int i = 0; i < l.length; i++) { + ((StateListener) l[i]).updateState(iState); + } + } + + /** + * Execute listener event fire + */ + protected void fireDataBrowse() { + + m_bIsAdjusting = true; + // Lanzamos los eventos... + Object obj = getCurrentElement(); + int iIndex = getIndex(); + int iCount = m_bd.getSize(); + + // actualizo el registro + if (obj == null) { + m_iState = ST_NORECORD; + m_editorrecord.writeValueEOF(); + } else { + m_iState = ST_UPDATE; + m_editorrecord.writeValueEdit(obj); + } + m_Dirty.setDirty(false); + fireStateUpdate(); + + // Invoco a los Editor Listener + EventListener[] l = listeners.getListeners(EditorListener.class); + for (int i = 0; i < l.length; i++) { + ((EditorListener) l[i]).updateValue(obj); + } + // Y luego a los Browse Listener + l = listeners.getListeners(BrowseListener.class); + for (int i = 0; i < l.length; i++) { + ((BrowseListener) l[i]).updateIndex(iIndex, iCount); + } + m_bIsAdjusting = false; + } + + /** + * Data available + * @return + */ + public boolean canLoadData() { + return m_bd.canLoadData(); + } + + /** + * Flag data editable + * @param value + */ + public void setEditable(boolean value) { + iseditable = value; + } + + /** + * Flag data can insert + * @return + */ + public boolean canInsertData() { + return iseditable && m_bd.canInsertData(); + } + + /** + * Flag data can delete + * @return + */ + public boolean canDeleteData() { + return iseditable && m_bd.canDeleteData(); + } + + /** + * Flag can update + * @return + */ + public boolean canUpdateData() { + return iseditable && m_bd.canUpdateData(); + } + + /** + * Refresh current state + */ + public void refreshCurrent() { + baseMoveTo(m_iIndex); + } + + /** + * Refresh object data + * @throws BasicException + */ + public void refreshData() throws BasicException { + saveData(); + m_bd.refreshData(); + m_editorrecord.refresh(); + baseMoveTo(0); + } + + /** + * Load object data + * @throws BasicException + */ + public void loadData() throws BasicException { + saveData(); + m_bd.loadData(); + m_editorrecord.refresh(); + baseMoveTo(0); + } + + /** + * Unload object data + * @throws BasicException + */ + public void unloadData() throws BasicException { + saveData(); + m_bd.unloadData(); + m_editorrecord.refresh(); + baseMoveTo(0); + } + + /** + * Sort object data + * @param c + * @throws BasicException + */ + public void sort(Comparator c) throws BasicException { + saveData(); + m_bd.sort(c); + baseMoveTo(0); + } + + /** + * Move data to object + * @param i + * @throws BasicException + */ + public void moveTo(int i) throws BasicException { + saveData(); + if (m_iIndex != i) { + baseMoveTo(i); + } + } + + /** + * Step into data -1 (Back) + * @throws BasicException + */ + public final void movePrev() throws BasicException { + saveData(); + if (m_iIndex > 0) { + baseMoveTo(m_iIndex - 1); + } + } + + /** + * Step into data +1 (Forward) + * @throws BasicException + */ + public final void moveNext() throws BasicException { + saveData(); + if (m_iIndex < m_bd.getSize() - 1) { + baseMoveTo(m_iIndex + 1); + } + } + + /** + * Step into data BOF (First) + * @throws BasicException + */ + public final void moveFirst() throws BasicException { + saveData(); + if (m_bd.getSize() > 0) { + baseMoveTo(0); + } + } + + /** + * Step into data EOF (End) + * @throws BasicException + */ + public final void moveLast() throws BasicException { + saveData(); + if (m_bd.getSize() > 0) { + baseMoveTo(m_bd.getSize() - 1); + } + } + + /** + * Step into data =value (Next) + * @param f + * @return + * @throws BasicException + */ + public final int findNext(Finder f) throws BasicException { + return m_bd.findNext(m_iIndex, f); + } + + /** + * Save data + * @throws BasicException + */ + public void saveData() throws BasicException { + + //Get the customer being referenced for firing action events + boolean isCustomerChangeEvent = false; + Object[] customer = new Object[27]; + if (m_editorrecord.getClass().getName().equals("com.unicenta.pos.customers.CustomersView")) { + isCustomerChangeEvent = true; + customer = (Object[]) m_editorrecord.createValue(); + } + + if (m_Dirty.isDirty()) { + if (m_iState == ST_UPDATE) { + int i = m_bd.updateRecord(m_iIndex, m_editorrecord.createValue()); + m_editorrecord.refresh(); + baseMoveTo(i); + + if (isCustomerChangeEvent) { + triggerCustomerEvent("customer.updated", customer, customer[27]); + } + + + } else if (m_iState == ST_INSERT) { + + if (isCustomerChangeEvent) { + m_editorrecord.refresh(); + + AppView appView = (AppView) customer[27]; + int i = m_bd.insertRecord(customer); + m_editorrecord.refresh(); + baseMoveTo(i); + + triggerCustomerEvent("customer.created", customer, customer[27]); + + int n = JOptionPane.showConfirmDialog( + null, + AppLocal.getIntString("message.customerassign"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION); + + if (n == 0) { + CustomerInfoGlobal customerInfoGlobal = CustomerInfoGlobal.getInstance(); + CustomerInfoExt customerInfoExt = new CustomerInfoExt(customer[0].toString()); + customerInfoGlobal.setCustomerInfoExt(customerInfoExt); + customerInfoExt.setName(customer[3].toString()); + + appView.getAppUserView().showTask("com.unicenta.pos.sales.JPanelTicketSales"); + } + + } else { + int i = m_bd.insertRecord(m_editorrecord.createValue()); + m_editorrecord.refresh(); + baseMoveTo(i); + } + + } else if (m_iState == ST_DELETE) { + int i = m_bd.removeRecord(m_iIndex); + m_editorrecord.refresh(); + baseMoveTo(i); + + if (isCustomerChangeEvent) { + triggerCustomerEvent("customer.deleted", customer, customer[27]); + } + } + } + } + + private void triggerCustomerEvent(String event, Object[] customer, Object appContext) { + try { + AppView appView = (AppView) appContext; + ScriptEngine scriptEngine = ScriptFactory.getScriptEngine(ScriptFactory.BEANSHELL); + + DataLogicSystem dlSystem = (DataLogicSystem) appView.getBean("com.unicenta.pos.forms.DataLogicSystem"); + String script = dlSystem.getResourceAsXML(event); + scriptEngine.put("customer", customer); + scriptEngine.put("device", appView.getProperties().getProperty("machine.hostname")); + scriptEngine.eval(script); + + } + catch (Exception e) { + System.err.println("Script Exception: "+e); + } + } + + /** + * Reinstantiate data + * @param c + */ + public void actionReloadCurrent(Component c) { + if (!m_Dirty.isDirty() || + JOptionPane.showConfirmDialog(c, + LocalRes.getIntString("message.changeslost"), + LocalRes.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { + refreshCurrent(); + } + } + + /** + * Evaluate data before before commit + * @param c + * @return + * @throws BasicException + */ + public boolean actionClosingForm(Component c) throws BasicException { + if (m_Dirty.isDirty()) { + int res = JOptionPane.showConfirmDialog(c, LocalRes.getIntString("message.wannasave"), LocalRes.getIntString("title.editor"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + if (res == JOptionPane.YES_OPTION) { + saveData(); + return true; + } else if (res == JOptionPane.NO_OPTION) { + refreshCurrent(); + return true; + } else { + return false; + } + } else { + return true; + } + } + + /* + * Metodos publicos finales (algunos protegidos que podrian ser finales + */ + + /** + * Instantiate data + * @throws BasicException + */ + + public final void actionLoad() throws BasicException { + loadData(); + if (m_bd.getSize() == 0) { + actionInsert(); + } + } + + /** + * Insert data - conditional + * @throws BasicException + */ + public final void actionInsert() throws BasicException { + // primero persistimos + saveData(); + + if (canInsertData()) { + // Y nos ponemos en estado de insert + m_iState = ST_INSERT; + m_editorrecord.writeValueInsert(); + m_Dirty.setDirty(false); + fireStateUpdate(); // ? + } + } + + /** + * Delete data + * @throws BasicException + */ + public final void actionDelete() throws BasicException { + // primero persistimos + saveData(); + + if (canDeleteData()) { + + // Y nos ponemos en estado de delete + Object obj = getCurrentElement(); + int iIndex = getIndex(); + int iCount = m_bd.getSize(); + if (iIndex >= 0 && iIndex < iCount) { + m_iState = ST_DELETE; + m_editorrecord.writeValueDelete(obj); + m_Dirty.setDirty(true); + fireStateUpdate(); // ? + } + } + } + + private final void baseMoveTo(int i) { + // Este senor y el constructor a INX_EOF, son los unicos que tienen potestad de modificar m_iIndex. + if (i >= 0 && i < m_bd.getSize()) { + m_iIndex = i; + } else { + m_iIndex = INX_EOF; + } + fireDataBrowse(); + } +} diff --git a/src/main/java/com/unicenta/data/user/BrowseListener.java b/src/main/java/com/unicenta/data/user/BrowseListener.java new file mode 100644 index 0000000..877f8d1 --- /dev/null +++ b/src/main/java/com/unicenta/data/user/BrowseListener.java @@ -0,0 +1,34 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +/** + * + * @author JG uniCenta + */ +public interface BrowseListener extends java.util.EventListener { + + /** + * + * @param iIndex + * @param iCounter + */ + public void updateIndex(int iIndex, int iCounter); +} diff --git a/src/main/java/com/unicenta/data/user/DirtyListener.java b/src/main/java/com/unicenta/data/user/DirtyListener.java new file mode 100644 index 0000000..dd5ab4a --- /dev/null +++ b/src/main/java/com/unicenta/data/user/DirtyListener.java @@ -0,0 +1,33 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +/** + * + * @author adrian + */ +public interface DirtyListener { + + /** + * + * @param bDirty + */ + public void changedDirty(boolean bDirty); +} diff --git a/src/main/java/com/unicenta/data/user/DirtyManager.java b/src/main/java/com/unicenta/data/user/DirtyManager.java new file mode 100644 index 0000000..1f0cb8a --- /dev/null +++ b/src/main/java/com/unicenta/data/user/DirtyManager.java @@ -0,0 +1,123 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +import java.awt.event.*; +import javax.swing.event.*; +import java.util.*; +import java.beans.*; + +/** + * + * @author adrian + */ +public class DirtyManager implements DocumentListener, ChangeListener, ActionListener, PropertyChangeListener { + + private boolean m_bDirty; + + /** + * + */ + protected Vector listeners = new Vector(); + + /** Creates a new instance of DirtyManager */ + public DirtyManager() { + m_bDirty = false; + } + + /** + * + * @param l + */ + public void addDirtyListener(DirtyListener l) { + listeners.add(l); + } + + /** + * + * @param l + */ + public void removeDirtyListener(DirtyListener l) { + listeners.remove(l); + } + + /** + * + */ + protected void fireChangedDirty() { + + Enumeration e = listeners.elements(); + while (e.hasMoreElements()) { + DirtyListener l = (DirtyListener) e.nextElement(); + l.changedDirty(m_bDirty); + } + } + + /** + * + * @param bValue + */ + public void setDirty(boolean bValue) { + + if (m_bDirty != bValue) { + m_bDirty = bValue; + fireChangedDirty(); + } + } + + /** + * + * @return + */ + public boolean isDirty() { + return m_bDirty; + } + + @Override + public void changedUpdate(DocumentEvent e) { + setDirty(true); + } + @Override + public void insertUpdate(DocumentEvent e) { + setDirty(true); + } + @Override + public void removeUpdate(DocumentEvent e) { + setDirty(true); + } + + @Override + public void stateChanged(ChangeEvent e) { + setDirty(true); + } + + @Override + public void actionPerformed(ActionEvent e) { + setDirty(true); + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + //if ("image".equals(evt.getPropertyName())) { + setDirty(true); + //} + } + +} diff --git a/src/main/java/com/unicenta/data/user/DocumentLoader.java b/src/main/java/com/unicenta/data/user/DocumentLoader.java new file mode 100644 index 0000000..d1d8969 --- /dev/null +++ b/src/main/java/com/unicenta/data/user/DocumentLoader.java @@ -0,0 +1,43 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +/** + * + * @author adrianromero + * Created on 22 de marzo de 2007, 0:00 + * + */ +public interface DocumentLoader { + + /** + * + * @param key + * @return + */ + public Object getValue(Object key); + + /** + * + * @param value + * @return + */ + public Object getKey(Object value); +} diff --git a/src/main/java/com/unicenta/data/user/DocumentLoaderBasic.java b/src/main/java/com/unicenta/data/user/DocumentLoaderBasic.java new file mode 100644 index 0000000..b0371b3 --- /dev/null +++ b/src/main/java/com/unicenta/data/user/DocumentLoaderBasic.java @@ -0,0 +1,56 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +/** + * + * @author adrianromero + * Created on 22 de marzo de 2007, 0:01 + * + */ +public class DocumentLoaderBasic implements DocumentLoader { + + /** + * + */ + public static final DocumentLoader INSTANCE = new DocumentLoaderBasic(); + + /** Creates a new instance of DocumentLoaderBasic */ + private DocumentLoaderBasic() { + } + + /** + * + * @param key + * @return + */ + public Object getValue(Object key) { + return key; + } + + /** + * + * @param value + * @return + */ + public Object getKey(Object value) { + return value; + } +} diff --git a/src/main/java/com/unicenta/data/user/EditorCreator.java b/src/main/java/com/unicenta/data/user/EditorCreator.java new file mode 100644 index 0000000..f88f5d2 --- /dev/null +++ b/src/main/java/com/unicenta/data/user/EditorCreator.java @@ -0,0 +1,36 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public interface EditorCreator { + + /** + * + * @return + * @throws BasicException + */ + public Object createValue() throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/user/EditorCreatorComposed.java b/src/main/java/com/unicenta/data/user/EditorCreatorComposed.java new file mode 100644 index 0000000..6288fbc --- /dev/null +++ b/src/main/java/com/unicenta/data/user/EditorCreatorComposed.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class EditorCreatorComposed implements EditorCreator{ + + private EditorCreator[] m_editors; + + /** Creates a new instance of EditorCreatorComposed + * @param editors */ + public EditorCreatorComposed(EditorCreator... editors) { + m_editors = editors; + } + + /** + * + * @return + * @throws BasicException + */ + public Object createValue() throws BasicException { + + Object[] value = new Object[m_editors.length]; + for (int i = 0; i < m_editors.length; i++) { + value[i] = m_editors[i].createValue(); + } + + return value; + } +} diff --git a/src/main/java/com/unicenta/data/user/EditorListener.java b/src/main/java/com/unicenta/data/user/EditorListener.java new file mode 100644 index 0000000..476bfda --- /dev/null +++ b/src/main/java/com/unicenta/data/user/EditorListener.java @@ -0,0 +1,33 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +/** + * + * @author JG uniCenta + */ +public interface EditorListener extends java.util.EventListener { + + /** + * + * @param value + */ + public void updateValue(Object value); +} diff --git a/src/main/java/com/unicenta/data/user/EditorRecord.java b/src/main/java/com/unicenta/data/user/EditorRecord.java new file mode 100644 index 0000000..357455a --- /dev/null +++ b/src/main/java/com/unicenta/data/user/EditorRecord.java @@ -0,0 +1,62 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +import java.awt.Component; + +/** + * + * @author JG uniCenta + */ +public interface EditorRecord extends EditorCreator { + + /** + * + */ + public void writeValueEOF(); + + /** + * + */ + public void writeValueInsert(); + + /** + * + * @param value + */ + public void writeValueEdit(Object value); // not null por definicion. + + /** + * + * @param value + */ + public void writeValueDelete(Object value); // not null por definicion. + + /** + * + */ + public void refresh(); + + /** + * + * @return + */ + public Component getComponent(); +} diff --git a/src/main/java/com/unicenta/data/user/FilterEditorCreator.java b/src/main/java/com/unicenta/data/user/FilterEditorCreator.java new file mode 100644 index 0000000..297576a --- /dev/null +++ b/src/main/java/com/unicenta/data/user/FilterEditorCreator.java @@ -0,0 +1,35 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +import com.unicenta.data.loader.SerializerWrite; + +/** + * + * @author adrian + */ +public interface FilterEditorCreator extends EditorCreator { + + /** + * + * @return + */ + public SerializerWrite getSerializerWrite(); +} diff --git a/src/main/java/com/unicenta/data/user/Finder.java b/src/main/java/com/unicenta/data/user/Finder.java new file mode 100644 index 0000000..db62ae4 --- /dev/null +++ b/src/main/java/com/unicenta/data/user/Finder.java @@ -0,0 +1,37 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public interface Finder { + + /** + * + * @param obj + * @return + * @throws BasicException + */ + public boolean match(Object obj) throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/user/ListProvider.java b/src/main/java/com/unicenta/data/user/ListProvider.java new file mode 100644 index 0000000..5176a72 --- /dev/null +++ b/src/main/java/com/unicenta/data/user/ListProvider.java @@ -0,0 +1,44 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +import com.unicenta.basic.BasicException; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public interface ListProvider { + + /** + * + * @return + * @throws BasicException + */ + public List loadData() throws BasicException; + + /** + * + * @return + * @throws BasicException + */ + public List refreshData() throws BasicException; +} diff --git a/src/main/java/com/unicenta/data/user/ListProviderCreator.java b/src/main/java/com/unicenta/data/user/ListProviderCreator.java new file mode 100644 index 0000000..f2f6e5d --- /dev/null +++ b/src/main/java/com/unicenta/data/user/ListProviderCreator.java @@ -0,0 +1,82 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.TableDefinition; +import java.util.*; + +/** + * + * @author JG uniCenta + */ +public class ListProviderCreator implements ListProvider { + + private SentenceList sent; + private EditorCreator prov; + private Object params; + + /** Creates a new instance of ListProviderEditor + * @param sent + * @param prov */ + public ListProviderCreator(SentenceList sent, EditorCreator prov) { + this.sent = sent; + this.prov = prov; + params = null; + } + + /** + * + * @param sent + */ + public ListProviderCreator(SentenceList sent) { + this(sent, null); + } + + /** + * + * @param table + */ + public ListProviderCreator(TableDefinition table) { + this(table.getListSentence(), null); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public List loadData() throws BasicException { + params = (prov == null) ? null : prov.createValue(); + return refreshData(); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public List refreshData() throws BasicException { + return sent.list(params); + } +} diff --git a/src/main/java/com/unicenta/data/user/SaveProvider.java b/src/main/java/com/unicenta/data/user/SaveProvider.java new file mode 100644 index 0000000..d40b3ed --- /dev/null +++ b/src/main/java/com/unicenta/data/user/SaveProvider.java @@ -0,0 +1,130 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.data.user; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.SentenceExec; + +/** + * + * @author JG uniCenta + */ +public class SaveProvider { + + /** + * + */ + protected SentenceExec m_sentupdate; + + /** + * + */ + protected SentenceExec m_sentinsert; + + /** + * + */ + protected SentenceExec m_sentdelete; + + /** Creates a new instance of SavePrSentence + * @param sentupdate + * @param sentdelete + * @param sentinsert */ + public SaveProvider(SentenceExec sentupdate, SentenceExec sentinsert, SentenceExec sentdelete) { + m_sentupdate = sentupdate; + m_sentinsert = sentinsert; + m_sentdelete = sentdelete; + } + + /** + * + * @param table + */ + public SaveProvider(TableDefinition table) { + m_sentupdate = table.getUpdateSentence(); + m_sentdelete = table.getDeleteSentence(); + m_sentinsert = table.getInsertSentence(); + } + + /** + * + * @param table + * @param fields + */ + public SaveProvider(TableDefinition table, int[] fields) { + m_sentupdate = table.getUpdateSentence(fields); + m_sentdelete = table.getDeleteSentence(); + m_sentinsert = table.getInsertSentence(fields); + } + + /** + * + * @return + */ + public boolean canDelete() { + return m_sentdelete != null; + } + + /** + * + * @param value + * @return + * @throws BasicException + */ + public int deleteData(Object value) throws BasicException { + return m_sentdelete.exec(value); + } + + /** + * + * @return + */ + public boolean canInsert() { + return m_sentinsert != null; + } + + /** + * + * @param value + * @return + * @throws BasicException + */ + public int insertData(Object value) throws BasicException { + return m_sentinsert.exec(value); + } + + /** + * + * @return + */ + public boolean canUpdate() { + return m_sentupdate != null; + } + + /** + * + * @param value + * @return + * @throws BasicException + */ + public int updateData(Object value) throws BasicException { + return m_sentupdate.exec(value); + } +} diff --git a/src/main/java/com/unicenta/data/user/StateListener.java b/src/main/java/com/unicenta/data/user/StateListener.java new file mode 100644 index 0000000..23177a3 --- /dev/null +++ b/src/main/java/com/unicenta/data/user/StateListener.java @@ -0,0 +1,34 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + + +package com.unicenta.data.user; + +/** + * + * @author adrian + */ +public interface StateListener extends java.util.EventListener { + + /** + * + * @param iState + */ + public void updateState(int iState); +} diff --git a/src/main/java/com/unicenta/editor/EditorComponent.java b/src/main/java/com/unicenta/editor/EditorComponent.java new file mode 100644 index 0000000..063b48d --- /dev/null +++ b/src/main/java/com/unicenta/editor/EditorComponent.java @@ -0,0 +1,58 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.editor; + +import java.awt.Component; + +/** + * + * @author JG uniCenta + */ +public interface EditorComponent { + + /** + * + * @param ed + */ + public void addEditorKeys(EditorKeys ed); + + /** + * + * @return + */ + public Component getComponent(); + + /** + * + */ + public void deactivate(); + + /** + * + * @param c + */ + public void typeChar(char c); + + /** + * + * @param c + */ + public void transChar(char c); +} diff --git a/src/main/java/com/unicenta/editor/EditorKeys.java b/src/main/java/com/unicenta/editor/EditorKeys.java new file mode 100644 index 0000000..ce616d2 --- /dev/null +++ b/src/main/java/com/unicenta/editor/EditorKeys.java @@ -0,0 +1,65 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.editor; + +/** + * + * @author JG uniCenta + */ +public interface EditorKeys { + + /** + * + */ + public final static int MODE_STRING = 0; + + /** + * + */ + public final static int MODE_DOUBLE = 1; + + /** + * + */ + public final static int MODE_DOUBLE_POSITIVE = 2; + + /** + * + */ + public final static int MODE_INTEGER = 3; + + /** + * + */ + public final static int MODE_INTEGER_POSITIVE = 4; + + /** + * + * @param e + * @param imode + */ + public void setActive(EditorComponent e, int imode); + + /** + * + * @param e + */ + public void setInactive(EditorComponent e); +} diff --git a/src/main/java/com/unicenta/editor/JEditorAbstract.form b/src/main/java/com/unicenta/editor/JEditorAbstract.form new file mode 100644 index 0000000..77c0558 --- /dev/null +++ b/src/main/java/com/unicenta/editor/JEditorAbstract.form @@ -0,0 +1,81 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/editor/JEditorAbstract.java b/src/main/java/com/unicenta/editor/JEditorAbstract.java new file mode 100644 index 0000000..584b4ef --- /dev/null +++ b/src/main/java/com/unicenta/editor/JEditorAbstract.java @@ -0,0 +1,245 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.editor; + +import com.unicenta.basic.BasicException; +import java.awt.Color; +import java.awt.Component; +import javax.swing.border.Border; + +/** + * + * @author JG uniCenta + */ +public abstract class JEditorAbstract extends javax.swing.JPanel implements EditorComponent { + + private EditorKeys editorkeys; + + private boolean m_bActive; + private final Border m_borderactive = new javax.swing.border.CompoundBorder(new javax.swing.border.LineBorder(javax.swing.UIManager.getDefaults().getColor("TextField.selectionBackground")), new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 4, 1, 4))); + private final Border m_borderinactive = new javax.swing.border.CompoundBorder(new javax.swing.border.LineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), new javax.swing.border.EmptyBorder(new java.awt.Insets(1, 4, 1, 4))); + + /** Creates new form JPanelNumber */ + public JEditorAbstract() { + + initComponents(); + + editorkeys = null; + m_bActive = false; + m_jText.setBorder(m_borderinactive); + } + + /** + * + * @return + */ + protected abstract int getMode(); + + /** + * + * @return + */ + protected abstract int getAlignment(); + + /** + * + * @return + */ + protected abstract String getEditMode(); + + /** + * + * @return + */ + protected abstract String getTextEdit(); + + /** + * + * @return + * @throws BasicException + */ + protected abstract String getTextFormat() throws BasicException; + + /** + * + * @param c + */ + protected abstract void typeCharInternal(char c); + + /** + * + * @param c + */ + protected abstract void transCharInternal(char c); + + /** + * + * @param c + */ + @Override + public void typeChar(char c) { + typeCharInternal(c); + reprintText(); + firePropertyChange("Edition", null, null); + } + + /** + * + * @param c + */ + @Override + public void transChar(char c) { + transCharInternal(c); + reprintText(); + firePropertyChange("Edition", null, null); + } + + /** + * + * @param ed + */ + @Override + public void addEditorKeys(EditorKeys ed) { + editorkeys = ed; + } + + /** + * + */ + @Override + public void deactivate() { + setActive(false); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + */ + public void activate() { + if (isEnabled()) { + editorkeys.setActive(this, getMode()); + setActive(true); + } + } + + private void setActive(boolean bValue) { + m_bActive = bValue; + m_jText.setBorder(m_bActive ? m_borderactive : m_borderinactive); + reprintText(); + } + + /** + * + */ + protected void reprintText() { + + m_jText.setHorizontalAlignment(getAlignment()); + if (m_bActive) { + m_jMode.setText(getEditMode()); + m_jText.setText(getTextEdit()); + m_jText.setForeground(javax.swing.UIManager.getDefaults().getColor("label.foreground")); + } else { + m_jMode.setText(null); + try { + m_jText.setText(getTextFormat()); + m_jText.setForeground(javax.swing.UIManager.getDefaults().getColor("label.foreground")); + } catch (BasicException e) { + m_jText.setText(getTextEdit()); + m_jText.setForeground(Color.RED); + } + } + } + + @Override + public void setEnabled(boolean b) { + + if (editorkeys != null) { + editorkeys.setInactive(this); + } + panBackground.setBackground(b + ? javax.swing.UIManager.getDefaults().getColor("TextField.background") + : javax.swing.UIManager.getDefaults().getColor("TextField.disabledBackground")); + super.setEnabled(b); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + panBackground = new javax.swing.JPanel(); + m_jText = new javax.swing.JButton(); + m_jMode = new javax.swing.JLabel(); + + setLayout(new java.awt.BorderLayout()); + + panBackground.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.background")); + panBackground.setLayout(new java.awt.BorderLayout()); + + m_jText.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.background")); + m_jText.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jText.setContentAreaFilled(false); + m_jText.setFocusPainted(false); + m_jText.setFocusable(false); + m_jText.setMinimumSize(new java.awt.Dimension(100, 25)); + m_jText.setPreferredSize(new java.awt.Dimension(100, 25)); + m_jText.setRequestFocusEnabled(false); + m_jText.setVerticalAlignment(javax.swing.SwingConstants.TOP); + m_jText.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jTextActionPerformed(evt); + } + }); + panBackground.add(m_jText, java.awt.BorderLayout.CENTER); + + add(panBackground, java.awt.BorderLayout.CENTER); + + m_jMode.setFont(new java.awt.Font("Dialog", 0, 9)); // NOI18N + m_jMode.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jMode.setVerticalAlignment(javax.swing.SwingConstants.TOP); + m_jMode.setPreferredSize(new java.awt.Dimension(32, 0)); + add(m_jMode, java.awt.BorderLayout.LINE_END); + }// //GEN-END:initComponents + + private void m_jTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jTextActionPerformed + + activate(); + + }//GEN-LAST:event_m_jTextActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel m_jMode; + private javax.swing.JButton m_jText; + private javax.swing.JPanel panBackground; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/editor/JEditorCurrency.java b/src/main/java/com/unicenta/editor/JEditorCurrency.java new file mode 100644 index 0000000..f6d30aa --- /dev/null +++ b/src/main/java/com/unicenta/editor/JEditorCurrency.java @@ -0,0 +1,51 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.editor; + +import com.unicenta.format.Formats; + +/** + * + * @author JG uniCenta + */ +public class JEditorCurrency extends JEditorNumber { + + private static final long serialVersionUID = 5096754100573262803L; + + /** Creates a new instance of JEditorCurrency */ + public JEditorCurrency() { + } + + /** + * + * @return + */ + protected Formats getFormat() { + return Formats.CURRENCY; + } + + /** + * + * @return + */ + protected int getMode() { + return EditorKeys.MODE_DOUBLE; + } +} diff --git a/src/main/java/com/unicenta/editor/JEditorCurrencyPositive.java b/src/main/java/com/unicenta/editor/JEditorCurrencyPositive.java new file mode 100644 index 0000000..7374490 --- /dev/null +++ b/src/main/java/com/unicenta/editor/JEditorCurrencyPositive.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.editor; + +import com.unicenta.format.Formats; + +/** + * + * @author JG uniCenta + */ +public class JEditorCurrencyPositive extends JEditorNumber { + + /** Creates a new instance of JEditorCurrencyPositive */ + public JEditorCurrencyPositive() { + } + + /** + * + * @return + */ + @Override + protected Formats getFormat() { + return Formats.CURRENCY; + + } + + /** + * + * @return + */ + @Override + protected int getMode() { + return EditorKeys.MODE_DOUBLE_POSITIVE; + } +} diff --git a/src/main/java/com/unicenta/editor/JEditorDouble.java b/src/main/java/com/unicenta/editor/JEditorDouble.java new file mode 100644 index 0000000..2322072 --- /dev/null +++ b/src/main/java/com/unicenta/editor/JEditorDouble.java @@ -0,0 +1,49 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.editor; + +import com.unicenta.format.Formats; + +/** + * + * @author JG uniCenta + */ +public class JEditorDouble extends JEditorNumber { + + /** Creates a new instance of JEditorDouble */ + public JEditorDouble() { + } + + /** + * + * @return + */ + protected Formats getFormat() { + return Formats.DOUBLE; + } + + /** + * + * @return + */ + protected int getMode() { + return EditorKeys.MODE_DOUBLE; + } +} diff --git a/src/main/java/com/unicenta/editor/JEditorDoublePositive.java b/src/main/java/com/unicenta/editor/JEditorDoublePositive.java new file mode 100644 index 0000000..48ad4b9 --- /dev/null +++ b/src/main/java/com/unicenta/editor/JEditorDoublePositive.java @@ -0,0 +1,49 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.editor; + +import com.unicenta.format.Formats; + +/** + * + * @author JG uniCenta + */ +public class JEditorDoublePositive extends JEditorNumber { + + /** Creates a new instance of JEditorDoublePositive */ + public JEditorDoublePositive() { + } + + /** + * + * @return + */ + protected Formats getFormat() { + return Formats.DOUBLE; + } + + /** + * + * @return + */ + protected int getMode() { + return EditorKeys.MODE_DOUBLE_POSITIVE; + } +} diff --git a/src/main/java/com/unicenta/editor/JEditorIntegerPositive.java b/src/main/java/com/unicenta/editor/JEditorIntegerPositive.java new file mode 100644 index 0000000..f67358d --- /dev/null +++ b/src/main/java/com/unicenta/editor/JEditorIntegerPositive.java @@ -0,0 +1,49 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.editor; + +import com.unicenta.format.Formats; + +/** + * + * @author JG uniCenta + */ +public class JEditorIntegerPositive extends JEditorNumber { + + /** Creates a new instance of JEditorIntegerPositive */ + public JEditorIntegerPositive() { + } + + /** + * + * @return + */ + protected Formats getFormat() { + return Formats.INT; + } + + /** + * + * @return + */ + protected int getMode() { + return EditorKeys.MODE_INTEGER_POSITIVE; + } +} diff --git a/src/main/java/com/unicenta/editor/JEditorKeys.form b/src/main/java/com/unicenta/editor/JEditorKeys.form new file mode 100644 index 0000000..758cdb5 --- /dev/null +++ b/src/main/java/com/unicenta/editor/JEditorKeys.form @@ -0,0 +1,279 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/editor/JEditorKeys.java b/src/main/java/com/unicenta/editor/JEditorKeys.java new file mode 100644 index 0000000..1710839 --- /dev/null +++ b/src/main/java/com/unicenta/editor/JEditorKeys.java @@ -0,0 +1,516 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.editor; + +import com.unicenta.pos.customers.JCustomerFinder; +import java.awt.ComponentOrientation; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.util.EventListener; +import javax.swing.event.EventListenerList; + +/** + * + * @author JG uniCenta + */ +public class JEditorKeys extends javax.swing.JPanel implements EditorKeys { + + private final static char[] SET_DOUBLE = {'\u007f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '-'}; + private final static char[] SET_DOUBLE_POSITIVE = {'\u007f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.'}; + private final static char[] SET_INTEGER = {'\u007f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-'}; + private final static char[] SET_INTEGER_POSITIVE = {'\u007f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; + + /** + * + */ + protected EventListenerList listeners = new EventListenerList(); + + private EditorComponent editorcurrent ; + + private char[] keysavailable; + private boolean m_bMinus; + private boolean m_bKeyDot; + private JCustomerFinder customerFinder; + + /* + HS KeyShortcuts + */ + + /** + * + * @return + */ + + public JCustomerFinder getCustomerFinder() { + return customerFinder; + } + + /** + * + * @param customerFinder + */ + public void setCustomerFinder(JCustomerFinder customerFinder) { + this.customerFinder = customerFinder; + } + + + /** Creates new form JEditorKeys */ + public JEditorKeys() { + initComponents(); + + m_jKey0.addActionListener(new MyKeyNumberListener('0')); + m_jKey1.addActionListener(new MyKeyNumberListener('1')); + m_jKey2.addActionListener(new MyKeyNumberListener('2')); + m_jKey3.addActionListener(new MyKeyNumberListener('3')); + m_jKey4.addActionListener(new MyKeyNumberListener('4')); + m_jKey5.addActionListener(new MyKeyNumberListener('5')); + m_jKey6.addActionListener(new MyKeyNumberListener('6')); + m_jKey7.addActionListener(new MyKeyNumberListener('7')); + m_jKey8.addActionListener(new MyKeyNumberListener('8')); + m_jKey9.addActionListener(new MyKeyNumberListener('9')); + m_jKeyDot.addActionListener(new MyKeyNumberListener('.')); + m_jCE.addActionListener(new MyKeyNumberListener('\u007f')); + m_jMinus.addActionListener(new MyKeyNumberListener('-')); + + editorcurrent = null; + setMode(MODE_STRING); + doEnabled(false); + } + + @Override + public void setComponentOrientation(ComponentOrientation o) { + // Nothing to change + } + + /** + * + * @param l + */ + public void addActionListener(ActionListener l) { + listeners.add(ActionListener.class, l); + } + + /** + * + * @param l + */ + public void removeActionListener(ActionListener l) { + listeners.remove(ActionListener.class, l); + } + + /** + * + */ + protected void fireActionPerformed() { + EventListener[] l = listeners.getListeners(ActionListener.class); + ActionEvent e = null; + for (int i = 0; i < l.length; i++) { + if (e == null) { + e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null); + } + ((ActionListener) l[i]).actionPerformed(e); + } + } + + private void doEnabled(boolean b) { + m_jKey0.setEnabled(b); + m_jKey1.setEnabled(b); + m_jKey2.setEnabled(b); + m_jKey3.setEnabled(b); + m_jKey4.setEnabled(b); + m_jKey5.setEnabled(b); + m_jKey6.setEnabled(b); + m_jKey7.setEnabled(b); + m_jKey8.setEnabled(b); + m_jKey9.setEnabled(b); + m_jKeyDot.setEnabled(b && m_bKeyDot); + m_jCE.setEnabled(b); + m_jMinus.setEnabled(b && m_bMinus); + } + + /** + * + * @param iMode + */ + public void setMode(int iMode) { + switch (iMode) { + case MODE_DOUBLE: + m_bMinus = true; + m_bKeyDot = true; + keysavailable = SET_DOUBLE; + break; + case MODE_DOUBLE_POSITIVE: + m_bMinus = false; + m_bKeyDot = true; + keysavailable = SET_DOUBLE_POSITIVE; + break; + case MODE_INTEGER: + m_bMinus = true; + m_bKeyDot = false; + keysavailable = SET_INTEGER; + break; + case MODE_INTEGER_POSITIVE: + m_bMinus = false; + m_bKeyDot = false; + keysavailable = SET_INTEGER_POSITIVE; + break; + case MODE_STRING: + default: + m_bMinus = true; + m_bKeyDot = true; + keysavailable = null; + break; + } + } + + private class MyKeyNumberListener implements java.awt.event.ActionListener { + + private char m_cCad; + + public MyKeyNumberListener(char cCad){ + m_cCad = cCad; + } + public void actionPerformed(java.awt.event.ActionEvent evt) { + + // como contenedor de editores + if (editorcurrent != null) { + editorcurrent.transChar(m_cCad); + } + } + } + + /** + * + * @param e + * @param iMode + */ + public void setActive(EditorComponent e, int iMode) { + + if (editorcurrent != null) { + editorcurrent.deactivate(); + } + editorcurrent = e; // e != null + setMode(iMode); + doEnabled(true); + + // keyboard listener activation + m_txtKeys.setText(null); + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + m_txtKeys.requestFocus(); + } + }); + } + + /** + * + * @param e + */ + public void setInactive(EditorComponent e) { + + if (e == editorcurrent && editorcurrent != null) { // e != null + editorcurrent.deactivate(); + editorcurrent = null; + setMode(MODE_STRING); + doEnabled(false); + } + } + + /** + * + * @param enabled + */ + public void dotIs00(boolean enabled) { + if (enabled) { + m_jKeyDot.setIcon(new javax.swing.ImageIcon(getClass() + .getResource("/com/unicenta/images/btn00.png"))); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + m_jCE = new javax.swing.JButton(); + m_jMinus = new javax.swing.JButton(); + m_jKey1 = new javax.swing.JButton(); + m_jKey2 = new javax.swing.JButton(); + m_jKey3 = new javax.swing.JButton(); + m_jKey4 = new javax.swing.JButton(); + m_jKey5 = new javax.swing.JButton(); + m_jKey6 = new javax.swing.JButton(); + m_jKey7 = new javax.swing.JButton(); + m_jKey8 = new javax.swing.JButton(); + m_jKey9 = new javax.swing.JButton(); + m_jKey0 = new javax.swing.JButton(); + m_jKeyDot = new javax.swing.JButton(); + m_txtKeys = new javax.swing.JTextField(); + + setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + setPreferredSize(new java.awt.Dimension(300, 300)); + setLayout(new java.awt.GridBagLayout()); + + m_jCE.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btnce.png"))); // NOI18N + m_jCE.setFocusPainted(false); + m_jCE.setFocusable(false); + m_jCE.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jCE.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.gridwidth = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0); + add(m_jCE, gridBagConstraints); + + m_jMinus.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btnminus.png"))); // NOI18N + m_jMinus.setFocusPainted(false); + m_jMinus.setFocusable(false); + m_jMinus.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jMinus.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0); + add(m_jMinus, gridBagConstraints); + + m_jKey1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn1.png"))); // NOI18N + m_jKey1.setFocusPainted(false); + m_jKey1.setFocusable(false); + m_jKey1.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey1.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey1, gridBagConstraints); + + m_jKey2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn2a.png"))); // NOI18N + m_jKey2.setFocusPainted(false); + m_jKey2.setFocusable(false); + m_jKey2.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey2.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey2, gridBagConstraints); + + m_jKey3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn3a.png"))); // NOI18N + m_jKey3.setFocusPainted(false); + m_jKey3.setFocusable(false); + m_jKey3.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey3.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey3, gridBagConstraints); + + m_jKey4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn4a.png"))); // NOI18N + m_jKey4.setFocusPainted(false); + m_jKey4.setFocusable(false); + m_jKey4.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey4.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey4, gridBagConstraints); + + m_jKey5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn5a.png"))); // NOI18N + m_jKey5.setFocusPainted(false); + m_jKey5.setFocusable(false); + m_jKey5.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey5.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey5, gridBagConstraints); + + m_jKey6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn6a.png"))); // NOI18N + m_jKey6.setFocusPainted(false); + m_jKey6.setFocusable(false); + m_jKey6.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey6.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey6, gridBagConstraints); + + m_jKey7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn7a.png"))); // NOI18N + m_jKey7.setFocusPainted(false); + m_jKey7.setFocusable(false); + m_jKey7.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey7.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 3; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey7, gridBagConstraints); + + m_jKey8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn8a.png"))); // NOI18N + m_jKey8.setFocusPainted(false); + m_jKey8.setFocusable(false); + m_jKey8.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey8.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 3; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey8, gridBagConstraints); + + m_jKey9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn9a.png"))); // NOI18N + m_jKey9.setFocusPainted(false); + m_jKey9.setFocusable(false); + m_jKey9.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey9.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 3; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + add(m_jKey9, gridBagConstraints); + + m_jKey0.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn0.png"))); // NOI18N + m_jKey0.setFocusPainted(false); + m_jKey0.setFocusable(false); + m_jKey0.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKey0.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 4; + gridBagConstraints.gridwidth = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); + add(m_jKey0, gridBagConstraints); + + m_jKeyDot.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btndot.png"))); // NOI18N + m_jKeyDot.setFocusPainted(false); + m_jKeyDot.setFocusable(false); + m_jKeyDot.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jKeyDot.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 4; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); + add(m_jKeyDot, gridBagConstraints); + + m_txtKeys.setPreferredSize(new java.awt.Dimension(0, 0)); + m_txtKeys.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + m_txtKeysFocusLost(evt); + } + }); + m_txtKeys.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { + m_txtKeysKeyTyped(evt); + } + }); + add(m_txtKeys, new java.awt.GridBagConstraints()); + }// //GEN-END:initComponents + + private void m_txtKeysKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_m_txtKeysKeyTyped + + // como contenedor de editores solo + if (editorcurrent != null) { + m_txtKeys.setText("0"); + + // solo lo lanzamos si esta dentro del set de teclas + char c = evt.getKeyChar(); + if (c == '\n') { + fireActionPerformed(); + } else { + if (keysavailable == null) { + // todo disponible + editorcurrent.typeChar(c); + } else { + for (int i = 0; i < keysavailable.length; i++) { + if (c == keysavailable[i]) { + // todo disponible + editorcurrent.typeChar(c); + } + } + } + } + } + + }//GEN-LAST:event_m_txtKeysKeyTyped + + private void m_txtKeysFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_m_txtKeysFocusLost + + setInactive(editorcurrent); + + }//GEN-LAST:event_m_txtKeysFocusLost + + + // Variables declaration - do not modify//GEN-BEGIN:variables + javax.swing.JButton m_jCE; + javax.swing.JButton m_jKey0; + javax.swing.JButton m_jKey1; + javax.swing.JButton m_jKey2; + javax.swing.JButton m_jKey3; + javax.swing.JButton m_jKey4; + javax.swing.JButton m_jKey5; + javax.swing.JButton m_jKey6; + javax.swing.JButton m_jKey7; + javax.swing.JButton m_jKey8; + javax.swing.JButton m_jKey9; + javax.swing.JButton m_jKeyDot; + javax.swing.JButton m_jMinus; + javax.swing.JTextField m_txtKeys; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/editor/JEditorNumber.java b/src/main/java/com/unicenta/editor/JEditorNumber.java new file mode 100644 index 0000000..41743ab --- /dev/null +++ b/src/main/java/com/unicenta/editor/JEditorNumber.java @@ -0,0 +1,286 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.editor; + +import com.unicenta.basic.BasicException; +import com.unicenta.format.DoubleUtils; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Toolkit; +import java.io.File; + +/** + * + * @author JG uniCenta + */ +public abstract class JEditorNumber extends JEditorAbstract { + + // Variable numerica + private final static int NUMBER_ZERONULL = 0; + private final static int NUMBER_INT = 1; + private final static int NUMBER_DEC = 2; + + private char DEC_SEP = '.'; + private int m_iNumberStatus; + private String m_sNumber; + private boolean m_bNegative; + + private Formats m_fmt; + + private Boolean priceWith00; + + /** Creates a new instance of JEditorNumber */ + public JEditorNumber() { + m_fmt = getFormat(); + +// added JDL 11.05.13 + AppConfig m_config = new AppConfig(new File((System.getProperty("user.home")), AppLocal.APP_ID + ".properties")); + m_config.load(); + priceWith00 =("true".equals(m_config.getProperty("till.pricewith00"))); + m_config=null; + reset(); + } + + /** + * + * @return + */ + protected abstract Formats getFormat(); + + /** + * + */ + public void reset() { + + String sOldText = getText(); + + m_sNumber = ""; + m_bNegative = false; + m_iNumberStatus = NUMBER_ZERONULL; + + reprintText(); + + firePropertyChange("Text", sOldText, getText()); + } + + /** + * + * @param dvalue + */ + public void setDoubleValue(Double dvalue) { + + String sOldText = getText(); + + if (dvalue == null) { + m_sNumber = ""; + m_bNegative = false; + m_iNumberStatus = NUMBER_ZERONULL; + } else if (dvalue >= 0.0) { + m_sNumber = formatDouble(dvalue); + m_bNegative = false; + m_iNumberStatus = NUMBER_ZERONULL; + } else { + m_sNumber = formatDouble(-dvalue); + m_bNegative = true; + m_iNumberStatus = NUMBER_ZERONULL; + } + reprintText(); + + firePropertyChange("Text", sOldText, getText()); + } + + /** + * + * @return + */ + public Double getDoubleValue() { + String text = getText(); + if (text == null || text.equals("")) { + return null; + } else { + try { + //return priceWith00? Double.parseDouble(text)/100 : Double.parseDouble(text); + return Double.parseDouble(text); + // return Double.parseDouble(text); + } catch (NumberFormatException e) { + return null; + } + } + } + + /** + * + * @param ivalue + */ + public void setValueInteger(int ivalue) { + + String sOldText = getText(); + + if (ivalue >= 0) { + m_sNumber = Integer.toString(ivalue); + m_bNegative = false; + m_iNumberStatus = NUMBER_ZERONULL; + } else { + m_sNumber = Integer.toString(-ivalue); + m_bNegative = true; + m_iNumberStatus = NUMBER_ZERONULL; + } + reprintText(); + + firePropertyChange("Text", sOldText, getText()); + } + + /** + * + * @return + * @throws BasicException + */ + public int getValueInteger() throws BasicException { + try { + return Integer.parseInt(getText()); + } catch (NumberFormatException e) { + throw new BasicException(e); + } + } + + private String formatDouble(Double value) { + String sNumber = Double.toString(DoubleUtils.fixDecimals(value)); + if (sNumber.endsWith(".0")) { + sNumber = sNumber.substring(0, sNumber.length() - 2); + } + return sNumber; + } + + /** + * + * @return + */ + @Override + protected String getEditMode() { + return "-1.23"; + } + + /** + * + * @return + */ + public String getText() { + return (m_bNegative ? "-" : "") + m_sNumber; + } + + /** + * + * @return + */ + @Override + protected int getAlignment() { + return javax.swing.SwingConstants.RIGHT; + } + + /** + * + * @return + */ + @Override + protected String getTextEdit() { + return getText(); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + protected String getTextFormat() throws BasicException { + return m_fmt.formatValue(getDoubleValue()); + } + + /** + * + * @param cTrans + */ + @Override + protected void typeCharInternal(char cTrans) { + transChar(cTrans); + } + + /** + * + * @param cTrans + */ + @Override + protected void transCharInternal(char cTrans) { + + String sOldText = getText(); + + if (cTrans == '\u007f') { + reset(); + } else if (cTrans == '-') { + m_bNegative = !m_bNegative; + } else if ((cTrans == '0') + && (m_iNumberStatus == NUMBER_ZERONULL)) { + // m_iNumberStatus = NUMBER_ZERO; + m_sNumber = "0"; + } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9') + && (m_iNumberStatus == NUMBER_ZERONULL)) { + m_iNumberStatus = NUMBER_INT; + m_sNumber = Character.toString(cTrans); +// } else if (cTrans == DEC_SEP && m_iNumberStatus == NUMBER_ZERONULL && !priceWith00) { + } else if (cTrans == DEC_SEP && m_iNumberStatus == NUMBER_ZERONULL) { + m_iNumberStatus = NUMBER_DEC; + m_sNumber = "0"+DEC_SEP; + } else if (cTrans == DEC_SEP && m_iNumberStatus == NUMBER_ZERONULL) { + m_iNumberStatus = NUMBER_INT; + m_sNumber = "0"; + + } else if ((cTrans == '0' || cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9') + && (m_iNumberStatus == NUMBER_INT)) { + //m_iNumberStatus = NUMBER_INT; + m_sNumber += cTrans; +// } else if (cTrans == DEC_SEP && m_iNumberStatus == NUMBER_INT && !priceWith00) { + } else if (cTrans == DEC_SEP && m_iNumberStatus == NUMBER_INT) { + m_iNumberStatus = NUMBER_DEC; + m_sNumber += DEC_SEP; + } else if (cTrans == DEC_SEP && m_iNumberStatus == NUMBER_INT) { +// m_iNumberStatus = NUMBER_DEC; + m_sNumber += "00"; + + } else if ((cTrans == '0' || cTrans == '1' || cTrans == '2' || cTrans == '3' || cTrans == '4' || cTrans == '5' || cTrans == '6' || cTrans == '7' || cTrans == '8' || cTrans == '9') + && (m_iNumberStatus == NUMBER_DEC)) { + m_sNumber += cTrans; + + } else { + Toolkit.getDefaultToolkit().beep(); + } + + firePropertyChange("Text", sOldText, getText()); + } + + + /* Added JDL 13.04.13 routine + * routine to set the amount appearance to show '.' + */ + private String setTempjPrice(String jPrice){ + jPrice = jPrice.replace(".",""); + return (jPrice.length()<= 2)? jPrice : (new StringBuffer(jPrice).insert(jPrice.length()-2,".").toString()); + } +} diff --git a/src/main/java/com/unicenta/editor/JEditorPassword.java b/src/main/java/com/unicenta/editor/JEditorPassword.java new file mode 100644 index 0000000..cc335eb --- /dev/null +++ b/src/main/java/com/unicenta/editor/JEditorPassword.java @@ -0,0 +1,104 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.editor; + +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public class JEditorPassword extends JEditorText { + + private static final char ECHO_CHAR = '*'; + + /** Creates a new instance of JEditorPassword */ + public JEditorPassword() { + super(); + } + + /** + * + * @return + */ + protected final int getMode() { + return EditorKeys.MODE_STRING; + } + + /** + * + * @return + */ + protected int getStartMode() { + return MODE_Abc1; + } + + /** + * + * @return + */ + protected String getTextEdit() { + + StringBuilder s = new StringBuilder(); + s.append(""); + s.append(getEcho(m_svalue)); + if (m_cLastChar != '\u0000') { + s.append(""); + s.append(ECHO_CHAR); + s.append(""); + } + s.append("_"); + + return s.toString(); + } + + /** + * + * @return + */ + public final String getPassword() { + + // como clave nunca devolvemos null + String sPassword = getText(); + return sPassword == null ? "" : sPassword; + } + + /** + * + * @return + * @throws BasicException + */ + protected String getTextFormat() throws BasicException { + return "" + getEcho(m_svalue); + } + + private String getEcho(String sValue) { + + if (sValue == null) { + return ""; + } else { + char[] c = new char[sValue.length()]; + for(int i = 0; i < sValue.length(); i++) { + c[i] = ECHO_CHAR; + } + return new String(c); + } + } +} diff --git a/src/main/java/com/unicenta/editor/JEditorString.java b/src/main/java/com/unicenta/editor/JEditorString.java new file mode 100644 index 0000000..a6f1351 --- /dev/null +++ b/src/main/java/com/unicenta/editor/JEditorString.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.editor; + +/** + * + * @author JG uniCenta + */ +public class JEditorString extends JEditorText { + + /** Creates a new instance of JEditorString */ + public JEditorString() { + super(); + } + + /** + * + * @return + */ + @Override + protected final int getMode() { + return EditorKeys.MODE_STRING; + } + + /** + * + * @return + */ + @Override + protected int getStartMode() { + return MODE_Abc1; + } + +} + diff --git a/src/main/java/com/unicenta/editor/JEditorStringNumber.java b/src/main/java/com/unicenta/editor/JEditorStringNumber.java new file mode 100644 index 0000000..2c36ce1 --- /dev/null +++ b/src/main/java/com/unicenta/editor/JEditorStringNumber.java @@ -0,0 +1,48 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.editor; + +/** + * + * @author adrian + */ +public class JEditorStringNumber extends JEditorText { + + /** Creates a new instance of JEditorStringNumber */ + public JEditorStringNumber() { + super(); + } + + /** + * + * @return + */ + protected int getMode() { + return EditorKeys.MODE_INTEGER_POSITIVE; + } + + /** + * + * @return + */ + protected int getStartMode() { + return MODE_123; + } +} diff --git a/src/main/java/com/unicenta/editor/JEditorText.java b/src/main/java/com/unicenta/editor/JEditorText.java new file mode 100644 index 0000000..bd811bd --- /dev/null +++ b/src/main/java/com/unicenta/editor/JEditorText.java @@ -0,0 +1,407 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.editor; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.Timer; +import com.unicenta.basic.BasicException; + +/** + * + * @author JG uniCenta + */ +public abstract class JEditorText extends JEditorAbstract { + + /** + * + */ + protected String m_svalue; + + /** + * + */ + public static final int MODE_Abc1 = 0; + + /** + * + */ + public static final int MODE_abc1 = 1; + + /** + * + */ + public static final int MODE_ABC1 = 2; + + /** + * + */ + public static final int MODE_123 = 3; + + /** + * + */ + public int m_iMode; + + /** + * + */ + protected int m_iTicks; + + /** + * + */ + protected char m_cLastChar; + + /** + * + */ + protected long m_lcount; + + private Timer m_jtimer; + + private static final char[] CHAR_abc1_1 = {'.', '?', '!', ',', '1', ';', ':'}; + private static final char[] CHAR_abc1_2 = {'a', 'b', 'c', '2', '\u00a0'}; + private static final char[] CHAR_abc1_3 = {'d', 'e', 'f', '3', '\u201a'}; + private static final char[] CHAR_abc1_4 = {'g', 'h', 'i', '4', '\u00a1'}; + private static final char[] CHAR_abc1_5 = {'j', 'k', 'l', '5'}; + private static final char[] CHAR_abc1_6 = {'m', 'n', 'o', '6', '\u00a4', '\u00a2'}; + private static final char[] CHAR_abc1_7 = {'p', 'q', 'r', 's', '7'}; + private static final char[] CHAR_abc1_8 = {'t', 'u', 'v', '8', '\u00a3', '\ufffd'}; + private static final char[] CHAR_abc1_9 = {'w', 'x', 'y', 'z', '9'}; + private static final char[] CHAR_abc1_0 = {' ', '0'}; + + private static final char[] CHAR_ABC1_1 = {'.', '?', '!', ',', '1', ';', ':'}; + private static final char[] CHAR_ABC1_2 = {'A', 'B', 'C', '2', '\u00b5'}; + private static final char[] CHAR_ABC1_3 = {'D', 'E', 'F', '3', '\u00c9'}; + private static final char[] CHAR_ABC1_4 = {'G', 'H', 'I', '4', '\u00cd'}; + private static final char[] CHAR_ABC1_5 = {'J', 'K', 'L', '5'}; + private static final char[] CHAR_ABC1_6 = {'M', 'N', 'O', '6', '\u00d1', '\u00d3'}; + private static final char[] CHAR_ABC1_7 = {'P', 'Q', 'R', 'S', '7'}; + private static final char[] CHAR_ABC1_8 = {'T', 'U', 'V', '8', '\u00da', '\u00dc'}; + private static final char[] CHAR_ABC1_9 = {'W', 'X', 'Y', 'Z', '9'}; + private static final char[] CHAR_ABC1_0 = {' ', '0'}; + + /** Creates a new instance of JEditorString */ + public JEditorText() { + m_svalue = null; + + m_iTicks = 0; + m_cLastChar = '\u0000'; + m_jtimer = new javax.swing.Timer(1000, new TimerAction()); + m_lcount = 0L; + m_iMode = getStartMode(); //MODE_Abc1; + m_jtimer.start(); + } + + /** + * + * @return + */ + protected abstract int getStartMode(); + + /** + * + */ + public final void reset() { + + String sOldText = getText(); + + // Los hemos borrado todos. + m_iMode = getStartMode(); //MODE_Abc1; + m_svalue = null; + m_iTicks = 0; + m_cLastChar = '\u0000'; + + reprintText(); + + firePropertyChange("Text", sOldText, getText()); + } + + /** + * + * @param sText + */ + public final void setText(String sText) { + + String sOldText = getText(); + + m_svalue = sText; + m_iTicks = 0; + m_cLastChar = '\u0000'; + + reprintText(); + + firePropertyChange("Text", sOldText, getText()); + } + + /** + * + * @param iMode + */ + public final void setEditModeEnum(int iMode) { + + m_iMode = iMode; + m_iTicks = 0; + m_cLastChar = '\u0000'; + + reprintText(); + } + + /** + * + * @return + */ + public final String getText() { + if (m_cLastChar == '\u0000') { + return m_svalue; + } else { + return appendChar2Value(getKeyChar()); + } + } + + /** + * + * @return + */ + protected final int getAlignment() { + return javax.swing.SwingConstants.LEFT; + } + + /** + * + * @return + */ + protected final String getEditMode() { + switch (m_iMode) { + case MODE_Abc1: return "Abc1"; + case MODE_abc1: return "abc1"; + case MODE_ABC1: return "ABC1"; + case MODE_123: return "123"; + default: return null; + } + } + + /** + * + * @return + */ + protected String getTextEdit() { + + StringBuilder s = new StringBuilder(); + s.append(""); + if (m_svalue != null) { + s.append(m_svalue); + } + if (m_cLastChar != '\u0000') { +// s.append(""); + s.append(""); + s.append(getKeyChar()); + s.append(""); + } +// s.append("_"); + s.append("_"); + + return s.toString(); + } + + /** + * + * @return + * @throws BasicException + */ + protected String getTextFormat() throws BasicException { + return (m_svalue == null) + ? "" + : "" + m_svalue; + } + + /** + * + * @param c + */ + protected void typeCharInternal(char c) { + + String sOldText = getText(); + + if (c == '\u0008') { + if (m_cLastChar == '\u0000') { + // borramos el \u00c3\u00baltimo caracter el si existe + if (m_svalue != null && m_svalue.length() > 0) { + m_svalue = m_svalue.substring(0, m_svalue.length() - 1); + } + } else { + // borramos el caracter pendiente + m_iTicks = 0; + m_cLastChar = '\u0000'; + } + } else if (c == '\u007f') { + // Los hemos borrado todos. + m_iMode = getStartMode(); //MODE_Abc1; + m_svalue = null; + m_iTicks = 0; + m_cLastChar = '\u0000'; + } else if (c >= ' ') { // es un caracter en condiciones + if (m_cLastChar != '\u0000') { + char ckey = getKeyChar(); + m_svalue = appendChar2Value(ckey); + acceptKeyChar(ckey); + } + m_iTicks = 0; + m_cLastChar = '\u0000'; + m_svalue = appendChar2Value(c); + } + + m_jtimer.restart(); + + firePropertyChange("Text", sOldText, getText()); + } + + /** + * + * @param c + */ + protected void transCharInternal(char c) { + + String sOldText = getText(); + + if (c == '-') { + if (m_cLastChar == '\u0000') { + // borramos el \u00c3\u00baltimo caracter el si existe + if (m_svalue != null && m_svalue.length() > 0) { + m_svalue = m_svalue.substring(0, m_svalue.length() - 1); + } + } else { + // borramos el caracter pendiente + m_iTicks = 0; + m_cLastChar = '\u0000'; + } + } else if (c == '\u007f') { + // Los hemos borrado todos. + m_iMode = getStartMode(); //MODE_Abc1; + m_svalue = null; + m_iTicks = 0; + m_cLastChar = '\u0000'; + } else if (c == '.') { + if (m_cLastChar != '\u0000') { + m_svalue = appendChar2Value(getKeyChar()); + } + m_iTicks = 0; + m_cLastChar = '\u0000'; + m_iMode = (m_iMode + 1) % 4; + } else if (c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9' || c == '0') { + if (m_iMode == MODE_123) { + m_svalue = appendChar2Value(c); + } else if (c == m_cLastChar) { + m_iTicks ++; + } else { + if (m_cLastChar != '\u0000') { + char ckey = getKeyChar(); + m_svalue = appendChar2Value(ckey); + acceptKeyChar(ckey); + } + m_iTicks = 0; + m_cLastChar = c; + } + } + + m_jtimer.restart(); + + firePropertyChange("Text", sOldText, getText()); + } + + private void acceptKeyChar(char c) { + if (m_iMode == MODE_Abc1 && c != ' ') { + m_iMode = MODE_abc1; + } else if (m_iMode == MODE_abc1 && c == '.') { + m_iMode = MODE_Abc1; + } + } + + /** + * + * @return + */ + protected char getKeyChar() { + + char[] clist = null; + switch (m_iMode) { + case MODE_abc1: + switch (m_cLastChar) { + case '1': clist = CHAR_abc1_1; break; + case '2': clist = CHAR_abc1_2; break; + case '3': clist = CHAR_abc1_3; break; + case '4': clist = CHAR_abc1_4; break; + case '5': clist = CHAR_abc1_5; break; + case '6': clist = CHAR_abc1_6; break; + case '7': clist = CHAR_abc1_7; break; + case '8': clist = CHAR_abc1_8; break; + case '9': clist = CHAR_abc1_9; break; + case '0': clist = CHAR_abc1_0; break; + } + break; + case MODE_Abc1: + case MODE_ABC1: + switch (m_cLastChar) { + case '1': clist = CHAR_ABC1_1; break; + case '2': clist = CHAR_ABC1_2; break; + case '3': clist = CHAR_ABC1_3; break; + case '4': clist = CHAR_ABC1_4; break; + case '5': clist = CHAR_ABC1_5; break; + case '6': clist = CHAR_ABC1_6; break; + case '7': clist = CHAR_ABC1_7; break; + case '8': clist = CHAR_ABC1_8; break; + case '9': clist = CHAR_ABC1_9; break; + case '0': clist = CHAR_ABC1_0; break; + } + break; + } + + if (clist == null) { + return m_cLastChar; + } else { + return clist[m_iTicks % clist.length]; + } + } + + private class TimerAction implements ActionListener { + public void actionPerformed(ActionEvent evt) { + if (m_cLastChar != '\u0000') { + // This method does not modify the "Text" property. + char ckey = getKeyChar(); + m_svalue = appendChar2Value(ckey); + acceptKeyChar(ckey); + m_iTicks = 0; + m_cLastChar = '\u0000'; + m_jtimer.restart(); + reprintText(); + } + } + } + + private String appendChar2Value(char c) { + StringBuilder s = new StringBuilder(); + if (m_svalue != null) { + s.append(m_svalue); + } + s.append(c); + return s.toString(); + } +} diff --git a/src/main/java/com/unicenta/format/DoubleUtils.java b/src/main/java/com/unicenta/format/DoubleUtils.java new file mode 100644 index 0000000..d268403 --- /dev/null +++ b/src/main/java/com/unicenta/format/DoubleUtils.java @@ -0,0 +1,22 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.unicenta.format; + +/** + * + * @author adrian + */ +public class DoubleUtils { + + /** + * + * @param value + * @return + */ + public static double fixDecimals(Number value) { + return Math.rint((value).doubleValue() * 1000000.0) / 1000000.0; + } +} diff --git a/src/main/java/com/unicenta/format/Formats.java b/src/main/java/com/unicenta/format/Formats.java new file mode 100644 index 0000000..edd39f5 --- /dev/null +++ b/src/main/java/com/unicenta/format/Formats.java @@ -0,0 +1,438 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.format; + +import java.text.*; +import com.unicenta.basic.BasicException; +import java.util.Date; + +/** + * + * @author JG uniCenta + */ +public abstract class Formats { + + public final static Formats NULL = new FormatsNULL(); + public final static Formats INT = new FormatsINT(); + public final static Formats STRING = new FormatsSTRING(); + public final static Formats DOUBLE = new FormatsDOUBLE(); + public final static Formats CURRENCY = new FormatsCURRENCY(); + public final static Formats PERCENT = new FormatsPERCENT(); + public final static Formats BOOLEAN = new FormatsBOOLEAN(); + public final static Formats TIMESTAMP = new FormatsTIMESTAMP(); + public final static Formats DATE = new FormatsDATE(); + public final static Formats TIME = new FormatsTIME(); + public final static Formats BYTEA = new FormatsBYTEA(); + public final static Formats HOURMIN = new FormatsHOURMIN(); + public final static Formats SIMPLEDATE = new FormatsSIMPLEDATE(); + + private static NumberFormat m_integerformat = NumberFormat.getIntegerInstance(); + private static NumberFormat m_doubleformat = NumberFormat.getNumberInstance(); + private static NumberFormat m_currencyformat = NumberFormat.getCurrencyInstance(); + private static NumberFormat m_percentformat = new DecimalFormat("#,##0.##%"); + private static DateFormat m_dateformat = DateFormat.getDateInstance(); + private static DateFormat m_timeformat = DateFormat.getTimeInstance(); + private static DateFormat m_datetimeformat = DateFormat.getDateTimeInstance(); + + private static final DateFormat m_hourminformat = new SimpleDateFormat("H:mm:ss"); + private static final DateFormat m_simpledate = new SimpleDateFormat("dd-MM-yyyy"); + /** Creates a new instance of Formats */ + + + protected Formats() { + } + + /** + * + * @return + */ + public static int getCurrencyDecimals() { + + return m_currencyformat.getMaximumFractionDigits(); + } + + /** + * + * @param value + * @return + */ + public String formatValue(Object value) { + if (value == null) { + return ""; + } else { + return formatValueInt(value); + } + } + + /** + * + * @param value + * @param defvalue + * @return + * @throws BasicException + */ + public Object parseValue(String value, Object defvalue) throws BasicException { + if (value == null || "".equals(value)) { + return defvalue; + } else { + try { + return parseValueInt(value); + } catch (ParseException e) { + throw new BasicException(e.getMessage(), e); + } + } + } + + /** + * + * @param value + * @return + * @throws BasicException + */ + public Object parseValue(String value) throws BasicException { + return parseValue(value, null); + } + + /** + * + * @param pattern + */ + public static void setIntegerPattern(String pattern) { + if (pattern == null || pattern.equals("")) { + m_integerformat = NumberFormat.getIntegerInstance(); + } else { + m_integerformat = new DecimalFormat(pattern); + } + } + + /** + * + * @param pattern + */ + public static void setDoublePattern(String pattern) { + if (pattern == null || pattern.equals("")) { + m_doubleformat = NumberFormat.getNumberInstance(); + } else { + m_doubleformat = new DecimalFormat(pattern); + } + } + + /** + * + * @param pattern + */ + public static void setCurrencyPattern(String pattern) { + if (pattern == null || pattern.equals("")) { + m_currencyformat = NumberFormat.getCurrencyInstance(); + } else { + m_currencyformat = new DecimalFormat(pattern); + } + } + + /** + * + * @param pattern + */ + public static void setPercentPattern(String pattern) { + if (pattern == null || pattern.equals("")) { + m_percentformat = new DecimalFormat("#,##0.##%"); + } else { + m_percentformat = new DecimalFormat(pattern); + } + } + + /** + * + * @param pattern + */ + public static void setDatePattern(String pattern) { + if (pattern == null || pattern.equals("")) { + m_dateformat = DateFormat.getDateInstance(); + } else { + m_dateformat = new SimpleDateFormat(pattern); + } + } + + /** + * + * @param pattern + */ + public static void setTimePattern(String pattern) { + if (pattern == null || pattern.equals("")) { + m_timeformat = DateFormat.getTimeInstance(); + } else { + m_timeformat = new SimpleDateFormat(pattern); + } + } + + /** + * + * @param pattern + */ + public static void setDateTimePattern(String pattern) { + if (pattern == null || pattern.equals("")) { + m_datetimeformat = DateFormat.getDateTimeInstance(); + } else { + m_datetimeformat = new SimpleDateFormat(pattern); + } + } + + /** + * + * @param value + * @return + */ + protected abstract String formatValueInt(Object value); + + /** + * + * @param value + * @return + * @throws ParseException + */ + protected abstract Object parseValueInt(String value) throws ParseException; + + /** + * + * @return + */ + public abstract int getAlignment(); + + private static final class FormatsNULL extends Formats { + @Override + protected String formatValueInt(Object value) { + return null; + } + @Override + protected Object parseValueInt(String value) throws ParseException { + return null; + } + @Override + public int getAlignment() { + return javax.swing.SwingConstants.LEFT; + } + } + private static final class FormatsINT extends Formats { + @Override + protected String formatValueInt(Object value) { + return m_integerformat.format(((Number) value).longValue()); + } + @Override + protected Object parseValueInt(String value) throws ParseException { + return m_integerformat.parse(value).intValue(); + } + @Override + public int getAlignment() { + return javax.swing.SwingConstants.RIGHT; + } + } + private static final class FormatsSTRING extends Formats { + @Override + protected String formatValueInt(Object value) { + return (String) value; + } + @Override + protected Object parseValueInt(String value) throws ParseException { + return value; + } + @Override + public int getAlignment() { + return javax.swing.SwingConstants.LEFT; + } + } + private static final class FormatsDOUBLE extends Formats { + @Override + protected String formatValueInt(Object value) { + return m_doubleformat.format(DoubleUtils.fixDecimals((Number) value)); // quickfix for 3838 + } + @Override + protected Object parseValueInt(String value) throws ParseException { + return m_doubleformat.parse(value).doubleValue(); + } + @Override + public int getAlignment() { + return javax.swing.SwingConstants.RIGHT; + } + } + private static final class FormatsPERCENT extends Formats { + @Override + protected String formatValueInt(Object value) { + return m_percentformat.format(DoubleUtils.fixDecimals((Number) value)); // quickfix for 3838 + } + @Override + protected Object parseValueInt(String value) throws ParseException { + try { + return m_percentformat.parse(value).doubleValue(); + } catch (ParseException e) { + // Segunda oportunidad como numero normalito + return m_doubleformat.parse(value).doubleValue() / 100; + } + } + @Override + public int getAlignment() { + return javax.swing.SwingConstants.RIGHT; + } + } + private static final class FormatsCURRENCY extends Formats { + @Override + protected String formatValueInt(Object value) { + return m_currencyformat.format(DoubleUtils.fixDecimals((Number) value)); // quickfix for 3838 + } + @Override + protected Object parseValueInt(String value) throws ParseException { + try { + return m_currencyformat.parse(value).doubleValue(); + } catch (ParseException e) { + // Segunda oportunidad como numero normalito + return m_doubleformat.parse(value).doubleValue(); + } + } + @Override + public int getAlignment() { + return javax.swing.SwingConstants.RIGHT; + } + } + private static final class FormatsBOOLEAN extends Formats { + @Override + protected String formatValueInt(Object value) { + return ((Boolean) value).toString(); + } + @Override + protected Object parseValueInt(String value) throws ParseException { + return Boolean.valueOf(value); + } + @Override + public int getAlignment() { + return javax.swing.SwingConstants.CENTER; + } + } + private static final class FormatsTIMESTAMP extends Formats { + @Override + protected String formatValueInt(Object value) { + return m_datetimeformat.format((Date) value); + } + @Override + protected Object parseValueInt(String value) throws ParseException { + try { + return m_datetimeformat.parse(value); + } catch (ParseException e) { + // segunda oportunidad como fecha normalita + return m_dateformat.parse(value); + } + } + @Override + public int getAlignment() { + return javax.swing.SwingConstants.CENTER; + } + } + private static final class FormatsDATE extends Formats { + @Override + protected String formatValueInt(Object value) { + return m_dateformat.format((Date) value); + } + @Override + protected Object parseValueInt(String value) throws ParseException { + return m_dateformat.parse(value); + } + @Override + public int getAlignment() { + return javax.swing.SwingConstants.CENTER; + } + } + private static final class FormatsTIME extends Formats { + @Override + protected String formatValueInt(Object value) { + return m_timeformat.format((Date) value); + } + @Override + protected Object parseValueInt(String value) throws ParseException { + return m_timeformat.parse(value); + } + @Override + public int getAlignment() { + return javax.swing.SwingConstants.CENTER; + } + } + private static final class FormatsBYTEA extends Formats { + @Override + protected String formatValueInt(Object value) { + try { + return new String((byte[]) value, "UTF-8"); + } catch (java.io.UnsupportedEncodingException eu) { + return ""; + } + } + @Override + protected Object parseValueInt(String value) throws ParseException { + try { + return value.getBytes("UTF-8"); + } catch (java.io.UnsupportedEncodingException eu) { + return new byte[0]; + } + } + @Override + public int getAlignment() { + return javax.swing.SwingConstants.LEADING; + } + } + private static final class FormatsHOURMIN extends Formats { + @Override + protected String formatValueInt(Object value) { + return m_hourminformat.format(value); +} + @Override + protected Date parseValueInt(String value) throws ParseException { + return m_hourminformat.parse(value); + } + @Override + public int getAlignment() { + + return javax.swing.SwingConstants.CENTER; + + } + + } + +/** Added; Thanks TSirwani 3 Mar 11 */ + private static final class FormatsSIMPLEDATE extends Formats { + + @Override + protected String formatValueInt(Object value) { + + return m_simpledate.format(value); + + } + + @Override + protected Date parseValueInt(String value) throws ParseException { + + return m_simpledate.parse(value); + + } + + @Override + public int getAlignment() { + + return javax.swing.SwingConstants.CENTER; + + } + + } +} diff --git a/src/main/java/com/unicenta/format/FormatsConstrain.java b/src/main/java/com/unicenta/format/FormatsConstrain.java new file mode 100644 index 0000000..dae1ca8 --- /dev/null +++ b/src/main/java/com/unicenta/format/FormatsConstrain.java @@ -0,0 +1,56 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.format; + +import java.text.ParseException; + +/** + * + * @author JG uniCenta + */ +public abstract class FormatsConstrain { + +// public final static FormatsConstrain NOTNULL = new FormatsConstrainNOTNULL(); + + /** + * + * @param value + * @return + * @throws ParseException + */ + + public abstract Object check(Object value) throws ParseException; + + /** + * + */ + public FormatsConstrain() { + } + +// private static class FormatsConstrainNOTNULL extends FormatsConstrain { +// public Object check(Object value) throws ParseException{ +// if (value == null) { +// throw new ParseException(LocalRes.getIntString("exception.notnull"), 0); +// } else { +// return value; +// } +// } +// } +} diff --git a/src/main/java/com/unicenta/format/FormatsException.java b/src/main/java/com/unicenta/format/FormatsException.java new file mode 100644 index 0000000..2bdf488 --- /dev/null +++ b/src/main/java/com/unicenta/format/FormatsException.java @@ -0,0 +1,41 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.format; + +/** + * + * @author JG uniCenta + */ +public class FormatsException extends java.lang.Exception { + + /** + * Creates a new instance of FormatsException without detail message. + */ + public FormatsException() { + } + + /** + * Constructs an instance of FormatsException with the specified detail message. + * @param msg the detail message. + */ + public FormatsException(String msg) { + super(msg); + } +} diff --git a/src/main/java/com/unicenta/format/FormatsRESOURCE.java b/src/main/java/com/unicenta/format/FormatsRESOURCE.java new file mode 100644 index 0000000..320971e --- /dev/null +++ b/src/main/java/com/unicenta/format/FormatsRESOURCE.java @@ -0,0 +1,76 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.format; + +import java.text.ParseException; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * + * @author JG uniCenta + */ +public class FormatsRESOURCE extends Formats { + + private ResourceBundle m_rb; + private String m_sPrefix; + + /** Creates a new instance of FormatsRESOURCE + * @param rb + * @param sPrefix */ + public FormatsRESOURCE(ResourceBundle rb, String sPrefix) { + m_rb = rb; + m_sPrefix = sPrefix; + } + + /** + * + * @param value + * @return + */ + @Override + protected String formatValueInt(Object value) { + try { + return m_rb.getString(m_sPrefix + (String) value); + } catch (MissingResourceException e) { + return (String) value; + } + } + + /** + * + * @param value + * @return + * @throws ParseException + */ + @Override + protected Object parseValueInt(String value) throws ParseException { + return value; + } + + /** + * + * @return + */ + @Override + public int getAlignment() { + return javax.swing.SwingConstants.LEFT; + } +} diff --git a/src/main/java/com/unicenta/format/FormatsValidate.java b/src/main/java/com/unicenta/format/FormatsValidate.java new file mode 100644 index 0000000..82e52f6 --- /dev/null +++ b/src/main/java/com/unicenta/format/FormatsValidate.java @@ -0,0 +1,87 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.format; + +import java.text.ParseException; + +/** + * + * @author JG uniCenta + */ +public class FormatsValidate extends Formats { + + private Formats m_fmt; + private FormatsConstrain[] m_aConstrains; + + /** Creates a new instance of FormatsValidate + * @param fmt + * @param constrains */ + public FormatsValidate(Formats fmt, FormatsConstrain[] constrains) { + m_fmt = fmt; + m_aConstrains = constrains; + } + /** Creates a new instance of FormatsValidate + * @param fmt */ + public FormatsValidate(Formats fmt) { + this(fmt, new FormatsConstrain[0]); + } + /** Creates a new instance of FormatsValidate + * @param fmt + * @param constrain */ + public FormatsValidate(Formats fmt, FormatsConstrain constrain) { + this(fmt, new FormatsConstrain[]{constrain}); + } + + /** + * + * @param value + * @return + */ + @Override + protected String formatValueInt(Object value) { + return m_fmt.formatValueInt(value); + } + + /** + * + * @param value + * @return + * @throws ParseException + */ + @Override + protected Object parseValueInt(String value) throws ParseException { + // Primero obtenemos el valor + Object val = m_fmt.parseValueInt(value); + for (int i = 0; i < m_aConstrains.length; i++) { + val = m_aConstrains[i].check(val); + } + + return val; + } + + /** + * + * @return + */ + @Override + public int getAlignment() { + return m_fmt.getAlignment(); + } +} diff --git a/src/main/java/com/unicenta/orderpop/OrderPop.java b/src/main/java/com/unicenta/orderpop/OrderPop.java new file mode 100644 index 0000000..48ad7e3 --- /dev/null +++ b/src/main/java/com/unicenta/orderpop/OrderPop.java @@ -0,0 +1,308 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2017 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta Remote Display +// +// uniCenta Remote Display 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. +// +// uniCenta Remote Display 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 uniCenta oPOS. If not, see . + +/* uniCenta's OrderPop is a simple utilty to list tickets sent to remote printer + * It connects to and list uniCenta oPOS orders table rows and requires a + * manual refresh using the button. + * It runs independently of uniCenta oPOS and uses the provided orderpop.bat + + */ + +package com.unicenta.orderpop; + +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.util.AltEncrypter; +import javafx.application.Application; +import javafx.application.Platform; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.concurrent.Task; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.ListView; +import javafx.scene.control.ProgressIndicator; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; +import javafx.stage.WindowEvent; +import lombok.extern.slf4j.Slf4j; + +import java.sql.*; +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicInteger; + +@Slf4j +public class OrderPop extends Application { + + public static void main(String[] args) { + launch(args); + } + + private ExecutorService databaseExecutor; + private Future databaseSetupFuture; + + @Override + public void init() throws Exception { + databaseExecutor = Executors.newFixedThreadPool( + 1, + new DatabaseThreadFactory() + ); + DBSetupTask setup = new DBSetupTask(); + databaseSetupFuture = databaseExecutor.submit(setup); + } + + // Pop the UI will use fxml rather than in code css to set styling later for release + @Override + public void start(Stage stage) throws InterruptedException, ExecutionException { + + databaseSetupFuture.get(); + final ListView orderView = new ListView<>(); + final ProgressIndicator databaseActivityIndicator = new ProgressIndicator(); + + Image fetchO = new Image(getClass().getResourceAsStream("/com/unicenta/images/resources.png")); + final Button fetchOrders = new Button("Fetch", new ImageView(fetchO)); + // fetch Orders table data and fill the list + databaseActivityIndicator.setVisible(false); + fetchOrders.setOnAction(event -> + fetchDBOrdersListView( + fetchOrders, + databaseActivityIndicator, + orderView + )); + + Image closeO = new Image(getClass().getResourceAsStream("/com/unicenta/images/fileclose.png")); + final Button closeOrderList = new Button("Close", new ImageView(closeO)); + closeOrderList.setOnAction(e -> { + try { + e.consume(); + stop(); + Platform.exit(); + } catch (Exception ex) { + log.error(ex.getMessage()); + } + }); + + stage.setOnCloseRequest((WindowEvent e) -> { + try { + Platform.exit(); + stop(); + Platform.exit(); + } catch (Exception ex) { + log.error(ex.getMessage()); + } + }); + + VBox layout = new VBox(10); + layout.setStyle("-fx-background-color: aliceblue; -fx-padding: 5;"); + //layout.getChildren().setAll( + // new HBox(10, + // fetchOrders, + // closeOrderList, + // databaseActivityIndicator + // ), + // orderView + //); + + layout.setPrefHeight(300); + layout.setPrefWidth(500); + + stage.getIcons().add(new Image("/com/unicenta/images/unicentaopos.png")); + stage.setTitle("Orders Waiting..."); + stage.setScene(new Scene(layout)); + //stage.setAlwaysOnTop(true); + stage.show(); + + } + + // shutdown the app + //@Override + public void istop() throws Exception { + + databaseExecutor.shutdown(); + if (!databaseExecutor.awaitTermination(3, TimeUnit.SECONDS)) { + log.info("DB thread time-out + 3 sec's not shut down clean"); + } + + Platform.exit(); + } + + private void fetchDBOrdersListView( + final Button triggerButton, + final ProgressIndicator databaseActivityIndicator, + final ListView listView) { + final FetchOrdersTask fetchOrdersTask = new FetchOrdersTask(); + + triggerButton.disableProperty().bind( + fetchOrdersTask.runningProperty() + ); + + databaseActivityIndicator.visibleProperty().bind( + fetchOrdersTask.runningProperty() + ); + + databaseActivityIndicator.progressProperty().bind( + fetchOrdersTask.progressProperty() + ); + + fetchOrdersTask.setOnSucceeded(t -> + listView.setItems(fetchOrdersTask.getValue()) + ); + + listView.setStyle("-fx-font-size: 14px;"); + +// prep for css +// listView.getStylesheets().add( +// this.getClass().getResource("listStyle.css").toExternalForm()); + + databaseExecutor.submit(fetchOrdersTask); + } + + abstract class DBTask extends Task { + DBTask() { + setOnFailed(t -> log.error(getException().getMessage())); + } + } + + class FetchOrdersTask extends DBTask> { + @Override + protected ObservableList call() throws Exception { + Thread.sleep(1000); + try (Connection con = getConnection()) { + return fetchOrders(con); + } + } + + // Using an ObservableList here but could use a table as well to give more + // flexibility to highlight specific row/column/cells + private ObservableList fetchOrders(Connection con) throws SQLException { + log.info("Fetch Orders from DB"); + ObservableList orders = FXCollections.observableArrayList(); + Statement st = con.createStatement(); + ResultSet rs = st.executeQuery("SELECT ticketid, orderid, " +// + "DATE_FORMAT(ordertime,'%b %d %Y %h:%i %p') AS ordertime, " + + "qty, " + + "ordertime, " + + "details " + + "FROM orders " + + "ORDER BY ordertime, orderid"); + + while (rs.next()) { + orders.add(rs.getString("ticketid") + " - " + + rs.getString("orderid") + " - " + + rs.getString("ordertime") + + " - " + rs.getString("qty") + + " * " + rs.getString("details")); + } + + log.info("Found {} orders", orders.size()); + return orders; + } + } + + /* + * Check to see if we have a connection to database and + * and pop some data in Orders table to prime if needed + */ + class DBSetupTask extends DBTask { + @Override + protected Void call() throws Exception { + try (Connection con = getConnection()) { + if (!schemaExists(con)) { + // un-comment if we need to create a new Orders table + // createSchema(con); + // populateDatabase(con); + } + } + + return null; + } + + private boolean schemaExists(Connection con) { + log.info("Check for Orders table"); + try { + Statement st = con.createStatement(); + st.executeQuery("select count(*) from orders"); + log.info("Orders table exists"); + } catch (SQLException ex) { + log.info("Create Orders table"); + return false; + } + return true; + } + +/* + * We don't need to create Orders table as should already exist + * as created by uniCenta oPOS or unicenta_remote_display apps + private void createSchema(Connection con) throws SQLException { + logger.info("Add Orders table to schema if not exist"); + Statement st = con.createStatement(); + String table = "create table orders(id integer, orderid varchar(50))"; + st.executeUpdate(table); + logger.info("Created schema"); + } +*/ + +/* + * Useful if we want to fill the Orders table with some sample data + * MySQL-createSampleData.sql - INSERT x12 rows + private void populateDatabase(Connection con) throws SQLException { + logger.info("Populating database"); + Statement st = con.createStatement(); + for (String order: SAMPLE_ORDER_DATA) { + st.executeUpdate("insert into orders values(1,'" + order + "')"); + } + logger.info("Populated database"); + } +*/ + } + + private Connection getConnection() throws ClassNotFoundException, SQLException { + // use explicit connection rather than uniCenta oPOS instance session + // better for this to be independent but use current instance's credentials + + log.info("Get DB connection"); + + String url = AppConfig.getInstance().getProperty("db.URL") + + AppConfig.getInstance().getProperty("db.schema") + + AppConfig.getInstance().getProperty("db.options"); + String sDBUser = AppConfig.getInstance().getProperty("db.user"); + String sDBPassword = AppConfig.getInstance().getProperty("db.password"); + + if (sDBUser != null && sDBPassword != null && sDBPassword.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + sDBUser); + sDBPassword = cypher.decrypt(sDBPassword.substring(6)); + } + + return DriverManager.getConnection(url, sDBUser, sDBPassword); + } + + static class DatabaseThreadFactory implements ThreadFactory { + static final AtomicInteger poolNumber = new AtomicInteger(1); + + @Override + public Thread newThread(Runnable runnable) { + Thread thread = new Thread(runnable, "Database-Connection-" + + poolNumber.getAndIncrement() + "-thread"); + thread.setDaemon(true); + return thread; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/orderpop/listStyle.css b/src/main/java/com/unicenta/orderpop/listStyle.css new file mode 100644 index 0000000..466e1aa --- /dev/null +++ b/src/main/java/com/unicenta/orderpop/listStyle.css @@ -0,0 +1,22 @@ +.root { + -fx-text-base-color: rgb(252.0, 240.0, 237.0); + -fx-text-fill: -fx-text-base-color; + -dark: rgb(47.0, 52.0, 57.0); + -fx-background-color: -dark; + + /*default font */ + -fx-font-family: 'Helvetica Neue'; + + -fx-font-size: 25.0px; + -fx-font-weight: 600; + -fx-disabled-opacity: 0.6; + + -flatter-red: rgb(237.0, 68.0, 37.0); + -flatter-blue: rgb(0.0, 184.0, 222.0); + + -fx-base: #383838; + -fx-background: -fx-base; + -fx-control-inner-background: -fx-base; + -fx-control-inner-background-alt: -fx-base; + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/admin/DataLogicAdmin.java b/src/main/java/com/unicenta/pos/admin/DataLogicAdmin.java new file mode 100644 index 0000000..9c0596b --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/DataLogicAdmin.java @@ -0,0 +1,131 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.admin; + +import com.unicenta.data.loader.*; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.BeanFactoryDataSingle; + +/** + * + * @author adrianromero + */ +public class DataLogicAdmin extends BeanFactoryDataSingle { + + private Session s; + private TableDefinition m_tpeople; + private TableDefinition m_troles; + private TableDefinition m_tresources; + + + /** Creates a new instance of DataLogicAdmin */ + public DataLogicAdmin() { + } + + /** + * + * @param s + */ + @Override + public void init(Session s){ + this.s = s; + + m_tpeople = new TableDefinition(s, + "people" + , new String[] {"ID", "NAME", "APPPASSWORD", "ROLE", "VISIBLE", "CARD", "IMAGE"} + , new String[] {"ID", AppLocal.getIntString("label.peoplename"), AppLocal.getIntString("label.Password"), AppLocal.getIntString("label.role"), AppLocal.getIntString("label.peoplevisible"), AppLocal.getIntString("label.card"), AppLocal.getIntString("label.peopleimage")} + , new Datas[] {Datas.STRING, Datas.STRING, Datas.STRING, Datas.STRING, Datas.BOOLEAN, Datas.STRING, Datas.IMAGE} + , new Formats[] {Formats.STRING, Formats.STRING, Formats.STRING, Formats.STRING, Formats.BOOLEAN, Formats.STRING, Formats.NULL} + , new int[] {0} + ); + + m_troles = new TableDefinition(s, + "roles" + , new String[] {"ID", "NAME", "PERMISSIONS"} + , new String[] {"ID", AppLocal.getIntString("label.name"), "PERMISSIONS"} + , new Datas[] {Datas.STRING, Datas.STRING, Datas.BYTES} + , new Formats[] {Formats.STRING, Formats.STRING, Formats.NULL} + , new int[] {0} + ); + + m_tresources = new TableDefinition(s, + "resources" + , new String[] { + "ID", "NAME", "RESTYPE", "CONTENT"} + , new String[] { + "ID", + AppLocal.getIntString("label.name"), + AppLocal.getIntString("label.type"), + "CONTENT"} + , new Datas[] { + Datas.STRING, Datas.STRING, Datas.INT, Datas.BYTES} + , new Formats[] { + Formats.STRING, Formats.STRING, Formats.INT, Formats.NULL} + , new int[] {0} + ); + } + + /** + * + * @return + */ + public final SentenceList getRolesList() { + return new StaticSentence(s + , "SELECT ID, NAME FROM roles ORDER BY NAME" + , null + , new SerializerReadClass(RoleInfo.class)); + } + + /** + * + * @return + */ + public final TableDefinition getTablePeople() { + return m_tpeople; + } + + /** + * + * @return + */ + public final TableDefinition getTableRoles() { + return m_troles; + } + + /** + * + * @return + */ + public final TableDefinition getTableResources() { + return m_tresources; + } + + /** + * + * @return + */ + public final SentenceList getPeopleList() { + return new StaticSentence(s + , "SELECT ID, NAME FROM people ORDER BY NAME" + , null + , new SerializerReadClass(PeopleInfo.class)); + } +} diff --git a/src/main/java/com/unicenta/pos/admin/JPeopleFinder.form b/src/main/java/com/unicenta/pos/admin/JPeopleFinder.form new file mode 100644 index 0000000..50e374f --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/JPeopleFinder.form @@ -0,0 +1,339 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/admin/JPeopleFinder.java b/src/main/java/com/unicenta/pos/admin/JPeopleFinder.java new file mode 100644 index 0000000..284db41 --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/JPeopleFinder.java @@ -0,0 +1,417 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.admin; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.user.EditorCreator; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.pos.forms.AppLocal; +import java.awt.*; +import java.util.ArrayList; +import javax.swing.JFrame; + +/** + * + * @author adrianromero + */ +public class JPeopleFinder extends javax.swing.JDialog implements EditorCreator { + + private PeopleInfo selectedPeople; + private ListProvider lpr; + + /** Creates new form JPeopleFinder */ + private JPeopleFinder(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + + /** + * Creates new form JPeopleFinder + */ + private JPeopleFinder(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + /** + * + * @param parent + * @param dlPeople + * @return + */ + public static JPeopleFinder getPeopleFinder(Component parent, DataLogicAdmin dlPeople) { + Window window = getWindow(parent); + + JPeopleFinder myMsg; + if (window instanceof Frame) { + myMsg = new JPeopleFinder((Frame) window, true); + } else { + myMsg = new JPeopleFinder((Dialog) window, true); + } + myMsg.init(dlPeople); + myMsg.applyComponentOrientation(parent.getComponentOrientation()); + return myMsg; + } + + /** + * + * @return + */ + public PeopleInfo getSelectedPeople() { + return selectedPeople; + } + + private void init(DataLogicAdmin dlPeople) { + + initComponents(); + + jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); + m_jtxtName.addEditorKeys(m_jKeys); + m_jtxtName.reset(); + lpr = new ListProviderCreator(dlPeople.getPeopleList(), this); + jListPeople.setCellRenderer(new PeopleRenderer()); + + getRootPane().setDefaultButton(jcmdOK); + + selectedPeople = null; + } + + /** + * + * @param people + */ + public void search(PeopleInfo people) { + + if (people == null + || people.getName() == null + || people.getName().equals("")) { + m_jtxtName.reset(); + cleanSearch(); + } else { + m_jtxtName.setText(people.getName()); + executeSearch(); + } + } + + private void cleanSearch() { + jListPeople.setModel(new MyListData(new ArrayList())); + } + + /** + * This method actions the User data search + */ + public void executeSearch() { + try { + jListPeople.setModel(new MyListData(lpr.loadData())); + if (jListPeople.getModel().getSize() > 0) { + jListPeople.setSelectedIndex(0); + } + } catch (BasicException e) { + } + } + + /** + * + * @return creates object for search method + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] afilter = new Object[12]; + + if (m_jtxtName.getText() == null + || m_jtxtName.getText().equals("")) { + afilter[0] = QBFCompareEnum.COMP_NONE; + afilter[1] = null; + } else { + afilter[0] = QBFCompareEnum.COMP_RE; + afilter[1] = "%" + m_jtxtName.getText() + "%"; + } + + return afilter; + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window) parent; + } else { + return getWindow(parent.getParent()); + } + } + + private static class MyListData extends javax.swing.AbstractListModel { + + private final java.util.List m_data; + + public MyListData(java.util.List data) { + m_data = data; + } + + @Override + public Object getElementAt(int index) { + return m_data.get(index); + } + + @Override + public int getSize() { + return m_data.size(); + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel3 = new javax.swing.JPanel(); + jPanel5 = new javax.swing.JPanel(); + jPanel7 = new javax.swing.JPanel(); + jLblName = new javax.swing.JLabel(); + m_jtxtName = new com.unicenta.editor.JEditorString(); + jPanel4 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jListPeople = new javax.swing.JList(); + jPanel6 = new javax.swing.JPanel(); + jButton1 = new javax.swing.JButton(); + jButton3 = new javax.swing.JButton(); + jPanel2 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel8 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jcmdCancel = new javax.swing.JButton(); + jcmdOK = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("form.usertitle")); // NOI18N + setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + setPreferredSize(new java.awt.Dimension(650, 300)); + + jPanel3.setPreferredSize(new java.awt.Dimension(450, 231)); + jPanel3.setLayout(new java.awt.BorderLayout()); + + jPanel5.setLayout(new java.awt.BorderLayout()); + + jPanel7.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + jLblName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblName.setText(AppLocal.getIntString("label.prodname")); // NOI18N + jLblName.setMaximumSize(new java.awt.Dimension(60, 15)); + jLblName.setMinimumSize(new java.awt.Dimension(60, 15)); + jLblName.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jtxtName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtName.setPreferredSize(new java.awt.Dimension(250, 30)); + + javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); + jPanel7.setLayout(jPanel7Layout); + jPanel7Layout.setHorizontalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLblName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel7Layout.setVerticalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + ); + + m_jtxtName.getAccessibleContext().setAccessibleName(""); + + jPanel5.add(jPanel7, java.awt.BorderLayout.CENTER); + + jPanel3.add(jPanel5, java.awt.BorderLayout.PAGE_START); + + jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel4.setLayout(new java.awt.BorderLayout()); + + jListPeople.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jListPeople.setFocusable(false); + jListPeople.setRequestFocusEnabled(false); + jListPeople.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jListPeopleMouseClicked(evt); + } + }); + jListPeople.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + jListPeopleValueChanged(evt); + } + }); + jScrollPane1.setViewportView(jListPeople); + + jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + jButton1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jButton1.setText(bundle.getString("button.reset")); // NOI18N + jButton1.setToolTipText("Clear Filter"); + jButton1.setActionCommand("Reset "); + jButton1.setFocusable(false); + jButton1.setPreferredSize(new java.awt.Dimension(110, 45)); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + jPanel6.add(jButton1); + jButton1.getAccessibleContext().setAccessibleDescription(""); + + jButton3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jButton3.setText(AppLocal.getIntString("button.executefilter")); // NOI18N + jButton3.setToolTipText("Execute Filter"); + jButton3.setFocusPainted(false); + jButton3.setPreferredSize(new java.awt.Dimension(110, 45)); + jButton3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton3ActionPerformed(evt); + } + }); + jPanel6.add(jButton3); + jButton3.getAccessibleContext().setAccessibleDescription(""); + + jPanel4.add(jPanel6, java.awt.BorderLayout.PAGE_START); + + jPanel3.add(jPanel4, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER); + + jPanel2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jPanel2.setLayout(new java.awt.BorderLayout()); + jPanel2.add(m_jKeys, java.awt.BorderLayout.NORTH); + + jPanel8.setLayout(new java.awt.BorderLayout()); + + jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setText(AppLocal.getIntString("button.Cancel")); // NOI18N + jcmdCancel.setFocusPainted(false); + jcmdCancel.setFocusable(false); + jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdCancel.setRequestFocusEnabled(false); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel1.add(jcmdCancel); + + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + jcmdOK.setEnabled(false); + jcmdOK.setFocusPainted(false); + jcmdOK.setFocusable(false); + jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdOK.setMaximumSize(new java.awt.Dimension(103, 44)); + jcmdOK.setMinimumSize(new java.awt.Dimension(103, 44)); + jcmdOK.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdOK.setRequestFocusEnabled(false); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel1.add(jcmdOK); + + jPanel8.add(jPanel1, java.awt.BorderLayout.LINE_END); + + jPanel2.add(jPanel8, java.awt.BorderLayout.SOUTH); + + getContentPane().add(jPanel2, java.awt.BorderLayout.LINE_END); + + setSize(new java.awt.Dimension(758, 497)); + setLocationRelativeTo(null); + }// //GEN-END:initComponents + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + selectedPeople = (PeopleInfo) jListPeople.getSelectedValue(); + dispose(); + + }//GEN-LAST:event_jcmdOKActionPerformed + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_jcmdCancelActionPerformed + + private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed + + executeSearch(); + + }//GEN-LAST:event_jButton3ActionPerformed + + private void jListPeopleValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListPeopleValueChanged + + jcmdOK.setEnabled(jListPeople.getSelectedValue() != null); + + }//GEN-LAST:event_jListPeopleValueChanged + + private void jListPeopleMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListPeopleMouseClicked + + if (evt.getClickCount() == 2) { + selectedPeople = (PeopleInfo) jListPeople.getSelectedValue(); + dispose(); + } + + }//GEN-LAST:event_jListPeopleMouseClicked + +private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + + m_jtxtName.reset(); + + cleanSearch(); +}//GEN-LAST:event_jButton1ActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton3; + private javax.swing.JLabel jLblName; + private javax.swing.JList jListPeople; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JPanel jPanel7; + private javax.swing.JPanel jPanel8; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + private com.unicenta.editor.JEditorKeys m_jKeys; + private com.unicenta.editor.JEditorString m_jtxtName; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/admin/OWWatch.java b/src/main/java/com/unicenta/pos/admin/OWWatch.java new file mode 100644 index 0000000..5b7eaf0 --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/OWWatch.java @@ -0,0 +1,174 @@ + +/*--------------------------------------------------------------------------- + * Copyright (c) 1999,2000 Dallas Semiconductor Corporation, All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Dallas Semiconductor + * shall not be used except as stated in the Dallas Semiconductor + * Branding Policy. + *--------------------------------------------------------------------------- + */ + +import com.dalsemi.onewire.OneWireAccessProvider; +import com.dalsemi.onewire.adapter.DSPortAdapter; +import com.dalsemi.onewire.adapter.OneWireIOException; +import com.dalsemi.onewire.container.OneWireContainer; +import com.dalsemi.onewire.utils.*; +import com.dalsemi.onewire.application.monitor.*; + + +/** + * Minimal demo to monitor a simple network. + * + * @version 0.00, 25 September 2000 + * @author DS,BA,SH + */ +public class OWWatch + implements DeviceMonitorEventListener +{ + + /** + * Method main + * + * + * @param args + * + */ + public static void main (String args []) + { + OneWireContainer owd; + int delay; + + try + { + + // get the default adapter + DSPortAdapter adapter = OneWireAccessProvider.getDefaultAdapter(); + + System.out.println(); + System.out.println("Adapter: " + adapter.getAdapterName() + + " Port: " + adapter.getPortName()); + System.out.println(); + + // clear any previous search restrictions + adapter.setSearchAllDevices(); + adapter.targetAllFamilies(); + adapter.setSpeed(adapter.SPEED_REGULAR); + + // create the watcher with this adapter + OWWatch nw = new OWWatch(adapter); + + // sleep for the specified time + if (args.length >= 1) + delay = Integer.decode(args [0]).intValue(); + else + delay = 20000; + + System.out.println("Monitor run for: " + delay + "ms"); + Thread.sleep(delay); + + // Kill any threads we have running. + nw.killWatch(); + + // free port used by adapter + adapter.freePort(); + } + catch (Exception e) + { + System.out.println(e); + } + + return; + } + + //-------- + //-------- Variables + //-------- + + /** Network Monitor instance */ + private DeviceMonitor dm; + + //-------- + //-------- Constructor + //-------- + + /** + * Create a 1-Wire Network Watcher + * + * @param adapter for 1-Wire Network to monitor + */ + public OWWatch (DSPortAdapter adapter) + { + // create a network monitor + dm = new DeviceMonitor(adapter); + + // add this to the event listers + try + { + dm.addDeviceMonitorEventListener(this); + } + catch (Exception e){} + + // start the monitor + Thread t = new Thread(dm); + t.start(); + } + + /** + * + */ + public void killWatch() + { + // Kill the OneWireMonitor thread. + dm.killMonitor(); + } + + /** + * Arrival event as a NetworkMonitorEventListener + * + * @param owme DeviceMonitorEvent add + */ + public void deviceArrival (DeviceMonitorEvent devt) + { + for(int i=0; i. + +package com.unicenta.pos.admin; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.loader.SerializableRead; + +/** + * + * @author adrianromero + * Created on 27 de febrero de 2007, 23:27 + * + */ +public class PeopleInfo implements SerializableRead, IKeyed { + + private static final long serialVersionUID = 9110127845966L; + private String m_sID; + + /** + * + */ + protected String m_sName; + + /** Creates a new instance of PeopleInfo */ + public PeopleInfo() { + m_sID = null; + m_sName = null; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return m_sID; + } + + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_sID = dr.getString(1); + m_sName = dr.getString(2); + } + + + /** + * + * @return + */ + public String getID() { + return m_sID; + } + public void setID(String sID) { + m_sID = sID; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + + /** + * + * @param sValue + */ + public void setName(String sValue) { + m_sName = sValue; + } + + @Override + public String toString() { + return m_sName; + } +} diff --git a/src/main/java/com/unicenta/pos/admin/PeoplePanel.java b/src/main/java/com/unicenta/pos/admin/PeoplePanel.java new file mode 100644 index 0000000..d1fbb85 --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/PeoplePanel.java @@ -0,0 +1,131 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.admin; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +/** + * + * @author adrianromero + */ +public class PeoplePanel extends JPanelTable { + + private TableDefinition tpeople; + private PeopleView jeditor; + + /** Creates a new instance of JPanelPeople */ + public PeoplePanel() { + } + + /** + * + */ + @Override + protected void init() { + DataLogicAdmin dlAdmin = (DataLogicAdmin) app.getBean("com.unicenta.pos.admin.DataLogicAdmin"); + tpeople = dlAdmin.getTablePeople(); + jeditor = new PeopleView(dlAdmin, dirty); + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return new ListProviderCreator(tpeople); + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(tpeople); + } + + /** + * + * @return + */ + @Override + public Vectorer getVectorer() { + return tpeople.getVectorerBasic(new int[]{1}); + } + + /** + * + * @return + */ + @Override + public ComparatorCreator getComparatorCreator() { + return tpeople.getComparatorCreator(new int[] {1, 3}); + } + + /** + * + * @return + */ + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(tpeople.getRenderStringBasic(new int[]{1})); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + jeditor.activate(); // primero el editor + super.activate(); // y luego cargamos los datos + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Users"); + } +} diff --git a/src/main/java/com/unicenta/pos/admin/PeopleRenderer.java b/src/main/java/com/unicenta/pos/admin/PeopleRenderer.java new file mode 100644 index 0000000..a0115a9 --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/PeopleRenderer.java @@ -0,0 +1,49 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.admin; + +import java.awt.Component; +import javax.swing.DefaultListCellRenderer; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JList; + +/** + * + * @author JG uniCenta + */ +public class PeopleRenderer extends DefaultListCellRenderer { + + private final Icon icopeople; + + /** Creates a new instance of PeopleRenderer */ + public PeopleRenderer() { + + icopeople = new ImageIcon(getClass().getClassLoader().getResource("com/unicenta/images/user_sml.png")); + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, null, index, isSelected, cellHasFocus); + setText(value.toString()); + setIcon(icopeople); + return this; + } +} diff --git a/src/main/java/com/unicenta/pos/admin/PeopleView.form b/src/main/java/com/unicenta/pos/admin/PeopleView.form new file mode 100644 index 0000000..dbc2f17 --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/PeopleView.form @@ -0,0 +1,289 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/admin/PeopleView.java b/src/main/java/com/unicenta/pos/admin/PeopleView.java new file mode 100644 index 0000000..3053bee --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/PeopleView.java @@ -0,0 +1,467 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.admin; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.user.*; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.Hashcypher; +import com.unicenta.pos.util.StringUtils; +import com.unicenta.pos.util.uOWWatch; +import java.awt.Component; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.image.BufferedImage; +import java.util.UUID; +import javax.swing.*; + +/** + * + * @author adrianromero + */ +public class PeopleView extends JPanel implements EditorRecord { + + private Object m_oId; + private String m_sPassword; + + private final DirtyManager m_Dirty; + + private final SentenceList m_sentrole; + private ComboBoxValModel m_RoleModel; + + private final ComboBoxValModel m_ReasonModel; + + /** Creates new form PeopleEditor + * @param dlAdmin + * @param dirty */ + public PeopleView(DataLogicAdmin dlAdmin, DirtyManager dirty) { + + initComponents(); + + // El modelo de roles + m_sentrole = dlAdmin.getRolesList(); + m_RoleModel = new ComboBoxValModel(); + + m_Dirty = dirty; + m_jName.getDocument().addDocumentListener(dirty); + m_jRole.addActionListener(dirty); + m_jVisible.addActionListener(dirty); + m_jImage.addPropertyChangeListener("image", dirty); + m_jcard.getDocument().addDocumentListener(dirty); + + m_ReasonModel = new ComboBoxValModel(); + m_ReasonModel.add(AppLocal.getIntString("cboption.generate")); + m_ReasonModel.add(AppLocal.getIntString("cboption.clear")); + m_ReasonModel.add(AppLocal.getIntString("cboption.iButton")); + + webCBSecurity.setModel(m_ReasonModel); + + writeValueEOF(); + } + + /** + * + */ + @Override + public void writeValueEOF() { + m_oId = null; + m_jName.setText(null); + m_sPassword = null; + m_RoleModel.setSelectedKey(null); + m_jVisible.setSelected(false); + m_jcard.setText(null); + m_jImage.setImage(null); + m_jName.setEnabled(false); + m_jRole.setEnabled(false); + m_jVisible.setEnabled(false); + m_jcard.setEnabled(false); + m_jImage.setEnabled(false); + jButton1.setEnabled(false); + webCBSecurity.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + m_oId = null; + m_jName.setText(null); + m_sPassword = null; + m_RoleModel.setSelectedKey(null); + m_jVisible.setSelected(true); + m_jcard.setText(null); + m_jImage.setImage(null); + m_jName.setEnabled(true); + m_jRole.setEnabled(true); + m_jVisible.setEnabled(true); + m_jcard.setEnabled(true); + m_jImage.setEnabled(true); + jButton1.setEnabled(true); + webCBSecurity.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + Object[] people = (Object[]) value; + m_oId = people[0]; + m_jName.setText(Formats.STRING.formatValue(people[1])); + m_sPassword = Formats.STRING.formatValue(people[2]); + m_RoleModel.setSelectedKey(people[3]); + m_jVisible.setSelected(((Boolean) people[4]).booleanValue()); + m_jcard.setText(Formats.STRING.formatValue(people[5])); + m_jImage.setImage((BufferedImage) people[6]); + + m_jName.setEnabled(false); + m_jRole.setEnabled(false); + m_jVisible.setEnabled(false); + m_jcard.setEnabled(false); + m_jImage.setEnabled(false); + jButton1.setEnabled(false); + webCBSecurity.setEnabled(false); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + Object[] people = (Object[]) value; + m_oId = people[0]; + m_jName.setText(Formats.STRING.formatValue(people[1])); + m_sPassword = Formats.STRING.formatValue(people[2]); + m_RoleModel.setSelectedKey(people[3]); + m_jVisible.setSelected(((Boolean) people[4]).booleanValue()); + m_jcard.setText(Formats.STRING.formatValue(people[5])); + m_jImage.setImage((BufferedImage) people[6]); + + if (m_jcard.getText().length() == 16) { + jLblCardID.setText(AppLocal.getIntString("label.ibutton")); + } else { + jLblCardID.setText(AppLocal.getIntString("label.card")); + } + System.out.println(m_jcard.getText().length()); + + m_jName.setEnabled(true); + m_jRole.setEnabled(true); + m_jVisible.setEnabled(true); + m_jcard.setEnabled(true); + m_jImage.setEnabled(true); + jButton1.setEnabled(true); + webCBSecurity.setEnabled(true); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + Object[] people = new Object[7]; + people[0] = m_oId == null ? UUID.randomUUID().toString() : m_oId; + people[1] = Formats.STRING.parseValue(m_jName.getText()); + people[2] = Formats.STRING.parseValue(m_sPassword); + people[3] = m_RoleModel.getSelectedKey(); + people[4] = m_jVisible.isSelected(); + people[5] = Formats.STRING.parseValue(m_jcard.getText()); + people[6] = m_jImage.getImage(); + return people; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @throws BasicException + */ + public void activate() throws BasicException { + + m_RoleModel = new ComboBoxValModel(m_sentrole.list()); + m_jRole.setModel(m_RoleModel); + } + + + /** + * + */ + @Override + public void refresh() { + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + m_jVisible = new javax.swing.JCheckBox(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + m_jImage = new com.unicenta.data.gui.JImageEditor(); + jButton1 = new javax.swing.JButton(); + m_jRole = new javax.swing.JComboBox(); + jLabel2 = new javax.swing.JLabel(); + m_jcard = new javax.swing.JTextField(); + jLblCardID = new javax.swing.JLabel(); + webCBSecurity = new com.alee.laf.combobox.WebComboBox(); + jLabel6 = new javax.swing.JLabel(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setPreferredSize(new java.awt.Dimension(500, 500)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/info.png"))); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.peoplenamem")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(110, 30)); + jLabel1.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel1MouseClicked(evt); + } + }); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jVisible.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jVisible.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.peoplevisible")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.peopleimage")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jImage.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jImage.setPreferredSize(new java.awt.Dimension(300, 250)); + + jButton1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/password.png"))); // NOI18N + jButton1.setText(AppLocal.getIntString("button.peoplepassword")); // NOI18N + jButton1.setToolTipText(""); + jButton1.setPreferredSize(new java.awt.Dimension(80, 45)); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + m_jRole.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jRole.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.rolem")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jcard.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jcard.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLblCardID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblCardID.setText(AppLocal.getIntString("label.card")); // NOI18N + jLblCardID.setPreferredSize(new java.awt.Dimension(110, 30)); + + webCBSecurity.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Generate new key", "Delete exisitng key", "Use iButton ID" })); + webCBSecurity.setSelectedIndex(0); + webCBSecurity.setToolTipText(AppLocal.getIntString("tooltip.peoplesecurity")); // NOI18N + webCBSecurity.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + webCBSecurity.setPreferredSize(new java.awt.Dimension(140, 45)); + webCBSecurity.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + webCBSecurityActionPerformed(evt); + } + }); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.Password")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(110, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(m_jVisible, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jRole, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jImage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLblCardID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jcard, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(webCBSecurity, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLblCardID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jcard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webCBSecurity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jRole, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jVisible, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(15, 15, 15) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jImage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + + String sNewPassword = Hashcypher.changePassword(this); + if (sNewPassword != null) { + m_sPassword = sNewPassword; + m_Dirty.setDirty(true); + } + + }//GEN-LAST:event_jButton1ActionPerformed + + private void webCBSecurityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_webCBSecurityActionPerformed + + + if(webCBSecurity.getSelectedIndex() == 0){ + if (JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.cardnew"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) + { + m_jcard.setText("C" + StringUtils.getCardNumber()); + m_Dirty.setDirty(true); + } + } + + if(webCBSecurity.getSelectedIndex() == 1){ + if (JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.cardremove"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) + { + m_jcard.setText(null); + m_Dirty.setDirty(true); + } + } + + if(webCBSecurity.getSelectedIndex() == 2){ + if (JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.ibuttonassign"), + AppLocal.getIntString("title.editor"), + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE) == JOptionPane.OK_OPTION) + + { + m_jcard.setText( uOWWatch.getibuttonid() ); + jLblCardID.setText(AppLocal.getIntString("label.ibutton")); + m_Dirty.setDirty(true); + } + + } + + }//GEN-LAST:event_webCBSecurityActionPerformed + + private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel1MouseClicked + if (evt.getClickCount() == 2) { + String uuidString = m_oId.toString(); + StringSelection stringSelection = new StringSelection(uuidString); + Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); + clpbrd.setContents(stringSelection, null); + + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.uuidcopy")); + } + }//GEN-LAST:event_jLabel1MouseClicked + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLblCardID; + private com.unicenta.data.gui.JImageEditor m_jImage; + private javax.swing.JTextField m_jName; + private javax.swing.JComboBox m_jRole; + private javax.swing.JCheckBox m_jVisible; + private javax.swing.JTextField m_jcard; + private com.alee.laf.combobox.WebComboBox webCBSecurity; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/admin/ResourceType.java b/src/main/java/com/unicenta/pos/admin/ResourceType.java new file mode 100644 index 0000000..2b7ad37 --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/ResourceType.java @@ -0,0 +1,39 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.admin; + +import com.unicenta.pos.panels.ComboItemLocal; + +/** + * + * @author adrianromero + * Created on February 12, 2007, 11:50 PM + * + */ +public class ResourceType extends ComboItemLocal { + + public static final ResourceType TEXT = new ResourceType(0, "resource.text"); + public static final ResourceType IMAGE = new ResourceType(1, "resource.image"); + public static final ResourceType BINARY = new ResourceType(2, "resource.binary"); + + private ResourceType(Integer iKey, String sKeyValue) { + super(iKey, sKeyValue); + } +} diff --git a/src/main/java/com/unicenta/pos/admin/ResourcesPanel.java b/src/main/java/com/unicenta/pos/admin/ResourcesPanel.java new file mode 100644 index 0000000..2ba4336 --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/ResourcesPanel.java @@ -0,0 +1,130 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.admin; + +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSystem; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +/** + * + * @author adrianromero + */ +public class ResourcesPanel extends JPanelTable { + + private TableDefinition tresources; + private ResourcesView jeditor; + + /** Creates a new instance of JPanelResources */ + public ResourcesPanel() { + } + + /** + * + */ + protected void init() { + DataLogicAdmin dlAdmin = (DataLogicAdmin) app.getBean("com.unicenta.pos.admin.DataLogicAdmin"); + tresources = dlAdmin.getTableResources(); + jeditor = new ResourcesView(dirty); + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + if (super.deactivate()) { + DataLogicSystem dlSystem = (DataLogicSystem) app.getBean("com.unicenta.pos.forms.DataLogicSystem"); + dlSystem.resetResourcesCache(); + return true; + } else { + return false; + } + } + + /** + * + * @return + */ + public ListProvider getListProvider() { + return new ListProviderCreator(tresources); + } + + /** + * + * @return + */ + public SaveProvider getSaveProvider() { + return new SaveProvider(tresources); + } + + /** + * + * @return + */ + @Override + public Vectorer getVectorer() { + return tresources.getVectorerBasic(new int[] {1}); + } + + /** + * + * @return + */ + @Override + public ComparatorCreator getComparatorCreator() { + return tresources.getComparatorCreator(new int[] {1, 2}); + } + + /** + * + * @return + */ + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(tresources.getRenderStringBasic(new int[] {1})); + } + + /** + * + * @return + */ + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + public String getTitle() { + return AppLocal.getIntString("Menu.Resources"); + } +} diff --git a/src/main/java/com/unicenta/pos/admin/ResourcesView.form b/src/main/java/com/unicenta/pos/admin/ResourcesView.form new file mode 100644 index 0000000..9ad8345 --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/ResourcesView.form @@ -0,0 +1,164 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/admin/ResourcesView.java b/src/main/java/com/unicenta/pos/admin/ResourcesView.java new file mode 100644 index 0000000..827dbc8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/ResourcesView.java @@ -0,0 +1,377 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.admin; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.ImageUtils; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.Base64Encoder; +import java.awt.CardLayout; +import java.awt.Component; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.UUID; +import javax.swing.JFileChooser; +import javax.swing.JPanel; + +/** + * + * @author adrianromero + */ +public final class ResourcesView extends JPanel implements EditorRecord { + + private Object m_oId; + private ComboBoxValModel m_ResourceModel; + + /** Creates new form ResourcesEditor + * @param dirty */ + public ResourcesView(DirtyManager dirty) { + initComponents(); + + m_ResourceModel = new ComboBoxValModel(); + m_ResourceModel.add(ResourceType.TEXT); + m_ResourceModel.add(ResourceType.IMAGE); + m_ResourceModel.add(ResourceType.BINARY); + m_jType.setModel(m_ResourceModel); + + m_jName.getDocument().addDocumentListener(dirty); + m_jType.addActionListener(dirty); + m_jText.getDocument().addDocumentListener(dirty); + m_jImage.addPropertyChangeListener("image", dirty); + + writeValueEOF(); + } + + /** + * + */ + @Override + public void writeValueEOF() { + m_oId = null; + m_jName.setText(null); + m_ResourceModel.setSelectedItem(null); + m_jText.setText(null); + m_jImage.setImage(null); + m_jName.setEnabled(false); + m_jType.setEnabled(false); + m_jText.setEnabled(false); + m_jImage.setEnabled(false); + m_jBtnReadScript.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + m_oId = null; + m_jName.setText(null); + m_ResourceModel.setSelectedItem(ResourceType.TEXT); + m_jText.setText(null); + m_jImage.setImage(null); + m_jName.setEnabled(true); + m_jType.setEnabled(true); + m_jText.setEnabled(true); + m_jImage.setEnabled(true); + m_jBtnReadScript.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + Object[] resource = (Object[]) value; + m_oId = resource[0]; + m_jName.setText((String) resource[1]); + m_ResourceModel.setSelectedKey(resource[2]); + + ResourceType restype = (ResourceType) m_ResourceModel.getSelectedItem(); + if (restype == ResourceType.TEXT) { + m_jText.setText(Formats.BYTEA.formatValue(resource[3])); + m_jText.setCaretPosition(0); + m_jImage.setImage(null); + } else if (restype == ResourceType.IMAGE) { + m_jText.setText(null); + m_jImage.setImage(ImageUtils.readImage((byte[]) resource[3])); + } else if (restype == ResourceType.BINARY) { + m_jText.setText(resource[3] == null + ? null + : Base64Encoder.encodeChunked((byte[]) resource[3])); + m_jText.setCaretPosition(0); + m_jImage.setImage(null); + } else { + m_jText.setText(null); + m_jImage.setImage(null); + } + m_jName.setEnabled(false); + m_jType.setEnabled(false); + m_jText.setEnabled(false); + m_jImage.setEnabled(false); + m_jBtnReadScript.setEnabled(false); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + Object[] resource = (Object[]) value; + m_oId = resource[0]; + m_jName.setText((String) resource[1]); + m_ResourceModel.setSelectedKey(resource[2]); + + ResourceType restype = (ResourceType) m_ResourceModel.getSelectedItem(); + if (restype == ResourceType.TEXT) { + m_jText.setText(Formats.BYTEA.formatValue(resource[3])); + m_jText.setCaretPosition(0); + m_jImage.setImage(null); + m_jBtnReadScript.setVisible(true); + } else if (restype == ResourceType.IMAGE) { + m_jText.setText(null); + m_jImage.setImage(ImageUtils.readImage((byte[]) resource[3])); + m_jBtnReadScript.setVisible(false); + } else if (restype == ResourceType.BINARY) { + m_jText.setText(resource[2] == null + ? null + : Base64Encoder.encodeChunked((byte[]) resource[3])); + m_jText.setCaretPosition(0); + m_jImage.setImage(null); + m_jBtnReadScript.setVisible(true); + } else { + m_jText.setText(null); + m_jImage.setImage(null); + m_jBtnReadScript.setVisible(true); + } + m_jName.setEnabled(true); + m_jType.setEnabled(true); + m_jText.setEnabled(true); + m_jImage.setEnabled(true); + m_jBtnReadScript.setEnabled(true); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + Object[] resource = new Object[4]; + + resource[0] = m_oId == null ? UUID.randomUUID().toString() : m_oId; + resource[1] = m_jName.getText(); + + ResourceType restype = (ResourceType) m_ResourceModel.getSelectedItem(); + resource[2] = restype.getKey(); + if (restype == ResourceType.TEXT) { + resource[3] = Formats.BYTEA.parseValue(m_jText.getText()); + } else if (restype == ResourceType.IMAGE) { + resource[3] = ImageUtils.writeImage(m_jImage.getImage()); + } else if (restype == ResourceType.BINARY) { + resource[3] = Base64Encoder.decode(m_jText.getText()); + } else { + resource[3] = null; + } + + return resource; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + */ + @Override + public void refresh() { + } + + private void showView(String view) { + CardLayout cl = (CardLayout)(m_jContainer.getLayout()); + cl.show(m_jContainer, view); + } + + public static String readFileAsString(String fileName) { + JFileChooser chooser = new JFileChooser(); + chooser.showOpenDialog(null); + File f = chooser.getSelectedFile(); + String filename = f.getAbsolutePath(); + + String data = ""; + try { + data = new String(Files.readAllBytes(Paths.get(filename))); + } catch (IOException e) { + e.printStackTrace(); + } + return data; + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + m_jGroupType = new javax.swing.ButtonGroup(); + jPanel3 = new javax.swing.JPanel(); + m_jContainer = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + m_jText = new javax.swing.JTextArea(); + jPanel1 = new javax.swing.JPanel(); + m_jImage = new com.unicenta.data.gui.JImageEditor(); + jLabel2 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + m_jType = new javax.swing.JComboBox(); + m_jBtnReadScript = new javax.swing.JButton(); + + jPanel3.setLayout(new java.awt.BorderLayout()); + + m_jContainer.setLayout(new java.awt.CardLayout()); + + m_jText.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jScrollPane1.setViewportView(m_jText); + + m_jContainer.add(jScrollPane1, "text"); + m_jContainer.add(jPanel1, "null"); + m_jContainer.add(m_jImage, "image"); + + jPanel3.add(m_jContainer, java.awt.BorderLayout.CENTER); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.resname")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jType.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jType.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jType.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jTypeActionPerformed(evt); + } + }); + + m_jBtnReadScript.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + m_jBtnReadScript.setText(bundle.getString("button.readscript")); // NOI18N + m_jBtnReadScript.setPreferredSize(new java.awt.Dimension(80, 30)); + m_jBtnReadScript.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBtnReadScriptActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 549, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(m_jBtnReadScript, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jBtnReadScript, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, 328, Short.MAX_VALUE) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + private void m_jTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jTypeActionPerformed + + ResourceType restype = (ResourceType) m_ResourceModel.getSelectedItem(); + if (restype == ResourceType.TEXT) { + showView("text"); + m_jBtnReadScript.setVisible(true); + } else if (restype == ResourceType.IMAGE) { + showView("image"); + m_jBtnReadScript.setVisible(false); + } else if (restype == ResourceType.BINARY) { + showView("text"); + m_jBtnReadScript.setVisible(true); + } else { + showView("null"); + m_jBtnReadScript.setVisible(true); + } + + }//GEN-LAST:event_m_jTypeActionPerformed + + private void m_jBtnReadScriptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBtnReadScriptActionPerformed + String filename=""; + String data = readFileAsString(filename); + if (data != null) { + m_jText.setText(data); + } + }//GEN-LAST:event_m_jBtnReadScriptActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel2; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel3; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton m_jBtnReadScript; + private javax.swing.JPanel m_jContainer; + private javax.swing.ButtonGroup m_jGroupType; + private com.unicenta.data.gui.JImageEditor m_jImage; + private javax.swing.JTextField m_jName; + private javax.swing.JTextArea m_jText; + private javax.swing.JComboBox m_jType; + // End of variables declaration//GEN-END:variables + + +} diff --git a/src/main/java/com/unicenta/pos/admin/RoleExtInfo.java b/src/main/java/com/unicenta/pos/admin/RoleExtInfo.java new file mode 100644 index 0000000..7d62d26 --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/RoleExtInfo.java @@ -0,0 +1,80 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.admin; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; + +/** + * + * @author adrianromero + * Created on 27 de febrero de 2007, 23:46 + * + */ +public class RoleExtInfo extends RoleInfo { + + /** + * + */ + protected byte[] m_aPermissions; + + /** Creates a new instance of RoleExtInfo */ + public RoleExtInfo() { + super(); + m_aPermissions = null; + } + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_sName = dr.getString(1); + m_aPermissions = dr.getBytes(2); + } + + // implements Vectorer, ComparatorCreator + + /** + * + * @return + */ + public static String[] getHeaders() { + return new String[] {"Name"}; + } + + /** + * + * @return + */ + public String[] toStringArray() { + return new String[] {m_sName}; + } + + /** + * + * @return + */ + public Comparable[] toComparableArray() { + return new Comparable[] {m_sName}; + } +} diff --git a/src/main/java/com/unicenta/pos/admin/RoleInfo.java b/src/main/java/com/unicenta/pos/admin/RoleInfo.java new file mode 100644 index 0000000..d63d849 --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/RoleInfo.java @@ -0,0 +1,105 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.admin; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.loader.SerializableRead; + +/** + * + * @author adrianromero + * Created on 27 de febrero de 2007, 23:27 + * + */ +public class RoleInfo implements SerializableRead, IKeyed { + + private static final long serialVersionUID = 9110127845966L; + private String m_sID; + + /** + * + */ + protected String m_sName; + + /** Creates a new instance of RoleInfo */ + public RoleInfo() { + m_sID = null; + m_sName = null; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return m_sID; + } + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_sID = dr.getString(1); + m_sName = dr.getString(2); + } + + /** + * + * @param sID + */ + public void setID(String sID) { + m_sID = sID; + } + + /** + * + * @return + */ + public String getID() { + return m_sID; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + + /** + * + * @param sValue + */ + public void setName(String sValue) { + m_sName = sValue; + } + + @Override + public String toString() { + return m_sName; + } +} diff --git a/src/main/java/com/unicenta/pos/admin/RolesPanel.java b/src/main/java/com/unicenta/pos/admin/RolesPanel.java new file mode 100644 index 0000000..923a37f --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/RolesPanel.java @@ -0,0 +1,121 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.admin; + +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +/** + * + * @author adrianromero + */ +public class RolesPanel extends JPanelTable { + + private TableDefinition troles; + private TableDefinition trolesmenu; + private RolesView jeditor; + + + /** Creates a new instance of RolesPanel */ + public RolesPanel() { + } + + /** + * + */ + @Override + protected void init() { + DataLogicAdmin dlAdmin = (DataLogicAdmin) app.getBean("com.unicenta.pos.admin.DataLogicAdmin"); + troles = dlAdmin.getTableRoles(); + jeditor = new RolesView(dirty); + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return new ListProviderCreator(troles); + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(troles); + } + + /** + * + * @return + */ + @Override + public Vectorer getVectorer() { + return troles.getVectorerBasic(new int[] {1}); + } + + /** + * + * @return + */ + @Override + public ComparatorCreator getComparatorCreator() { + return troles.getComparatorCreator(new int[] {1}); + } + + /** + * + * @return + */ + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(troles.getRenderStringBasic(new int[] {1})); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Roles"); + } +} diff --git a/src/main/java/com/unicenta/pos/admin/RolesView.java b/src/main/java/com/unicenta/pos/admin/RolesView.java new file mode 100644 index 0000000..783c875 --- /dev/null +++ b/src/main/java/com/unicenta/pos/admin/RolesView.java @@ -0,0 +1,192 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.admin; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; +import java.util.UUID; + +/** + * + * @author adrianromero + */ +public final class RolesView extends javax.swing.JPanel implements EditorRecord { + + private Object m_oId; + + /** Creates new form RolesEditor + * @param dirty */ + public RolesView(DirtyManager dirty) { + initComponents(); + + m_jName.getDocument().addDocumentListener(dirty); + m_jText.getDocument().addDocumentListener(dirty); + + writeValueEOF(); + } + + /** + * + */ + @Override + public void writeValueEOF() { + m_oId = null; + m_jName.setText(null); + m_jText.setText(null); + m_jName.setEnabled(false); + m_jText.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + m_oId = null; + m_jName.setText(null); + m_jText.setText(null); + m_jName.setEnabled(true); + m_jText.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + + Object[] role = (Object[]) value; + m_oId = role[0]; + m_jName.setText(Formats.STRING.formatValue(role[1])); + m_jText.setText(Formats.BYTEA.formatValue(role[2])); + m_jText.setCaretPosition(0); + m_jName.setEnabled(false); + m_jText.setEnabled(false); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + + Object[] role = (Object[]) value; + m_oId = role[0]; + m_jName.setText(Formats.STRING.formatValue(role[1])); + m_jText.setText(Formats.BYTEA.formatValue(role[2])); + m_jText.setCaretPosition(0); + m_jName.setEnabled(true); + m_jText.setEnabled(true); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] role = new Object[3]; + role[0] = m_oId == null ? UUID.randomUUID().toString() : m_oId; + role[1] = m_jName.getText(); + role[2] = Formats.BYTEA.parseValue(m_jText.getText()); + return role; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + */ + @Override + public void refresh() { + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + m_jText = new javax.swing.JTextArea(); + jLabel2 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + + m_jText.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jScrollPane1.setViewportView(m_jText); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.namem")); // NOI18N + + m_jName.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 477, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 312, Short.MAX_VALUE) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel2; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextField m_jName; + private javax.swing.JTextArea m_jText; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/catalog/CatalogSelector.java b/src/main/java/com/unicenta/pos/catalog/CatalogSelector.java new file mode 100644 index 0000000..757983f --- /dev/null +++ b/src/main/java/com/unicenta/pos/catalog/CatalogSelector.java @@ -0,0 +1,67 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.catalog; + +import com.unicenta.basic.BasicException; +import java.awt.Component; +import java.awt.event.ActionListener; + +/** + * + * @author adrianromero + */ +public interface CatalogSelector { + + /** + * + * @throws BasicException + */ + public void loadCatalog() throws BasicException; + + /** + * + * @param id + */ + public void showCatalogPanel(String id); + + /** + * + * @param value + */ + public void setComponentEnabled(boolean value); + + /** + * + * @return + */ + public Component getComponent(); + + /** + * + * @param l + */ + public void addActionListener(ActionListener l); + + /** + * + * @param l + */ + public void removeActionListener(ActionListener l); +} diff --git a/src/main/java/com/unicenta/pos/catalog/CategoryStock.java b/src/main/java/com/unicenta/pos/catalog/CategoryStock.java new file mode 100644 index 0000000..1b5e3cd --- /dev/null +++ b/src/main/java/com/unicenta/pos/catalog/CategoryStock.java @@ -0,0 +1,118 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.catalog; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.SerializerRead; + +/** + * + * @author JG uniCenta Dec 17 + * Used in Categories to display all this Categories Products + */ + +public class CategoryStock { + + String productId; + String productName; + String productCode; + String categoryId; + + /** + * Main method to return all customer's transactions + */ + public CategoryStock() { + } + + /** + * + * @param productId + * @param productName + * @param cId + */ + public CategoryStock(String productId, String productName, String productCode, String pId) { + this.productId = productId; + this.productName = productName; + this.productCode = productCode; + this.categoryId = pId; + } + + /** + * + * @return product string + */ + public String getProductId() { + return productId; + } + public void setProductId(String productId) { + this.productId = productId; + } + + /** + * + * @return product name string + */ + public String getProductName() { + return productName; + } + public void setProductName(String productName) { + this.productName = productName; + } + + /** + * + * @return product barcode string + */ + public String getProductCode() { + return productCode; + } + public void setProductCode(String productCode) { + this.productCode = productCode; + } + + /** + * + * @return category name string + */ + public String getCategoryId() { + return categoryId; + } + public void setCategoryId(String categoryId) { + this.categoryId = categoryId; + } + + /** + * + * @return products for this category + */ + public static SerializerRead getSerializerRead() { + return new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + String productId = dr.getString(1); + String productName = dr.getString(2); + String productCode = dr.getString(3); + String categoryId = dr.getString(4); + return new CategoryStock(productId, productName, productCode, categoryId); + } + }; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/catalog/JCatalog.form b/src/main/java/com/unicenta/pos/catalog/JCatalog.form new file mode 100644 index 0000000..d62c18e --- /dev/null +++ b/src/main/java/com/unicenta/pos/catalog/JCatalog.form @@ -0,0 +1,229 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/catalog/JCatalog.java b/src/main/java/com/unicenta/pos/catalog/JCatalog.java new file mode 100644 index 0000000..caa2e75 --- /dev/null +++ b/src/main/java/com/unicenta/pos/catalog/JCatalog.java @@ -0,0 +1,622 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.catalog; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.JMessageDialog; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.sales.TaxesLogic; +import com.unicenta.pos.ticket.CategoryInfo; +import com.unicenta.pos.ticket.ProductInfoExt; +import com.unicenta.pos.ticket.TaxInfo; +import com.unicenta.pos.util.ThumbNailBuilder; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.*; +import javax.swing.*; +import javax.swing.event.EventListenerList; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +/** + * + * @author adrianromero + */ +public class JCatalog extends JPanel implements ListSelectionListener, CatalogSelector { + + /** + * + */ + protected EventListenerList listeners = new EventListenerList(); + private DataLogicSales m_dlSales; + private TaxesLogic taxeslogic; + + private boolean pricevisible; + private boolean taxesincluded; + + // Set of Products panels + private final Map m_productsset = new HashMap<>(); + + // Set of Categoriespanels + private final Set m_categoriesset = new HashSet<>(); + + private ThumbNailBuilder tnbbutton; + private ThumbNailBuilder tnbcat; + private ThumbNailBuilder tnbsubcat; + + private CategoryInfo showingcategory = null; + + /** Creates new form JCatalog + * @param dlSales */ + public JCatalog(DataLogicSales dlSales) { + this(dlSales, false, false, 90, 60); + } + + /** + * + * @param dlSales + * @param pricevisible + * @param taxesincluded + * @param width + * @param height + */ + public JCatalog(DataLogicSales dlSales, boolean pricevisible, + boolean taxesincluded, int width, int height) { + + m_dlSales = dlSales; + this.pricevisible = pricevisible; + this.taxesincluded = taxesincluded; + + initComponents(); + + m_jListCategories.addListSelectionListener(this); + + m_jscrollcat.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); + + tnbcat = new ThumbNailBuilder(48, 48, "com/unicenta/images/category.png"); + tnbsubcat = new ThumbNailBuilder(width, height, "com/unicenta/images/subcategory.png"); + tnbbutton = new ThumbNailBuilder(width, height, "com/unicenta/images/null.png"); + + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @param id + */ + @Override + public void showCatalogPanel(String id) { + + if (id == null) { + showRootCategoriesPanel(); + } else { + showProductPanel(id); + } + } + + public Component getCatComponent() { + return m_jCategories; + } + + public Component getProductComponent() { + return m_jProducts; + } + + public boolean setControls(String position) { + if (position.equals("south")) { + m_jRootCategories.add(jPanel2, BorderLayout.SOUTH); + m_jSubCategories.add(jPanel1, BorderLayout.SOUTH); + ((GridLayout) jPanel3.getLayout()).setRows(1); + ((GridLayout) jPanel5.getLayout()).setRows(1); + return true; + } + return false; + } + + + /** + * + * @throws BasicException + */ + @Override + public void loadCatalog() throws BasicException { + + // delete all categories panel + m_jProducts.removeAll(); + + m_productsset.clear(); + m_categoriesset.clear(); + + showingcategory = null; + + // Load the taxes logic + taxeslogic = new TaxesLogic(m_dlSales.getTaxList().list()); + + // Load all categories. + java.util.List categories = m_dlSales.getRootCategories(); + + // Select the first category + m_jListCategories.setCellRenderer(new SmallCategoryRenderer()); + m_jListCategories.setModel(new CategoriesListModel(categories)); // aCatList + + if (m_jListCategories.getModel().getSize() == 0) { + m_jscrollcat.setVisible(false); + jPanel2.setVisible(false); + } else { + m_jscrollcat.setVisible(true); + jPanel2.setVisible(true); + m_jListCategories.setSelectedIndex(0); + } + + showRootCategoriesPanel(); + } + + /** + * + * @param value + */ + @Override + public void setComponentEnabled(boolean value) { + + m_jListCategories.setEnabled(value); + m_jscrollcat.setEnabled(value); + m_lblIndicator.setEnabled(value); + m_btnBack1.setEnabled(value); + m_jProducts.setEnabled(value); + + synchronized (m_jProducts.getTreeLock()) { + int compCount = m_jProducts.getComponentCount(); + for (int i = 0 ; i < compCount ; i++) { + m_jProducts.getComponent(i).setEnabled(value); + } + } + + this.setEnabled(value); + } + + /** + * + * @param l + */ + @Override + public void addActionListener(ActionListener l) { + listeners.add(ActionListener.class, l); + } + + /** + * + * @param l + */ + @Override + public void removeActionListener(ActionListener l) { + listeners.remove(ActionListener.class, l); + } + + @Override + public void valueChanged(ListSelectionEvent evt) { + + if (!evt.getValueIsAdjusting()) { + int i = m_jListCategories.getSelectedIndex(); + if (i >= 0) { + // Lo hago visible... + Rectangle oRect = m_jListCategories.getCellBounds(i, i); + m_jListCategories.scrollRectToVisible(oRect); + } + } + } + + /** + * + * @param prod + */ + protected void fireSelectedProduct(ProductInfoExt prod) { + EventListener[] l = listeners.getListeners(ActionListener.class); + ActionEvent e = null; + for (EventListener l1 : l) { + if (e == null) { + e = new ActionEvent(prod, ActionEvent.ACTION_PERFORMED, prod.getID()); + } + ((ActionListener) l1).actionPerformed(e); + } + } + + private void selectCategoryPanel(String catid) { + try { + if (!m_categoriesset.contains(catid)) { + + JCatalogTab jcurrTab = new JCatalogTab(); + jcurrTab.applyComponentOrientation(getComponentOrientation()); + m_jProducts.add(jcurrTab, catid); + m_categoriesset.add(catid); + + java.util.List categories = m_dlSales.getSubcategories(catid); + for (CategoryInfo cat : categories) { + + if (cat.getCatShowName()) { + jcurrTab.addButton(new ImageIcon(tnbsubcat.getThumbNailText + (cat.getImage(), cat.getName())), + new SelectedCategory(cat),cat.getTextTip()); + }else{ + jcurrTab.addButton(new ImageIcon( + tnbsubcat.getThumbNailText(cat.getImage(), "")), + new SelectedCategory(cat),cat.getTextTip()); + } + } + + java.util.List prods = m_dlSales.getProductConstant(); + for (ProductInfoExt prod : prods) { + jcurrTab.addButton( + new ImageIcon(tnbbutton.getThumbNailText(prod.getImage(), + getProductLabel(prod))), + new SelectedAction(prod), + prod.getTextTip()); + } + + java.util.List products = m_dlSales.getProductCatalog(catid); + + for (ProductInfoExt prod : products) { + jcurrTab.addButton( + new ImageIcon(tnbbutton.getThumbNailText(prod.getImage(), + getProductLabel(prod))), + new SelectedAction(prod),prod.getTextTip()); + } + } + + CardLayout cl = (CardLayout)(m_jProducts.getLayout()); + cl.show(m_jProducts, catid); + } catch (BasicException e) { + JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.notactive"), e)); + } + } + + private String getProductLabel(ProductInfoExt product) { + + if (pricevisible) { + if (taxesincluded) { + TaxInfo tax = taxeslogic.getTaxInfo(product.getTaxCategoryID()); + if(!"".equals(product.getDisplay())){ + return "
" + product.getDisplay() + "
" + product.printPriceSellTax(tax); + } else { + return "
" + product.getName() + "
" + product.printPriceSellTax(tax); + } + } else { + if(!"".equals(product.getDisplay())){ + return "
" + product.getDisplay() + "
" + product.printPriceSell(); + } else { + return "
" + product.getName() + "
" + product.printPriceSell(); + } + } + } else { + + if (!"".equals(product.getDisplay())) { + return product.getDisplay(); + } else { + return product.getName(); + } + } + } + + private void selectIndicatorPanel(Icon icon, String label, String texttip) { + + m_lblIndicator.setText(label); + m_lblIndicator.setIcon(icon); + + // Show subcategories panel + CardLayout cl = (CardLayout)(m_jCategories.getLayout()); + cl.show(m_jCategories, "subcategories"); + } + + private void selectIndicatorCategories() { + // Show root categories panel + CardLayout cl = (CardLayout)(m_jCategories.getLayout()); + cl.show(m_jCategories, "rootcategories"); + } + + private void showRootCategoriesPanel() { + + selectIndicatorCategories(); + // Show selected root category + CategoryInfo cat = (CategoryInfo) m_jListCategories.getSelectedValue(); + + if (cat != null) { + selectCategoryPanel(cat.getID()); + } + showingcategory = null; + } + + private void showSubcategoryPanel(CategoryInfo category) { +// Modified JDL 13.04.13 +// this is the new panel that displays when a sub catergory is selected mouse does not work here + selectIndicatorPanel(new ImageIcon(tnbsubcat.getThumbNail( + category.getImage())),category.getName(), category.getTextTip()); + selectCategoryPanel(category.getID()); + showingcategory = category; + } + + private void showProductPanel(String id) { + + ProductInfoExt product = m_productsset.get(id); + + if (product == null) { + if (m_productsset.containsKey(id)) { + // It is an empty panel + if (showingcategory == null) { + showRootCategoriesPanel(); + } else { + showSubcategoryPanel(showingcategory); + } + } else { + try { + // Create products panel + java.util.List products = m_dlSales.getProductComments(id); + + if (products.isEmpty()) { + m_productsset.put(id, null); + + if (showingcategory == null) { + showRootCategoriesPanel(); + } else { + showSubcategoryPanel(showingcategory); + } + } else { + + product = m_dlSales.getProductInfo(id); + m_productsset.put(id, product); + + JCatalogTab jcurrTab = new JCatalogTab(); + jcurrTab.applyComponentOrientation(getComponentOrientation()); + m_jProducts.add(jcurrTab, "PRODUCT." + id); + + // Add products + for (ProductInfoExt prod : products) { + jcurrTab.addButton(new ImageIcon(tnbbutton.getThumbNailText(prod.getImage(), + getProductLabel(prod))), new SelectedAction(prod),prod.getTextTip()); + } + selectIndicatorPanel(new ImageIcon(tnbbutton.getThumbNail(product.getImage())), + product.getDisplay(), product.getTextTip()); + + CardLayout cl = (CardLayout)(m_jProducts.getLayout()); + cl.show(m_jProducts, "PRODUCT." + id); + } + } catch (BasicException eb) { + m_productsset.put(id, null); + if (showingcategory == null) { + showRootCategoriesPanel(); + } else { + showSubcategoryPanel(showingcategory); + } + } + } + } else { + selectIndicatorPanel(new ImageIcon(tnbbutton.getThumbNail( + product.getImage())), product.getName(), product.getTextTip()); + + CardLayout cl = (CardLayout)(m_jProducts.getLayout()); + cl.show(m_jProducts, "PRODUCT." + id); + } + } + + private class SelectedAction implements ActionListener { + private final ProductInfoExt prod; + public SelectedAction(ProductInfoExt prod) { + this.prod = prod; + } + @Override + public void actionPerformed(ActionEvent e) { + fireSelectedProduct(prod); + } + } + + private class SelectedCategory implements ActionListener { + private final CategoryInfo category; + public SelectedCategory(CategoryInfo category) { + this.category = category; + } + @Override + public void actionPerformed(ActionEvent e) { + showSubcategoryPanel(category); + } + } + + private class CategoriesListModel extends AbstractListModel { + private final java.util.List m_aCategories; + public CategoriesListModel(java.util.List aCategories) { + m_aCategories = aCategories; + } + @Override + public int getSize() { + return m_aCategories.size(); + } + @Override + public Object getElementAt(int i) { + return m_aCategories.get(i); + } + } + + private class SmallCategoryRenderer extends DefaultListCellRenderer { + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + super.getListCellRendererComponent(list, null, index, isSelected, cellHasFocus); + CategoryInfo cat = (CategoryInfo) value; + setText(cat.getName()); + setIcon(new ImageIcon(tnbcat.getThumbNail(cat.getImage()))); + + return this; + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + m_jCategories = new javax.swing.JPanel(); + m_jRootCategories = new javax.swing.JPanel(); + m_jscrollcat = new javax.swing.JScrollPane(); + m_jListCategories = new javax.swing.JList(); + jPanel2 = new javax.swing.JPanel(); + jPanel3 = new javax.swing.JPanel(); + m_jSubCategories = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + m_lblIndicator = new javax.swing.JLabel(); + jPanel1 = new javax.swing.JPanel(); + jPanel5 = new javax.swing.JPanel(); + m_btnBack1 = new javax.swing.JButton(); + m_jProducts = new javax.swing.JPanel(); + + setLayout(new java.awt.BorderLayout()); + + m_jCategories.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jCategories.setMaximumSize(new java.awt.Dimension(275, 600)); + m_jCategories.setPreferredSize(new java.awt.Dimension(265, 0)); + m_jCategories.setLayout(new java.awt.CardLayout()); + + m_jRootCategories.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + m_jRootCategories.setMinimumSize(new java.awt.Dimension(200, 100)); + m_jRootCategories.setPreferredSize(new java.awt.Dimension(275, 130)); + m_jRootCategories.setLayout(new java.awt.BorderLayout()); + + m_jscrollcat.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + m_jscrollcat.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + m_jscrollcat.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jscrollcat.setPreferredSize(new java.awt.Dimension(265, 130)); + + m_jListCategories.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jListCategories.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + m_jListCategories.setFocusable(false); + m_jListCategories.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + m_jListCategoriesValueChanged(evt); + } + }); + m_jscrollcat.setViewportView(m_jListCategories); + + m_jRootCategories.add(m_jscrollcat, java.awt.BorderLayout.CENTER); + + jPanel2.setLayout(new java.awt.BorderLayout()); + + jPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5)); + jPanel3.setLayout(new java.awt.GridLayout(0, 1, 0, 5)); + jPanel2.add(jPanel3, java.awt.BorderLayout.NORTH); + + m_jRootCategories.add(jPanel2, java.awt.BorderLayout.LINE_END); + + m_jCategories.add(m_jRootCategories, "rootcategories"); + + m_jSubCategories.setLayout(new java.awt.BorderLayout()); + + jPanel4.setLayout(new java.awt.BorderLayout()); + + m_lblIndicator.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_lblIndicator.setText("jLabel1"); + jPanel4.add(m_lblIndicator, java.awt.BorderLayout.NORTH); + + m_jSubCategories.add(jPanel4, java.awt.BorderLayout.WEST); + + jPanel1.setLayout(new java.awt.BorderLayout()); + + jPanel5.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5)); + jPanel5.setLayout(new java.awt.GridLayout(0, 1, 0, 5)); + + m_btnBack1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/2uparrow.png"))); // NOI18N + m_btnBack1.setFocusPainted(false); + m_btnBack1.setFocusable(false); + m_btnBack1.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_btnBack1.setPreferredSize(new java.awt.Dimension(60, 45)); + m_btnBack1.setRequestFocusEnabled(false); + m_btnBack1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_btnBack1ActionPerformed(evt); + } + }); + jPanel5.add(m_btnBack1); + + jPanel1.add(jPanel5, java.awt.BorderLayout.NORTH); + + m_jSubCategories.add(jPanel1, java.awt.BorderLayout.LINE_END); + + m_jCategories.add(m_jSubCategories, "subcategories"); + + add(m_jCategories, java.awt.BorderLayout.LINE_START); + + m_jProducts.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jProducts.setLayout(new java.awt.CardLayout()); + add(m_jProducts, java.awt.BorderLayout.CENTER); + }// //GEN-END:initComponents + + private void m_jListCategoriesValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_m_jListCategoriesValueChanged + + if (!evt.getValueIsAdjusting()) { + CategoryInfo cat = (CategoryInfo) m_jListCategories.getSelectedValue(); + if (cat != null) { + selectCategoryPanel(cat.getID()); + } + } + + }//GEN-LAST:event_m_jListCategoriesValueChanged + + private void m_btnBack1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_btnBack1ActionPerformed + + showRootCategoriesPanel(); + + }//GEN-LAST:event_m_btnBack1ActionPerformed + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JButton m_btnBack1; + private javax.swing.JPanel m_jCategories; + private javax.swing.JList m_jListCategories; + private javax.swing.JPanel m_jProducts; + private javax.swing.JPanel m_jRootCategories; + private javax.swing.JPanel m_jSubCategories; + private javax.swing.JScrollPane m_jscrollcat; + private javax.swing.JLabel m_lblIndicator; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/catalog/JCatalogTab.form b/src/main/java/com/unicenta/pos/catalog/JCatalogTab.form new file mode 100644 index 0000000..5f7b79d --- /dev/null +++ b/src/main/java/com/unicenta/pos/catalog/JCatalogTab.form @@ -0,0 +1,22 @@ + + +
+ + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/catalog/JCatalogTab.java b/src/main/java/com/unicenta/pos/catalog/JCatalogTab.java new file mode 100644 index 0000000..5882ed6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/catalog/JCatalogTab.java @@ -0,0 +1,98 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.catalog; + +import com.unicenta.beans.JFlowPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Insets; +import java.awt.event.ActionListener; +import javax.swing.*; + +/** + * + * @author adrianromero + */ +public class JCatalogTab extends javax.swing.JPanel { + + private JFlowPanel flowpanel; + + /** Creates new form JCategoryProducts */ + public JCatalogTab() { + initComponents(); + + flowpanel = new JFlowPanel(); + JScrollPane scroll = new JScrollPane(flowpanel); + scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + scroll.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); + + add(scroll, BorderLayout.CENTER); + } + + @Override + public void setEnabled(boolean value) { + flowpanel.setEnabled(value); + super.setEnabled(value); + } + + /** + * + * @param ico + * @param al + * @param textTip + */ + public void addButton(Icon ico, ActionListener al, String textTip) { + JButton btn = new JButton(); + btn.applyComponentOrientation(getComponentOrientation()); + btn.setIcon(ico); + btn.setFocusPainted(false); + btn.setFocusable(false); + + if (textTip != null){ + btn.setToolTipText(textTip); + } + + btn.setRequestFocusEnabled(false); + btn.setHorizontalTextPosition(SwingConstants.CENTER); + btn.setVerticalTextPosition(SwingConstants.BOTTOM); + btn.setMargin(new Insets(2, 2, 2, 2)); + btn.addActionListener(al); + + flowpanel.add(btn); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setLayout(new java.awt.BorderLayout()); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/catalog/JProductsSelector.form b/src/main/java/com/unicenta/pos/catalog/JProductsSelector.form new file mode 100644 index 0000000..28175e5 --- /dev/null +++ b/src/main/java/com/unicenta/pos/catalog/JProductsSelector.form @@ -0,0 +1,44 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/catalog/JProductsSelector.java b/src/main/java/com/unicenta/pos/catalog/JProductsSelector.java new file mode 100644 index 0000000..1aae710 --- /dev/null +++ b/src/main/java/com/unicenta/pos/catalog/JProductsSelector.java @@ -0,0 +1,95 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.catalog; + +import com.unicenta.beans.JFlowPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Image; +import java.awt.Insets; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.SwingConstants; + +/** + * + * @author adrianromero + */ +public class JProductsSelector extends javax.swing.JPanel { + + private final JFlowPanel flowpanel; + + /** Creates new form JProductsSelector */ + public JProductsSelector() { + initComponents(); + + flowpanel = new JFlowPanel(); + + add(flowpanel, BorderLayout.CENTER); + } + + + /** + * + * @param img + * @param display + * @param al + * @param textTip + */ + public void addProduct(Image img, String display, ActionListener al,String textTip) { + JButton btn = new JButton(); + btn.applyComponentOrientation(getComponentOrientation()); + btn.setText(display); + btn.setFocusPainted(false); + + if (textTip != null){ + btn.setToolTipText(textTip); + } + + btn.setFocusable(false); + btn.setRequestFocusEnabled(false); + btn.setHorizontalTextPosition(SwingConstants.CENTER); + btn.setVerticalTextPosition(SwingConstants.TOP); + btn.setMargin(new Insets(0, 0, 0, 0)); + btn.setMaximumSize(new Dimension(80, 70)); +// btn.setPreferredSize(new Dimension(20, 20)); + btn.setMinimumSize(new Dimension(40, 30)); + btn.addActionListener(al); + + flowpanel.add(btn); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setLayout(new org.jdesktop.swingx.VerticalLayout()); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/comm/CommStream.java b/src/main/java/com/unicenta/pos/comm/CommStream.java new file mode 100644 index 0000000..75b6fc7 --- /dev/null +++ b/src/main/java/com/unicenta/pos/comm/CommStream.java @@ -0,0 +1,123 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.comm; + +import gnu.io.CommPort; +import gnu.io.CommPortIdentifier; +import gnu.io.ParallelPort; +import gnu.io.SerialPort; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * + * @author adrianromero + */ +public class CommStream { + + private String m_sPort; + + private CommPortIdentifier m_PortIdPrinter; + private CommPort m_CommPortPrinter; + + private OutputStream m_out; + private InputStream m_in; + + /** Creates a new instance of CommPort + * @param port */ + public CommStream(String port) { + m_sPort = port; + + m_PortIdPrinter = null; + m_CommPortPrinter = null; + m_out = null; + m_in = null; + } + + private void init() { + + try { + if (m_out == null) { + m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPort); // Tomamos el puerto + m_CommPortPrinter = m_PortIdPrinter.open("PORTID", 2000); // Abrimos el puerto + + m_out = m_CommPortPrinter.getOutputStream(); // Tomamos el chorro de escritura + + if (m_PortIdPrinter.getPortType() == CommPortIdentifier.PORT_SERIAL) { + ((SerialPort)m_CommPortPrinter).setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); // Configuramos el puerto + } else if (m_PortIdPrinter.getPortType() == CommPortIdentifier.PORT_PARALLEL) { + ((ParallelPort)m_CommPortPrinter).setMode(1); + } + } + } catch (Exception e) { + m_PortIdPrinter = null; + m_CommPortPrinter = null; + m_out = null; + m_in = null; +// } catch (NoSuchPortException e) { +// } catch (PortInUseException e) { +// } catch (UnsupportedCommOperationException e) { +// } catch (IOException e) { + } + } + + /** + * + * @throws IOException + */ + public void closeAll() throws IOException { + + if (m_out != null) { + m_in = null; + m_out.flush(); + m_out.close(); + m_out = null; + m_CommPortPrinter = null; + m_PortIdPrinter = null; + } + } + + /** + * + * @return + */ + public String getPort() { + return m_sPort; + } + + /** + * + * @return + */ + public InputStream getIn() { + init(); + return m_in; + } + + /** + * + * @return + */ + public OutputStream getOut() { + init(); + return m_out; + } +} diff --git a/src/main/java/com/unicenta/pos/config/JFrmConfig.form b/src/main/java/com/unicenta/pos/config/JFrmConfig.form new file mode 100644 index 0000000..8f7b4a2 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JFrmConfig.form @@ -0,0 +1,31 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/config/JFrmConfig.java b/src/main/java/com/unicenta/pos/config/JFrmConfig.java new file mode 100644 index 0000000..8d4c28a --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JFrmConfig.java @@ -0,0 +1,128 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.config; + +import com.alee.laf.WebLookAndFeel; +import com.unicenta.basic.BasicException; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppProperties; +import com.unicenta.pos.forms.JRootFrame; +import java.awt.BorderLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.IOException; +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.plaf.metal.MetalLookAndFeel; + +/** + * + * @author adrianromero + */ +public class JFrmConfig extends javax.swing.JFrame { + + private final JPanelConfiguration config; + + /** Creates new form JFrmConfig + * @param props */ + public JFrmConfig(AppProperties props) { + + initComponents(); + + try { + this.setIconImage(ImageIO.read(JRootFrame.class.getResourceAsStream("/com/unicenta/images/favicon.png"))); + } catch (IOException e) { + } + setTitle(AppLocal.APP_NAME + " - " + AppLocal.APP_VERSION + " - " + AppLocal.getIntString("Menu.Configuration")); + + addWindowListener(new MyFrameListener()); + + config = new JPanelConfiguration(props); + + getContentPane().add(config, BorderLayout.CENTER); + + try { + config.activate(); + } catch (BasicException e) { // never thrown ;-) + } + } + + private class MyFrameListener extends WindowAdapter{ + + @Override + public void windowClosing(WindowEvent evt) { + if (config.deactivate()) { + dispose(); + } + } + @Override + public void windowClosed(WindowEvent evt) { + System.exit(0); + } + } + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); + setMinimumSize(new java.awt.Dimension(950, 450)); + setPreferredSize(new java.awt.Dimension(950, 500)); + + setSize(new java.awt.Dimension(808, 794)); + setLocationRelativeTo(null); + }// //GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(final String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + + AppConfig config = new AppConfig(args); + config.load(); + + // Set the look and feel + try { + Object laf = Class.forName(config.getProperty("swing.defaultlaf")).newInstance(); + if (!(laf instanceof MetalLookAndFeel) && laf instanceof LookAndFeel) { + UIManager.setLookAndFeel((LookAndFeel) laf); + } else { + UIManager.setLookAndFeel("com.formdev.flatlaf.intellijthemes.FlatGrayIJTheme"); + } + } catch (Exception e) { + System.out.println("Cannot set Look and Feel "+e.getMessage()); + } + + new JFrmConfig(config).setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigCompany.form b/src/main/java/com/unicenta/pos/config/JPanelConfigCompany.form new file mode 100644 index 0000000..f01b04b --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigCompany.form @@ -0,0 +1,492 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigCompany.java b/src/main/java/com/unicenta/pos/config/JPanelConfigCompany.java new file mode 100644 index 0000000..3b8fe75 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigCompany.java @@ -0,0 +1,425 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.config; + +import com.unicenta.data.user.DirtyManager; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; +import javax.swing.ImageIcon; + +/** + * + * @author JG uniCenta + */ +public class JPanelConfigCompany extends javax.swing.JPanel implements PanelConfig { + + private final DirtyManager dirty = new DirtyManager(); + + + /** + * + */ + public JPanelConfigCompany() { + + initComponents(); + + jtxtTktHeader1.getDocument().addDocumentListener(dirty); + jtxtTktHeader2.getDocument().addDocumentListener(dirty); + jtxtTktHeader3.getDocument().addDocumentListener(dirty); + jtxtTktHeader4.getDocument().addDocumentListener(dirty); + jtxtTktHeader5.getDocument().addDocumentListener(dirty); + jtxtTktHeader6.getDocument().addDocumentListener(dirty); + + jtxtTktFooter1.getDocument().addDocumentListener(dirty); + jtxtTktFooter2.getDocument().addDocumentListener(dirty); + jtxtTktFooter3.getDocument().addDocumentListener(dirty); + jtxtTktFooter4.getDocument().addDocumentListener(dirty); + jtxtTktFooter5.getDocument().addDocumentListener(dirty); + jtxtTktFooter6.getDocument().addDocumentListener(dirty); + +// JG - For future + lblLogo.setVisible(false); + jLbllogoPath.setVisible(false); + webSwtch_Logo.setVisible(false); + + } + + /** + * + * @return + */ + @Override + public boolean hasChanged() { + return dirty.isDirty(); + } + + /** + * + * @return + */ + @Override + public Component getConfigComponent() { + return this; + } + + /** + * + * @param config + */ + @Override + public void loadProperties(AppConfig config) { + + jtxtTktHeader1.setText(config.getProperty("tkt.header1")); + jtxtTktHeader2.setText(config.getProperty("tkt.header2")); + jtxtTktHeader3.setText(config.getProperty("tkt.header3")); + jtxtTktHeader4.setText(config.getProperty("tkt.header4")); + jtxtTktHeader5.setText(config.getProperty("tkt.header5")); + jtxtTktHeader6.setText(config.getProperty("tkt.header6")); + + jtxtTktFooter1.setText(config.getProperty("tkt.footer1")); + jtxtTktFooter2.setText(config.getProperty("tkt.footer2")); + jtxtTktFooter3.setText(config.getProperty("tkt.footer3")); + jtxtTktFooter4.setText(config.getProperty("tkt.footer4")); + jtxtTktFooter5.setText(config.getProperty("tkt.footer5")); + jtxtTktFooter6.setText(config.getProperty("tkt.footer6")); + +/** JG - here for future per terminal + jLbllogoPath.setText(config.getProperty("tkt.logopath")); + ImageIcon image = new ImageIcon(jLbllogoPath.getText()); + jLogo.setIcon(image); +*/ + dirty.setDirty(false); + } + + /** + * + * @param config + */ + @Override + public void saveProperties(AppConfig config) { + + config.setProperty("tkt.header1", jtxtTktHeader1.getText()); + config.setProperty("tkt.header2", jtxtTktHeader2.getText()); + config.setProperty("tkt.header3", jtxtTktHeader3.getText()); + config.setProperty("tkt.header4", jtxtTktHeader4.getText()); + config.setProperty("tkt.header5", jtxtTktHeader5.getText()); + config.setProperty("tkt.header6", jtxtTktHeader6.getText()); + + config.setProperty("tkt.footer1", jtxtTktFooter1.getText()); + config.setProperty("tkt.footer2", jtxtTktFooter2.getText()); + config.setProperty("tkt.footer3", jtxtTktFooter3.getText()); + config.setProperty("tkt.footer4", jtxtTktFooter4.getText()); + config.setProperty("tkt.footer5", jtxtTktFooter5.getText()); + config.setProperty("tkt.footer6", jtxtTktFooter6.getText()); + + config.setProperty("tkt.logopath", jLbllogoPath.getText()); + + dirty.setDirty(false); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + lblTktHeader1 = new javax.swing.JLabel(); + lblTktFooter1 = new javax.swing.JLabel(); + webSwtch_Logo = new com.alee.extended.button.WebSwitch(); + jPanel1 = new javax.swing.JPanel(); + jtxtTktHeader3 = new javax.swing.JTextField(); + jtxtTktFooter6 = new javax.swing.JTextField(); + jtxtTktHeader2 = new javax.swing.JTextField(); + jtxtTktHeader5 = new javax.swing.JTextField(); + jtxtTktHeader6 = new javax.swing.JTextField(); + jtxtTktFooter4 = new javax.swing.JTextField(); + jtxtTktHeader4 = new javax.swing.JTextField(); + jtxtTktFooter5 = new javax.swing.JTextField(); + jtxtTktHeader1 = new javax.swing.JTextField(); + jtxtTktFooter3 = new javax.swing.JTextField(); + jtxtTktFooter2 = new javax.swing.JTextField(); + jtxtTktFooter1 = new javax.swing.JTextField(); + jLogo = new javax.swing.JLabel(); + jLbllogoPath = new javax.swing.JLabel(); + lblLogo = new javax.swing.JLabel(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setOpaque(false); + setPreferredSize(new java.awt.Dimension(700, 500)); + + lblTktHeader1.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + lblTktHeader1.setText(AppLocal.getIntString("label.tktheader1")); // NOI18N + lblTktHeader1.setMaximumSize(new java.awt.Dimension(0, 25)); + lblTktHeader1.setMinimumSize(new java.awt.Dimension(0, 0)); + lblTktHeader1.setPreferredSize(new java.awt.Dimension(150, 30)); + + lblTktFooter1.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + lblTktFooter1.setText(AppLocal.getIntString("label.tktfooter1")); // NOI18N + lblTktFooter1.setMaximumSize(new java.awt.Dimension(0, 25)); + lblTktFooter1.setMinimumSize(new java.awt.Dimension(0, 0)); + lblTktFooter1.setPreferredSize(new java.awt.Dimension(150, 30)); + + webSwtch_Logo.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + webSwtch_Logo.setPreferredSize(new java.awt.Dimension(80, 30)); + webSwtch_Logo.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + webSwtch_LogoActionPerformed(evt); + } + }); + + jtxtTktHeader3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtTktHeader3.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jtxtTktHeader3.setBorder(null); + jtxtTktHeader3.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtTktHeader3.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtTktHeader3.setPreferredSize(new java.awt.Dimension(300, 30)); + + jtxtTktFooter6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtTktFooter6.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jtxtTktFooter6.setBorder(null); + jtxtTktFooter6.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtTktFooter6.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtTktFooter6.setPreferredSize(new java.awt.Dimension(300, 30)); + + jtxtTktHeader2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtTktHeader2.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jtxtTktHeader2.setBorder(null); + jtxtTktHeader2.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtTktHeader2.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtTktHeader2.setPreferredSize(new java.awt.Dimension(300, 30)); + + jtxtTktHeader5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtTktHeader5.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jtxtTktHeader5.setBorder(null); + jtxtTktHeader5.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtTktHeader5.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtTktHeader5.setPreferredSize(new java.awt.Dimension(300, 30)); + + jtxtTktHeader6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtTktHeader6.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jtxtTktHeader6.setBorder(null); + jtxtTktHeader6.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtTktHeader6.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtTktHeader6.setPreferredSize(new java.awt.Dimension(300, 30)); + + jtxtTktFooter4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtTktFooter4.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jtxtTktFooter4.setBorder(null); + jtxtTktFooter4.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtTktFooter4.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtTktFooter4.setPreferredSize(new java.awt.Dimension(300, 30)); + + jtxtTktHeader4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtTktHeader4.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jtxtTktHeader4.setBorder(null); + jtxtTktHeader4.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtTktHeader4.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtTktHeader4.setPreferredSize(new java.awt.Dimension(300, 30)); + + jtxtTktFooter5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtTktFooter5.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jtxtTktFooter5.setBorder(null); + jtxtTktFooter5.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtTktFooter5.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtTktFooter5.setPreferredSize(new java.awt.Dimension(300, 30)); + + jtxtTktHeader1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtTktHeader1.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jtxtTktHeader1.setBorder(null); + jtxtTktHeader1.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtTktHeader1.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtTktHeader1.setPreferredSize(new java.awt.Dimension(300, 30)); + + jtxtTktFooter3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtTktFooter3.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jtxtTktFooter3.setBorder(null); + jtxtTktFooter3.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtTktFooter3.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtTktFooter3.setPreferredSize(new java.awt.Dimension(300, 30)); + + jtxtTktFooter2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtTktFooter2.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jtxtTktFooter2.setBorder(null); + jtxtTktFooter2.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtTktFooter2.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtTktFooter2.setPreferredSize(new java.awt.Dimension(300, 30)); + + jtxtTktFooter1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtTktFooter1.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jtxtTktFooter1.setBorder(null); + jtxtTktFooter1.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtTktFooter1.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtTktFooter1.setPreferredSize(new java.awt.Dimension(300, 30)); + + jLogo.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLogo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/printer.ticket.logo.jpg"))); // NOI18N + jLogo.setToolTipText(""); + jLogo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jLogo.setOpaque(true); + jLogo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jtxtTktFooter5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jtxtTktFooter4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jtxtTktFooter3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jtxtTktFooter2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jtxtTktFooter1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jtxtTktHeader6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jtxtTktHeader5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jtxtTktHeader4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jtxtTktHeader3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jtxtTktHeader2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jtxtTktHeader1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jtxtTktFooter6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLogo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 91, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jtxtTktHeader1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(1, 1, 1) + .addComponent(jtxtTktHeader2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(1, 1, 1) + .addComponent(jtxtTktHeader3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(1, 1, 1) + .addComponent(jtxtTktHeader4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(1, 1, 1) + .addComponent(jtxtTktHeader5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(1, 1, 1) + .addComponent(jtxtTktHeader6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jtxtTktFooter1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(1, 1, 1) + .addComponent(jtxtTktFooter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(1, 1, 1) + .addComponent(jtxtTktFooter3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(1, 1, 1) + .addComponent(jtxtTktFooter4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(1, 1, 1) + .addComponent(jtxtTktFooter5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(1, 1, 1) + .addComponent(jtxtTktFooter6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + jLbllogoPath.setBackground(new java.awt.Color(255, 255, 255)); + jLbllogoPath.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLbllogoPath.setForeground(new java.awt.Color(153, 153, 153)); + jLbllogoPath.setText(AppLocal.getIntString("label.tktheader1")); // NOI18N + jLbllogoPath.setMaximumSize(new java.awt.Dimension(0, 25)); + jLbllogoPath.setMinimumSize(new java.awt.Dimension(0, 0)); + jLbllogoPath.setPreferredSize(new java.awt.Dimension(150, 30)); + + lblLogo.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + lblLogo.setText(AppLocal.getIntString("label.tktheader1")); // NOI18N + lblLogo.setMaximumSize(new java.awt.Dimension(0, 25)); + lblLogo.setMinimumSize(new java.awt.Dimension(0, 0)); + lblLogo.setPreferredSize(new java.awt.Dimension(150, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(lblTktFooter1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(lblTktHeader1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(lblLogo, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(webSwtch_Logo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(jLbllogoPath, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(214, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(39, 39, 39) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(lblLogo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webSwtch_Logo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(55, 55, 55) + .addComponent(lblTktHeader1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(163, 163, 163) + .addComponent(lblTktFooter1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(70, 70, 70) + .addComponent(jLbllogoPath, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void webSwtch_LogoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_webSwtch_LogoActionPerformed +// JG - For future + if (webSwtch_Logo.isSelected()) { + + } else { + + } + + }//GEN-LAST:event_webSwtch_LogoActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLbllogoPath; + private javax.swing.JLabel jLogo; + private javax.swing.JPanel jPanel1; + private javax.swing.JTextField jtxtTktFooter1; + private javax.swing.JTextField jtxtTktFooter2; + private javax.swing.JTextField jtxtTktFooter3; + private javax.swing.JTextField jtxtTktFooter4; + private javax.swing.JTextField jtxtTktFooter5; + private javax.swing.JTextField jtxtTktFooter6; + private javax.swing.JTextField jtxtTktHeader1; + private javax.swing.JTextField jtxtTktHeader2; + private javax.swing.JTextField jtxtTktHeader3; + private javax.swing.JTextField jtxtTktHeader4; + private javax.swing.JTextField jtxtTktHeader5; + private javax.swing.JTextField jtxtTktHeader6; + private javax.swing.JLabel lblLogo; + private javax.swing.JLabel lblTktFooter1; + private javax.swing.JLabel lblTktHeader1; + private com.alee.extended.button.WebSwitch webSwtch_Logo; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigDatabase.form b/src/main/java/com/unicenta/pos/config/JPanelConfigDatabase.form new file mode 100644 index 0000000..ba778bb --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigDatabase.form @@ -0,0 +1,1150 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigDatabase.java b/src/main/java/com/unicenta/pos/config/JPanelConfigDatabase.java new file mode 100644 index 0000000..dc66f05 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigDatabase.java @@ -0,0 +1,1298 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.config; + +import com.unicenta.data.gui.JMessageDialog; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.Session; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DriverWrapper; +import com.unicenta.pos.util.AltEncrypter; +import com.unicenta.pos.util.DirectoryEvent; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import java.awt.*; +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.sql.*; + +/** + * @author Jack Gerrard + * @author adrianromero + */ +@Slf4j +public class JPanelConfigDatabase extends javax.swing.JPanel implements PanelConfig { + + private final DirtyManager dirty = new DirtyManager(); + + /** Creates new form JPanelConfigDatabase */ + public JPanelConfigDatabase() { + + initComponents(); + + dbDriverLibraryValue.getDocument().addDocumentListener(dirty); + dbDriverClassValue.getDocument().addDocumentListener(dirty); + dbDriverLibrarySelect.addActionListener(new DirectoryEvent(dbDriverLibraryValue)); + jcboDBDriver.addActionListener(dirty); + // still in development! + //jcboDBDriver.addItem("SQLite"); + jcboDBDriver.addItem("Apache Derby"); + jcboDBDriver.addItem("MariaDB"); + jcboDBDriver.addItem("MySQL"); + jcboDBDriver.setSelectedIndex(0); + multiDBButton.addActionListener(dirty); + +// primary DB + dbNameValue.getDocument().addDocumentListener(dirty); + dbURLValue.getDocument().addDocumentListener(dirty); + jtxtDbSchema.getDocument().addDocumentListener(dirty); + jtxtDbOptions.getDocument().addDocumentListener(dirty); + dbPasswordValue.getDocument().addDocumentListener(dirty); + dbUserValue.getDocument().addDocumentListener(dirty); + jCBSchema.addActionListener(dirty); + +// secondary DB + db2NameValue.getDocument().addDocumentListener(dirty); + db2URLValue.getDocument().addDocumentListener(dirty); + jtxtDbSchema1.getDocument().addDocumentListener(dirty); + db2OptionsValue.getDocument().addDocumentListener(dirty); + db2PasswordValue.getDocument().addDocumentListener(dirty); + db2UserValue.getDocument().addDocumentListener(dirty); + jCBSchema1.addActionListener(dirty); + + dbConfigPanel.setVisible(false); + validUserAlert.setVisible(true); + dbVersionLabel.setVisible(false); + } + + /** + * + * @return + */ + @Override + public boolean hasChanged() { + return dirty.isDirty(); + } + + /** + * + * @return + */ + @Override + public Component getConfigComponent() { + return this; + } + + /** + * + * @param config + */ + @Override + public void loadProperties(AppConfig config) { + + multiDBButton.setSelected(Boolean.parseBoolean(config.getProperty("db.multi"))); + + jcboDBDriver.setSelectedItem(config.getProperty("db.engine")); + dbDriverLibraryValue.setText(config.getProperty("db.driverlib")); + dbDriverClassValue.setText(config.getProperty("db.driver")); + +// primary DB + dbNameValue.setText(config.getProperty("db.name")); + dbURLValue.setText("jdbc:mysql://localhost:3306/"); + dbURLValue.setText(config.getProperty("db.URL")); + jtxtDbSchema.setText(config.getProperty("db.schema")); + jtxtDbOptions.setText(config.getProperty("db.options")); + String sDBUser = config.getProperty("db.user"); + String sDBPassword = config.getProperty("db.password"); + + if (sDBUser != null && sDBPassword != null && sDBPassword.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + sDBUser); + sDBPassword = cypher.decrypt(sDBPassword.substring(6)); + } + dbUserValue.setText(sDBUser); + dbPasswordValue.setText(sDBPassword); + +// secondary DB + db2NameValue.setText(config.getProperty("db1.name")); + db2URLValue.setText(config.getProperty("db1.URL")); + jtxtDbSchema1.setText(config.getProperty("db1.schema")); + jtxtDbSchema1.setEnabled(false); + db2OptionsValue.setText(config.getProperty("db1.options")); + String sDBUser1 = config.getProperty("db1.user"); + String sDBPassword1 = config.getProperty("db1.password"); + + if (sDBUser1 != null && sDBPassword1 != null && sDBPassword1.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + sDBUser1); + sDBPassword1 = cypher.decrypt(sDBPassword1.substring(6)); + } + db2UserValue.setText(sDBUser1); + db2PasswordValue.setText(sDBPassword1); + + dirty.setDirty(false); + } + + /** + * + * @param config + */ + @Override + public void saveProperties(AppConfig config) { + +// multi-db + config.setProperty("db.multi",Boolean.toString(multiDBButton.isSelected())); + + config.setProperty("db.engine", comboValue(jcboDBDriver.getSelectedItem())); + config.setProperty("db.driverlib", dbDriverLibraryValue.getText()); + config.setProperty("db.driver", dbDriverClassValue.getText()); + +// primary DB + config.setProperty("db.name", dbNameValue.getText()); + config.setProperty("db.URL", dbURLValue.getText()); + config.setProperty("db.schema", jtxtDbSchema.getText()); + config.setProperty("db.options", jtxtDbOptions.getText()); + config.setProperty("db.user", dbUserValue.getText()); + AltEncrypter cypher = new AltEncrypter("cypherkey" + dbUserValue.getText()); + config.setProperty("db.password", "crypt:" + + cypher.encrypt(new String(dbPasswordValue.getPassword()))); + +// secondary DB + config.setProperty("db1.name", db2NameValue.getText()); + config.setProperty("db1.URL", db2URLValue.getText()); + config.setProperty("db1.schema", jtxtDbSchema1.getText()); + config.setProperty("db1.options", db2OptionsValue.getText()); + config.setProperty("db1.user", db2UserValue.getText()); + cypher = new AltEncrypter("cypherkey" + db2UserValue.getText()); + config.setProperty("db1.password", "crypt:" + + cypher.encrypt(new String(db2PasswordValue.getPassword()))); + + dirty.setDirty(false); + } + + private String comboValue(Object value) { + return value == null ? "" : value.toString(); + } + + public void fillSchema() { + /* Use existing session credentials but declare new session and connection + * to keep separated from current session instance as database could + * be a different server + */ + + if (jCBSchema.getItemCount() >= 1 ) { + jCBSchema.removeAllItems(); + } + + try { + String driverlib = dbDriverLibraryValue.getText(); + String driver = dbDriverClassValue.getText(); + String url = dbURLValue.getText(); + String user = dbUserValue.getText(); + String password = new String(dbPasswordValue.getPassword()); + + ClassLoader cloader = new URLClassLoader(new URL[]{new File(driverlib).toURI().toURL()}); + DriverManager.registerDriver(new DriverWrapper((Driver) Class.forName(driver, true, cloader).newInstance())); + + Session session1 = new Session(url, user, password); + Connection connection1 = session1.getConnection(); + ResultSet rs = connection1.getMetaData().getCatalogs(); + + while (rs.next()) { + jCBSchema.addItem(rs.getString("TABLE_CAT")); + } + + jCBSchema.setEnabled(true); + jCBSchema.setSelectedIndex(0); + + } catch (MalformedURLException | ClassNotFoundException | SQLException + | InstantiationException | IllegalAccessException ex) { + log.error(ex.getMessage()); + } + } + public void fillSchema1() { + /* Use existing session credentials but declare new session and connection + * to keep separated from current session instance as database could + * be a different server + */ + + if (jCBSchema1.getItemCount() >= 1 ) { + jCBSchema1.removeAllItems(); + } + + try { + String driverlib = dbDriverLibraryValue.getText(); + String driver = dbDriverClassValue.getText(); + String url = db2URLValue.getText(); + String user = db2UserValue.getText(); + String password = new String(db2PasswordValue.getPassword()); + + ClassLoader cloader = new URLClassLoader(new URL[]{new File(driverlib).toURI().toURL()}); + DriverManager.registerDriver(new DriverWrapper((Driver) Class.forName(driver, true, cloader).newInstance())); + + Session session1 = new Session(url, user, password); + Connection connection1 = session1.getConnection(); + ResultSet rs1 = connection1.getMetaData().getCatalogs(); + + while (rs1.next()) { + jCBSchema1.addItem(rs1.getString("TABLE_CAT")); + } + + jCBSchema1.setEnabled(true); + jCBSchema1.setSelectedIndex(0); + + } catch (MalformedURLException | ClassNotFoundException | SQLException + | InstantiationException | IllegalAccessException ex) { + log.error(ex.getMessage()); + } + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + webPopOver1 = new com.alee.extended.window.WebPopOver(); + headerPanel = new javax.swing.JPanel(); + dbTypeLabel = new javax.swing.JLabel(); + jcboDBDriver = new javax.swing.JComboBox(); + dbMessageLabel = new javax.swing.JLabel(); + dbConfigPanel = new javax.swing.JPanel(); + jLabel7 = new javax.swing.JLabel(); + jCBSchema = new javax.swing.JComboBox<>(); + jLabel8 = new javax.swing.JLabel(); + jtxtDbOptions = new javax.swing.JTextField(); + jbtnCreateDB = new javax.swing.JButton(); + jtxtDbSchema = new javax.swing.JTextField(); + jbtnSetDB = new javax.swing.JButton(); + dbDriverLibrarySelect = new javax.swing.JButton(); + dbURLLabel = new javax.swing.JLabel(); + dbDriverClassLabel = new javax.swing.JLabel(); + dbPasswordLabel = new javax.swing.JLabel(); + dbNameLabel = new javax.swing.JLabel(); + dbPasswordValue = new javax.swing.JPasswordField(); + dbDriverLibraryLabel = new javax.swing.JLabel(); + dbDriverLibraryValue = new javax.swing.JTextField(); + dbUserValue = new javax.swing.JTextField(); + dbURLValue = new javax.swing.JTextField(); + dbDriverClassValue = new javax.swing.JTextField(); + dbUserLabel = new javax.swing.JLabel(); + jSeparator1 = new javax.swing.JSeparator(); + dbNameValue = new javax.swing.JTextField(); + dbVersionLabel = new javax.swing.JLabel(); + dbConnectButton = new javax.swing.JButton(); + dbResetButton = new javax.swing.JButton(); + validUserAlert = new javax.swing.JLabel(); + db2ConfigPanel = new javax.swing.JPanel(); + db2NameLabel = new javax.swing.JLabel(); + db2NameValue = new javax.swing.JTextField(); + db2URLLabel = new javax.swing.JLabel(); + db2URLValue = new javax.swing.JTextField(); + db2UserValue = new javax.swing.JTextField(); + db2UserLabel = new javax.swing.JLabel(); + db2PasswordLabel = new javax.swing.JLabel(); + db2PasswordValue = new javax.swing.JPasswordField(); + jbtnConnect1 = new javax.swing.JButton(); + jbtnReset1 = new javax.swing.JButton(); + jLblDBServerversion1 = new javax.swing.JLabel(); + db2DBLabel = new javax.swing.JLabel(); + jCBSchema1 = new javax.swing.JComboBox<>(); + db2OptionsLabel = new javax.swing.JLabel(); + db2OptionsValue = new javax.swing.JTextField(); + jbtnSetDB1 = new javax.swing.JButton(); + jtxtDbSchema1 = new javax.swing.JTextField(); + multiDBPanel = new javax.swing.JPanel(); + multiDBButton = new com.alee.extended.button.WebSwitch(); + LblMultiDB = new com.alee.laf.label.WebLabel(); + dbInfoLabel = new javax.swing.JLabel(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setOpaque(false); + setPreferredSize(new java.awt.Dimension(900, 500)); + + dbTypeLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + dbTypeLabel.setText(bundle.getString("label.Database")); // NOI18N + dbTypeLabel.setPreferredSize(new java.awt.Dimension(125, 30)); + + jcboDBDriver.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboDBDriver.setToolTipText(bundle.getString("tooltip.config.db.dbtype")); // NOI18N + jcboDBDriver.setPreferredSize(new java.awt.Dimension(160, 30)); + jcboDBDriver.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboDBDriverActionPerformed(evt); + } + }); + + dbMessageLabel.setForeground(new java.awt.Color(51, 204, 255)); + dbMessageLabel.setText("If you require a multiple terminal config please use MariaDB"); + + javax.swing.GroupLayout headerPanelLayout = new javax.swing.GroupLayout(headerPanel); + headerPanel.setLayout(headerPanelLayout); + headerPanelLayout.setHorizontalGroup( + headerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(headerPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(dbTypeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboDBDriver, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(dbMessageLabel) + .addContainerGap(2327, Short.MAX_VALUE)) + ); + headerPanelLayout.setVerticalGroup( + headerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(headerPanelLayout.createSequentialGroup() + .addGroup(headerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jcboDBDriver, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(dbTypeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(dbMessageLabel)) + .addGap(0, 6, Short.MAX_VALUE)) + ); + + dbConfigPanel.setBackground(new java.awt.Color(255, 255, 255)); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLabel7.setText(AppLocal.getIntString("label.DBName")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(125, 30)); + + jCBSchema.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jCBSchema.setToolTipText(bundle.getString("tooltip.config.db.schema")); // NOI18N + jCBSchema.setPreferredSize(new java.awt.Dimension(160, 30)); + jCBSchema.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jCBSchemaActionPerformed(evt); + } + }); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLabel8.setText(AppLocal.getIntString("label.DbOptions")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(125, 30)); + + jtxtDbOptions.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtDbOptions.setToolTipText(bundle.getString("tooltip.config.db.options")); // NOI18N + jtxtDbOptions.setPreferredSize(new java.awt.Dimension(330, 30)); + + jbtnCreateDB.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnCreateDB.setText("CREATE DEFAULT"); + jbtnCreateDB.setToolTipText(bundle.getString("message.databasecreate")); // NOI18N + jbtnCreateDB.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jbtnCreateDB.setPreferredSize(new java.awt.Dimension(160, 45)); + jbtnCreateDB.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnCreateDBActionPerformed(evt); + } + }); + + jtxtDbSchema.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtDbSchema.setEnabled(false); + jtxtDbSchema.setPreferredSize(new java.awt.Dimension(250, 30)); + + jbtnSetDB.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jbtnSetDB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn2.png"))); // NOI18N + jbtnSetDB.setText("SET"); + jbtnSetDB.setToolTipText(bundle.getString("tooltip.config.db.databaseset")); // NOI18N + jbtnSetDB.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jbtnSetDB.setPreferredSize(new java.awt.Dimension(160, 45)); + jbtnSetDB.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnSetDBActionPerformed(evt); + } + }); + + dbDriverLibrarySelect.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/fileopen.png"))); // NOI18N + dbDriverLibrarySelect.setText(" "); + dbDriverLibrarySelect.setToolTipText(bundle.getString("tooltip.config.db.file")); // NOI18N + dbDriverLibrarySelect.setMaximumSize(new java.awt.Dimension(64, 32)); + dbDriverLibrarySelect.setMinimumSize(new java.awt.Dimension(64, 32)); + dbDriverLibrarySelect.setPreferredSize(new java.awt.Dimension(80, 30)); + + dbURLLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + dbURLLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + dbURLLabel.setText(AppLocal.getIntString("label.DbURL")); // NOI18N + dbURLLabel.setPreferredSize(new java.awt.Dimension(125, 30)); + + dbDriverClassLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + dbDriverClassLabel.setText(AppLocal.getIntString("label.DbDriver")); // NOI18N + dbDriverClassLabel.setPreferredSize(new java.awt.Dimension(125, 30)); + + dbPasswordLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + dbPasswordLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + dbPasswordLabel.setText(AppLocal.getIntString("label.DbPassword")); // NOI18N + dbPasswordLabel.setPreferredSize(new java.awt.Dimension(125, 30)); + + dbNameLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + dbNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + dbNameLabel.setText(AppLocal.getIntString("label.DbName")); // NOI18N + dbNameLabel.setPreferredSize(new java.awt.Dimension(125, 30)); + + dbPasswordValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + dbPasswordValue.setToolTipText(bundle.getString("tooltip.config.db.password")); // NOI18N + dbPasswordValue.setPreferredSize(new java.awt.Dimension(160, 30)); + + dbDriverLibraryLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + dbDriverLibraryLabel.setText(AppLocal.getIntString("label.dbdriverlib")); // NOI18N + dbDriverLibraryLabel.setPreferredSize(new java.awt.Dimension(125, 30)); + + dbDriverLibraryValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + dbDriverLibraryValue.setToolTipText(bundle.getString("tooltip.config.db.driverlib")); // NOI18N + dbDriverLibraryValue.setPreferredSize(new java.awt.Dimension(500, 30)); + + dbUserValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + dbUserValue.setText(bundle.getString("tooltip.config.db.user")); // NOI18N + dbUserValue.setToolTipText(bundle.getString("tooltip.config.db.user")); // NOI18N + dbUserValue.setPreferredSize(new java.awt.Dimension(160, 30)); + + dbURLValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + dbURLValue.setToolTipText(bundle.getString("tooltip.config.db.url")); // NOI18N + dbURLValue.setPreferredSize(new java.awt.Dimension(320, 30)); + + dbDriverClassValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + dbDriverClassValue.setToolTipText(bundle.getString("tooltip.config.db.driverclass")); // NOI18N + dbDriverClassValue.setPreferredSize(new java.awt.Dimension(150, 30)); + dbDriverClassValue.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + dbDriverClassValueActionPerformed(evt); + } + }); + + dbUserLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + dbUserLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + dbUserLabel.setText(AppLocal.getIntString("label.DbUser")); // NOI18N + dbUserLabel.setPreferredSize(new java.awt.Dimension(125, 30)); + + dbNameValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + dbNameValue.setToolTipText(bundle.getString("tooltip.config.db.name")); // NOI18N + dbNameValue.setPreferredSize(new java.awt.Dimension(160, 30)); + + dbVersionLabel.setBackground(new java.awt.Color(51, 204, 255)); + dbVersionLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + dbVersionLabel.setForeground(new java.awt.Color(255, 255, 255)); + dbVersionLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + dbVersionLabel.setOpaque(true); + dbVersionLabel.setPreferredSize(new java.awt.Dimension(170, 30)); + + dbConnectButton.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + dbConnectButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn1.png"))); // NOI18N + dbConnectButton.setText(bundle.getString("button.connect")); // NOI18N + dbConnectButton.setToolTipText(bundle.getString("tooltip.config.db.connect")); // NOI18N + dbConnectButton.setActionCommand(bundle.getString("Button.Test")); // NOI18N + dbConnectButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + dbConnectButton.setPreferredSize(new java.awt.Dimension(160, 45)); + dbConnectButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + dbConnectButtonActionPerformed(evt); + } + }); + + dbResetButton.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + dbResetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + dbResetButton.setToolTipText(AppLocal.getIntString("tooltip.config.db.reset")); // NOI18N + dbResetButton.setPreferredSize(new java.awt.Dimension(80, 45)); + dbResetButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + dbResetButtonActionPerformed(evt); + } + }); + + validUserAlert.setBackground(new java.awt.Color(255, 0, 51)); + validUserAlert.setFont(new java.awt.Font("Lucida Sans Unicode", 0, 14)); // NOI18N + validUserAlert.setForeground(new java.awt.Color(255, 255, 255)); + validUserAlert.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + validUserAlert.setText(bundle.getString("message.dbalert")); // NOI18N + validUserAlert.setOpaque(true); + validUserAlert.setPreferredSize(new java.awt.Dimension(570, 30)); + + javax.swing.GroupLayout dbConfigPanelLayout = new javax.swing.GroupLayout(dbConfigPanel); + dbConfigPanel.setLayout(dbConfigPanelLayout); + dbConfigPanelLayout.setHorizontalGroup( + dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(dbConfigPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(dbConfigPanelLayout.createSequentialGroup() + .addComponent(validUserAlert, javax.swing.GroupLayout.DEFAULT_SIZE, 992, Short.MAX_VALUE) + .addGap(786, 786, 786)) + .addGroup(dbConfigPanelLayout.createSequentialGroup() + .addGroup(dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(dbConfigPanelLayout.createSequentialGroup() + .addComponent(dbDriverLibraryLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbDriverLibraryValue, javax.swing.GroupLayout.PREFERRED_SIZE, 326, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbDriverLibrarySelect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbDriverClassLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbDriverClassValue, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(dbConfigPanelLayout.createSequentialGroup() + .addComponent(dbNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbNameValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbURLLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbURLValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbVersionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(dbConfigPanelLayout.createSequentialGroup() + .addComponent(dbUserLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbUserValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbPasswordLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbPasswordValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbConnectButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbResetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(dbConfigPanelLayout.createSequentialGroup() + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(dbConfigPanelLayout.createSequentialGroup() + .addComponent(jCBSchema, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jbtnSetDB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(dbConfigPanelLayout.createSequentialGroup() + .addComponent(jtxtDbSchema, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(32, 32, 32) + .addComponent(jbtnCreateDB, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jtxtDbOptions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGap(0, 0, Short.MAX_VALUE)))) + .addGroup(dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(dbConfigPanelLayout.createSequentialGroup() + .addGap(898, 898, 898) + .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 880, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + ); + dbConfigPanelLayout.setVerticalGroup( + dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(dbConfigPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(dbDriverLibraryValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(dbDriverLibrarySelect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(dbDriverClassLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(dbDriverClassValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(dbDriverLibraryLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(dbNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(dbNameValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(dbURLLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(dbURLValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(dbVersionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(dbUserLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(dbUserValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(dbPasswordLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(dbPasswordValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(dbConnectButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(dbResetButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jCBSchema, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtDbOptions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jbtnSetDB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnCreateDB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtDbSchema, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(validUserAlert, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(dbConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(dbConfigPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(246, Short.MAX_VALUE))) + ); + + db2ConfigPanel.setBackground(new java.awt.Color(255, 255, 255)); + + db2NameLabel.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + db2NameLabel.setText(AppLocal.getIntString("label.DbName1")); // NOI18N + db2NameLabel.setPreferredSize(new java.awt.Dimension(125, 30)); + + db2NameValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + db2NameValue.setToolTipText(bundle.getString("tooltip.config.db.name1")); // NOI18N + db2NameValue.setPreferredSize(new java.awt.Dimension(160, 30)); + + db2URLLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + db2URLLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + db2URLLabel.setText(AppLocal.getIntString("label.DbURL")); // NOI18N + db2URLLabel.setPreferredSize(new java.awt.Dimension(125, 30)); + + db2URLValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + db2URLValue.setToolTipText(bundle.getString("tooltip.config.db.url1")); // NOI18N + db2URLValue.setPreferredSize(new java.awt.Dimension(320, 30)); + db2URLValue.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + db2URLValueActionPerformed(evt); + } + }); + + db2UserValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + db2UserValue.setToolTipText(bundle.getString("tooltip.config.db.user1")); // NOI18N + db2UserValue.setPreferredSize(new java.awt.Dimension(160, 30)); + + db2UserLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + db2UserLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + db2UserLabel.setText(AppLocal.getIntString("label.DbUser")); // NOI18N + db2UserLabel.setPreferredSize(new java.awt.Dimension(125, 30)); + + db2PasswordLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + db2PasswordLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + db2PasswordLabel.setText(AppLocal.getIntString("label.DbPassword")); // NOI18N + db2PasswordLabel.setPreferredSize(new java.awt.Dimension(125, 30)); + + db2PasswordValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + db2PasswordValue.setToolTipText(bundle.getString("tooltip.config.db.password1")); // NOI18N + db2PasswordValue.setPreferredSize(new java.awt.Dimension(160, 30)); + + jbtnConnect1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnConnect1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn1.png"))); // NOI18N + jbtnConnect1.setText(bundle.getString("button.connect")); // NOI18N + jbtnConnect1.setToolTipText(bundle.getString("tooltip.config.db.connect")); // NOI18N + jbtnConnect1.setActionCommand(bundle.getString("Button.Test")); // NOI18N + jbtnConnect1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jbtnConnect1.setPreferredSize(new java.awt.Dimension(160, 45)); + jbtnConnect1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnConnect1ActionPerformed(evt); + } + }); + + jbtnReset1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnReset1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jbtnReset1.setToolTipText(AppLocal.getIntString("tooltip.config.db.reset1")); // NOI18N + jbtnReset1.setPreferredSize(new java.awt.Dimension(80, 45)); + jbtnReset1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnReset1ActionPerformed(evt); + } + }); + + jLblDBServerversion1.setBackground(new java.awt.Color(51, 204, 255)); + jLblDBServerversion1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLblDBServerversion1.setForeground(new java.awt.Color(255, 255, 255)); + jLblDBServerversion1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLblDBServerversion1.setOpaque(true); + jLblDBServerversion1.setPreferredSize(new java.awt.Dimension(170, 30)); + + db2DBLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + db2DBLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + db2DBLabel.setText(AppLocal.getIntString("label.DBName")); // NOI18N + db2DBLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); + db2DBLabel.setPreferredSize(new java.awt.Dimension(125, 30)); + + jCBSchema1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jCBSchema1.setToolTipText(bundle.getString("tooltip.config.db.schema1")); // NOI18N + jCBSchema1.setPreferredSize(new java.awt.Dimension(160, 30)); + jCBSchema1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jCBSchema1ActionPerformed(evt); + } + }); + + db2OptionsLabel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + db2OptionsLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + db2OptionsLabel.setText(AppLocal.getIntString("label.DbOptions")); // NOI18N + db2OptionsLabel.setPreferredSize(new java.awt.Dimension(125, 30)); + + db2OptionsValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + db2OptionsValue.setToolTipText(bundle.getString("tooltip.config.db.options")); // NOI18N + db2OptionsValue.setPreferredSize(new java.awt.Dimension(330, 30)); + + jbtnSetDB1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jbtnSetDB1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn2.png"))); // NOI18N + jbtnSetDB1.setText("SET"); + jbtnSetDB1.setToolTipText(bundle.getString("tooltip.config.db.databaseset1")); // NOI18N + jbtnSetDB1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jbtnSetDB1.setPreferredSize(new java.awt.Dimension(160, 45)); + jbtnSetDB1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnSetDB1ActionPerformed(evt); + } + }); + + jtxtDbSchema1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtDbSchema1.setPreferredSize(new java.awt.Dimension(250, 30)); + + javax.swing.GroupLayout db2ConfigPanelLayout = new javax.swing.GroupLayout(db2ConfigPanel); + db2ConfigPanel.setLayout(db2ConfigPanelLayout); + db2ConfigPanelLayout.setHorizontalGroup( + db2ConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(db2ConfigPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(db2ConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(db2ConfigPanelLayout.createSequentialGroup() + .addComponent(db2NameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(db2NameValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(db2URLLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(db2URLValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLblDBServerversion1, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(db2ConfigPanelLayout.createSequentialGroup() + .addComponent(db2UserLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(db2UserValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(db2PasswordLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(db2PasswordValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jbtnConnect1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jbtnReset1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(db2ConfigPanelLayout.createSequentialGroup() + .addComponent(db2DBLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(db2ConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(db2ConfigPanelLayout.createSequentialGroup() + .addComponent(jbtnSetDB1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(137, 137, 137) + .addComponent(jtxtDbSchema1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(db2ConfigPanelLayout.createSequentialGroup() + .addComponent(jCBSchema1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(db2OptionsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(db2OptionsValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + db2ConfigPanelLayout.setVerticalGroup( + db2ConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(db2ConfigPanelLayout.createSequentialGroup() + .addGroup(db2ConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(db2NameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(db2NameValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(db2ConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(db2URLLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(db2URLValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLblDBServerversion1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(db2ConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jbtnConnect1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(db2ConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(db2PasswordValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(db2PasswordLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnReset1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(db2UserValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(db2UserLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(db2ConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(db2DBLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jCBSchema1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(db2OptionsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(db2OptionsValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(db2ConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(db2ConfigPanelLayout.createSequentialGroup() + .addComponent(jtxtDbSchema1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(12, Short.MAX_VALUE)) + .addGroup(db2ConfigPanelLayout.createSequentialGroup() + .addGap(1, 1, 1) + .addComponent(jbtnSetDB1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))) + ); + + multiDBButton.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + multiDBButton.setPreferredSize(new java.awt.Dimension(80, 30)); + multiDBButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + multiDBButtonActionPerformed(evt); + } + }); + + LblMultiDB.setText(AppLocal.getIntString("label.multidb")); // NOI18N + LblMultiDB.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + LblMultiDB.setPreferredSize(new java.awt.Dimension(125, 30)); + + dbInfoLabel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + dbInfoLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + dbInfoLabel.setText(bundle.getString("message.DBDefault")); // NOI18N + dbInfoLabel.setToolTipText(""); + dbInfoLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP); + dbInfoLabel.setPreferredSize(new java.awt.Dimension(889, 120)); + dbInfoLabel.setVerticalTextPosition(javax.swing.SwingConstants.TOP); + + javax.swing.GroupLayout multiDBPanelLayout = new javax.swing.GroupLayout(multiDBPanel); + multiDBPanel.setLayout(multiDBPanelLayout); + multiDBPanelLayout.setHorizontalGroup( + multiDBPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(multiDBPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(LblMultiDB, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(multiDBButton, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbInfoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 740, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(72, Short.MAX_VALUE)) + ); + multiDBPanelLayout.setVerticalGroup( + multiDBPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(multiDBPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(multiDBPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(LblMultiDB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(multiDBButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(multiDBPanelLayout.createSequentialGroup() + .addComponent(dbInfoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(headerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(dbConfigPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(multiDBPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(db2ConfigPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(headerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(dbConfigPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(multiDBPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(db2ConfigPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void dbDriverClassValueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dbDriverClassValueActionPerformed + + }//GEN-LAST:event_dbDriverClassValueActionPerformed + + private void jcboDBDriverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboDBDriverActionPerformed + + String dirname = System.getProperty("dirname.path"); + dirname = dirname == null ? "./" : dirname; + + if ("Apache Derby".equals(jcboDBDriver.getSelectedItem())) { + dbDriverLibraryValue.setText(new File(new File(dirname), "derby-10.14.2.0.jar").getAbsolutePath()); + dbDriverClassValue.setText("org.apache.derby.jdbc.EmbeddedDriver"); + dbURLValue.setText("jdbc:derby:" + System.getProperty("user.home")+"/.unicenta/"); + jtxtDbSchema.setText("unicentaopos-database;create=true"); + dbUserValue.setText(""); + dbPasswordValue.setText(""); + //jtxtDbSchema.setText("unicentaopos-derby"); + jtxtDbOptions.setText(""); + dbConfigPanel.setVisible(false); + db2ConfigPanel.setVisible(false); + multiDBPanel.setVisible(false); + dbMessageLabel.setText("Single terminal only. If you require a multiple terminal config please use MariaDB"); + dbMessageLabel.setForeground(new java.awt.Color(51, 204, 255)); + } + else if ("SQLite".equals(jcboDBDriver.getSelectedItem())) { + dbDriverLibraryValue.setText(new File(new File(dirname), "sqlite-jdbc-3.7.2.jar").getAbsolutePath()); + dbDriverClassValue.setText("org.sqlite.JDBC"); + dbURLValue.setText("jdbc:sqlite:" + System.getProperty("user.home")+"/.unicenta/"); + dbUserValue.setText(""); + dbPasswordValue.setText(""); + jtxtDbSchema.setText("unicentaopos"); + jtxtDbOptions.setText(""); + dbConfigPanel.setVisible(false); + db2ConfigPanel.setVisible(false); + multiDBPanel.setVisible(false); + } + else if ("MariaDB".equals(jcboDBDriver.getSelectedItem())) { + dbDriverLibraryValue.setText(new File(new File(dirname), "mariadb-java-client-2.7.0.jar").getAbsolutePath()); + dbDriverClassValue.setText("org.mariadb.jdbc.Driver"); + dbURLValue.setText("jdbc:mariadb://localhost:3306/"); + jtxtDbSchema.setText("unicentaopos"); + jtxtDbOptions.setText("?zeroDateTimeBehavior=convertToNull"); + dbConfigPanel.setVisible(true); + multiDBPanel.setVisible(true); + dbMessageLabel.setText("This is the best option for multiple terminal configuration"); + dbMessageLabel.setForeground(new java.awt.Color(51, 204, 255)); + + } else { + dbDriverLibraryValue.setText(new File(new File(dirname), "mysql-connector-java-5.1.39.jar").getAbsolutePath()); + dbDriverClassValue.setText("com.mysql.jdbc.Driver"); + dbURLValue.setText("jdbc:mysql://localhost:3306/"); + jtxtDbSchema.setText("unicentaopos"); + jtxtDbOptions.setText("?zeroDateTimeBehavior=convertToNull"); + dbConfigPanel.setVisible(true); + multiDBPanel.setVisible(true); + dbMessageLabel.setText("MySQL is deprecated and will be remove in a subsequent release. Please migrate to MariaDB"); + dbMessageLabel.setForeground(new Color(255,0,51)); + } + }//GEN-LAST:event_jcboDBDriverActionPerformed + + private void dbConnectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dbConnectButtonActionPerformed + try { + String driverlib = dbDriverLibraryValue.getText(); + String driver = dbDriverClassValue.getText(); + String url = dbURLValue.getText(); + String user = dbUserValue.getText(); + String password = new String(dbPasswordValue.getPassword()); + + ClassLoader cloader = new URLClassLoader(new URL[]{new File(driverlib).toURI().toURL()}); + DriverManager.registerDriver(new DriverWrapper((Driver) Class.forName(driver, true, cloader).newInstance())); + + Session session = new Session(url, user, password); + Connection connection = session.getConnection(); + + boolean isValid; + if (connection != null && connection.getClass().getName().equals("org.sqlite.Conn") ) { + isValid = true; + } + else isValid = connection != null && connection.isValid(1000); + + if (isValid) { + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.databasesuccess"), + "Connection Test", JOptionPane.INFORMATION_MESSAGE); + fillSchema(); + validUserAlert.setVisible(false); + dbConfigPanel.setVisible(true); + } else { + validUserAlert.setVisible(true); + dbConfigPanel.setVisible(false); + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, "Connection Error")); + } + + ResultSet rs = connection.getMetaData().getCatalogs(); + String SQL="SELECT LEFT(VERSION(),3) "; + Statement stmt = (Statement) connection.createStatement(); + rs = stmt.executeQuery(SQL); + rs.next(); + dbVersionLabel.setVisible(true); + dbVersionLabel.setText(" MySQL Server : " + rs.getString(1)); + + //if (!rs.getString(1).equals("5.7")) { + // jLblDBServerversion.setBackground(Color.RED); + // JOptionPane.showMessageDialog(this, + // AppLocal.getIntString("message.databasefail"), + // "Connection Test", JOptionPane.WARNING_MESSAGE); + //} + + } catch (InstantiationException | IllegalAccessException | MalformedURLException | ClassNotFoundException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.databasedrivererror"), e)); + } catch (SQLException e) { + validUserAlert.setVisible(true); + dbVersionLabel.setText(""); + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.databaseconnectionerror"), e)); + } catch (Exception e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, "Unknown exception", e)); + } + }//GEN-LAST:event_dbConnectButtonActionPerformed + + private void jbtnConnect1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnConnect1ActionPerformed + /* Even though TEST & TEST1 could be consolidated into method am deliberately + * keeping this separate as plan is to also include alternative + */ + try { + String driverlib = dbDriverLibraryValue.getText(); + String driver = dbDriverClassValue.getText(); + String url = db2URLValue.getText(); + String user = db2UserValue.getText(); + String password = new String(db2PasswordValue.getPassword()); + + ClassLoader cloader = new URLClassLoader(new URL[]{new File(driverlib).toURI().toURL()}); + DriverManager.registerDriver(new DriverWrapper((Driver) Class.forName(driver, true, cloader).newInstance())); + + Session session = new Session(url, user, password); + Connection connection = session.getConnection(); + + boolean isValid; + isValid = (connection == null) ? false : connection.isValid(1000); + + if (isValid) { + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.databasesuccess"), + "Connection Test", JOptionPane.INFORMATION_MESSAGE); + fillSchema1(); + validUserAlert.setVisible(false); + } else { + validUserAlert.setVisible(true); + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, "Connection Error")); + } + + ResultSet rs = connection.getMetaData().getCatalogs(); + String SQL="SELECT LEFT(VERSION(),3) "; + Statement stmt = (Statement) connection.createStatement(); + rs = stmt.executeQuery(SQL); + rs.next(); + jLblDBServerversion1.setText(" MySQL Server : " + rs.getString(1)); + + } catch (InstantiationException | IllegalAccessException | MalformedURLException | ClassNotFoundException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.databasedrivererror"), e)); + } catch (SQLException e) { + validUserAlert.setVisible(true); + jLblDBServerversion1.setText(""); + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.databaseconnectionerror"), e)); + } catch (Exception e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, "Unknown exception", e)); + } + }//GEN-LAST:event_jbtnConnect1ActionPerformed + + private void multiDBButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multiDBButtonActionPerformed + if (multiDBButton.isSelected()) { + dbConfigPanel.setVisible(true); + db2ConfigPanel.setVisible(true); + multiDBPanel.setVisible(true); + } else { + db2ConfigPanel.setVisible(false); + } + }//GEN-LAST:event_multiDBButtonActionPerformed + + private void dbResetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dbResetButtonActionPerformed + if (jCBSchema.getItemCount() >= 1 ) { + jCBSchema.removeAllItems(); + } + + String dirname = System.getProperty("dirname.path"); + dirname = dirname == null ? "./" : dirname; + + dbDriverLibraryValue.setText(new File(new File(dirname), "lib/mysql-connector-java-5.1.39.jar").getAbsolutePath()); + dbDriverClassValue.setText("com.mysql.jdbc.Driver"); + + dbNameValue.setText("Main DB"); + dbURLValue.setText("jdbc:mysql://localhost:3306/"); + jtxtDbSchema.setText("unicentaopos"); + jtxtDbOptions.setText("?zeroDateTimeBehavior=convertToNull"); + dbUserValue.setText(null); + dbPasswordValue.setText(null); + dbVersionLabel.setText(null); + dbVersionLabel.setVisible(false); + dbConfigPanel.setVisible(false); + }//GEN-LAST:event_dbResetButtonActionPerformed + + private void jbtnReset1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnReset1ActionPerformed + if (jCBSchema1.getItemCount() >= 1 ) { + jCBSchema1.removeAllItems(); + } + + db2NameValue.setText("Other DB"); + db2URLValue.setText("jdbc:mysql://localhost:3306/"); + jtxtDbSchema1.setText("unicentaopos1"); + db2OptionsValue.setText("?zeroDateTimeBehavior=convertToNull"); + db2UserValue.setText(null); + db2PasswordValue.setText(null); + jLblDBServerversion1.setText(null); + }//GEN-LAST:event_jbtnReset1ActionPerformed + + private void jCBSchemaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBSchemaActionPerformed +/* + if (jCBSchema.getItemCount() > 0 ) { + String selected = jCBSchema.getSelectedItem().toString(); + if(!selected.equals(null)) { + jtxtDbSchema.setText(selected); + } + } +*/ + }//GEN-LAST:event_jCBSchemaActionPerformed + + private void jCBSchema1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBSchema1ActionPerformed +/* + if (jCBSchema1.getItemCount() > 0 ) { + String selected1 = jCBSchema1.getSelectedItem().toString(); + if(!selected1.equals(null)) { + jtxtDbSchema1.setText(selected1); + } + } +*/ + }//GEN-LAST:event_jCBSchema1ActionPerformed + + private void db2URLValueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_db2URLValueActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_db2URLValueActionPerformed + + private void jbtnCreateDBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnCreateDBActionPerformed + try { + String driverlib = dbDriverLibraryValue.getText(); + String driver = dbDriverClassValue.getText(); + String url = dbURLValue.getText(); + String user = dbUserValue.getText(); + String password = new String(dbPasswordValue.getPassword()); + + ClassLoader cloader = new URLClassLoader(new URL[]{new File(driverlib).toURI().toURL()}); + DriverManager.registerDriver(new DriverWrapper((Driver) Class.forName(driver, true, cloader).newInstance())); + + Session session = new Session(url, user, password); + Connection connection = session.getConnection(); + + boolean isValid; + isValid = (connection == null) ? false : connection.isValid(1000); + + if (isValid) { + String SQL="CREATE DATABASE if not exists unicentaopos"; + Statement stmt = (Statement) connection.createStatement(); + stmt.executeUpdate(SQL); + + fillSchema(); + validUserAlert.setVisible(false); + jtxtDbSchema.setText("unicentaopos"); + + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.createdefaultdb"), + "Create Default Database", JOptionPane.INFORMATION_MESSAGE); + } else { + validUserAlert.setVisible(true); + dbConfigPanel.setVisible(false); + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, "Connection Error")); + } + + } catch (MalformedURLException ex) { + log.error(ex.getMessage()); + } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.databasedrivererror"), e)); + } catch (SQLException e) { + validUserAlert.setVisible(true); + dbVersionLabel.setText(""); + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.databaseconnectionerror"), e)); + } catch (Exception e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, "Unknown exception", e)); + } + }//GEN-LAST:event_jbtnCreateDBActionPerformed + + private void jbtnSetDBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSetDBActionPerformed + + if (jCBSchema.getItemCount() > 0 ) { + String selected = jCBSchema.getSelectedItem().toString(); + if(selected != null) { + jtxtDbSchema.setText(selected); + } + } + }//GEN-LAST:event_jbtnSetDBActionPerformed + + private void jbtnSetDB1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSetDB1ActionPerformed + + if (jCBSchema1.getItemCount() > 0 ) { + String selected1 = jCBSchema1.getSelectedItem().toString(); + if(selected1 != null) { + jtxtDbSchema1.setText(selected1); + } + } + }//GEN-LAST:event_jbtnSetDB1ActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private com.alee.laf.label.WebLabel LblMultiDB; + private javax.swing.JPanel db2ConfigPanel; + private javax.swing.JLabel db2DBLabel; + private javax.swing.JLabel db2NameLabel; + private javax.swing.JTextField db2NameValue; + private javax.swing.JLabel db2OptionsLabel; + private javax.swing.JTextField db2OptionsValue; + private javax.swing.JLabel db2PasswordLabel; + private javax.swing.JPasswordField db2PasswordValue; + private javax.swing.JLabel db2URLLabel; + private javax.swing.JTextField db2URLValue; + private javax.swing.JLabel db2UserLabel; + private javax.swing.JTextField db2UserValue; + private javax.swing.JPanel dbConfigPanel; + private javax.swing.JButton dbConnectButton; + private javax.swing.JLabel dbDriverClassLabel; + private javax.swing.JTextField dbDriverClassValue; + private javax.swing.JLabel dbDriverLibraryLabel; + private javax.swing.JButton dbDriverLibrarySelect; + private javax.swing.JTextField dbDriverLibraryValue; + private javax.swing.JLabel dbInfoLabel; + private javax.swing.JLabel dbMessageLabel; + private javax.swing.JLabel dbNameLabel; + private javax.swing.JTextField dbNameValue; + private javax.swing.JLabel dbPasswordLabel; + private javax.swing.JPasswordField dbPasswordValue; + private javax.swing.JButton dbResetButton; + private javax.swing.JLabel dbTypeLabel; + private javax.swing.JLabel dbURLLabel; + private javax.swing.JTextField dbURLValue; + private javax.swing.JLabel dbUserLabel; + private javax.swing.JTextField dbUserValue; + private javax.swing.JLabel dbVersionLabel; + private javax.swing.JPanel headerPanel; + private javax.swing.JComboBox jCBSchema; + private javax.swing.JComboBox jCBSchema1; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLblDBServerversion1; + private javax.swing.JSeparator jSeparator1; + private javax.swing.JButton jbtnConnect1; + private javax.swing.JButton jbtnCreateDB; + private javax.swing.JButton jbtnReset1; + private javax.swing.JButton jbtnSetDB; + private javax.swing.JButton jbtnSetDB1; + private javax.swing.JComboBox jcboDBDriver; + private javax.swing.JTextField jtxtDbOptions; + private javax.swing.JTextField jtxtDbSchema; + private javax.swing.JTextField jtxtDbSchema1; + private com.alee.extended.button.WebSwitch multiDBButton; + private javax.swing.JPanel multiDBPanel; + private javax.swing.JLabel validUserAlert; + private com.alee.extended.window.WebPopOver webPopOver1; + // End of variables declaration//GEN-END:variables + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigERP.form b/src/main/java/com/unicenta/pos/config/JPanelConfigERP.form new file mode 100644 index 0000000..14e1956 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigERP.form @@ -0,0 +1,226 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigERP.java b/src/main/java/com/unicenta/pos/config/JPanelConfigERP.java new file mode 100644 index 0000000..acf0f97 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigERP.java @@ -0,0 +1,247 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.config; + +import com.unicenta.data.user.DirtyManager; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.AltEncrypter; +import java.awt.Component; + +/** + * + * @author adrianromero + */ +public class JPanelConfigERP extends javax.swing.JPanel implements PanelConfig { + + private DirtyManager dirty = new DirtyManager(); + + /** Creates new form JPanelConfigERP */ + public JPanelConfigERP() { + initComponents(); + + jTextField1.getDocument().addDocumentListener(dirty); + jTextField2.getDocument().addDocumentListener(dirty); + jtxtId.getDocument().addDocumentListener(dirty); + jtxtName.getDocument().addDocumentListener(dirty); + jtxtPassword.getDocument().addDocumentListener(dirty); + jtxtUrl.getDocument().addDocumentListener(dirty); + } + + /** + * + * @return + */ + @Override + public boolean hasChanged() { + return dirty.isDirty(); + } + + /** + * + * @return + */ + @Override + public Component getConfigComponent() { + return this; + } + + /** + * + * @param config + */ + @Override + public void loadProperties(AppConfig config) { + + jtxtUrl.setText(config.getProperty("erp.URL")); + jtxtId.setText(config.getProperty("erp.id")); + jTextField2.setText(config.getProperty("erp.pos")); + jTextField1.setText(config.getProperty("erp.org")); + + String sERPUser = config.getProperty("erp.user"); + String sERPPassword = config.getProperty("erp.password"); + if (sERPUser != null && sERPPassword != null && sERPPassword.startsWith("crypt:")) { + // La clave esta encriptada. + AltEncrypter cypher = new AltEncrypter("cypherkey" + sERPUser); + sERPPassword = cypher.decrypt(sERPPassword.substring(6)); + } + jtxtName.setText(sERPUser); + jtxtPassword.setText(sERPPassword); + + dirty.setDirty(false); + } + + /** + * + * @param config + */ + @Override + public void saveProperties(AppConfig config) { + + config.setProperty("erp.URL", jtxtUrl.getText()); + config.setProperty("erp.id", jtxtId.getText()); + config.setProperty("erp.pos", jTextField2.getText()); + config.setProperty("erp.org", jTextField1.getText()); + + config.setProperty("erp.user", jtxtName.getText()); + AltEncrypter cypher = new AltEncrypter("cypherkey" + jtxtName.getText()); + config.setProperty("erp.password", "crypt:" + cypher.encrypt(new String(jtxtPassword.getPassword()))); + + dirty.setDirty(false); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jtxtUrl = new javax.swing.JTextField(); + jtxtId = new javax.swing.JTextField(); + jTextField1 = new javax.swing.JTextField(); + jTextField2 = new javax.swing.JTextField(); + jtxtName = new javax.swing.JTextField(); + jtxtPassword = new javax.swing.JPasswordField(); + jlabelUrl = new javax.swing.JLabel(); + jLabelId = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabelName = new javax.swing.JLabel(); + jLabelProperties = new javax.swing.JLabel(); + + setBackground(new java.awt.Color(255, 255, 255)); + setPreferredSize(new java.awt.Dimension(700, 500)); + + jtxtUrl.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtUrl.setPreferredSize(new java.awt.Dimension(350, 30)); + + jtxtId.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtId.setPreferredSize(new java.awt.Dimension(250, 30)); + + jTextField1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextField1.setPreferredSize(new java.awt.Dimension(250, 30)); + + jTextField2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextField2.setPreferredSize(new java.awt.Dimension(250, 30)); + + jtxtName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtName.setPreferredSize(new java.awt.Dimension(250, 30)); + + jtxtPassword.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtPassword.setPreferredSize(new java.awt.Dimension(250, 30)); + + jlabelUrl.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jlabelUrl.setText(AppLocal.getIntString("label.erpurl")); // NOI18N + jlabelUrl.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabelId.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabelId.setText(AppLocal.getIntString("label.erpid")); // NOI18N + jLabelId.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.erporg")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.erppos")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabelName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabelName.setText(AppLocal.getIntString("label.erpuser")); // NOI18N + jLabelName.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabelProperties.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabelProperties.setText(AppLocal.getIntString("label.erppassword")); // NOI18N + jLabelProperties.setPreferredSize(new java.awt.Dimension(150, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jlabelUrl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabelId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabelName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabelProperties, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtxtUrl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jtxtUrl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jtxtId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jtxtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jlabelUrl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabelId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabelName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabelProperties, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + ); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabelId; + private javax.swing.JLabel jLabelName; + private javax.swing.JLabel jLabelProperties; + private javax.swing.JTextField jTextField1; + private javax.swing.JTextField jTextField2; + private javax.swing.JLabel jlabelUrl; + private javax.swing.JTextField jtxtId; + private javax.swing.JTextField jtxtName; + private javax.swing.JPasswordField jtxtPassword; + private javax.swing.JTextField jtxtUrl; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigGeneral.form b/src/main/java/com/unicenta/pos/config/JPanelConfigGeneral.form new file mode 100644 index 0000000..19ef05d --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigGeneral.form @@ -0,0 +1,655 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigGeneral.java b/src/main/java/com/unicenta/pos/config/JPanelConfigGeneral.java new file mode 100644 index 0000000..d53e206 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigGeneral.java @@ -0,0 +1,668 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . +package com.unicenta.pos.config; + +import com.formdev.flatlaf.FlatLaf; +import com.formdev.flatlaf.FlatLightLaf; +import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightContrastIJTheme; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.FileChooserEvent; +import com.unicenta.pos.util.FlatLookAndFeel; +import lombok.extern.slf4j.Slf4j; +import org.pushingpixels.substance.api.SubstanceLookAndFeel; +import org.pushingpixels.substance.api.SubstanceSkin; +import org.pushingpixels.substance.api.skin.SkinInfo; + +import javax.swing.*; +import javax.swing.UIManager.LookAndFeelInfo; +import java.awt.*; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.Map; + +/** + * @author JG uniCenta + */ + +@Slf4j +public class JPanelConfigGeneral extends javax.swing.JPanel implements PanelConfig { + + private final DirtyManager dirty = new DirtyManager(); + + /** + * Creates new form JPanelConfigGeneral + */ + public JPanelConfigGeneral() { + + initComponents(); + + InetAddress IP = null; + try { + IP = InetAddress.getLocalHost(); + } catch (UnknownHostException ex) { + log.error(ex.getMessage()); + } + + jtxtMachineHostname.getDocument().addDocumentListener(dirty); + jtxtMachineDepartment.getDocument().addDocumentListener(dirty); + lblIP_Address.setText(IP.toString()); + jcboLAF.addActionListener(dirty); + jcboMachineScreenmode.addActionListener(dirty); + jcboTicketsBag.addActionListener(dirty); + jchkHideInfo.addActionListener(dirty); + jtxtStartupText.getDocument().addDocumentListener(dirty); + jbtnText.addActionListener(new FileChooserEvent(jtxtStartupText)); + jtxtStartupLogo.getDocument().addDocumentListener(dirty); + jbtnLogo.addActionListener(new FileChooserEvent(jtxtStartupLogo)); + jtxtStartupHTML.getDocument().addDocumentListener(dirty); + jbtnHTML.addActionListener(new FileChooserEvent(jtxtStartupHTML)); + + FlatLookAndFeel.getLafs().forEach((key, value) -> + jcboLAF.addItem(new LAFInfo(key, value)) + ); + + jcboLAF.addActionListener((java.awt.event.ActionEvent evt) -> { + changeLAF(); + }); + + jcboMachineScreenmode.addItem("window"); + jcboMachineScreenmode.addItem("fullscreen"); + + jcboTicketsBag.addItem("simple"); + jcboTicketsBag.addItem("standard"); + jcboTicketsBag.addItem("restaurant"); + + } + + /** + * @return + */ + @Override + public boolean hasChanged() { + return dirty.isDirty(); + } + + /** + * @return + */ + @Override + public Component getConfigComponent() { + return this; + } + + /** + * @param config + */ + @Override + public void loadProperties(AppConfig config) { + + jtxtMachineHostname.setText(config.getProperty("machine.hostname")); + jtxtMachineDepartment.setText(config.getProperty("machine.department")); + + String lafclass = config.getProperty("swing.defaultlaf"); + jcboLAF.setSelectedItem(null); + for (int i = 0; i < jcboLAF.getItemCount(); i++) { + LAFInfo lafinfo = (LAFInfo) jcboLAF.getItemAt(i); + if (lafinfo.getClassName().equals(lafclass)) { + jcboLAF.setSelectedIndex(i); + break; + } + } + + jcboMachineScreenmode.setSelectedItem(config.getProperty("machine.screenmode")); + jcboTicketsBag.setSelectedItem(config.getProperty("machine.ticketsbag")); + jchkHideInfo.setSelected(Boolean.parseBoolean(config.getProperty("till.hideinfo"))); + jtxtStartupLogo.setText(config.getProperty("start.logo")); + jtxtStartupText.setText(config.getProperty("start.text")); + jtxtStartupLogo.setText(config.getProperty("start.logo")); + jtxtStartupHTML.setText(config.getProperty("start.html")); + + String txtPIN = (config.getProperty("override.pin")); + if (txtPIN == null) { + config.setProperty("override.check", "true"); + config.setProperty("override.pin", "1234"); + } + +// jtxtStartupMedia.setText(config.getProperty("start.media")); // Coming later!! + + dirty.setDirty(false); + } + + /** + * @param config + */ + @Override + public void saveProperties(AppConfig config) { + + config.setProperty("machine.hostname", jtxtMachineHostname.getText()); + config.setProperty("machine.department", jtxtMachineDepartment.getText()); + + LAFInfo laf = (LAFInfo) jcboLAF.getSelectedItem(); + config.setProperty("swing.defaultlaf", laf == null + ? System.getProperty("swing.defaultlaf", "javax.swing.plaf.metal.MetalLookAndFeel") + : laf.getClassName()); + + config.setProperty("machine.screenmode", comboValue(jcboMachineScreenmode.getSelectedItem())); + config.setProperty("machine.ticketsbag", comboValue(jcboTicketsBag.getSelectedItem())); + config.setProperty("till.hideinfo", Boolean.toString(jchkHideInfo.isSelected())); + config.setProperty("start.logo", jtxtStartupLogo.getText()); + config.setProperty("start.text", jtxtStartupText.getText()); + config.setProperty("start.html", jtxtStartupHTML.getText()); + +// config.setProperty("start.media", jtxtStartupMedia.getText()); // Coming later! + + dirty.setDirty(false); + } + + private String comboValue(Object value) { + return value == null ? "" : value.toString(); + } + + private void changeLAF() { + + final LAFInfo laf = (LAFInfo) jcboLAF.getSelectedItem(); + if (laf != null && !laf.getClassName().equals(UIManager.getLookAndFeel().getClass().getName())) { + // The selected look and feel is different from the current look and feel. + SwingUtilities.invokeLater(() -> { + try { + String lafname = laf.getClassName(); + Object laf1 = Class.forName(lafname).newInstance(); + if (laf1 instanceof LookAndFeel) { + UIManager.setLookAndFeel((LookAndFeel) laf1); + } else if (laf1 instanceof SubstanceSkin) { + SubstanceLookAndFeel.setSkin((SubstanceSkin) laf1); + } + SwingUtilities.updateComponentTreeUI(JPanelConfigGeneral.this.getTopLevelAncestor()); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { + } + }); + } + } + + private static class LAFInfo { + + private final String name; + private final String classname; + + public LAFInfo(String name, String classname) { + this.name = name; + this.classname = classname; + } + + public String getName() { + return name; + } + + public String getClassName() { + return classname; + } + + @Override + public String toString() { + return name; + } + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel11 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jtxtMachineHostname = new javax.swing.JTextField(); + jcboLAF = new javax.swing.JComboBox(); + jcboMachineScreenmode = new javax.swing.JComboBox(); + jcboTicketsBag = new javax.swing.JComboBox(); + jchkHideInfo = new javax.swing.JCheckBox(); + jLabel18 = new javax.swing.JLabel(); + jtxtStartupLogo = new javax.swing.JTextField(); + jLabel19 = new javax.swing.JLabel(); + jtxtStartupText = new javax.swing.JTextField(); + jbtnLogo = new javax.swing.JButton(); + jbtnText = new javax.swing.JButton(); + jbtnTextClear = new javax.swing.JButton(); + jLabel6 = new javax.swing.JLabel(); + jtxtMachineDepartment = new javax.swing.JTextField(); + lblIP_Address = new com.alee.laf.label.WebLabel(); + webLabel1 = new com.alee.laf.label.WebLabel(); + jLblURL = new javax.swing.JLabel(); + jtxtStartupHTML = new javax.swing.JTextField(); + jbtnHTML = new javax.swing.JButton(); + jbtnClearHTML = new javax.swing.JButton(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setOpaque(false); + setPreferredSize(new java.awt.Dimension(800, 450)); + + jPanel11.setBackground(new java.awt.Color(255, 255, 255)); + jPanel11.setOpaque(false); + jPanel11.setPreferredSize(new java.awt.Dimension(750, 450)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.MachineName")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.looknfeel")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.MachineScreen")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.Ticketsbag")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(150, 30)); + + jtxtMachineHostname.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtMachineHostname.setToolTipText(AppLocal.getIntString("tooltip.config.general.terminal")); // NOI18N + jtxtMachineHostname.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jtxtMachineHostname.setMinimumSize(new java.awt.Dimension(130, 25)); + jtxtMachineHostname.setPreferredSize(new java.awt.Dimension(200, 30)); + + jcboLAF.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboLAF.setToolTipText(AppLocal.getIntString("tooltip.config.general.skin")); // NOI18N + jcboLAF.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jcboLAF.setPreferredSize(new java.awt.Dimension(200, 30)); + jcboLAF.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboLAFActionPerformed(evt); + } + }); + + jcboMachineScreenmode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboMachineScreenmode.setToolTipText(AppLocal.getIntString("tooltip.config.general.screen")); // NOI18N + jcboMachineScreenmode.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jcboMachineScreenmode.setPreferredSize(new java.awt.Dimension(200, 30)); + + jcboTicketsBag.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboTicketsBag.setToolTipText(AppLocal.getIntString("tooltip.config.general.tickets")); // NOI18N + jcboTicketsBag.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jcboTicketsBag.setPreferredSize(new java.awt.Dimension(200, 30)); + + jchkHideInfo.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jchkHideInfo.setSelected(true); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jchkHideInfo.setText(bundle.getString("label.Infopanel")); // NOI18N + jchkHideInfo.setToolTipText(AppLocal.getIntString("tooltip.config.general.footer")); // NOI18N + jchkHideInfo.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jchkHideInfo.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + jchkHideInfo.setMaximumSize(new java.awt.Dimension(0, 25)); + jchkHideInfo.setMinimumSize(new java.awt.Dimension(0, 0)); + jchkHideInfo.setOpaque(false); + jchkHideInfo.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel18.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel18.setText(bundle.getString("label.startuplogo")); // NOI18N + jLabel18.setMaximumSize(new java.awt.Dimension(0, 25)); + jLabel18.setMinimumSize(new java.awt.Dimension(0, 0)); + jLabel18.setPreferredSize(new java.awt.Dimension(150, 30)); + + jtxtStartupLogo.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtStartupLogo.setToolTipText(AppLocal.getIntString("tooltip.config.general.logo")); // NOI18N + jtxtStartupLogo.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtStartupLogo.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtStartupLogo.setPreferredSize(new java.awt.Dimension(400, 30)); + + jLabel19.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel19.setText(AppLocal.getIntString("label.startuptext")); // NOI18N + jLabel19.setMaximumSize(new java.awt.Dimension(0, 25)); + jLabel19.setMinimumSize(new java.awt.Dimension(0, 0)); + jLabel19.setPreferredSize(new java.awt.Dimension(150, 30)); + + jtxtStartupText.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtStartupText.setToolTipText(AppLocal.getIntString("tooltip.config.general.text")); // NOI18N + jtxtStartupText.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtStartupText.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtStartupText.setPreferredSize(new java.awt.Dimension(400, 30)); + jtxtStartupText.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jtxtStartupTextFocusGained(evt); + } + }); + jtxtStartupText.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jtxtStartupTextActionPerformed(evt); + } + }); + + jbtnLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/fileopen.png"))); // NOI18N + jbtnLogo.setText(" "); + jbtnLogo.setToolTipText(AppLocal.getIntString("tooltip.config.general.logo")); // NOI18N + jbtnLogo.setMaximumSize(new java.awt.Dimension(64, 32)); + jbtnLogo.setMinimumSize(new java.awt.Dimension(64, 32)); + jbtnLogo.setPreferredSize(new java.awt.Dimension(80, 45)); + jbtnLogo.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnLogoActionPerformed(evt); + } + }); + + jbtnText.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/fileopen.png"))); // NOI18N + jbtnText.setText(" "); + jbtnText.setToolTipText(AppLocal.getIntString("tooltip.config.general.text")); // NOI18N + jbtnText.setMaximumSize(new java.awt.Dimension(64, 32)); + jbtnText.setMinimumSize(new java.awt.Dimension(64, 32)); + jbtnText.setPreferredSize(new java.awt.Dimension(80, 45)); + jbtnText.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnTextActionPerformed(evt); + } + }); + + jbtnTextClear.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N + jbtnTextClear.setForeground(new java.awt.Color(255, 0, 153)); + jbtnTextClear.setText("X"); + jbtnTextClear.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnTextClearActionPerformed(evt); + } + }); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.MachineDepartment")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(150, 30)); + + jtxtMachineDepartment.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtMachineDepartment.setToolTipText(AppLocal.getIntString("tooltip.config.general.dept")); // NOI18N + jtxtMachineDepartment.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jtxtMachineDepartment.setMinimumSize(new java.awt.Dimension(130, 25)); + jtxtMachineDepartment.setPreferredSize(new java.awt.Dimension(200, 30)); + + lblIP_Address.setBackground(new java.awt.Color(240, 240, 240)); + lblIP_Address.setBorder(null); + lblIP_Address.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + lblIP_Address.setToolTipText(AppLocal.getIntString("tooltip.config.general.compip")); // NOI18N + lblIP_Address.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + lblIP_Address.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); + lblIP_Address.setPreferredSize(new java.awt.Dimension(230, 30)); + + webLabel1.setBackground(new java.awt.Color(240, 240, 240)); + webLabel1.setBorder(null); + webLabel1.setText(bundle.getString("label.nameIP")); // NOI18N + webLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + webLabel1.setPreferredSize(new java.awt.Dimension(300, 30)); + + jLblURL.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblURL.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/pay.png"))); // NOI18N + jLblURL.setText(AppLocal.getIntString("label.URL")); // NOI18N + jLblURL.setToolTipText(bundle.getString("tooltip.config.general.URL")); // NOI18N + jLblURL.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); + jLblURL.setMaximumSize(new java.awt.Dimension(0, 25)); + jLblURL.setMinimumSize(new java.awt.Dimension(0, 0)); + jLblURL.setPreferredSize(new java.awt.Dimension(150, 30)); + jLblURL.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLblURLMouseClicked(evt); + } + }); + + jtxtStartupHTML.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtStartupHTML.setToolTipText(AppLocal.getIntString("tooltip.config.general.text")); // NOI18N + jtxtStartupHTML.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtStartupHTML.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtStartupHTML.setPreferredSize(new java.awt.Dimension(400, 30)); + jtxtStartupHTML.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jtxtStartupHTMLFocusGained(evt); + } + }); + jtxtStartupHTML.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jtxtStartupHTMLActionPerformed(evt); + } + }); + + jbtnHTML.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/fileopen.png"))); // NOI18N + jbtnHTML.setText(" "); + jbtnHTML.setToolTipText(AppLocal.getIntString("tooltip.config.general.text")); // NOI18N + jbtnHTML.setMaximumSize(new java.awt.Dimension(64, 32)); + jbtnHTML.setMinimumSize(new java.awt.Dimension(64, 32)); + jbtnHTML.setPreferredSize(new java.awt.Dimension(80, 45)); + jbtnHTML.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnHTMLActionPerformed(evt); + } + }); + + jbtnClearHTML.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N + jbtnClearHTML.setForeground(new java.awt.Color(255, 0, 153)); + jbtnClearHTML.setText("X"); + jbtnClearHTML.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnClearHTMLActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11); + jPanel11.setLayout(jPanel11Layout); + jPanel11Layout.setHorizontalGroup( + jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel11Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel11Layout.createSequentialGroup() + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel11Layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jtxtMachineHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel11Layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jtxtMachineDepartment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(webLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(lblIP_Address, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel11Layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jcboLAF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel11Layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jcboMachineScreenmode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel11Layout.createSequentialGroup() + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel11Layout.createSequentialGroup() + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jtxtStartupLogo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel11Layout.createSequentialGroup() + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblURL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jchkHideInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 287, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtStartupText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtStartupHTML, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jbtnLogo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel11Layout.createSequentialGroup() + .addComponent(jbtnText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jbtnTextClear, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel11Layout.createSequentialGroup() + .addComponent(jbtnHTML, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jbtnClearHTML, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGroup(jPanel11Layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jcboTicketsBag, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel11Layout.setVerticalGroup( + jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel11Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtMachineHostname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(lblIP_Address, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtMachineDepartment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboLAF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboMachineScreenmode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboTicketsBag, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(48, 48, 48) + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtStartupLogo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnLogo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtStartupText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnTextClear)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblURL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtStartupHTML, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnHTML, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnClearHTML)) + .addGap(18, 18, 18) + .addComponent(jchkHideInfo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + + getAccessibleContext().setAccessibleName(""); + }// //GEN-END:initComponents + + private void jcboLAFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboLAFActionPerformed + + }//GEN-LAST:event_jcboLAFActionPerformed + + private void jtxtStartupTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtStartupTextActionPerformed + + }//GEN-LAST:event_jtxtStartupTextActionPerformed + + private void jtxtStartupTextFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtxtStartupTextFocusGained + // JG 31 August 2103 GNU GPL License Warning + +// transferFocus(); + +// JOptionPane.showMessageDialog(jPanel1,"Changing default Startup Text content may violate the
" +// + " Free Software Foundation's GNU General Public License GPL","GNU GPL Warning",JOptionPane.WARNING_MESSAGE); + + }//GEN-LAST:event_jtxtStartupTextFocusGained + + private void jbtnTextClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnTextClearActionPerformed + jtxtStartupText.setText(""); + }//GEN-LAST:event_jbtnTextClearActionPerformed + + private void jtxtStartupHTMLFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jtxtStartupHTMLFocusGained + // TODO add your handling code here: + }//GEN-LAST:event_jtxtStartupHTMLFocusGained + + private void jtxtStartupHTMLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtStartupHTMLActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jtxtStartupHTMLActionPerformed + + private void jbtnClearHTMLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnClearHTMLActionPerformed + jtxtStartupHTML.setText(""); + }//GEN-LAST:event_jbtnClearHTMLActionPerformed + + private void jbtnHTMLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnHTMLActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jbtnHTMLActionPerformed + + private void jbtnLogoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnLogoActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jbtnLogoActionPerformed + + private void jLblURLMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLblURLMouseClicked + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.URL"), + "URL", + JOptionPane.INFORMATION_MESSAGE); + }//GEN-LAST:event_jLblURLMouseClicked + + private void jbtnTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnTextActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jbtnTextActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel19; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLblURL; + private javax.swing.JPanel jPanel11; + private javax.swing.JButton jbtnClearHTML; + private javax.swing.JButton jbtnHTML; + private javax.swing.JButton jbtnLogo; + private javax.swing.JButton jbtnText; + private javax.swing.JButton jbtnTextClear; + private javax.swing.JComboBox jcboLAF; + private javax.swing.JComboBox jcboMachineScreenmode; + private javax.swing.JComboBox jcboTicketsBag; + private javax.swing.JCheckBox jchkHideInfo; + private javax.swing.JTextField jtxtMachineDepartment; + private javax.swing.JTextField jtxtMachineHostname; + private javax.swing.JTextField jtxtStartupHTML; + private javax.swing.JTextField jtxtStartupLogo; + private javax.swing.JTextField jtxtStartupText; + private com.alee.laf.label.WebLabel lblIP_Address; + private com.alee.laf.label.WebLabel webLabel1; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigLocale.form b/src/main/java/com/unicenta/pos/config/JPanelConfigLocale.form new file mode 100644 index 0000000..dcc99f0 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigLocale.form @@ -0,0 +1,347 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigLocale.java b/src/main/java/com/unicenta/pos/config/JPanelConfigLocale.java new file mode 100644 index 0000000..db38801 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigLocale.java @@ -0,0 +1,425 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.config; + +import com.unicenta.data.user.DirtyManager; +import java.awt.Component; +import java.util.Locale; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * + * @author adrianromero + */ +public class JPanelConfigLocale extends javax.swing.JPanel implements PanelConfig { + + private final DirtyManager dirty = new DirtyManager(); + + private final static String DEFAULT_VALUE = "(Default)"; + + /** Creates new form JPanelConfigLocale */ + public JPanelConfigLocale() { + + initComponents(); + + jcboLocale.addActionListener(dirty); + jcboInteger.addActionListener(dirty); + jcboDouble.addActionListener(dirty); + jcboCurrency.addActionListener(dirty); + jcboPercent.addActionListener(dirty); + jcboDate.addActionListener(dirty); + jcboTime.addActionListener(dirty); + jcboDatetime.addActionListener(dirty); + + List availablelocales = new ArrayList<>(); + availablelocales.addAll(Arrays.asList(Locale.getAvailableLocales())); // Available java locales +// addLocale(availablelocales, new Locale("en", "GB", "")); // English GB +// addLocale(availablelocales, new Locale("en", "US", "")); // English USA + + Collections.sort(availablelocales, new LocaleComparator()); + + jcboLocale.addItem(new LocaleInfo (null)); + for (Locale l : availablelocales) { + jcboLocale.addItem(new LocaleInfo(l)); + } + + jcboInteger.addItem(DEFAULT_VALUE); + jcboInteger.addItem("#0"); + jcboInteger.addItem("#,##0"); + + jcboDouble.addItem(DEFAULT_VALUE); + jcboDouble.addItem("#0.0"); + jcboDouble.addItem("#,##0.#"); + + jcboCurrency.addItem(DEFAULT_VALUE); + jcboCurrency.addItem("\u00A4 #0.00"); + jcboCurrency.addItem("'$' #,##0.00"); + + jcboPercent.addItem(DEFAULT_VALUE); + jcboPercent.addItem("#,##0.##%"); + + jcboDate.addItem(DEFAULT_VALUE); + + jcboTime.addItem(DEFAULT_VALUE); + + jcboDatetime.addItem(DEFAULT_VALUE); + + } + + private void addLocale(List ll, Locale l) { + if (!ll.contains(l)) { + ll.add(l); + } + } + + /** + * + * @return + */ + @Override + public boolean hasChanged() { + return dirty.isDirty(); + } + + /** + * + * @return + */ + @Override + public Component getConfigComponent() { + return this; + } + + /** + * + * @param config + */ + @Override + public void loadProperties(AppConfig config) { + + String slang = config.getProperty("user.language"); + String scountry = config.getProperty("user.country"); + String svariant = config.getProperty("user.variant"); + + if (slang != null && !slang.equals("") && scountry != null && svariant != null) { + Locale currentlocale = new Locale(slang, scountry, svariant); + for (int i = 0 ; i < jcboLocale.getItemCount(); i++) { + LocaleInfo l = (LocaleInfo) jcboLocale.getItemAt(i); + if (currentlocale.equals(l.getLocale())) { + jcboLocale.setSelectedIndex(i); + break; + } + } + } else { + jcboLocale.setSelectedIndex(0); + } + + jcboInteger.setSelectedItem(writeWithDefault(config.getProperty("format.integer"))); + jcboDouble.setSelectedItem(writeWithDefault(config.getProperty("format.double"))); + jcboCurrency.setSelectedItem(writeWithDefault(config.getProperty("format.currency"))); + jcboPercent.setSelectedItem(writeWithDefault(config.getProperty("format.percent"))); + jcboDate.setSelectedItem(writeWithDefault(config.getProperty("format.date"))); + jcboTime.setSelectedItem(writeWithDefault(config.getProperty("format.time"))); + jcboDatetime.setSelectedItem(writeWithDefault(config.getProperty("format.datetime"))); + + dirty.setDirty(false); + } + + /** + * + * @param config + */ + @Override + public void saveProperties(AppConfig config) { + + Locale l = ((LocaleInfo) jcboLocale.getSelectedItem()).getLocale(); + if (l == null) { + config.setProperty("user.language", ""); + config.setProperty("user.country", ""); + config.setProperty("user.variant", ""); + } else { + config.setProperty("user.language", l.getLanguage()); + config.setProperty("user.country", l.getCountry()); + config.setProperty("user.variant", l.getVariant()); + } + + config.setProperty("format.integer", readWithDefault(jcboInteger.getSelectedItem())); + config.setProperty("format.double", readWithDefault(jcboDouble.getSelectedItem())); + config.setProperty("format.currency", readWithDefault(jcboCurrency.getSelectedItem())); + config.setProperty("format.percent", readWithDefault(jcboPercent.getSelectedItem())); + config.setProperty("format.date", readWithDefault(jcboDate.getSelectedItem())); + config.setProperty("format.time", readWithDefault(jcboTime.getSelectedItem())); + config.setProperty("format.datetime", readWithDefault(jcboDatetime.getSelectedItem())); + + dirty.setDirty(false); + } + + private String readWithDefault(Object value) { + if (DEFAULT_VALUE.equals(value)) { + return ""; + } else { + return value.toString(); + } + } + + private Object writeWithDefault(String value) { + if (value == null || value.equals("") || value.equals(DEFAULT_VALUE)) { + return DEFAULT_VALUE; + } else { + return value; + } + } + + private static class LocaleInfo { + private final Locale locale; + + public LocaleInfo(Locale locale) { + this.locale = locale; + } + public Locale getLocale() { + return locale; + } + @Override + public String toString() { + return locale == null + ? "(System default)" + : locale.getDisplayName(); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLabel5 = new javax.swing.JLabel(); + jcboLocale = new javax.swing.JComboBox(); + jLabel1 = new javax.swing.JLabel(); + jcboInteger = new javax.swing.JComboBox(); + jLabel2 = new javax.swing.JLabel(); + jcboDouble = new javax.swing.JComboBox(); + jLabel3 = new javax.swing.JLabel(); + jcboCurrency = new javax.swing.JComboBox(); + jLabel4 = new javax.swing.JLabel(); + jcboPercent = new javax.swing.JComboBox(); + jLabel6 = new javax.swing.JLabel(); + jcboDate = new javax.swing.JComboBox(); + jLabel7 = new javax.swing.JLabel(); + jcboTime = new javax.swing.JComboBox(); + jLabel8 = new javax.swing.JLabel(); + jcboDatetime = new javax.swing.JComboBox(); + + setMinimumSize(new java.awt.Dimension(0, 0)); + setOpaque(false); + setPreferredSize(new java.awt.Dimension(650, 450)); + + jPanel1.setOpaque(false); + jPanel1.setPreferredSize(new java.awt.Dimension(600, 400)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.locale")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(150, 30)); + + jcboLocale.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboLocale.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.integer")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(150, 30)); + + jcboInteger.setEditable(true); + jcboInteger.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboInteger.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.double")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(150, 30)); + + jcboDouble.setEditable(true); + jcboDouble.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboDouble.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.currency")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(150, 30)); + + jcboCurrency.setEditable(true); + jcboCurrency.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboCurrency.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.percent")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(150, 30)); + + jcboPercent.setEditable(true); + jcboPercent.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboPercent.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.date")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(150, 30)); + + jcboDate.setEditable(true); + jcboDate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboDate.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.time")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(150, 30)); + + jcboTime.setEditable(true); + jcboTime.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboTime.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.datetime")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(150, 30)); + + jcboDatetime.setEditable(true); + jcboDatetime.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboDatetime.setPreferredSize(new java.awt.Dimension(0, 30)); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jcboDatetime, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jcboTime, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jcboDate, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jcboPercent, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jcboCurrency, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jcboDouble, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jcboInteger, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jcboLocale, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(51, 51, 51)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jcboLocale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboInteger, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboDouble, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboCurrency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboPercent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboDatetime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(100, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(200, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(2, 2, 2) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(148, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JPanel jPanel1; + private javax.swing.JComboBox jcboCurrency; + private javax.swing.JComboBox jcboDate; + private javax.swing.JComboBox jcboDatetime; + private javax.swing.JComboBox jcboDouble; + private javax.swing.JComboBox jcboInteger; + private javax.swing.JComboBox jcboLocale; + private javax.swing.JComboBox jcboPercent; + private javax.swing.JComboBox jcboTime; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigPayment.form b/src/main/java/com/unicenta/pos/config/JPanelConfigPayment.form new file mode 100644 index 0000000..01da136 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigPayment.form @@ -0,0 +1,216 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigPayment.java b/src/main/java/com/unicenta/pos/config/JPanelConfigPayment.java new file mode 100644 index 0000000..0e7391c --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigPayment.java @@ -0,0 +1,303 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.config; + +import com.unicenta.data.user.DirtyManager; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.payment.ConfigPaymentPanelEmpty; +import com.unicenta.pos.payment.PaymentConfiguration; +import java.awt.Component; +import java.util.HashMap; +import java.util.Map; + +/** + * + * @author adrianromero + * @author Mikel Irurita + */ +public class JPanelConfigPayment extends javax.swing.JPanel implements PanelConfig { + + private final DirtyManager dirty = new DirtyManager(); + private final Map paymentsName = new HashMap<>(); + private PaymentConfiguration paymentConfiguration; + + /** Creates new form JPanelConfigPayment */ + public JPanelConfigPayment() { + + initComponents(); + + // dirty manager + jcboCardReader.addActionListener(dirty); + jcboPaymentGateway.addActionListener(dirty); + + // Payment Provider + initPayments("Not defined", new ConfigPaymentPanelEmpty()); + initPayments("external", new ConfigPaymentPanelEmpty()); + initPayments("PaymentSense", new ConfigPaymentPanelEmpty()); + + // Lector de tarjetas. + jcboCardReader.addItem("Not defined"); + jcboCardReader.addItem("EMV"); + jcboCardReader.addItem("External"); + jcboCardReader.addItem("Generic"); + jcboCardReader.addItem("Intelligent"); + jcboCardReader.addItem("Keyboard"); + jcboCardReader.addItem("NFC/RFID"); + } + + /** + * + * @return + */ + @Override + public boolean hasChanged() { + return dirty.isDirty(); + } + + /** + * + * @return + */ + @Override + public Component getConfigComponent() { + return this; + } + + /** + * + * @param config + */ + @Override + public void loadProperties(AppConfig config) { + + jcboCardReader.setSelectedItem(config.getProperty("payment.magcardreader")); + jcboPaymentGateway.setSelectedItem(config.getProperty("payment.gateway")); + urlValue.setText(config.getProperty("payment.URL")); + deviceIdValue.setText(config.getProperty("payment.device-id")); + securityKeyValue.setText(config.getProperty("payment.security-key")); + paymentConfiguration.loadProperties(config); + dirty.setDirty(false); + } + + /** + * + * @param config + */ + @Override + public void saveProperties(AppConfig config) { + + config.setProperty("payment.magcardreader", comboValue(jcboCardReader.getSelectedItem())); + config.setProperty("payment.gateway", comboValue(jcboPaymentGateway.getSelectedItem())); + config.setProperty("payment.URL", urlValue.getText()); + config.setProperty("payment.device-id", deviceIdValue.getText()); + config.setProperty("payment.security-key", securityKeyValue.getText()); + paymentConfiguration.saveProperties(config); + dirty.setDirty(false); + } + + private void initPayments(String name, PaymentConfiguration pc) { + jcboPaymentGateway.addItem(name); + paymentsName.put(name, pc); + } + + private String comboValue(Object value) { + return value == null ? "" : value.toString(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel13 = new javax.swing.JLabel(); + jcboPaymentGateway = new javax.swing.JComboBox(); + jLabel11 = new javax.swing.JLabel(); + jcboCardReader = new javax.swing.JComboBox(); + emvConfigPanel = new javax.swing.JPanel(); + urlLabel = new javax.swing.JLabel(); + urlValue = new javax.swing.JTextField(); + deviceIdLabel = new javax.swing.JLabel(); + deviceIdValue = new javax.swing.JTextField(); + securityKeyLabel = new javax.swing.JLabel(); + securityKeyValue = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setOpaque(false); + setPreferredSize(new java.awt.Dimension(590, 450)); + + jLabel13.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel13.setText(AppLocal.getIntString("label.paymentgateway")); // NOI18N + jLabel13.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); + jLabel13.setPreferredSize(new java.awt.Dimension(150, 30)); + + jcboPaymentGateway.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboPaymentGateway.setPreferredSize(new java.awt.Dimension(200, 30)); + jcboPaymentGateway.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboPaymentGatewayActionPerformed(evt); + } + }); + + jLabel11.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel11.setText(AppLocal.getIntString("label.cardreader")); // NOI18N + jLabel11.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); + jLabel11.setPreferredSize(new java.awt.Dimension(150, 30)); + + jcboCardReader.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboCardReader.setPreferredSize(new java.awt.Dimension(200, 30)); + + emvConfigPanel.setBackground(new java.awt.Color(255, 255, 255)); + + urlLabel.setText("URL"); + urlLabel.setFont(new java.awt.Font("Arial", 0, 14)); + + urlValue.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + urlValueActionPerformed(evt); + } + }); + + deviceIdLabel.setText("Device ID"); + deviceIdLabel.setFont(new java.awt.Font("Arial", 0, 14)); + + securityKeyLabel.setText("Security Key"); + securityKeyLabel.setFont(new java.awt.Font("Arial", 0, 14)); + + jLabel1.setFont(new java.awt.Font("Liberation Sans", 1, 18)); // NOI18N + jLabel1.setText("Device Configuration"); + + javax.swing.GroupLayout emvConfigPanelLayout = new javax.swing.GroupLayout(emvConfigPanel); + emvConfigPanel.setLayout(emvConfigPanelLayout); + emvConfigPanelLayout.setHorizontalGroup( + emvConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(emvConfigPanelLayout.createSequentialGroup() + .addGap(18, 18, 18) + .addGroup(emvConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(securityKeyLabel) + .addComponent(deviceIdLabel) + .addComponent(urlLabel)) + .addGap(59, 59, 59) + .addGroup(emvConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(urlValue) + .addComponent(deviceIdValue) + .addComponent(securityKeyValue)) + .addContainerGap()) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, emvConfigPanelLayout.createSequentialGroup() + .addContainerGap(125, Short.MAX_VALUE) + .addComponent(jLabel1) + .addGap(114, 114, 114)) + ); + emvConfigPanelLayout.setVerticalGroup( + emvConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, emvConfigPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE) + .addGroup(emvConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(urlValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(urlLabel)) + .addGap(18, 18, 18) + .addGroup(emvConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(deviceIdValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(deviceIdLabel)) + .addGap(15, 15, 15) + .addGroup(emvConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(securityKeyValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(securityKeyLabel)) + .addContainerGap()) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(149, 149, 149) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jcboCardReader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboPaymentGateway, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addGap(109, 109, 109) + .addComponent(emvConfigPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(127, 127, 127)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(11, 11, 11) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboPaymentGateway, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboCardReader, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(64, 64, 64) + .addComponent(emvConfigPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(152, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void urlValueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_urlValueActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_urlValueActionPerformed + + private void jcboPaymentGatewayActionPerformed(java.awt.event.ActionEvent evt) { + paymentConfiguration = paymentsName.get(comboValue(jcboPaymentGateway.getSelectedItem())); + + if (comboValue(jcboPaymentGateway.getSelectedItem()).equals("PaymentSense")) { + emvConfigPanel.setVisible(Boolean.TRUE); + jcboCardReader.setSelectedItem("EMV"); + jcboCardReader.setEnabled(Boolean.FALSE); + } + else { + emvConfigPanel.setVisible(Boolean.FALSE); + jcboCardReader.setEnabled(Boolean.TRUE); + } + } + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel deviceIdLabel; + private javax.swing.JTextField deviceIdValue; + private javax.swing.JPanel emvConfigPanel; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel13; + private javax.swing.JComboBox jcboCardReader; + private javax.swing.JComboBox jcboPaymentGateway; + private javax.swing.JLabel securityKeyLabel; + private javax.swing.JTextField securityKeyValue; + private javax.swing.JLabel urlLabel; + private javax.swing.JTextField urlValue; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigPeripheral.form b/src/main/java/com/unicenta/pos/config/JPanelConfigPeripheral.form new file mode 100644 index 0000000..af35e80 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigPeripheral.form @@ -0,0 +1,2344 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigPeripheral.java b/src/main/java/com/unicenta/pos/config/JPanelConfigPeripheral.java new file mode 100644 index 0000000..4b3673e --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigPeripheral.java @@ -0,0 +1,2549 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . +package com.unicenta.pos.config; + +import com.unicenta.data.user.DirtyManager; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.ReportUtils; +import com.unicenta.pos.util.StringParser; +import java.awt.CardLayout; +import java.awt.Component; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; + + +/** + * + * @author JG uniCenta + */ + +public class JPanelConfigPeripheral extends javax.swing.JPanel implements PanelConfig { + + private final DirtyManager dirty = new DirtyManager(); + + private PrintService[] printServices; + + private final ParametersConfig printer1printerparams; + private final ParametersConfig printer2printerparams; + private final ParametersConfig printer3printerparams; + private final ParametersConfig printer4printerparams; + private final ParametersConfig printer5printerparams; + private final ParametersConfig printer6printerparams; + + /** Creates new form JPanelConfigGeneral */ + public JPanelConfigPeripheral() { + + initComponents(); + + printServices = PrintServiceLookup.lookupPrintServices(null, null); + String[] printernames = ReportUtils.getPrintNames(); + + jcboMachineDisplay.addActionListener(dirty); + jcboConnDisplay.addActionListener(dirty); + jcboSerialDisplay.addActionListener(dirty); + m_jtxtJPOSName.getDocument().addDocumentListener(dirty); + + jcboMachinePrinter.addActionListener(dirty); + jcboConnPrinter.addActionListener(dirty); + jcboSerialPrinter.addActionListener(dirty); + m_jtxtJPOSPrinter.getDocument().addDocumentListener(dirty); + m_jtxtJPOSDrawer.getDocument().addDocumentListener(dirty); + + printer1printerparams = new ParametersPrinter(printernames); + printer1printerparams.addDirtyManager(dirty); + m_jPrinterParams1.add(printer1printerparams.getComponent(), "printer"); + + jcboMachinePrinter2.addActionListener(dirty); + jcboConnPrinter2.addActionListener(dirty); + jcboSerialPrinter2.addActionListener(dirty); + m_jtxtJPOSPrinter2.getDocument().addDocumentListener(dirty); + m_jtxtJPOSDrawer2.getDocument().addDocumentListener(dirty); + + printer2printerparams = new ParametersPrinter(printernames); + printer2printerparams.addDirtyManager(dirty); + m_jPrinterParams2.add(printer2printerparams.getComponent(), "printer"); + + jcboMachinePrinter3.addActionListener(dirty); + jcboConnPrinter3.addActionListener(dirty); + jcboSerialPrinter3.addActionListener(dirty); + m_jtxtJPOSPrinter3.getDocument().addDocumentListener(dirty); + m_jtxtJPOSDrawer3.getDocument().addDocumentListener(dirty); + + printer3printerparams = new ParametersPrinter(printernames); + printer3printerparams.addDirtyManager(dirty); + m_jPrinterParams3.add(printer3printerparams.getComponent(), "printer"); + + jcboMachinePrinter4.addActionListener(dirty); + jcboConnPrinter4.addActionListener(dirty); + jcboSerialPrinter4.addActionListener(dirty); + m_jtxtJPOSPrinter4.getDocument().addDocumentListener(dirty); + m_jtxtJPOSDrawer4.getDocument().addDocumentListener(dirty); + + printer4printerparams = new ParametersPrinter(printernames); + printer4printerparams.addDirtyManager(dirty); + m_jPrinterParams4.add(printer4printerparams.getComponent(), "printer"); + + jcboMachinePrinter5.addActionListener(dirty); + jcboConnPrinter5.addActionListener(dirty); + jcboSerialPrinter5.addActionListener(dirty); + m_jtxtJPOSPrinter5.getDocument().addDocumentListener(dirty); + m_jtxtJPOSDrawer5.getDocument().addDocumentListener(dirty); + + printer5printerparams = new ParametersPrinter(printernames); + printer5printerparams.addDirtyManager(dirty); + m_jPrinterParams5.add(printer5printerparams.getComponent(), "printer"); + + jcboMachinePrinter6.addActionListener(dirty); + jcboConnPrinter6.addActionListener(dirty); + jcboSerialPrinter6.addActionListener(dirty); + m_jtxtJPOSPrinter6.getDocument().addDocumentListener(dirty); + m_jtxtJPOSDrawer6.getDocument().addDocumentListener(dirty); + + printer6printerparams = new ParametersPrinter(printernames); + printer6printerparams.addDirtyManager(dirty); + m_jPrinterParams6.add(printer6printerparams.getComponent(), "printer"); + + jcboMachineScale.addActionListener(dirty); + jcboSerialScale.addActionListener(dirty); + + jcboMachineScanner.addActionListener(dirty); + jcboSerialScanner.addActionListener(dirty); + + cboPrinters.addActionListener(dirty); + + webSwtch_iButton.addActionListener(dirty); + webSlider.addChangeListener(dirty); + +// printers + jcboMachinePrinter.addItem("Not defined"); + jcboMachinePrinter.addItem("screen"); + jcboMachinePrinter.addItem("printer"); + jcboMachinePrinter.addItem("epson"); + jcboMachinePrinter.addItem("tmu220"); + jcboMachinePrinter.addItem("star"); + jcboMachinePrinter.addItem("ODP1000"); + jcboMachinePrinter.addItem("ithaca"); + jcboMachinePrinter.addItem("surepos"); + jcboMachinePrinter.addItem("plain"); + jcboMachinePrinter.addItem("javapos"); + + jcboConnPrinter.addItem("file"); + jcboConnPrinter.addItem("serial"); + + jcboSerialPrinter.addItem("COM1"); + jcboSerialPrinter.addItem("COM2"); + jcboSerialPrinter.addItem("COM3"); + jcboSerialPrinter.addItem("COM4"); + jcboSerialPrinter.addItem("COM5"); + jcboSerialPrinter.addItem("COM6"); + jcboSerialPrinter.addItem("COM7"); + jcboSerialPrinter.addItem("COM8"); + jcboSerialPrinter.addItem("LPT1"); + jcboSerialPrinter.addItem("/dev/ttyS0"); + jcboSerialPrinter.addItem("/dev/ttyS1"); + jcboSerialPrinter.addItem("/dev/ttyS2"); + jcboSerialPrinter.addItem("/dev/ttyS3"); + jcboSerialPrinter.addItem("/dev/ttyS4"); + jcboSerialPrinter.addItem("/dev/ttyS5"); + + jcboMachinePrinter2.addItem("Not defined"); + jcboMachinePrinter2.addItem("screen"); + jcboMachinePrinter2.addItem("printer"); + jcboMachinePrinter2.addItem("epson"); + jcboMachinePrinter2.addItem("tmu220"); + jcboMachinePrinter2.addItem("star"); + jcboMachinePrinter2.addItem("ODP1000"); + jcboMachinePrinter2.addItem("ithaca"); + jcboMachinePrinter2.addItem("surepos"); + jcboMachinePrinter2.addItem("plain"); + jcboMachinePrinter2.addItem("javapos"); + + jcboConnPrinter2.addItem("file"); + jcboConnPrinter2.addItem("serial"); + + jcboSerialPrinter2.addItem("COM1"); + jcboSerialPrinter2.addItem("COM2"); + jcboSerialPrinter2.addItem("COM3"); + jcboSerialPrinter2.addItem("COM4"); + jcboSerialPrinter2.addItem("COM5"); + jcboSerialPrinter2.addItem("COM6"); + jcboSerialPrinter2.addItem("COM7"); + jcboSerialPrinter2.addItem("COM8"); + jcboSerialPrinter2.addItem("LPT1"); + jcboSerialPrinter2.addItem("/dev/ttyS0"); + jcboSerialPrinter2.addItem("/dev/ttyS1"); + jcboSerialPrinter2.addItem("/dev/ttyS2"); + jcboSerialPrinter2.addItem("/dev/ttyS3"); + jcboSerialPrinter2.addItem("/dev/ttyS4"); + jcboSerialPrinter2.addItem("/dev/ttyS5"); + + jcboMachinePrinter3.addItem("Not defined"); + jcboMachinePrinter3.addItem("screen"); + jcboMachinePrinter3.addItem("printer"); + jcboMachinePrinter3.addItem("epson"); + jcboMachinePrinter3.addItem("tmu220"); + jcboMachinePrinter3.addItem("star"); + jcboMachinePrinter3.addItem("ODP1000"); + jcboMachinePrinter3.addItem("ithaca"); + jcboMachinePrinter3.addItem("surepos"); + jcboMachinePrinter3.addItem("plain"); + jcboMachinePrinter3.addItem("javapos"); + + jcboConnPrinter3.addItem("file"); + jcboConnPrinter3.addItem("serial"); + + jcboSerialPrinter3.addItem("COM1"); + jcboSerialPrinter3.addItem("COM2"); + jcboSerialPrinter3.addItem("COM3"); + jcboSerialPrinter3.addItem("COM4"); + jcboSerialPrinter3.addItem("COM5"); + jcboSerialPrinter3.addItem("COM6"); + jcboSerialPrinter3.addItem("COM7"); + jcboSerialPrinter3.addItem("COM8"); + jcboSerialPrinter3.addItem("LPT1"); + jcboSerialPrinter3.addItem("/dev/ttyS0"); + jcboSerialPrinter3.addItem("/dev/ttyS1"); + jcboSerialPrinter3.addItem("/dev/ttyS2"); + jcboSerialPrinter3.addItem("/dev/ttyS3"); + jcboSerialPrinter3.addItem("/dev/ttyS4"); + jcboSerialPrinter3.addItem("/dev/ttyS5"); + + jcboMachinePrinter4.addItem("Not defined"); + jcboMachinePrinter4.addItem("screen"); + jcboMachinePrinter4.addItem("printer"); + jcboMachinePrinter4.addItem("epson"); + jcboMachinePrinter4.addItem("tmu220"); + jcboMachinePrinter4.addItem("star"); + jcboMachinePrinter4.addItem("ODP1000"); + jcboMachinePrinter4.addItem("ithaca"); + jcboMachinePrinter4.addItem("surepos"); + jcboMachinePrinter4.addItem("plain"); + jcboMachinePrinter4.addItem("javapos"); + + jcboConnPrinter4.addItem("file"); + jcboConnPrinter4.addItem("serial"); + + jcboSerialPrinter4.addItem("COM1"); + jcboSerialPrinter4.addItem("COM2"); + jcboSerialPrinter4.addItem("COM3"); + jcboSerialPrinter4.addItem("COM4"); + jcboSerialPrinter4.addItem("COM5"); + jcboSerialPrinter4.addItem("COM6"); + jcboSerialPrinter4.addItem("COM7"); + jcboSerialPrinter4.addItem("COM8"); + jcboSerialPrinter4.addItem("LPT1"); + jcboSerialPrinter4.addItem("/dev/ttyS0"); + jcboSerialPrinter4.addItem("/dev/ttyS1"); + jcboSerialPrinter4.addItem("/dev/ttyS2"); + jcboSerialPrinter4.addItem("/dev/ttyS3"); + jcboSerialPrinter4.addItem("/dev/ttyS4"); + jcboSerialPrinter4.addItem("/dev/ttyS5"); + + jcboMachinePrinter5.addItem("Not defined"); + jcboMachinePrinter5.addItem("screen"); + jcboMachinePrinter5.addItem("printer"); + jcboMachinePrinter5.addItem("epson"); + jcboMachinePrinter5.addItem("tmu220"); + jcboMachinePrinter5.addItem("star"); + jcboMachinePrinter5.addItem("ODP1000"); + jcboMachinePrinter5.addItem("ithaca"); + jcboMachinePrinter5.addItem("surepos"); + jcboMachinePrinter5.addItem("plain"); + jcboMachinePrinter5.addItem("javapos"); + + jcboConnPrinter5.addItem("file"); + jcboConnPrinter5.addItem("serial"); + + jcboSerialPrinter5.addItem("COM1"); + jcboSerialPrinter5.addItem("COM2"); + jcboSerialPrinter5.addItem("COM3"); + jcboSerialPrinter5.addItem("COM4"); + jcboSerialPrinter5.addItem("COM5"); + jcboSerialPrinter5.addItem("COM6"); + jcboSerialPrinter5.addItem("COM7"); + jcboSerialPrinter5.addItem("COM8"); + jcboSerialPrinter5.addItem("LPT1"); + jcboSerialPrinter5.addItem("/dev/ttyS0"); + jcboSerialPrinter5.addItem("/dev/ttyS1"); + jcboSerialPrinter5.addItem("/dev/ttyS2"); + jcboSerialPrinter5.addItem("/dev/ttyS3"); + jcboSerialPrinter5.addItem("/dev/ttyS4"); + jcboSerialPrinter5.addItem("/dev/ttyS5"); + + jcboMachinePrinter6.addItem("Not defined"); + jcboMachinePrinter6.addItem("screen"); + jcboMachinePrinter6.addItem("printer"); + jcboMachinePrinter6.addItem("epson"); + jcboMachinePrinter6.addItem("tmu220"); + jcboMachinePrinter6.addItem("star"); + jcboMachinePrinter6.addItem("ODP1000"); + jcboMachinePrinter6.addItem("ithaca"); + jcboMachinePrinter6.addItem("surepos"); + jcboMachinePrinter6.addItem("plain"); + jcboMachinePrinter6.addItem("javapos"); + + jcboConnPrinter6.addItem("file"); + jcboConnPrinter6.addItem("serial"); + + jcboSerialPrinter6.addItem("COM1"); + jcboSerialPrinter6.addItem("COM2"); + jcboSerialPrinter6.addItem("COM3"); + jcboSerialPrinter6.addItem("COM4"); + jcboSerialPrinter6.addItem("COM5"); + jcboSerialPrinter6.addItem("COM6"); + jcboSerialPrinter6.addItem("COM7"); + jcboSerialPrinter6.addItem("COM8"); + jcboSerialPrinter6.addItem("LPT1"); + jcboSerialPrinter6.addItem("/dev/ttyS0"); + jcboSerialPrinter6.addItem("/dev/ttyS1"); + jcboSerialPrinter6.addItem("/dev/ttyS2"); + jcboSerialPrinter6.addItem("/dev/ttyS3"); + jcboSerialPrinter6.addItem("/dev/ttyS4"); + jcboSerialPrinter6.addItem("/dev/ttyS5"); + + + // Display + jcboMachineDisplay.addItem("Not defined"); + jcboMachineDisplay.addItem("screen"); + jcboMachineDisplay.addItem("window"); + jcboMachineDisplay.addItem("javapos"); + jcboMachineDisplay.addItem("epson"); + jcboMachineDisplay.addItem("ld200"); + jcboMachineDisplay.addItem("surepos"); + + jcboConnDisplay.addItem("serial"); + jcboConnDisplay.addItem("file"); + + jcboSerialDisplay.addItem("COM1"); + jcboSerialDisplay.addItem("COM2"); + jcboSerialDisplay.addItem("COM3"); + jcboSerialDisplay.addItem("COM4"); + jcboSerialDisplay.addItem("COM5"); + jcboSerialDisplay.addItem("COM6"); + jcboSerialDisplay.addItem("COM7"); + jcboSerialDisplay.addItem("COM8"); + jcboSerialDisplay.addItem("LPT1"); + jcboSerialDisplay.addItem("/dev/ttyS0"); + jcboSerialDisplay.addItem("/dev/ttyS1"); + jcboSerialDisplay.addItem("/dev/ttyS2"); + jcboSerialDisplay.addItem("/dev/ttyS3"); + jcboSerialDisplay.addItem("/dev/ttyS4"); + jcboSerialDisplay.addItem("/dev/ttyS5"); + + + // Scale + jcboMachineScale.addItem("Not defined"); + jcboMachineScale.addItem("screen"); + jcboMachineScale.addItem("acompc100"); + jcboMachineScale.addItem("averyberkel6720"); + jcboMachineScale.addItem("casiopd1"); + jcboMachineScale.addItem("caspdii"); + jcboMachineScale.addItem("dialog1"); + jcboMachineScale.addItem("mtind221"); + jcboMachineScale.addItem("samsungesp"); + + jcboSerialScale.addItem("COM1"); + jcboSerialScale.addItem("COM2"); + jcboSerialScale.addItem("COM3"); + jcboSerialScale.addItem("COM4"); + jcboSerialScale.addItem("COM5"); + jcboSerialScale.addItem("COM6"); + jcboSerialScale.addItem("COM7"); + jcboSerialScale.addItem("COM8"); + jcboSerialScale.addItem("/dev/ttyS0"); + jcboSerialScale.addItem("/dev/ttyS1"); + jcboSerialScale.addItem("/dev/ttyS2"); + jcboSerialScale.addItem("/dev/ttyS3"); + jcboSerialScale.addItem("/dev/ttyS4"); + jcboSerialScale.addItem("/dev/ttyS5"); + + // Scanner + jcboMachineScanner.addItem("Not defined"); + jcboMachineScanner.addItem("scanpal2"); + + jcboSerialScanner.addItem("COM1"); + jcboSerialScanner.addItem("COM2"); + jcboSerialScanner.addItem("COM3"); + jcboSerialScanner.addItem("COM4"); + jcboSerialScanner.addItem("COM5"); + jcboSerialScanner.addItem("COM6"); + jcboSerialScanner.addItem("COM7"); + jcboSerialScanner.addItem("COM8"); + jcboSerialScanner.addItem("/dev/ttyS0"); + jcboSerialScanner.addItem("/dev/ttyS1"); + jcboSerialScanner.addItem("/dev/ttyS2"); + jcboSerialScanner.addItem("/dev/ttyS3"); + jcboSerialScanner.addItem("/dev/ttyS4"); + jcboSerialScanner.addItem("/dev/ttyS5"); + + // Printers + cboPrinters.addItem("(Default)"); + cboPrinters.addItem("(Show dialog)"); + for (String name : printernames) { + cboPrinters.addItem(name); + } + } + + /** + * + * @return + */ + @Override + public boolean hasChanged() { + return dirty.isDirty(); + } + + /** + * + * @return + */ + @Override + public Component getConfigComponent() { + return this; + } + + /** + * + * @param config + */ + @Override + public void loadProperties(AppConfig config) { + +// JG 6 May 2013 to switch + StringParser p = new StringParser(config.getProperty("machine.printer")); + String sparam = unifySerialInterface(p.nextToken(':')); + + switch (sparam) { + case "serial": + case "file": + jcboMachinePrinter.setSelectedItem("epson"); + jcboConnPrinter.setSelectedItem(sparam); + jcboSerialPrinter.setSelectedItem(p.nextToken(',')); + break; + case "javapos": + jcboMachinePrinter.setSelectedItem(sparam); + m_jtxtJPOSPrinter.setText(p.nextToken(',')); + m_jtxtJPOSDrawer.setText(p.nextToken(',')); + break; + case "printer": + jcboMachinePrinter.setSelectedItem(sparam); + printer1printerparams.setParameters(p); + break; + default: + jcboMachinePrinter.setSelectedItem(sparam); + jcboConnPrinter.setSelectedItem(unifySerialInterface(p.nextToken(','))); + jcboSerialPrinter.setSelectedItem(p.nextToken(',')); + break; + } + +// JG 6 May 2013 to switch + p = new StringParser(config.getProperty("machine.printer.2")); + sparam = unifySerialInterface(p.nextToken(':')); + switch (sparam) { + case "serial": + case "file": + jcboMachinePrinter2.setSelectedItem("epson"); + jcboConnPrinter2.setSelectedItem(sparam); + jcboSerialPrinter2.setSelectedItem(p.nextToken(',')); + break; + case "javapos": + jcboMachinePrinter2.setSelectedItem(sparam); + m_jtxtJPOSPrinter2.setText(p.nextToken(',')); + m_jtxtJPOSDrawer2.setText(p.nextToken(',')); + break; + case "printer": + jcboMachinePrinter2.setSelectedItem(sparam); + printer2printerparams.setParameters(p); + break; + default: + jcboMachinePrinter2.setSelectedItem(sparam); + jcboConnPrinter2.setSelectedItem(unifySerialInterface(p.nextToken(','))); + jcboSerialPrinter2.setSelectedItem(p.nextToken(',')); + break; + } + +// JG 6 May 2013 to switch + p = new StringParser(config.getProperty("machine.printer.3")); + sparam = unifySerialInterface(p.nextToken(':')); + switch (sparam) { + case "serial": + case "file": + jcboMachinePrinter3.setSelectedItem("epson"); + jcboConnPrinter3.setSelectedItem(sparam); + jcboSerialPrinter3.setSelectedItem(p.nextToken(',')); + break; + case "javapos": + jcboMachinePrinter3.setSelectedItem(sparam); + m_jtxtJPOSPrinter3.setText(p.nextToken(',')); + m_jtxtJPOSDrawer3.setText(p.nextToken(',')); + break; + case "printer": + jcboMachinePrinter3.setSelectedItem(sparam); + printer3printerparams.setParameters(p); + break; + default: + jcboMachinePrinter3.setSelectedItem(sparam); + jcboConnPrinter3.setSelectedItem(unifySerialInterface(p.nextToken(','))); + jcboSerialPrinter3.setSelectedItem(p.nextToken(',')); + break; + } + +// new printers add jdl 10.11.12 + + p = new StringParser(config.getProperty("machine.printer.4")); + sparam = unifySerialInterface(p.nextToken(':')); + switch (sparam) { + case "serial": + case "file": + jcboMachinePrinter4.setSelectedItem("epson"); + jcboConnPrinter4.setSelectedItem(sparam); + jcboSerialPrinter4.setSelectedItem(p.nextToken(',')); + break; + case "javapos": + jcboMachinePrinter4.setSelectedItem(sparam); + m_jtxtJPOSPrinter4.setText(p.nextToken(',')); + m_jtxtJPOSDrawer4.setText(p.nextToken(',')); + break; + case "printer": + jcboMachinePrinter4.setSelectedItem(sparam); + printer4printerparams.setParameters(p); + break; + default: + jcboMachinePrinter4.setSelectedItem(sparam); + jcboConnPrinter4.setSelectedItem(unifySerialInterface(p.nextToken(','))); + jcboSerialPrinter4.setSelectedItem(p.nextToken(',')); + break; + } + + + p = new StringParser(config.getProperty("machine.printer.5")); + sparam = unifySerialInterface(p.nextToken(':')); + switch (sparam) { + case "serial": + case "file": + jcboMachinePrinter5.setSelectedItem("epson"); + jcboConnPrinter5.setSelectedItem(sparam); + jcboSerialPrinter5.setSelectedItem(p.nextToken(',')); + break; + case "javapos": + jcboMachinePrinter5.setSelectedItem(sparam); + m_jtxtJPOSPrinter5.setText(p.nextToken(',')); + m_jtxtJPOSDrawer5.setText(p.nextToken(',')); + break; + case "printer": + jcboMachinePrinter5.setSelectedItem(sparam); + printer5printerparams.setParameters(p); + break; + default: + jcboMachinePrinter5.setSelectedItem(sparam); + jcboConnPrinter5.setSelectedItem(unifySerialInterface(p.nextToken(','))); + jcboSerialPrinter5.setSelectedItem(p.nextToken(',')); + break; + } + + + p = new StringParser(config.getProperty("machine.printer.6")); + sparam = unifySerialInterface(p.nextToken(':')); + switch (sparam) { + case "serial": + case "file": + jcboMachinePrinter6.setSelectedItem("epson"); + jcboConnPrinter6.setSelectedItem(sparam); + jcboSerialPrinter6.setSelectedItem(p.nextToken(',')); + break; + case "javapos": + jcboMachinePrinter6.setSelectedItem(sparam); + m_jtxtJPOSPrinter6.setText(p.nextToken(',')); + m_jtxtJPOSDrawer6.setText(p.nextToken(',')); + break; + case "printer": + jcboMachinePrinter6.setSelectedItem(sparam); + printer6printerparams.setParameters(p); + break; + default: + jcboMachinePrinter6.setSelectedItem(sparam); + jcboConnPrinter6.setSelectedItem(unifySerialInterface(p.nextToken(','))); + jcboSerialPrinter6.setSelectedItem(p.nextToken(',')); + break; + } + + + p = new StringParser(config.getProperty("machine.display")); + sparam = unifySerialInterface(p.nextToken(':')); + switch (sparam) { + case "serial": + case "file": + jcboMachineDisplay.setSelectedItem("epson"); + jcboConnDisplay.setSelectedItem(sparam); + jcboSerialDisplay.setSelectedItem(p.nextToken(',')); + break; + case "javapos": + jcboMachineDisplay.setSelectedItem(sparam); + m_jtxtJPOSName.setText(p.nextToken(',')); + break; + default: + jcboMachineDisplay.setSelectedItem(sparam); + jcboConnDisplay.setSelectedItem(unifySerialInterface(p.nextToken(','))); + jcboSerialDisplay.setSelectedItem(p.nextToken(',')); + break; + } + + + p = new StringParser(config.getProperty("machine.scale")); + sparam = p.nextToken(':'); + jcboMachineScale.setSelectedItem(sparam); + if ("casiopd1".equals(sparam) || + "dialog1".equals(sparam) || + "samsungesp".equals(sparam) || + "caspdii".equals(sparam) || + "acompc100".equals(sparam) || + "averyberkel6720".equals(sparam) || + "mtind221".equals(sparam)) { + jcboSerialScale.setSelectedItem(p.nextToken(',')); + } + + p = new StringParser(config.getProperty("machine.scanner")); + sparam = p.nextToken(':'); + jcboMachineScanner.setSelectedItem(sparam); + if ("scanpal2".equals(sparam)) { + jcboSerialScanner.setSelectedItem(p.nextToken(',')); + } + + cboPrinters.setSelectedItem(config.getProperty("machine.printername")); + + webSwtch_iButton.setSelected(Boolean.parseBoolean(config.getProperty("machine.iButton"))); + webSlider.setValue(Integer.valueOf(config.getProperty("machine.iButtonResponse"))); + + dirty.setDirty(false); + } + + /** + * + * @param config + */ + @Override + public void saveProperties(AppConfig config) { + +// JG 6 May 2013 to switch + String sMachinePrinter = comboValue(jcboMachinePrinter.getSelectedItem()); + switch (sMachinePrinter) { + case "epson": + case "tmu220": + case "star": + case "ODP1000": + case "ithaca": + case "surepos": + config.setProperty("machine.printer", sMachinePrinter + ":" + + comboValue(jcboConnPrinter.getSelectedItem()) + "," + + comboValue(jcboSerialPrinter.getSelectedItem())); + break; + case "javapos": + config.setProperty("machine.printer", sMachinePrinter + ":" + + m_jtxtJPOSPrinter.getText() + "," + + m_jtxtJPOSDrawer.getText()); + break; + case "printer": + config.setProperty("machine.printer", sMachinePrinter + ":" + + printer1printerparams.getParameters()); + break; + default: + config.setProperty("machine.printer", sMachinePrinter); + break; + } +// JG 6 May 2013 to switch + String sMachinePrinter2 = comboValue(jcboMachinePrinter2.getSelectedItem()); + switch (sMachinePrinter2) { + case "epson": + case "tmu220": + case "star": + case "ODP1000": + case "ithaca": + case "surepos": + config.setProperty("machine.printer.2", sMachinePrinter2 + ":" + + comboValue(jcboConnPrinter2.getSelectedItem()) + "," + + comboValue(jcboSerialPrinter2.getSelectedItem())); + break; + case "javapos": + config.setProperty("machine.printer.2", sMachinePrinter2 + ":" + + m_jtxtJPOSPrinter2.getText() + "," + + m_jtxtJPOSDrawer2.getText()); + break; + case "printer": + config.setProperty("machine.printer.2", sMachinePrinter2 + ":" + + printer2printerparams.getParameters()); + break; + default: + config.setProperty("machine.printer.2", sMachinePrinter2); + break; + } + +// JG 6 May 2013 to switch + String sMachinePrinter3 = comboValue(jcboMachinePrinter3.getSelectedItem()); + switch (sMachinePrinter3) { + case "epson": + case "tmu220": + case "star": + case "ODP1000": + case "ithaca": + case "surepos": + config.setProperty("machine.printer.3", sMachinePrinter3 + ":" + + comboValue(jcboConnPrinter3.getSelectedItem()) + "," + + comboValue(jcboSerialPrinter3.getSelectedItem())); + break; + case "javapos": + config.setProperty("machine.printer.3", sMachinePrinter3 + ":" + + m_jtxtJPOSPrinter3.getText() + "," + m_jtxtJPOSDrawer3.getText()); + break; + case "printer": + config.setProperty("machine.printer.3", sMachinePrinter3 + ":" + + printer3printerparams.getParameters()); + break; + default: + config.setProperty("machine.printer.3", sMachinePrinter3); + break; + } +// new printers added 10.11.12 + String sMachinePrinter4 = comboValue(jcboMachinePrinter4.getSelectedItem()); + switch (sMachinePrinter4) { + case "epson": + case "tmu220": + case "star": + case "ODP1000": + case "ithaca": + case "surepos": + config.setProperty("machine.printer.4", sMachinePrinter4 + ":" + + comboValue(jcboConnPrinter4.getSelectedItem()) + "," + + comboValue(jcboSerialPrinter4.getSelectedItem())); + break; + case "javapos": + config.setProperty("machine.printer.4", sMachinePrinter4 + ":" + + m_jtxtJPOSPrinter4.getText() + "," + m_jtxtJPOSDrawer4.getText()); + break; + case "printer": + config.setProperty("machine.printer.4", sMachinePrinter4 + ":" + + printer4printerparams.getParameters()); + break; + default: + config.setProperty("machine.printer.4", sMachinePrinter4); + break; + } + + String sMachinePrinter5 = comboValue(jcboMachinePrinter5.getSelectedItem()); + switch (sMachinePrinter5) { + case "epson": + case "tmu220": + case "star": + case "ODP1000": + case "ithaca": + case "surepos": + config.setProperty("machine.printer.5", sMachinePrinter5 + ":" + + comboValue(jcboConnPrinter5.getSelectedItem()) + "," + + comboValue(jcboSerialPrinter5.getSelectedItem())); + break; + case "javapos": + config.setProperty("machine.printer.5", sMachinePrinter5 + ":" + + m_jtxtJPOSPrinter5.getText() + "," + m_jtxtJPOSDrawer5.getText()); + break; + case "printer": + config.setProperty("machine.printer.5", sMachinePrinter5 + ":" + + printer5printerparams.getParameters()); + break; + default: + config.setProperty("machine.printer.5", sMachinePrinter5); + break; + } + + + String sMachinePrinter6 = comboValue(jcboMachinePrinter6.getSelectedItem()); + switch (sMachinePrinter6) { + case "epson": + case "tmu220": + case "star": + case "ODP1000": + case "ithaca": + case "surepos": + config.setProperty("machine.printer.6", sMachinePrinter6 + ":" + + comboValue(jcboConnPrinter6.getSelectedItem()) + "," + + comboValue(jcboSerialPrinter6.getSelectedItem())); + break; + case "javapos": + config.setProperty("machine.printer.6", sMachinePrinter6 + ":" + + m_jtxtJPOSPrinter6.getText() + "," + m_jtxtJPOSDrawer6.getText()); + break; + case "printer": + config.setProperty("machine.printer.6", sMachinePrinter6 + ":" + + printer6printerparams.getParameters()); + break; + default: + config.setProperty("machine.printer.6", sMachinePrinter6); + break; + } + + +// JG 6 May 2013 to switch + String sMachineDisplay = comboValue(jcboMachineDisplay.getSelectedItem()); + switch (sMachineDisplay) { + case "epson": + case "ld200": + case "surepos": + config.setProperty("machine.display", sMachineDisplay + ":" + + comboValue(jcboConnDisplay.getSelectedItem()) + "," + + comboValue(jcboSerialDisplay.getSelectedItem())); + break; + case "javapos": + config.setProperty("machine.display", sMachineDisplay + ":" + m_jtxtJPOSName.getText()); + break; + default: + config.setProperty("machine.display", sMachineDisplay); + break; + } + +// acompc100 + averyberkel6720 scales added Feb 2017 + String sMachineScale = comboValue(jcboMachineScale.getSelectedItem()); + if ("casiopd1".equals(sMachineScale) || + "dialog1".equals(sMachineScale) || + "samsungesp".equals(sMachineScale) || + "caspdii".equals(sMachineScale) || + "acompc100".equals(sMachineScale) || + "averyberkel6720".equals(sMachineScale) || + "mtind221".equals(sMachineScale)) { + config.setProperty("machine.scale", sMachineScale + ":" + + comboValue(jcboSerialScale.getSelectedItem())); + } else { + config.setProperty("machine.scale", sMachineScale); + } + + // El scanner + String sMachineScanner = comboValue(jcboMachineScanner.getSelectedItem()); + if ("scanpal2".equals(sMachineScanner)) { + config.setProperty("machine.scanner", sMachineScanner + ":" + + comboValue(jcboSerialScanner.getSelectedItem())); + } else { + config.setProperty("machine.scanner", sMachineScanner); + } + + config.setProperty("machine.printername", comboValue(cboPrinters.getSelectedItem())); + +// iButton + config.setProperty("machine.iButton",Boolean.toString(webSwtch_iButton.isSelected())); + config.setProperty("machine.iButtonResponse",Integer.toString(webSlider.getValue())); + + dirty.setDirty(false); + } + + private String unifySerialInterface(String sparam) { + + // for backward compatibility + return ("rxtx".equals(sparam)) + ? "serial" + : sparam; + } + + private String comboValue(Object value) { + return value == null ? "" : value.toString(); + } + + private void buildPrinterList(javax.swing.JComboBox comboBox) { + + comboBox.addItem("COM1"); + comboBox.addItem("COM2"); + comboBox.addItem("COM3"); + comboBox.addItem("COM4"); + comboBox.addItem("COM5"); + comboBox.addItem("COM6"); + comboBox.addItem("COM7"); + comboBox.addItem("COM8"); + comboBox.addItem("COM9"); + comboBox.addItem("COM10"); + comboBox.addItem("COM11"); + comboBox.addItem("COM12"); + + comboBox.addItem("LPT1"); + comboBox.addItem("/dev/ttyS0"); + comboBox.addItem("/dev/ttyS1"); + comboBox.addItem("/dev/ttyS2"); + comboBox.addItem("/dev/ttyS3"); + comboBox.addItem("/dev/ttyS4"); + comboBox.addItem("/dev/ttyS5"); + } + + private void addRegisteredPrinters(javax.swing.JComboBox comboBox) { + for (PrintService printer : printServices) { + comboBox.addItem(printer.getName()); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel13 = new javax.swing.JPanel(); + jLabel5 = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + jLabel7 = new javax.swing.JLabel(); + jLabel8 = new javax.swing.JLabel(); + jLabel9 = new javax.swing.JLabel(); + jLabel10 = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + jLabel12 = new javax.swing.JLabel(); + jLabel13 = new javax.swing.JLabel(); + jLabel14 = new javax.swing.JLabel(); + jcboMachineDisplay = new javax.swing.JComboBox(); + jcboMachinePrinter = new javax.swing.JComboBox(); + jcboMachinePrinter2 = new javax.swing.JComboBox(); + jcboMachinePrinter3 = new javax.swing.JComboBox(); + jcboMachinePrinter4 = new javax.swing.JComboBox(); + jcboMachinePrinter5 = new javax.swing.JComboBox(); + jcboMachinePrinter6 = new javax.swing.JComboBox(); + jcboMachineScale = new javax.swing.JComboBox(); + jcboMachineScanner = new javax.swing.JComboBox(); + cboPrinters = new javax.swing.JComboBox(); + m_jDisplayParams = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jlblConnDisplay = new javax.swing.JLabel(); + jcboConnDisplay = new javax.swing.JComboBox(); + jlblDisplayPort = new javax.swing.JLabel(); + jcboSerialDisplay = new javax.swing.JComboBox(); + jPanel3 = new javax.swing.JPanel(); + jLabel20 = new javax.swing.JLabel(); + m_jtxtJPOSName = new javax.swing.JTextField(); + m_jPrinterParams1 = new javax.swing.JPanel(); + jPanel5 = new javax.swing.JPanel(); + jPanel6 = new javax.swing.JPanel(); + jlblConnPrinter = new javax.swing.JLabel(); + jcboConnPrinter = new javax.swing.JComboBox(); + jlblPrinterPort = new javax.swing.JLabel(); + jcboSerialPrinter = new javax.swing.JComboBox(); + jPanel4 = new javax.swing.JPanel(); + jLabel21 = new javax.swing.JLabel(); + m_jtxtJPOSPrinter = new javax.swing.JTextField(); + m_jtxtJPOSDrawer = new javax.swing.JTextField(); + jLabel24 = new javax.swing.JLabel(); + m_jPrinterParams2 = new javax.swing.JPanel(); + jPanel7 = new javax.swing.JPanel(); + jPanel8 = new javax.swing.JPanel(); + jlblConnPrinter2 = new javax.swing.JLabel(); + jcboConnPrinter2 = new javax.swing.JComboBox(); + jlblPrinterPort2 = new javax.swing.JLabel(); + jcboSerialPrinter2 = new javax.swing.JComboBox(); + jPanel11 = new javax.swing.JPanel(); + m_jtxtJPOSPrinter2 = new javax.swing.JTextField(); + m_jtxtJPOSDrawer2 = new javax.swing.JTextField(); + jLabel27 = new javax.swing.JLabel(); + jLabel22 = new javax.swing.JLabel(); + m_jPrinterParams3 = new javax.swing.JPanel(); + jPanel9 = new javax.swing.JPanel(); + jPanel10 = new javax.swing.JPanel(); + jlblConnPrinter3 = new javax.swing.JLabel(); + jcboConnPrinter3 = new javax.swing.JComboBox(); + jlblPrinterPort3 = new javax.swing.JLabel(); + jcboSerialPrinter3 = new javax.swing.JComboBox(); + jPanel12 = new javax.swing.JPanel(); + m_jtxtJPOSPrinter3 = new javax.swing.JTextField(); + m_jtxtJPOSDrawer3 = new javax.swing.JTextField(); + jLabel28 = new javax.swing.JLabel(); + jLabel23 = new javax.swing.JLabel(); + m_jPrinterParams4 = new javax.swing.JPanel(); + jPanel14 = new javax.swing.JPanel(); + jPanel15 = new javax.swing.JPanel(); + jlblConnPrinter4 = new javax.swing.JLabel(); + jcboConnPrinter4 = new javax.swing.JComboBox(); + jlblPrinterPort6 = new javax.swing.JLabel(); + jcboSerialPrinter4 = new javax.swing.JComboBox(); + jPanel18 = new javax.swing.JPanel(); + m_jtxtJPOSPrinter4 = new javax.swing.JTextField(); + m_jtxtJPOSDrawer4 = new javax.swing.JTextField(); + jLabel30 = new javax.swing.JLabel(); + jLabel31 = new javax.swing.JLabel(); + m_jPrinterParams5 = new javax.swing.JPanel(); + jPanel20 = new javax.swing.JPanel(); + jPanel21 = new javax.swing.JPanel(); + jlblConnPrinter5 = new javax.swing.JLabel(); + jcboConnPrinter5 = new javax.swing.JComboBox(); + jlblPrinterPort7 = new javax.swing.JLabel(); + jcboSerialPrinter5 = new javax.swing.JComboBox(); + jPanel22 = new javax.swing.JPanel(); + m_jtxtJPOSPrinter5 = new javax.swing.JTextField(); + m_jtxtJPOSDrawer5 = new javax.swing.JTextField(); + jLabel33 = new javax.swing.JLabel(); + jLabel34 = new javax.swing.JLabel(); + m_jPrinterParams6 = new javax.swing.JPanel(); + jPanel23 = new javax.swing.JPanel(); + jPanel25 = new javax.swing.JPanel(); + jlblConnPrinter6 = new javax.swing.JLabel(); + jcboConnPrinter6 = new javax.swing.JComboBox(); + jlblPrinterPort8 = new javax.swing.JLabel(); + jcboSerialPrinter6 = new javax.swing.JComboBox(); + jPanel26 = new javax.swing.JPanel(); + m_jtxtJPOSPrinter6 = new javax.swing.JTextField(); + m_jtxtJPOSDrawer6 = new javax.swing.JTextField(); + jLabel36 = new javax.swing.JLabel(); + jLabel37 = new javax.swing.JLabel(); + m_jScaleParams = new javax.swing.JPanel(); + jPanel16 = new javax.swing.JPanel(); + jPanel17 = new javax.swing.JPanel(); + jlblPrinterPort4 = new javax.swing.JLabel(); + jcboSerialScale = new javax.swing.JComboBox(); + m_jScannerParams = new javax.swing.JPanel(); + jPanel24 = new javax.swing.JPanel(); + jPanel19 = new javax.swing.JPanel(); + jcboSerialScanner = new javax.swing.JComboBox(); + jlblPrinterPort5 = new javax.swing.JLabel(); + jPanel27 = new javax.swing.JPanel(); + webSwtch_iButton = new com.alee.extended.button.WebSwitch(); + webLbliButton = new com.alee.laf.label.WebLabel(); + webSlider = new com.alee.laf.slider.WebSlider(); + webLabel1 = new com.alee.laf.label.WebLabel(); + webLabel2 = new com.alee.laf.label.WebLabel(); + webLabel3 = new com.alee.laf.label.WebLabel(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setOpaque(false); + setPreferredSize(new java.awt.Dimension(800, 525)); + + jPanel13.setOpaque(false); + jPanel13.setPreferredSize(new java.awt.Dimension(800, 520)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.MachineDisplay")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.MachinePrinter")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.MachinePrinter2")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.MachinePrinter3")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel9.setText(AppLocal.getIntString("label.MachinePrinter4")); // NOI18N + jLabel9.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel10.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel10.setText(AppLocal.getIntString("label.MachinePrinter5")); // NOI18N + jLabel10.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel11.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel11.setText(AppLocal.getIntString("label.MachinePrinter6")); // NOI18N + jLabel11.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel12.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel12.setText(AppLocal.getIntString("label.scale")); // NOI18N + jLabel12.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel13.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel13.setText(AppLocal.getIntString("label.scanner")); // NOI18N + jLabel13.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel14.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel14.setText(AppLocal.getIntString("label.reportsprinter")); // NOI18N + jLabel14.setPreferredSize(new java.awt.Dimension(150, 30)); + + jcboMachineDisplay.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboMachineDisplay.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jcboMachineDisplay.setPreferredSize(new java.awt.Dimension(200, 30)); + jcboMachineDisplay.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboMachineDisplayActionPerformed(evt); + } + }); + + jcboMachinePrinter.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboMachinePrinter.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jcboMachinePrinter.setPreferredSize(new java.awt.Dimension(200, 30)); + jcboMachinePrinter.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboMachinePrinterActionPerformed(evt); + } + }); + + jcboMachinePrinter2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboMachinePrinter2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jcboMachinePrinter2.setPreferredSize(new java.awt.Dimension(200, 30)); + jcboMachinePrinter2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboMachinePrinter2ActionPerformed(evt); + } + }); + + jcboMachinePrinter3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboMachinePrinter3.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jcboMachinePrinter3.setPreferredSize(new java.awt.Dimension(200, 30)); + jcboMachinePrinter3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboMachinePrinter3ActionPerformed(evt); + } + }); + + jcboMachinePrinter4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboMachinePrinter4.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jcboMachinePrinter4.setPreferredSize(new java.awt.Dimension(200, 30)); + jcboMachinePrinter4.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboMachinePrinter4ActionPerformed(evt); + } + }); + + jcboMachinePrinter5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboMachinePrinter5.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jcboMachinePrinter5.setPreferredSize(new java.awt.Dimension(200, 30)); + jcboMachinePrinter5.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboMachinePrinter5ActionPerformed(evt); + } + }); + + jcboMachinePrinter6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboMachinePrinter6.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jcboMachinePrinter6.setPreferredSize(new java.awt.Dimension(200, 30)); + jcboMachinePrinter6.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboMachinePrinter6ActionPerformed(evt); + } + }); + + jcboMachineScale.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboMachineScale.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jcboMachineScale.setPreferredSize(new java.awt.Dimension(200, 30)); + jcboMachineScale.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboMachineScaleActionPerformed(evt); + } + }); + + jcboMachineScanner.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboMachineScanner.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jcboMachineScanner.setPreferredSize(new java.awt.Dimension(200, 30)); + jcboMachineScanner.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboMachineScannerActionPerformed(evt); + } + }); + + cboPrinters.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + cboPrinters.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + cboPrinters.setPreferredSize(new java.awt.Dimension(200, 30)); + + m_jDisplayParams.setPreferredSize(new java.awt.Dimension(400, 30)); + m_jDisplayParams.setLayout(new java.awt.CardLayout()); + + jPanel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel2.setOpaque(false); + jPanel2.setPreferredSize(new java.awt.Dimension(400, 30)); + m_jDisplayParams.add(jPanel2, "empty"); + + jPanel1.setBackground(new java.awt.Color(255, 255, 255)); + jPanel1.setPreferredSize(new java.awt.Dimension(400, 30)); + + jlblConnDisplay.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblConnDisplay.setText(AppLocal.getIntString("label.machinedisplayconn")); // NOI18N + jlblConnDisplay.setPreferredSize(new java.awt.Dimension(50, 30)); + + jcboConnDisplay.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboConnDisplay.setMinimumSize(new java.awt.Dimension(80, 28)); + jcboConnDisplay.setPreferredSize(new java.awt.Dimension(80, 30)); + + jlblDisplayPort.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblDisplayPort.setText(AppLocal.getIntString("label.machinedisplayport")); // NOI18N + jlblDisplayPort.setPreferredSize(new java.awt.Dimension(50, 30)); + + jcboSerialDisplay.setEditable(true); + jcboSerialDisplay.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboSerialDisplay.setPreferredSize(new java.awt.Dimension(150, 28)); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jlblConnDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboConnDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jlblDisplayPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboSerialDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(62, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jcboConnDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblDisplayPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboSerialDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblConnDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jDisplayParams.add(jPanel1, "comm"); + + jLabel20.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel20.setText(AppLocal.getIntString("Label.Name")); // NOI18N + jLabel20.setPreferredSize(new java.awt.Dimension(50, 25)); + + m_jtxtJPOSName.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jtxtJPOSName.setPreferredSize(new java.awt.Dimension(120, 25)); + m_jtxtJPOSName.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jtxtJPOSNameActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtJPOSName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(224, Short.MAX_VALUE)) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jtxtJPOSName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jDisplayParams.add(jPanel3, "javapos"); + + m_jPrinterParams1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jPrinterParams1.setPreferredSize(new java.awt.Dimension(400, 30)); + m_jPrinterParams1.setLayout(new java.awt.CardLayout()); + + jPanel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel5.setOpaque(false); + jPanel5.setPreferredSize(new java.awt.Dimension(450, 30)); + m_jPrinterParams1.add(jPanel5, "empty"); + + jPanel6.setBackground(new java.awt.Color(255, 255, 255)); + jPanel6.setPreferredSize(new java.awt.Dimension(450, 30)); + + jlblConnPrinter.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblConnPrinter.setText(AppLocal.getIntString("label.machinedisplayconn")); // NOI18N + jlblConnPrinter.setPreferredSize(new java.awt.Dimension(50, 30)); + + jcboConnPrinter.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboConnPrinter.setMinimumSize(new java.awt.Dimension(80, 28)); + jcboConnPrinter.setPreferredSize(new java.awt.Dimension(80, 30)); + jcboConnPrinter.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboConnPrinterActionPerformed(evt); + } + }); + + jlblPrinterPort.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblPrinterPort.setText(AppLocal.getIntString("label.machineprinterport")); // NOI18N + jlblPrinterPort.setPreferredSize(new java.awt.Dimension(50, 30)); + + jcboSerialPrinter.setEditable(true); + jcboSerialPrinter.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboSerialPrinter.setPreferredSize(new java.awt.Dimension(150, 28)); + + javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); + jPanel6.setLayout(jPanel6Layout); + jPanel6Layout.setHorizontalGroup( + jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jlblConnPrinter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboConnPrinter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jlblPrinterPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboSerialPrinter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel6Layout.setVerticalGroup( + jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() + .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jcboConnPrinter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblPrinterPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboSerialPrinter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblConnPrinter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jPrinterParams1.add(jPanel6, "comm"); + + jLabel21.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel21.setText(AppLocal.getIntString("label.javapos.drawer")); // NOI18N + jLabel21.setPreferredSize(new java.awt.Dimension(50, 25)); + + m_jtxtJPOSPrinter.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jtxtJPOSPrinter.setPreferredSize(new java.awt.Dimension(120, 25)); + + m_jtxtJPOSDrawer.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jtxtJPOSDrawer.setPreferredSize(new java.awt.Dimension(120, 25)); + + jLabel24.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel24.setText(AppLocal.getIntString("label.javapos.printer")); // NOI18N + jLabel24.setPreferredSize(new java.awt.Dimension(50, 25)); + + javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtJPOSPrinter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtJPOSDrawer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jtxtJPOSPrinter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtJPOSDrawer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jPrinterParams1.add(jPanel4, "javapos"); + + m_jPrinterParams2.setPreferredSize(new java.awt.Dimension(400, 30)); + m_jPrinterParams2.setLayout(new java.awt.CardLayout()); + + jPanel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel7.setOpaque(false); + jPanel7.setPreferredSize(new java.awt.Dimension(200, 30)); + m_jPrinterParams2.add(jPanel7, "empty"); + + jPanel8.setBackground(new java.awt.Color(255, 255, 255)); + jPanel8.setPreferredSize(new java.awt.Dimension(450, 30)); + + jlblConnPrinter2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblConnPrinter2.setText(AppLocal.getIntString("label.machinedisplayconn")); // NOI18N + jlblConnPrinter2.setPreferredSize(new java.awt.Dimension(50, 30)); + + jcboConnPrinter2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboConnPrinter2.setMinimumSize(new java.awt.Dimension(80, 28)); + jcboConnPrinter2.setPreferredSize(new java.awt.Dimension(80, 30)); + jcboConnPrinter2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboConnPrinter2ActionPerformed(evt); + } + }); + + jlblPrinterPort2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblPrinterPort2.setText(AppLocal.getIntString("label.machineprinterport")); // NOI18N + jlblPrinterPort2.setPreferredSize(new java.awt.Dimension(50, 30)); + + jcboSerialPrinter2.setEditable(true); + jcboSerialPrinter2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboSerialPrinter2.setPreferredSize(new java.awt.Dimension(150, 28)); + + javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8); + jPanel8.setLayout(jPanel8Layout); + jPanel8Layout.setHorizontalGroup( + jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel8Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jlblConnPrinter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboConnPrinter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jlblPrinterPort2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboSerialPrinter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel8Layout.setVerticalGroup( + jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel8Layout.createSequentialGroup() + .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jcboConnPrinter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblPrinterPort2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboSerialPrinter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblConnPrinter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jPrinterParams2.add(jPanel8, "comm"); + + m_jtxtJPOSPrinter2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jtxtJPOSPrinter2.setPreferredSize(new java.awt.Dimension(120, 25)); + + m_jtxtJPOSDrawer2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jtxtJPOSDrawer2.setPreferredSize(new java.awt.Dimension(120, 25)); + + jLabel27.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel27.setText(AppLocal.getIntString("label.javapos.printer")); // NOI18N + jLabel27.setPreferredSize(new java.awt.Dimension(50, 25)); + + jLabel22.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel22.setText(AppLocal.getIntString("label.javapos.drawer")); // NOI18N + jLabel22.setPreferredSize(new java.awt.Dimension(50, 25)); + + javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11); + jPanel11.setLayout(jPanel11Layout); + jPanel11Layout.setHorizontalGroup( + jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel11Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel27, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtJPOSPrinter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtJPOSDrawer2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel11Layout.setVerticalGroup( + jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel11Layout.createSequentialGroup() + .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jtxtJPOSPrinter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtJPOSDrawer2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel27, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jPrinterParams2.add(jPanel11, "javapos"); + + m_jPrinterParams3.setPreferredSize(new java.awt.Dimension(400, 30)); + m_jPrinterParams3.setLayout(new java.awt.CardLayout()); + + jPanel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel9.setOpaque(false); + jPanel9.setPreferredSize(new java.awt.Dimension(200, 30)); + m_jPrinterParams3.add(jPanel9, "empty"); + + jPanel10.setBackground(new java.awt.Color(255, 255, 255)); + jPanel10.setPreferredSize(new java.awt.Dimension(450, 30)); + + jlblConnPrinter3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblConnPrinter3.setText(AppLocal.getIntString("label.machinedisplayconn")); // NOI18N + jlblConnPrinter3.setPreferredSize(new java.awt.Dimension(50, 30)); + + jcboConnPrinter3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboConnPrinter3.setMinimumSize(new java.awt.Dimension(80, 28)); + jcboConnPrinter3.setPreferredSize(new java.awt.Dimension(80, 30)); + jcboConnPrinter3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboConnPrinter3ActionPerformed(evt); + } + }); + + jlblPrinterPort3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblPrinterPort3.setText(AppLocal.getIntString("label.machineprinterport")); // NOI18N + jlblPrinterPort3.setPreferredSize(new java.awt.Dimension(50, 30)); + + jcboSerialPrinter3.setEditable(true); + jcboSerialPrinter3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboSerialPrinter3.setPreferredSize(new java.awt.Dimension(150, 28)); + + javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10); + jPanel10.setLayout(jPanel10Layout); + jPanel10Layout.setHorizontalGroup( + jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel10Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jlblConnPrinter3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboConnPrinter3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jlblPrinterPort3, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboSerialPrinter3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel10Layout.setVerticalGroup( + jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel10Layout.createSequentialGroup() + .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jcboConnPrinter3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblPrinterPort3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboSerialPrinter3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblConnPrinter3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jPrinterParams3.add(jPanel10, "comm"); + + m_jtxtJPOSPrinter3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jtxtJPOSPrinter3.setPreferredSize(new java.awt.Dimension(120, 25)); + + m_jtxtJPOSDrawer3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jtxtJPOSDrawer3.setPreferredSize(new java.awt.Dimension(120, 25)); + + jLabel28.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel28.setText(AppLocal.getIntString("label.javapos.printer")); // NOI18N + jLabel28.setPreferredSize(new java.awt.Dimension(50, 25)); + + jLabel23.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel23.setText(AppLocal.getIntString("label.javapos.drawer")); // NOI18N + jLabel23.setPreferredSize(new java.awt.Dimension(50, 25)); + + javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12); + jPanel12.setLayout(jPanel12Layout); + jPanel12Layout.setHorizontalGroup( + jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel12Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel28, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtJPOSPrinter3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtJPOSDrawer3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel12Layout.setVerticalGroup( + jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel12Layout.createSequentialGroup() + .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jtxtJPOSPrinter3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtJPOSDrawer3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel28, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jPrinterParams3.add(jPanel12, "javapos"); + + m_jPrinterParams4.setPreferredSize(new java.awt.Dimension(400, 30)); + m_jPrinterParams4.setLayout(new java.awt.CardLayout()); + + jPanel14.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel14.setOpaque(false); + jPanel14.setPreferredSize(new java.awt.Dimension(200, 30)); + m_jPrinterParams4.add(jPanel14, "empty"); + + jPanel15.setBackground(new java.awt.Color(255, 255, 255)); + jPanel15.setPreferredSize(new java.awt.Dimension(450, 30)); + + jlblConnPrinter4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblConnPrinter4.setText(AppLocal.getIntString("label.machinedisplayconn")); // NOI18N + jlblConnPrinter4.setPreferredSize(new java.awt.Dimension(50, 30)); + + jcboConnPrinter4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboConnPrinter4.setMinimumSize(new java.awt.Dimension(80, 28)); + jcboConnPrinter4.setPreferredSize(new java.awt.Dimension(80, 30)); + jcboConnPrinter4.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboConnPrinter4ActionPerformed(evt); + } + }); + + jlblPrinterPort6.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblPrinterPort6.setText(AppLocal.getIntString("label.machineprinterport")); // NOI18N + jlblPrinterPort6.setPreferredSize(new java.awt.Dimension(50, 30)); + + jcboSerialPrinter4.setEditable(true); + jcboSerialPrinter4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboSerialPrinter4.setPreferredSize(new java.awt.Dimension(150, 28)); + + javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15); + jPanel15.setLayout(jPanel15Layout); + jPanel15Layout.setHorizontalGroup( + jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel15Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jlblConnPrinter4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboConnPrinter4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jlblPrinterPort6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboSerialPrinter4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel15Layout.setVerticalGroup( + jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel15Layout.createSequentialGroup() + .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jcboConnPrinter4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblPrinterPort6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboSerialPrinter4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblConnPrinter4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jPrinterParams4.add(jPanel15, "comm"); + + m_jtxtJPOSPrinter4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jtxtJPOSPrinter4.setPreferredSize(new java.awt.Dimension(120, 25)); + + m_jtxtJPOSDrawer4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jtxtJPOSDrawer4.setPreferredSize(new java.awt.Dimension(120, 25)); + + jLabel30.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel30.setText(AppLocal.getIntString("label.javapos.printer")); // NOI18N + jLabel30.setPreferredSize(new java.awt.Dimension(50, 25)); + + jLabel31.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel31.setText(AppLocal.getIntString("label.javapos.drawer")); // NOI18N + jLabel31.setPreferredSize(new java.awt.Dimension(50, 25)); + + javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18); + jPanel18.setLayout(jPanel18Layout); + jPanel18Layout.setHorizontalGroup( + jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel18Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel30, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtJPOSPrinter4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel31, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtJPOSDrawer4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel18Layout.setVerticalGroup( + jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel18Layout.createSequentialGroup() + .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jtxtJPOSPrinter4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel31, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtJPOSDrawer4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel30, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jPrinterParams4.add(jPanel18, "javapos"); + + m_jPrinterParams5.setPreferredSize(new java.awt.Dimension(400, 30)); + m_jPrinterParams5.setLayout(new java.awt.CardLayout()); + + jPanel20.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel20.setOpaque(false); + jPanel20.setPreferredSize(new java.awt.Dimension(200, 30)); + m_jPrinterParams5.add(jPanel20, "empty"); + + jPanel21.setBackground(new java.awt.Color(255, 255, 255)); + jPanel21.setPreferredSize(new java.awt.Dimension(450, 30)); + + jlblConnPrinter5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblConnPrinter5.setText(AppLocal.getIntString("label.machinedisplayconn")); // NOI18N + jlblConnPrinter5.setPreferredSize(new java.awt.Dimension(50, 30)); + + jcboConnPrinter5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboConnPrinter5.setMinimumSize(new java.awt.Dimension(80, 28)); + jcboConnPrinter5.setPreferredSize(new java.awt.Dimension(80, 30)); + jcboConnPrinter5.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboConnPrinter5ActionPerformed(evt); + } + }); + + jlblPrinterPort7.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblPrinterPort7.setText(AppLocal.getIntString("label.machineprinterport")); // NOI18N + jlblPrinterPort7.setPreferredSize(new java.awt.Dimension(50, 30)); + + jcboSerialPrinter5.setEditable(true); + jcboSerialPrinter5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboSerialPrinter5.setPreferredSize(new java.awt.Dimension(150, 28)); + + javax.swing.GroupLayout jPanel21Layout = new javax.swing.GroupLayout(jPanel21); + jPanel21.setLayout(jPanel21Layout); + jPanel21Layout.setHorizontalGroup( + jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel21Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jlblConnPrinter5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboConnPrinter5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jlblPrinterPort7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboSerialPrinter5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel21Layout.setVerticalGroup( + jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel21Layout.createSequentialGroup() + .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jcboConnPrinter5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblPrinterPort7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboSerialPrinter5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblConnPrinter5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jPrinterParams5.add(jPanel21, "comm"); + + m_jtxtJPOSPrinter5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jtxtJPOSPrinter5.setPreferredSize(new java.awt.Dimension(120, 25)); + + m_jtxtJPOSDrawer5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jtxtJPOSDrawer5.setPreferredSize(new java.awt.Dimension(120, 25)); + + jLabel33.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel33.setText(AppLocal.getIntString("label.javapos.printer")); // NOI18N + jLabel33.setPreferredSize(new java.awt.Dimension(50, 25)); + + jLabel34.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel34.setText(AppLocal.getIntString("label.javapos.drawer")); // NOI18N + jLabel34.setPreferredSize(new java.awt.Dimension(50, 25)); + + javax.swing.GroupLayout jPanel22Layout = new javax.swing.GroupLayout(jPanel22); + jPanel22.setLayout(jPanel22Layout); + jPanel22Layout.setHorizontalGroup( + jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel22Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel33, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtJPOSPrinter5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel34, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtJPOSDrawer5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel22Layout.setVerticalGroup( + jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel22Layout.createSequentialGroup() + .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jtxtJPOSPrinter5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel34, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtJPOSDrawer5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel33, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jPrinterParams5.add(jPanel22, "javapos"); + + m_jPrinterParams6.setPreferredSize(new java.awt.Dimension(400, 30)); + m_jPrinterParams6.setLayout(new java.awt.CardLayout()); + + jPanel23.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel23.setOpaque(false); + jPanel23.setPreferredSize(new java.awt.Dimension(200, 30)); + m_jPrinterParams6.add(jPanel23, "empty"); + + jPanel25.setBackground(new java.awt.Color(255, 255, 255)); + jPanel25.setPreferredSize(new java.awt.Dimension(450, 30)); + + jlblConnPrinter6.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblConnPrinter6.setText(AppLocal.getIntString("label.machinedisplayconn")); // NOI18N + jlblConnPrinter6.setPreferredSize(new java.awt.Dimension(50, 30)); + + jcboConnPrinter6.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboConnPrinter6.setPreferredSize(new java.awt.Dimension(80, 30)); + jcboConnPrinter6.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboConnPrinter6ActionPerformed(evt); + } + }); + + jlblPrinterPort8.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblPrinterPort8.setText(AppLocal.getIntString("label.machineprinterport")); // NOI18N + jlblPrinterPort8.setPreferredSize(new java.awt.Dimension(50, 25)); + + jcboSerialPrinter6.setEditable(true); + jcboSerialPrinter6.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboSerialPrinter6.setPreferredSize(new java.awt.Dimension(150, 28)); + + javax.swing.GroupLayout jPanel25Layout = new javax.swing.GroupLayout(jPanel25); + jPanel25.setLayout(jPanel25Layout); + jPanel25Layout.setHorizontalGroup( + jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel25Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jlblConnPrinter6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboConnPrinter6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jlblPrinterPort8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboSerialPrinter6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel25Layout.setVerticalGroup( + jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel25Layout.createSequentialGroup() + .addGroup(jPanel25Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jcboConnPrinter6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblPrinterPort8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboSerialPrinter6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblConnPrinter6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jPrinterParams6.add(jPanel25, "comm"); + + m_jtxtJPOSPrinter6.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jtxtJPOSPrinter6.setPreferredSize(new java.awt.Dimension(120, 25)); + + m_jtxtJPOSDrawer6.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jtxtJPOSDrawer6.setPreferredSize(new java.awt.Dimension(120, 25)); + + jLabel36.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel36.setText(AppLocal.getIntString("label.javapos.printer")); // NOI18N + jLabel36.setPreferredSize(new java.awt.Dimension(50, 25)); + + jLabel37.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel37.setText(AppLocal.getIntString("label.javapos.drawer")); // NOI18N + jLabel37.setPreferredSize(new java.awt.Dimension(50, 25)); + + javax.swing.GroupLayout jPanel26Layout = new javax.swing.GroupLayout(jPanel26); + jPanel26.setLayout(jPanel26Layout); + jPanel26Layout.setHorizontalGroup( + jPanel26Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel26Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel36, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtJPOSPrinter6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel37, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtJPOSDrawer6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel26Layout.setVerticalGroup( + jPanel26Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel26Layout.createSequentialGroup() + .addGroup(jPanel26Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jtxtJPOSPrinter6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel37, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtJPOSDrawer6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel36, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jPrinterParams6.add(jPanel26, "javapos"); + + m_jScaleParams.setPreferredSize(new java.awt.Dimension(400, 30)); + m_jScaleParams.setLayout(new java.awt.CardLayout()); + + jPanel16.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel16.setOpaque(false); + jPanel16.setPreferredSize(new java.awt.Dimension(400, 30)); + m_jScaleParams.add(jPanel16, "empty"); + + jPanel17.setBackground(new java.awt.Color(255, 255, 255)); + jPanel17.setPreferredSize(new java.awt.Dimension(400, 30)); + + jlblPrinterPort4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblPrinterPort4.setText(AppLocal.getIntString("label.machineprinterport")); // NOI18N + jlblPrinterPort4.setPreferredSize(new java.awt.Dimension(50, 30)); + + jcboSerialScale.setEditable(true); + jcboSerialScale.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboSerialScale.setMinimumSize(new java.awt.Dimension(80, 28)); + jcboSerialScale.setPreferredSize(new java.awt.Dimension(80, 28)); + + javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17); + jPanel17.setLayout(jPanel17Layout); + jPanel17Layout.setHorizontalGroup( + jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel17Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jlblPrinterPort4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboSerialScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel17Layout.setVerticalGroup( + jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel17Layout.createSequentialGroup() + .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jcboSerialScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblPrinterPort4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + ); + + m_jScaleParams.add(jPanel17, "comm"); + + m_jScannerParams.setPreferredSize(new java.awt.Dimension(400, 30)); + m_jScannerParams.setLayout(new java.awt.CardLayout()); + + jPanel24.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel24.setOpaque(false); + jPanel24.setPreferredSize(new java.awt.Dimension(400, 30)); + m_jScannerParams.add(jPanel24, "empty"); + + jPanel19.setBackground(new java.awt.Color(255, 255, 255)); + jPanel19.setPreferredSize(new java.awt.Dimension(400, 30)); + + jcboSerialScanner.setEditable(true); + jcboSerialScanner.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcboSerialScanner.setMinimumSize(new java.awt.Dimension(80, 28)); + jcboSerialScanner.setPreferredSize(new java.awt.Dimension(80, 28)); + + jlblPrinterPort5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jlblPrinterPort5.setText(AppLocal.getIntString("label.machineprinterport")); // NOI18N + jlblPrinterPort5.setPreferredSize(new java.awt.Dimension(50, 30)); + + javax.swing.GroupLayout jPanel19Layout = new javax.swing.GroupLayout(jPanel19); + jPanel19.setLayout(jPanel19Layout); + jPanel19Layout.setHorizontalGroup( + jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel19Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jlblPrinterPort5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboSerialScanner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel19Layout.setVerticalGroup( + jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel19Layout.createSequentialGroup() + .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jcboSerialScanner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblPrinterPort5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(6, 6, 6)) + ); + + m_jScannerParams.add(jPanel19, "comm"); + + jPanel27.setOpaque(false); + + webSwtch_iButton.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + webSwtch_iButton.setPreferredSize(new java.awt.Dimension(80, 30)); + webSwtch_iButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + webSwtch_iButtonActionPerformed(evt); + } + }); + + webLbliButton.setBackground(new java.awt.Color(240, 240, 240)); + webLbliButton.setText(AppLocal.getIntString("label.ibutton")); // NOI18N + webLbliButton.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + webLbliButton.setPreferredSize(new java.awt.Dimension(150, 30)); + + webSlider.setMajorTickSpacing(10); + webSlider.setMinorTickSpacing(5); + webSlider.setPaintLabels(true); + webSlider.setPaintTicks(true); + webSlider.setSnapToTicks(true); + webSlider.setToolTipText(""); + webSlider.setValue(5); + webSlider.setAnimated(false); + webSlider.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + webSlider.setPreferredSize(new java.awt.Dimension(270, 47)); + webSlider.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + webSliderStateChanged(evt); + } + }); + + webLabel1.setBackground(new java.awt.Color(240, 240, 240)); + webLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + webLabel1.setText(bundle.getString("label.ibuttonresponsespeed")); // NOI18N + webLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + webLabel1.setPreferredSize(new java.awt.Dimension(150, 30)); + + webLabel2.setText(bundle.getString("label.fast")); // NOI18N + webLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + + webLabel3.setText(bundle.getString("label.slow")); // NOI18N + webLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + + javax.swing.GroupLayout jPanel27Layout = new javax.swing.GroupLayout(jPanel27); + jPanel27.setLayout(jPanel27Layout); + jPanel27Layout.setHorizontalGroup( + jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel27Layout.createSequentialGroup() + .addComponent(webLbliButton, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(webSwtch_iButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(webLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(14, 14, 14) + .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel27Layout.createSequentialGroup() + .addComponent(webLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(194, 194, 194) + .addComponent(webLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(webSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + jPanel27Layout.setVerticalGroup( + jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel27Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(webLbliButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webSwtch_iButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE) + .addGroup(jPanel27Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(webLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13); + jPanel13.setLayout(jPanel13Layout); + jPanel13Layout.setHorizontalGroup( + jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createSequentialGroup() + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboMachinePrinter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPrinterParams2, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE)) + .addGroup(jPanel13Layout.createSequentialGroup() + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboMachinePrinter3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPrinterParams3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(jPanel13Layout.createSequentialGroup() + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboMachineScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jScaleParams, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(jPanel13Layout.createSequentialGroup() + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboMachinePrinter4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPrinterParams4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(jPanel13Layout.createSequentialGroup() + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboMachinePrinter5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPrinterParams5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(jPanel13Layout.createSequentialGroup() + .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboMachinePrinter6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPrinterParams6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(jPanel13Layout.createSequentialGroup() + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createSequentialGroup() + .addComponent(jcboMachineDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jDisplayParams, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(jPanel13Layout.createSequentialGroup() + .addComponent(jcboMachinePrinter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPrinterParams1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) + .addGroup(jPanel13Layout.createSequentialGroup() + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createSequentialGroup() + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createSequentialGroup() + .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jcboMachineScanner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel13Layout.createSequentialGroup() + .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cboPrinters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jScannerParams, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jPanel27, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, Short.MAX_VALUE))) + .addGap(16, 16, 16)) + ); + jPanel13Layout.setVerticalGroup( + jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboMachineDisplay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jDisplayParams, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboMachinePrinter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jPrinterParams1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboMachinePrinter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jPrinterParams2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboMachinePrinter3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jPrinterParams3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboMachinePrinter4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jPrinterParams4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboMachinePrinter5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jPrinterParams5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboMachinePrinter6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jPrinterParams6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboMachineScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jScaleParams, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel13Layout.createSequentialGroup() + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcboMachineScanner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(cboPrinters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(m_jScannerParams, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jPanel27, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void jcboMachinePrinter3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboMachinePrinter3ActionPerformed + CardLayout cl = (CardLayout) (m_jPrinterParams3.getLayout()); + + if ("epson".equals(jcboMachinePrinter3.getSelectedItem()) || + "ODP1000".equals(jcboMachinePrinter3.getSelectedItem()) || + "tmu220".equals(jcboMachinePrinter3.getSelectedItem()) || + "star".equals(jcboMachinePrinter3.getSelectedItem()) || + "ithaca".equals(jcboMachinePrinter3.getSelectedItem()) || + "surepos".equals(jcboMachinePrinter3.getSelectedItem())) { + cl.show(m_jPrinterParams3, "comm"); + } else if ("javapos".equals(jcboMachinePrinter3.getSelectedItem())) { + cl.show(m_jPrinterParams3, "javapos"); + } else if ("printer".equals(jcboMachinePrinter3.getSelectedItem())) { + cl.show(m_jPrinterParams3, "printer"); + } else { + cl.show(m_jPrinterParams3, "empty"); + } + }//GEN-LAST:event_jcboMachinePrinter3ActionPerformed + + private void jcboMachinePrinter2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboMachinePrinter2ActionPerformed + CardLayout cl = (CardLayout) (m_jPrinterParams2.getLayout()); + + if ("epson".equals(jcboMachinePrinter2.getSelectedItem()) || + "ODP1000".equals(jcboMachinePrinter2.getSelectedItem()) || + "tmu220".equals(jcboMachinePrinter2.getSelectedItem()) || + "star".equals(jcboMachinePrinter2.getSelectedItem()) || + "ithaca".equals(jcboMachinePrinter2.getSelectedItem()) || + "surepos".equals(jcboMachinePrinter2.getSelectedItem())) { + cl.show(m_jPrinterParams2, "comm"); + } else if ("javapos".equals(jcboMachinePrinter2.getSelectedItem())) { + cl.show(m_jPrinterParams2, "javapos"); + } else if ("printer".equals(jcboMachinePrinter2.getSelectedItem())) { + cl.show(m_jPrinterParams2, "printer"); + } else { + cl.show(m_jPrinterParams2, "empty"); + } + }//GEN-LAST:event_jcboMachinePrinter2ActionPerformed + + private void jcboMachinePrinterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboMachinePrinterActionPerformed + CardLayout cl = (CardLayout) (m_jPrinterParams1.getLayout()); + + if ("epson".equals(jcboMachinePrinter.getSelectedItem()) || + "ODP1000".equals(jcboMachinePrinter.getSelectedItem()) || + "tmu220".equals(jcboMachinePrinter.getSelectedItem()) || + "star".equals(jcboMachinePrinter.getSelectedItem()) || + "ithaca".equals(jcboMachinePrinter.getSelectedItem()) || + "surepos".equals(jcboMachinePrinter.getSelectedItem())) { + cl.show(m_jPrinterParams1, "comm"); + } else if ("javapos".equals(jcboMachinePrinter.getSelectedItem())) { + cl.show(m_jPrinterParams1, "javapos"); + } else if ("printer".equals(jcboMachinePrinter.getSelectedItem())) { + cl.show(m_jPrinterParams1, "printer"); + } else { + cl.show(m_jPrinterParams1, "empty"); + } + }//GEN-LAST:event_jcboMachinePrinterActionPerformed + + private void jcboMachinePrinter4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboMachinePrinter4ActionPerformed + CardLayout cl = (CardLayout) (m_jPrinterParams4.getLayout()); + + if ("epson".equals(jcboMachinePrinter4.getSelectedItem()) || + "ODP1000".equals(jcboMachinePrinter4.getSelectedItem()) || + "tmu220".equals(jcboMachinePrinter4.getSelectedItem()) || + "star".equals(jcboMachinePrinter4.getSelectedItem()) || + "ithaca".equals(jcboMachinePrinter4.getSelectedItem()) || + "surepos".equals(jcboMachinePrinter4.getSelectedItem())) { + cl.show(m_jPrinterParams4, "comm"); + } else if ("javapos".equals(jcboMachinePrinter4.getSelectedItem())) { + cl.show(m_jPrinterParams4, "javapos"); + } else if ("printer".equals(jcboMachinePrinter4.getSelectedItem())) { + cl.show(m_jPrinterParams4, "printer"); + } else { + cl.show(m_jPrinterParams4, "empty"); + } + }//GEN-LAST:event_jcboMachinePrinter4ActionPerformed + + private void jcboMachinePrinter5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboMachinePrinter5ActionPerformed + CardLayout cl = (CardLayout) (m_jPrinterParams5.getLayout()); + + if ("epson".equals(jcboMachinePrinter5.getSelectedItem()) || + "ODP1000".equals(jcboMachinePrinter5.getSelectedItem()) || + "tmu220".equals(jcboMachinePrinter5.getSelectedItem()) || + "star".equals(jcboMachinePrinter5.getSelectedItem()) || + "ithaca".equals(jcboMachinePrinter5.getSelectedItem()) || + "surepos".equals(jcboMachinePrinter5.getSelectedItem())) { + cl.show(m_jPrinterParams5, "comm"); + } else if ("javapos".equals(jcboMachinePrinter5.getSelectedItem())) { + cl.show(m_jPrinterParams5, "javapos"); + } else if ("printer".equals(jcboMachinePrinter5.getSelectedItem())) { + cl.show(m_jPrinterParams5, "printer"); + } else { + cl.show(m_jPrinterParams5, "empty"); + } + }//GEN-LAST:event_jcboMachinePrinter5ActionPerformed + + private void jcboMachinePrinter6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboMachinePrinter6ActionPerformed + CardLayout cl = (CardLayout) (m_jPrinterParams6.getLayout()); + + if ("epson".equals(jcboMachinePrinter6.getSelectedItem()) || + "ODP1000".equals(jcboMachinePrinter6.getSelectedItem()) || + "tmu220".equals(jcboMachinePrinter6.getSelectedItem()) || + "star".equals(jcboMachinePrinter6.getSelectedItem()) || + "ithaca".equals(jcboMachinePrinter6.getSelectedItem()) || + "surepos".equals(jcboMachinePrinter6.getSelectedItem())) { + cl.show(m_jPrinterParams6, "comm"); + } else if ("javapos".equals(jcboMachinePrinter6.getSelectedItem())) { + cl.show(m_jPrinterParams6, "javapos"); + } else if ("printer".equals(jcboMachinePrinter6.getSelectedItem())) { + cl.show(m_jPrinterParams6, "printer"); + } else { + cl.show(m_jPrinterParams6, "empty"); + } + }//GEN-LAST:event_jcboMachinePrinter6ActionPerformed + + private void m_jtxtJPOSNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jtxtJPOSNameActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_m_jtxtJPOSNameActionPerformed + + private void jcboMachineScannerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboMachineScannerActionPerformed + CardLayout cl = (CardLayout) (m_jScannerParams.getLayout()); + + if ("scanpal2".equals(jcboMachineScanner.getSelectedItem())) { + cl.show(m_jScannerParams, "comm"); + } else { + cl.show(m_jScannerParams, "empty"); + } + }//GEN-LAST:event_jcboMachineScannerActionPerformed + + private void jcboMachineScaleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboMachineScaleActionPerformed + CardLayout cl = (CardLayout) (m_jScaleParams.getLayout()); + + // JG 29 Aug 13 - Add Casio PD1 Scale + if ("casiopd1".equals(jcboMachineScale.getSelectedItem()) || + "dialog1".equals(jcboMachineScale.getSelectedItem()) || + "samsungesp".equals(jcboMachineScale.getSelectedItem()) || + "caspdii".equals(jcboMachineScale.getSelectedItem())|| + "acompc100".equals(jcboMachineScale.getSelectedItem())|| + "averyberkel6720".equals(jcboMachineScale.getSelectedItem())|| + "mtind221".equals(jcboMachineScale.getSelectedItem())) { + cl.show(m_jScaleParams, "comm"); + } else { + cl.show(m_jScaleParams, "empty"); + } + }//GEN-LAST:event_jcboMachineScaleActionPerformed + + private void jcboMachineDisplayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboMachineDisplayActionPerformed + CardLayout cl = (CardLayout) (m_jDisplayParams.getLayout()); + + if ("epson".equals(jcboMachineDisplay.getSelectedItem()) || + "ld200".equals(jcboMachineDisplay.getSelectedItem()) || + "surepos".equals(jcboMachineDisplay.getSelectedItem())) { + cl.show(m_jDisplayParams, "comm"); + } else if ("javapos".equals(jcboMachineDisplay.getSelectedItem())) { + cl.show(m_jDisplayParams, "javapos"); + } else { + cl.show(m_jDisplayParams, "empty"); + } + }//GEN-LAST:event_jcboMachineDisplayActionPerformed + + private void webSwtch_iButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_webSwtch_iButtonActionPerformed + if (webSwtch_iButton.isSelected()) { + + } else { + + } + + }//GEN-LAST:event_webSwtch_iButtonActionPerformed + + private void webSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_webSliderStateChanged + webSlider.getValue(); + + }//GEN-LAST:event_webSliderStateChanged + + private void jcboConnPrinterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboConnPrinterActionPerformed + jcboSerialPrinter.removeAllItems(); + if (("raw".equals(jcboConnPrinter.getSelectedItem())) + || ("usb".equals(jcboConnPrinter.getSelectedItem()))) { + jlblPrinterPort.setText("Printer"); + addRegisteredPrinters(jcboSerialPrinter); + } else { + jlblPrinterPort.setText("Port"); + buildPrinterList(jcboSerialPrinter); + } + jcboSerialPrinter.setSelectedItem(null); + }//GEN-LAST:event_jcboConnPrinterActionPerformed + + private void jcboConnPrinter2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboConnPrinter2ActionPerformed + jcboSerialPrinter2.removeAllItems(); + if (("raw".equals(jcboConnPrinter2.getSelectedItem())) + || ("usb".equals(jcboConnPrinter2.getSelectedItem()))) { + jlblPrinterPort2.setText("Printer"); + addRegisteredPrinters(jcboSerialPrinter2); + } else { + jlblPrinterPort2.setText("Port"); + buildPrinterList(jcboSerialPrinter2); + } + jcboSerialPrinter2.setSelectedItem(null); + + }//GEN-LAST:event_jcboConnPrinter2ActionPerformed + + private void jcboConnPrinter3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboConnPrinter3ActionPerformed + jcboSerialPrinter3.removeAllItems(); + if (("raw".equals(jcboConnPrinter3.getSelectedItem())) + || ("usb".equals(jcboConnPrinter3.getSelectedItem()))) { + jlblPrinterPort3.setText("Printer"); + addRegisteredPrinters(jcboSerialPrinter3); + } else { + jlblPrinterPort3.setText("Port"); + buildPrinterList(jcboSerialPrinter3); + } + jcboSerialPrinter2.setSelectedItem(null); + }//GEN-LAST:event_jcboConnPrinter3ActionPerformed + + private void jcboConnPrinter4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboConnPrinter4ActionPerformed + jcboSerialPrinter4.removeAllItems(); + if (("raw".equals(jcboConnPrinter4.getSelectedItem())) + || ("usb".equals(jcboConnPrinter4.getSelectedItem()))) { + jlblPrinterPort4.setText("Printer"); + addRegisteredPrinters(jcboSerialPrinter4); + } else { + jlblPrinterPort4.setText("Port"); + buildPrinterList(jcboSerialPrinter4); + } + jcboSerialPrinter4.setSelectedItem(null); + }//GEN-LAST:event_jcboConnPrinter4ActionPerformed + + private void jcboConnPrinter5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboConnPrinter5ActionPerformed + jcboSerialPrinter5.removeAllItems(); + if (("raw".equals(jcboConnPrinter5.getSelectedItem())) + || ("usb".equals(jcboConnPrinter5.getSelectedItem()))) { + jlblPrinterPort5.setText("Printer"); + addRegisteredPrinters(jcboSerialPrinter5); + } else { + jlblPrinterPort5.setText("Port"); + buildPrinterList(jcboSerialPrinter5); + } + jcboSerialPrinter5.setSelectedItem(null); + }//GEN-LAST:event_jcboConnPrinter5ActionPerformed + + private void jcboConnPrinter6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboConnPrinter6ActionPerformed + jcboSerialPrinter6.removeAllItems(); + if (("raw".equals(jcboConnPrinter.getSelectedItem())) + || ("usb".equals(jcboConnPrinter6.getSelectedItem()))) { + jlblPrinterPort6.setText("Printer"); + addRegisteredPrinters(jcboSerialPrinter6); + } else { + jlblPrinterPort6.setText("Port"); + buildPrinterList(jcboSerialPrinter6); + } + jcboSerialPrinter6.setSelectedItem(null); + }//GEN-LAST:event_jcboConnPrinter6ActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox cboPrinters; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel20; + private javax.swing.JLabel jLabel21; + private javax.swing.JLabel jLabel22; + private javax.swing.JLabel jLabel23; + private javax.swing.JLabel jLabel24; + private javax.swing.JLabel jLabel27; + private javax.swing.JLabel jLabel28; + private javax.swing.JLabel jLabel30; + private javax.swing.JLabel jLabel31; + private javax.swing.JLabel jLabel33; + private javax.swing.JLabel jLabel34; + private javax.swing.JLabel jLabel36; + private javax.swing.JLabel jLabel37; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel10; + private javax.swing.JPanel jPanel11; + private javax.swing.JPanel jPanel12; + private javax.swing.JPanel jPanel13; + private javax.swing.JPanel jPanel14; + private javax.swing.JPanel jPanel15; + private javax.swing.JPanel jPanel16; + private javax.swing.JPanel jPanel17; + private javax.swing.JPanel jPanel18; + private javax.swing.JPanel jPanel19; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel20; + private javax.swing.JPanel jPanel21; + private javax.swing.JPanel jPanel22; + private javax.swing.JPanel jPanel23; + private javax.swing.JPanel jPanel24; + private javax.swing.JPanel jPanel25; + private javax.swing.JPanel jPanel26; + private javax.swing.JPanel jPanel27; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JPanel jPanel7; + private javax.swing.JPanel jPanel8; + private javax.swing.JPanel jPanel9; + private javax.swing.JComboBox jcboConnDisplay; + private javax.swing.JComboBox jcboConnPrinter; + private javax.swing.JComboBox jcboConnPrinter2; + private javax.swing.JComboBox jcboConnPrinter3; + private javax.swing.JComboBox jcboConnPrinter4; + private javax.swing.JComboBox jcboConnPrinter5; + private javax.swing.JComboBox jcboConnPrinter6; + private javax.swing.JComboBox jcboMachineDisplay; + private javax.swing.JComboBox jcboMachinePrinter; + private javax.swing.JComboBox jcboMachinePrinter2; + private javax.swing.JComboBox jcboMachinePrinter3; + private javax.swing.JComboBox jcboMachinePrinter4; + private javax.swing.JComboBox jcboMachinePrinter5; + private javax.swing.JComboBox jcboMachinePrinter6; + private javax.swing.JComboBox jcboMachineScale; + private javax.swing.JComboBox jcboMachineScanner; + private javax.swing.JComboBox jcboSerialDisplay; + private javax.swing.JComboBox jcboSerialPrinter; + private javax.swing.JComboBox jcboSerialPrinter2; + private javax.swing.JComboBox jcboSerialPrinter3; + private javax.swing.JComboBox jcboSerialPrinter4; + private javax.swing.JComboBox jcboSerialPrinter5; + private javax.swing.JComboBox jcboSerialPrinter6; + private javax.swing.JComboBox jcboSerialScale; + private javax.swing.JComboBox jcboSerialScanner; + private javax.swing.JLabel jlblConnDisplay; + private javax.swing.JLabel jlblConnPrinter; + private javax.swing.JLabel jlblConnPrinter2; + private javax.swing.JLabel jlblConnPrinter3; + private javax.swing.JLabel jlblConnPrinter4; + private javax.swing.JLabel jlblConnPrinter5; + private javax.swing.JLabel jlblConnPrinter6; + private javax.swing.JLabel jlblDisplayPort; + private javax.swing.JLabel jlblPrinterPort; + private javax.swing.JLabel jlblPrinterPort2; + private javax.swing.JLabel jlblPrinterPort3; + private javax.swing.JLabel jlblPrinterPort4; + private javax.swing.JLabel jlblPrinterPort5; + private javax.swing.JLabel jlblPrinterPort6; + private javax.swing.JLabel jlblPrinterPort7; + private javax.swing.JLabel jlblPrinterPort8; + private javax.swing.JPanel m_jDisplayParams; + private javax.swing.JPanel m_jPrinterParams1; + private javax.swing.JPanel m_jPrinterParams2; + private javax.swing.JPanel m_jPrinterParams3; + private javax.swing.JPanel m_jPrinterParams4; + private javax.swing.JPanel m_jPrinterParams5; + private javax.swing.JPanel m_jPrinterParams6; + private javax.swing.JPanel m_jScaleParams; + private javax.swing.JPanel m_jScannerParams; + private javax.swing.JTextField m_jtxtJPOSDrawer; + private javax.swing.JTextField m_jtxtJPOSDrawer2; + private javax.swing.JTextField m_jtxtJPOSDrawer3; + private javax.swing.JTextField m_jtxtJPOSDrawer4; + private javax.swing.JTextField m_jtxtJPOSDrawer5; + private javax.swing.JTextField m_jtxtJPOSDrawer6; + private javax.swing.JTextField m_jtxtJPOSName; + private javax.swing.JTextField m_jtxtJPOSPrinter; + private javax.swing.JTextField m_jtxtJPOSPrinter2; + private javax.swing.JTextField m_jtxtJPOSPrinter3; + private javax.swing.JTextField m_jtxtJPOSPrinter4; + private javax.swing.JTextField m_jtxtJPOSPrinter5; + private javax.swing.JTextField m_jtxtJPOSPrinter6; + private com.alee.laf.label.WebLabel webLabel1; + private com.alee.laf.label.WebLabel webLabel2; + private com.alee.laf.label.WebLabel webLabel3; + private com.alee.laf.label.WebLabel webLbliButton; + private com.alee.laf.slider.WebSlider webSlider; + private com.alee.extended.button.WebSwitch webSwtch_iButton; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigSystem.form b/src/main/java/com/unicenta/pos/config/JPanelConfigSystem.form new file mode 100644 index 0000000..37ada68 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigSystem.form @@ -0,0 +1,922 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfigSystem.java b/src/main/java/com/unicenta/pos/config/JPanelConfigSystem.java new file mode 100644 index 0000000..b238ccd --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfigSystem.java @@ -0,0 +1,828 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.config; + +import com.unicenta.data.user.DirtyManager; +import com.unicenta.pos.forms.AppConfig; +import java.awt.*; +import com.alee.extended.colorchooser.*; +import com.alee.managers.language.*; +import com.alee.laf.*; +import com.alee.extended.colorchooser.ColorDisplayType; +import javax.swing.*; + + +/** + * + * @author JG uniCenta + */ +public class JPanelConfigSystem extends javax.swing.JPanel implements PanelConfig { + + private DirtyManager dirty = new DirtyManager(); + + /** Creates new form JPanelConfigDatabase */ + public JPanelConfigSystem() { + + WebLookAndFeel.initializeManagers (); + + initComponents(); + + + jTextAutoLogoffTime.getDocument().addDocumentListener(dirty); + jchkInstance.addActionListener(dirty); + jchkTextOverlay.addActionListener(dirty); + jchkAutoLogoff.addActionListener(dirty); + jchkAutoLogoffToTables.addActionListener(dirty); + jTaxIncluded.addActionListener(dirty); + jCheckPrice00.addActionListener(dirty); + jMoveAMountBoxToTop.addActionListener(dirty); + jCloseCashbtn.addActionListener(dirty); + jchkautoRefreshTableMap.addActionListener(dirty); + jTxtautoRefreshTimer.getDocument().addDocumentListener(dirty); + jchkSCOnOff.addActionListener(dirty); + jchkSCRestaurant.addActionListener(dirty); + jTextSCRate.getDocument().addDocumentListener(dirty); + jchkPriceUpdate.addActionListener(dirty); + jchkBarcodetype.addActionListener(dirty); + jchkShowCustomerDetails.addActionListener(dirty); + jchkShowWaiterDetails.addActionListener(dirty); + CustomerColour.addActionListener(dirty); + WaiterColour.addActionListener(dirty); + TableNameColour.addActionListener(dirty); + jchkTransBtn.addActionListener(dirty); + jchkOverride.addActionListener(dirty); + jtxtPIN.getDocument().addDocumentListener(dirty); + disableAnonymousStats.addActionListener(dirty); + + } + + /** + * + * @return + */ + @Override + public boolean hasChanged() { + return dirty.isDirty(); + } + + /** + * + * @return + */ + @Override + public Component getConfigComponent() { + return this; + } + + /** + * + * @param config + */ + @Override + public void loadProperties(AppConfig config) { + + String timerCheck =(config.getProperty("till.autotimer")); + if (timerCheck == null){ + config.setProperty("till.autotimer","100"); + } else { + jTextAutoLogoffTime.setText(config.getProperty("till.autotimer")); + } + + String autoRefreshtimerCheck =(config.getProperty("till.autoRefreshTimer")); + if (autoRefreshtimerCheck == null){ + config.setProperty("till.autoRefreshTableMap","false"); + config.setProperty("till.autoRefreshTimer","5"); + } + jTxtautoRefreshTimer.setText(config.getProperty("till.autoRefreshTimer")); + + jchkInstance.setSelected(Boolean.parseBoolean(config.getProperty("machine.uniqueinstance"))); + + jchkTextOverlay.setSelected(Boolean.parseBoolean(config.getProperty("payments.textoverlay"))); + jchkAutoLogoff.setSelected(Boolean.parseBoolean(config.getProperty("till.autoLogoff"))); + jchkAutoLogoffToTables.setSelected(Boolean.parseBoolean(config.getProperty("till.autoLogoffrestaurant"))); + jTaxIncluded.setSelected(Boolean.parseBoolean(config.getProperty("till.taxincluded"))); + jCheckPrice00.setSelected(Boolean.parseBoolean(config.getProperty("till.pricewith00"))); + jMoveAMountBoxToTop.setSelected(Boolean.parseBoolean(config.getProperty("till.amountattop"))); + jCloseCashbtn.setSelected(Boolean.parseBoolean(config.getProperty("screen.600800"))); + jchkautoRefreshTableMap.setSelected(Boolean.parseBoolean(config.getProperty("till.autoRefreshTableMap"))); + jchkPriceUpdate.setSelected(AppConfig.getInstance().getBoolean("db.prodpriceupdate")); + jchkBarcodetype.setSelected(Boolean.parseBoolean(config.getProperty("machine.barcodetype"))); + + String txtPIN =(config.getProperty("override.pin")); + if (txtPIN == null){ + config.setProperty("override.check","true"); + config.setProperty("override.pin","1234"); + } + jchkOverride.setSelected(Boolean.parseBoolean(config.getProperty("override.check"))); + jtxtPIN.setText(config.getProperty("override.pin")); + +/** Added: JG 23 July 13 */ + String SCCheck =(config.getProperty("till.SCRate")); + if (SCCheck == null){ + config.setProperty("till.SCRate","0"); + } + jTextSCRate.setText(config.getProperty("till.SCRate")); + jchkSCOnOff.setSelected(Boolean.parseBoolean(config.getProperty("till.SCOnOff"))); + jchkSCRestaurant.setSelected(Boolean.parseBoolean(config.getProperty("till.SCRestaurant"))); + + if (jchkSCOnOff.isSelected()){ + jchkSCRestaurant.setVisible(true); + jLabelSCRate.setVisible(true); + jTextSCRate.setVisible(true); + jLabelSCRatePerCent.setVisible(true); + }else{ + jchkSCRestaurant.setVisible(false); + jLabelSCRate.setVisible(false); + jTextSCRate.setVisible(false); + jLabelSCRatePerCent.setVisible(false); + } + + if (jchkAutoLogoff.isSelected()){ + jchkAutoLogoffToTables.setVisible(true); + jLabelInactiveTime.setVisible(true); + jLabelTimedMessage.setVisible(true); + jTextAutoLogoffTime.setVisible(true); + }else{ + jchkAutoLogoffToTables.setVisible(false); + jLabelInactiveTime.setVisible(false); + jLabelTimedMessage.setVisible(false); + jTextAutoLogoffTime.setVisible(false); + } + + if (jchkautoRefreshTableMap.isSelected()){ + jLblautoRefresh.setVisible(true); + jLabelInactiveTime1.setVisible(true); + jTxtautoRefreshTimer.setVisible(true); + }else{ + jLblautoRefresh.setVisible(false); + jLabelInactiveTime1.setVisible(false); + jTxtautoRefreshTimer.setVisible(false); + } + + String customerCheck =(config.getProperty("table.showcustomerdetails")); + if (customerCheck == null) { + config.setProperty("table.showcustomerdetails","true"); + } + jchkShowCustomerDetails.setSelected(Boolean.parseBoolean(config.getProperty("table.showcustomerdetails"))); + if (config.getProperty("table.customercolour")==null){ + CustomerColour.setText(""); + }else{ + CustomerColour.setText(config.getProperty("table.customercolour")); + } + + String waiterCheck =(config.getProperty("table.showwaiterdetails")); + if (waiterCheck == null) { + config.setProperty("table.showwaiterdetails","true"); + } + jchkShowWaiterDetails.setSelected(Boolean.parseBoolean(config.getProperty("table.showwaiterdetails"))); + if (config.getProperty("table.waitercolour")==null){ + WaiterColour.setText(""); + }else{ + WaiterColour.setText(config.getProperty("table.waitercolour")); + } + if (config.getProperty("table.tablecolour")==null){ + TableNameColour.setText(""); + }else{ + TableNameColour.setText(config.getProperty("table.tablecolour")); + } + + jchkTransBtn.setSelected(Boolean.parseBoolean(config.getProperty("table.transbtn"))); + + dirty.setDirty(false); + } + + /** + * + * @param config + */ + @Override + public void saveProperties(AppConfig config) { + + config.setProperty("till.autotimer",jTextAutoLogoffTime.getText()); + config.setProperty("machine.uniqueinstance", Boolean.toString(jchkInstance.isSelected())); + config.setProperty("table.showcustomerdetails", Boolean.toString(jchkShowCustomerDetails.isSelected())); + config.setProperty("table.showwaiterdetails", Boolean.toString(jchkShowWaiterDetails.isSelected())); + config.setProperty("payments.textoverlay", Boolean.toString(jchkTextOverlay.isSelected())); + config.setProperty("till.autoLogoff", Boolean.toString(jchkAutoLogoff.isSelected())); + config.setProperty("till.autoLogoffrestaurant", Boolean.toString(jchkAutoLogoffToTables.isSelected())); + config.setProperty("table.customercolour",CustomerColour.getText()); + config.setProperty("table.waitercolour",WaiterColour.getText()); + config.setProperty("table.tablecolour",TableNameColour.getText()); + config.setProperty("till.taxincluded",Boolean.toString(jTaxIncluded.isSelected())); + config.setProperty("till.pricewith00",Boolean.toString(jCheckPrice00.isSelected())); + config.setProperty("till.amountattop",Boolean.toString(jMoveAMountBoxToTop.isSelected())); + config.setProperty("screen.600800",Boolean.toString(jCloseCashbtn.isSelected())); + config.setProperty("till.autoRefreshTableMap", Boolean.toString(jchkautoRefreshTableMap.isSelected())); + config.setProperty("till.autoRefreshTimer", jTxtautoRefreshTimer.getText()); + + config.setProperty("till.SCOnOff",Boolean.toString(jchkSCOnOff.isSelected())); + config.setProperty("till.SCRate",jTextSCRate.getText()); + config.setProperty("till.SCRestaurant",Boolean.toString(jchkSCRestaurant.isSelected())); + + config.setProperty("db.prodpriceupdate", Boolean.toString(jchkPriceUpdate.isSelected())); + config.setProperty("machine.barcodetype", Boolean.toString(jchkBarcodetype.isSelected())); + + config.setProperty("table.transbtn", Boolean.toString(jchkTransBtn.isSelected())); + + config.setProperty("override.check", Boolean.toString(jchkOverride.isSelected())); + config.setProperty("override.pin",jtxtPIN.getText()); + config.setProperty("disable.stats", Boolean.toString(disableAnonymousStats.isSelected())); + + dirty.setDirty(false); + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jchkInstance = new javax.swing.JCheckBox(); + jLabelInactiveTime = new javax.swing.JLabel(); + jTextAutoLogoffTime = new javax.swing.JTextField(); + jLabelTimedMessage = new javax.swing.JLabel(); + jchkAutoLogoff = new javax.swing.JCheckBox(); + jchkAutoLogoffToTables = new javax.swing.JCheckBox(); + jchkShowCustomerDetails = new javax.swing.JCheckBox(); + jchkShowWaiterDetails = new javax.swing.JCheckBox(); + jLabelTableNameTextColour = new javax.swing.JLabel(); + jCheckPrice00 = new javax.swing.JCheckBox(); + jTaxIncluded = new javax.swing.JCheckBox(); + jCloseCashbtn = new javax.swing.JCheckBox(); + jMoveAMountBoxToTop = new javax.swing.JCheckBox(); + jchkTextOverlay = new javax.swing.JCheckBox(); + jchkautoRefreshTableMap = new javax.swing.JCheckBox(); + jLabelInactiveTime1 = new javax.swing.JLabel(); + jTxtautoRefreshTimer = new javax.swing.JTextField(); + jLblautoRefresh = new javax.swing.JLabel(); + jchkSCOnOff = new javax.swing.JCheckBox(); + jLabelSCRate = new javax.swing.JLabel(); + jTextSCRate = new javax.swing.JTextField(); + jLabelSCRatePerCent = new javax.swing.JLabel(); + jchkSCRestaurant = new javax.swing.JCheckBox(); + jchkPriceUpdate = new javax.swing.JCheckBox(); + jchkBarcodetype = new javax.swing.JCheckBox(); + jchkTransBtn = new javax.swing.JCheckBox(); + WaiterColour = new com.alee.extended.colorchooser.WebColorChooserField(); + TableNameColour = new com.alee.extended.colorchooser.WebColorChooserField(); + CustomerColour = new com.alee.extended.colorchooser.WebColorChooserField(); + jchkOverride = new javax.swing.JCheckBox(); + jtxtPIN = new javax.swing.JTextField(); + jLabel5 = new javax.swing.JLabel(); + disableAnonymousStats = new javax.swing.JCheckBox(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setOpaque(false); + setPreferredSize(new java.awt.Dimension(700, 500)); + + jLabel1.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLabel1.setText(bundle.getString("label.configOptionStartup")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + jLabel2.setText(bundle.getString("label.configOptionKeypad")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + jLabel3.setText(bundle.getString("label.configOptionLogOff")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + jLabel4.setText(bundle.getString("label.configOptionRestaurant")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(250, 30)); + + jchkInstance.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jchkInstance.setSelected(true); + jchkInstance.setText(bundle.getString("label.instance")); // NOI18N + jchkInstance.setMaximumSize(new java.awt.Dimension(0, 25)); + jchkInstance.setMinimumSize(new java.awt.Dimension(0, 0)); + jchkInstance.setPreferredSize(new java.awt.Dimension(250, 25)); + + jLabelInactiveTime.setBackground(new java.awt.Color(255, 255, 255)); + jLabelInactiveTime.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabelInactiveTime.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabelInactiveTime.setText(bundle.getString("label.autolofftime")); // NOI18N + jLabelInactiveTime.setMaximumSize(new java.awt.Dimension(0, 25)); + jLabelInactiveTime.setMinimumSize(new java.awt.Dimension(0, 0)); + jLabelInactiveTime.setPreferredSize(new java.awt.Dimension(100, 30)); + + jTextAutoLogoffTime.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextAutoLogoffTime.setText("0"); + jTextAutoLogoffTime.setMaximumSize(new java.awt.Dimension(0, 25)); + jTextAutoLogoffTime.setMinimumSize(new java.awt.Dimension(0, 0)); + jTextAutoLogoffTime.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabelTimedMessage.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabelTimedMessage.setText(bundle.getString("label.autologoffzero")); // NOI18N + jLabelTimedMessage.setMaximumSize(new java.awt.Dimension(0, 25)); + jLabelTimedMessage.setMinimumSize(new java.awt.Dimension(0, 0)); + jLabelTimedMessage.setPreferredSize(new java.awt.Dimension(200, 30)); + + jchkAutoLogoff.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jchkAutoLogoff.setText(bundle.getString("label.autologonoff")); // NOI18N + jchkAutoLogoff.setMaximumSize(new java.awt.Dimension(0, 25)); + jchkAutoLogoff.setMinimumSize(new java.awt.Dimension(0, 0)); + jchkAutoLogoff.setPreferredSize(new java.awt.Dimension(200, 30)); + jchkAutoLogoff.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jchkAutoLogoffActionPerformed(evt); + } + }); + + jchkAutoLogoffToTables.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jchkAutoLogoffToTables.setText(bundle.getString("label.autoloffrestaurant")); // NOI18N + jchkAutoLogoffToTables.setMaximumSize(new java.awt.Dimension(0, 25)); + jchkAutoLogoffToTables.setMinimumSize(new java.awt.Dimension(0, 0)); + jchkAutoLogoffToTables.setPreferredSize(new java.awt.Dimension(0, 30)); + jchkAutoLogoffToTables.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jchkAutoLogoffToTablesActionPerformed(evt); + } + }); + + jchkShowCustomerDetails.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jchkShowCustomerDetails.setSelected(true); + jchkShowCustomerDetails.setText(bundle.getString("label.tableshowcustomerdetails")); // NOI18N + jchkShowCustomerDetails.setMaximumSize(new java.awt.Dimension(0, 25)); + jchkShowCustomerDetails.setMinimumSize(new java.awt.Dimension(0, 0)); + jchkShowCustomerDetails.setPreferredSize(new java.awt.Dimension(350, 30)); + jchkShowCustomerDetails.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jchkShowCustomerDetailsActionPerformed(evt); + } + }); + + jchkShowWaiterDetails.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jchkShowWaiterDetails.setSelected(true); + jchkShowWaiterDetails.setText(bundle.getString("label.tableshowwaiterdetails")); // NOI18N + jchkShowWaiterDetails.setMaximumSize(new java.awt.Dimension(0, 25)); + jchkShowWaiterDetails.setMinimumSize(new java.awt.Dimension(0, 0)); + jchkShowWaiterDetails.setPreferredSize(new java.awt.Dimension(350, 30)); + + jLabelTableNameTextColour.setBackground(new java.awt.Color(255, 255, 255)); + jLabelTableNameTextColour.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabelTableNameTextColour.setText(bundle.getString("label.textclourtablename")); // NOI18N + jLabelTableNameTextColour.setMaximumSize(new java.awt.Dimension(0, 25)); + jLabelTableNameTextColour.setMinimumSize(new java.awt.Dimension(0, 0)); + jLabelTableNameTextColour.setPreferredSize(new java.awt.Dimension(350, 30)); + + jCheckPrice00.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jCheckPrice00.setText(bundle.getString("label.pricewith00")); // NOI18N + jCheckPrice00.setToolTipText(""); + jCheckPrice00.setMaximumSize(new java.awt.Dimension(0, 25)); + jCheckPrice00.setMinimumSize(new java.awt.Dimension(0, 0)); + jCheckPrice00.setPreferredSize(new java.awt.Dimension(250, 25)); + jCheckPrice00.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jCheckPrice00ActionPerformed(evt); + } + }); + + jTaxIncluded.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTaxIncluded.setText(bundle.getString("label.taxincluded")); // NOI18N + jTaxIncluded.setMaximumSize(new java.awt.Dimension(0, 25)); + jTaxIncluded.setMinimumSize(new java.awt.Dimension(0, 0)); + jTaxIncluded.setPreferredSize(new java.awt.Dimension(250, 25)); + + jCloseCashbtn.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jCloseCashbtn.setText(bundle.getString("message.systemclosecash")); // NOI18N + jCloseCashbtn.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jCloseCashbtn.setMaximumSize(new java.awt.Dimension(0, 25)); + jCloseCashbtn.setMinimumSize(new java.awt.Dimension(0, 0)); + jCloseCashbtn.setPreferredSize(new java.awt.Dimension(250, 25)); + + jMoveAMountBoxToTop.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jMoveAMountBoxToTop.setSelected(true); + jMoveAMountBoxToTop.setText(bundle.getString("label.inputamount")); // NOI18N + jMoveAMountBoxToTop.setMaximumSize(new java.awt.Dimension(0, 25)); + jMoveAMountBoxToTop.setMinimumSize(new java.awt.Dimension(0, 0)); + jMoveAMountBoxToTop.setPreferredSize(new java.awt.Dimension(250, 25)); + + jchkTextOverlay.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jchkTextOverlay.setText(bundle.getString("label.currencybutton")); // NOI18N + jchkTextOverlay.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jchkTextOverlay.setMaximumSize(new java.awt.Dimension(0, 25)); + jchkTextOverlay.setMinimumSize(new java.awt.Dimension(0, 0)); + jchkTextOverlay.setPreferredSize(new java.awt.Dimension(250, 25)); + + jchkautoRefreshTableMap.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jchkautoRefreshTableMap.setText(bundle.getString("label.autoRefreshTableMap")); // NOI18N + jchkautoRefreshTableMap.setMaximumSize(new java.awt.Dimension(0, 25)); + jchkautoRefreshTableMap.setMinimumSize(new java.awt.Dimension(0, 0)); + jchkautoRefreshTableMap.setPreferredSize(new java.awt.Dimension(200, 30)); + jchkautoRefreshTableMap.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jchkautoRefreshTableMapActionPerformed(evt); + } + }); + + jLabelInactiveTime1.setBackground(new java.awt.Color(255, 255, 255)); + jLabelInactiveTime1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabelInactiveTime1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabelInactiveTime1.setText(bundle.getString("label.autolofftime")); // NOI18N + jLabelInactiveTime1.setMaximumSize(new java.awt.Dimension(0, 25)); + jLabelInactiveTime1.setMinimumSize(new java.awt.Dimension(0, 0)); + jLabelInactiveTime1.setPreferredSize(new java.awt.Dimension(100, 30)); + + jTxtautoRefreshTimer.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTxtautoRefreshTimer.setText("0"); + jTxtautoRefreshTimer.setMaximumSize(new java.awt.Dimension(0, 25)); + jTxtautoRefreshTimer.setMinimumSize(new java.awt.Dimension(0, 0)); + jTxtautoRefreshTimer.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLblautoRefresh.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblautoRefresh.setText(bundle.getString("label.autoRefreshTableMapTimer")); // NOI18N + jLblautoRefresh.setMaximumSize(new java.awt.Dimension(0, 25)); + jLblautoRefresh.setMinimumSize(new java.awt.Dimension(0, 0)); + jLblautoRefresh.setPreferredSize(new java.awt.Dimension(200, 30)); + + jchkSCOnOff.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jchkSCOnOff.setText(bundle.getString("label.SCOnOff")); // NOI18N + jchkSCOnOff.setMaximumSize(new java.awt.Dimension(0, 25)); + jchkSCOnOff.setMinimumSize(new java.awt.Dimension(0, 0)); + jchkSCOnOff.setPreferredSize(new java.awt.Dimension(0, 25)); + jchkSCOnOff.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jchkSCOnOffActionPerformed(evt); + } + }); + + jLabelSCRate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabelSCRate.setText(bundle.getString("label.SCRate")); // NOI18N + jLabelSCRate.setMaximumSize(new java.awt.Dimension(0, 25)); + jLabelSCRate.setMinimumSize(new java.awt.Dimension(0, 0)); + jLabelSCRate.setPreferredSize(new java.awt.Dimension(190, 30)); + + jTextSCRate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextSCRate.setText("0"); + jTextSCRate.setMaximumSize(new java.awt.Dimension(0, 25)); + jTextSCRate.setMinimumSize(new java.awt.Dimension(0, 0)); + jTextSCRate.setPreferredSize(new java.awt.Dimension(0, 30)); + jTextSCRate.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextSCRateActionPerformed(evt); + } + }); + + jLabelSCRatePerCent.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabelSCRatePerCent.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + jLabelSCRatePerCent.setText(bundle.getString("label.SCZero")); // NOI18N + jLabelSCRatePerCent.setMaximumSize(new java.awt.Dimension(0, 25)); + jLabelSCRatePerCent.setMinimumSize(new java.awt.Dimension(0, 0)); + jLabelSCRatePerCent.setPreferredSize(new java.awt.Dimension(0, 30)); + + jchkSCRestaurant.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jchkSCRestaurant.setText(bundle.getString("label.SCRestaurant")); // NOI18N + jchkSCRestaurant.setMaximumSize(new java.awt.Dimension(0, 25)); + jchkSCRestaurant.setMinimumSize(new java.awt.Dimension(0, 0)); + jchkSCRestaurant.setPreferredSize(new java.awt.Dimension(0, 25)); + + jchkPriceUpdate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jchkPriceUpdate.setText(bundle.getString("label.priceupdate")); // NOI18N + jchkPriceUpdate.setToolTipText(bundle.getString("tooltip.priceupdate")); // NOI18N + jchkPriceUpdate.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jchkPriceUpdate.setMaximumSize(new java.awt.Dimension(0, 25)); + jchkPriceUpdate.setMinimumSize(new java.awt.Dimension(0, 0)); + jchkPriceUpdate.setPreferredSize(new java.awt.Dimension(250, 25)); + + jchkBarcodetype.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jchkBarcodetype.setText(bundle.getString("label.barcodetype")); // NOI18N + jchkBarcodetype.setToolTipText(bundle.getString("tooltip.barcodetype")); // NOI18N + jchkBarcodetype.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jchkBarcodetype.setMaximumSize(new java.awt.Dimension(0, 25)); + jchkBarcodetype.setMinimumSize(new java.awt.Dimension(0, 0)); + jchkBarcodetype.setPreferredSize(new java.awt.Dimension(250, 25)); + + jchkTransBtn.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jchkTransBtn.setText(bundle.getString("label.tabletransbutton")); // NOI18N + jchkTransBtn.setMaximumSize(new java.awt.Dimension(0, 25)); + jchkTransBtn.setMinimumSize(new java.awt.Dimension(0, 0)); + jchkTransBtn.setPreferredSize(new java.awt.Dimension(350, 30)); + jchkTransBtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jchkTransBtnActionPerformed(evt); + } + }); + + WaiterColour.setToolTipText(bundle.getString("tooltip.prodhtmldisplayColourChooser")); // NOI18N + WaiterColour.setColorDisplayType(com.alee.extended.colorchooser.ColorDisplayType.hex); + WaiterColour.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + WaiterColour.setMinimumSize(new java.awt.Dimension(51, 30)); + + TableNameColour.setToolTipText(bundle.getString("tooltip.prodhtmldisplayColourChooser")); // NOI18N + TableNameColour.setColorDisplayType(com.alee.extended.colorchooser.ColorDisplayType.hex); + TableNameColour.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + TableNameColour.setMinimumSize(new java.awt.Dimension(51, 30)); + + CustomerColour.setToolTipText(bundle.getString("tooltip.prodhtmldisplayColourChooser")); // NOI18N + CustomerColour.setColorDisplayType(com.alee.extended.colorchooser.ColorDisplayType.hex); + CustomerColour.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + CustomerColour.setMinimumSize(new java.awt.Dimension(51, 30)); + + jchkOverride.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jchkOverride.setText(bundle.getString("label.override")); // NOI18N + jchkOverride.setMaximumSize(new java.awt.Dimension(0, 25)); + jchkOverride.setMinimumSize(new java.awt.Dimension(0, 0)); + jchkOverride.setPreferredSize(new java.awt.Dimension(200, 30)); + + jtxtPIN.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtPIN.setText("1234"); + jtxtPIN.setToolTipText(""); + jtxtPIN.setMaximumSize(new java.awt.Dimension(0, 25)); + jtxtPIN.setMinimumSize(new java.awt.Dimension(0, 0)); + jtxtPIN.setPreferredSize(new java.awt.Dimension(60, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText("PIN"); + + disableAnonymousStats.setText("Disable Anonymous Stats"); + disableAnonymousStats.setFont(new java.awt.Font("Arial", 0, 14)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(10, 10, 10) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jchkSCOnOff, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jchkautoRefreshTableMap, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabelInactiveTime1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jchkShowWaiterDetails, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabelTableNameTextColour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jchkShowCustomerDetails, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jchkTransBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(50, 50, 50)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jLabelSCRate, javax.swing.GroupLayout.PREFERRED_SIZE, 333, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(12, 12, 12) + .addComponent(jLabelSCRatePerCent, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jTextSCRate, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jchkSCRestaurant, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jTxtautoRefreshTimer, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLblautoRefresh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(WaiterColour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(TableNameColour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(CustomerColour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(15, 15, 15) + .addComponent(jchkAutoLogoffToTables, javax.swing.GroupLayout.PREFERRED_SIZE, 340, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jchkAutoLogoff, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabelInactiveTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(100, 100, 100) + .addComponent(jTextAutoLogoffTime, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabelTimedMessage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(0, 0, Short.MAX_VALUE)))) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 654, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addGap(10, 10, 10) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jchkInstance, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTaxIncluded, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jchkTextOverlay, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jchkPriceUpdate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addComponent(jchkOverride, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jtxtPIN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel5)) + .addComponent(disableAnonymousStats)))) + .addGap(107, 107, 107) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jCheckPrice00, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jMoveAMountBoxToTop, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jCloseCashbtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jchkBarcodetype, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGap(0, 0, Short.MAX_VALUE)))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jTaxIncluded, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jCheckPrice00, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jchkInstance, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jMoveAMountBoxToTop, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jchkTextOverlay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jCloseCashbtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jchkPriceUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jchkBarcodetype, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5) + .addComponent(jtxtPIN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jchkOverride, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(disableAnonymousStats) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jchkAutoLogoff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabelInactiveTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextAutoLogoffTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabelTimedMessage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jchkAutoLogoffToTables, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jchkautoRefreshTableMap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabelInactiveTime1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTxtautoRefreshTimer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblautoRefresh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jchkSCOnOff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabelSCRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextSCRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabelSCRatePerCent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jchkSCRestaurant, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jchkShowCustomerDetails, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(CustomerColour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jchkShowWaiterDetails, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(WaiterColour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(TableNameColour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabelTableNameTextColour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jchkTransBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(32, 32, 32)) + ); + }// //GEN-END:initComponents + + private void jchkAutoLogoffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jchkAutoLogoffActionPerformed + if (jchkAutoLogoff.isSelected()){ + jchkAutoLogoffToTables.setVisible(true); + jLabelInactiveTime.setVisible(true); + jLabelTimedMessage.setVisible(true); + jTextAutoLogoffTime.setVisible(true); + }else{ + jchkAutoLogoffToTables.setVisible(false); + jLabelInactiveTime.setVisible(false); + jLabelTimedMessage.setVisible(false); + jTextAutoLogoffTime.setVisible(false); + } + }//GEN-LAST:event_jchkAutoLogoffActionPerformed + + private void jCheckPrice00ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckPrice00ActionPerformed + + }//GEN-LAST:event_jCheckPrice00ActionPerformed + + private void jchkAutoLogoffToTablesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jchkAutoLogoffToTablesActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jchkAutoLogoffToTablesActionPerformed + + private void jchkShowCustomerDetailsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jchkShowCustomerDetailsActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jchkShowCustomerDetailsActionPerformed + + private void jchkautoRefreshTableMapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jchkautoRefreshTableMapActionPerformed + if (jchkautoRefreshTableMap.isSelected()){ + jLblautoRefresh.setVisible(true); + jLabelInactiveTime1.setVisible(true); + jTxtautoRefreshTimer.setVisible(true); + }else{ + jLblautoRefresh.setVisible(false); + jLabelInactiveTime1.setVisible(false); + jTxtautoRefreshTimer.setVisible(false); + } + }//GEN-LAST:event_jchkautoRefreshTableMapActionPerformed + + private void jchkSCOnOffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jchkSCOnOffActionPerformed + if (jchkSCOnOff.isSelected()){ + jchkSCRestaurant.setVisible(true); + jLabelSCRate.setVisible(true); + jTextSCRate.setVisible(true); + jLabelSCRatePerCent.setVisible(true); + }else{ + jchkSCRestaurant.setVisible(false); + jLabelSCRate.setVisible(false); + jTextSCRate.setVisible(false); + jLabelSCRatePerCent.setVisible(false); + } + }//GEN-LAST:event_jchkSCOnOffActionPerformed + + private void jTextSCRateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextSCRateActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jTextSCRateActionPerformed + + private void jchkTransBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jchkTransBtnActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jchkTransBtnActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private com.alee.extended.colorchooser.WebColorChooserField CustomerColour; + private com.alee.extended.colorchooser.WebColorChooserField TableNameColour; + private com.alee.extended.colorchooser.WebColorChooserField WaiterColour; + private javax.swing.JCheckBox disableAnonymousStats; + private javax.swing.JCheckBox jCheckPrice00; + private javax.swing.JCheckBox jCloseCashbtn; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabelInactiveTime; + private javax.swing.JLabel jLabelInactiveTime1; + private javax.swing.JLabel jLabelSCRate; + private javax.swing.JLabel jLabelSCRatePerCent; + private javax.swing.JLabel jLabelTableNameTextColour; + private javax.swing.JLabel jLabelTimedMessage; + private javax.swing.JLabel jLblautoRefresh; + private javax.swing.JCheckBox jMoveAMountBoxToTop; + private javax.swing.JCheckBox jTaxIncluded; + private javax.swing.JTextField jTextAutoLogoffTime; + private javax.swing.JTextField jTextSCRate; + private javax.swing.JTextField jTxtautoRefreshTimer; + private javax.swing.JCheckBox jchkAutoLogoff; + private javax.swing.JCheckBox jchkAutoLogoffToTables; + private javax.swing.JCheckBox jchkBarcodetype; + private javax.swing.JCheckBox jchkInstance; + private javax.swing.JCheckBox jchkOverride; + private javax.swing.JCheckBox jchkPriceUpdate; + private javax.swing.JCheckBox jchkSCOnOff; + private javax.swing.JCheckBox jchkSCRestaurant; + private javax.swing.JCheckBox jchkShowCustomerDetails; + private javax.swing.JCheckBox jchkShowWaiterDetails; + private javax.swing.JCheckBox jchkTextOverlay; + private javax.swing.JCheckBox jchkTransBtn; + private javax.swing.JCheckBox jchkautoRefreshTableMap; + private javax.swing.JTextField jtxtPIN; + // End of variables declaration//GEN-END:variables + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfiguration.form b/src/main/java/com/unicenta/pos/config/JPanelConfiguration.form new file mode 100644 index 0000000..4793651 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfiguration.form @@ -0,0 +1,312 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/config/JPanelConfiguration.java b/src/main/java/com/unicenta/pos/config/JPanelConfiguration.java new file mode 100644 index 0000000..60332dd --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelConfiguration.java @@ -0,0 +1,384 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.config; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.JMessageDialog; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.pos.forms.*; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import javax.swing.*; +/** + * + * @author adrianromero + */ +public class JPanelConfiguration extends JPanel implements JPanelView { + + private List m_panelconfig; + + private AppConfig config; + + /** Creates new form JPanelConfiguration + * @param oApp */ + public JPanelConfiguration(AppView oApp) { + this(oApp.getProperties()); + if (oApp!= null) { + jbtnExit.setVisible(false); + } + + + } + + /** + * + * @param props + */ + public JPanelConfiguration(AppProperties props) { + + initComponents(); + config = new AppConfig(props.getConfigFile()); + + m_panelconfig = new ArrayList<>(); + + PanelConfig panel; + + panel = new JPanelConfigDatabase(); + m_panelconfig.add(panel); + jPanelDatabase.add(panel.getConfigComponent()); + + panel = new JPanelConfigGeneral(); + m_panelconfig.add(panel); + jPanelGeneral.add(panel.getConfigComponent()); + + panel = new JPanelConfigLocale(); + m_panelconfig.add(panel); + jPanelLocale.add(panel.getConfigComponent()); + + panel = new JPanelConfigPayment(); + m_panelconfig.add(panel); + jPanelPayment.add(panel.getConfigComponent()); + + panel = new JPanelConfigPeripheral(); + m_panelconfig.add(panel); + jPanelPeripheral.add(panel.getConfigComponent()); + + panel = new JPanelConfigSystem(); + m_panelconfig.add(panel); + jPanelSystem.add(panel.getConfigComponent()); + + panel = new JPanelTicketSetup(); + m_panelconfig.add(panel); + jPanelTicketSetup.add(panel.getConfigComponent()); + + panel = new JPanelConfigCompany(); + m_panelconfig.add(panel); + jPanelCompany.add(panel.getConfigComponent()); + + } + + private void restoreProperties() { + + if (config.delete()) { + loadProperties(); + } else { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotdeleteconfig"))); + } + } + + private void loadProperties() { + + config.load(); + + // paneles auxiliares + for (PanelConfig c: m_panelconfig) { + c.loadProperties(config); + } + } + + private void saveProperties() { + + // paneles auxiliares + for (PanelConfig c: m_panelconfig) { + c.saveProperties(config); + } + + try { + config.save(); + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.restartchanges"), + AppLocal.getIntString("message.title"), + JOptionPane.INFORMATION_MESSAGE); + } catch (IOException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotsaveconfig"), e)); + } + } + + /** + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Configuration"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + loadProperties(); + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + + boolean haschanged = false; + for (PanelConfig c: m_panelconfig) { + if (c.hasChanged()) { + haschanged = true; + } + } + + + if (haschanged) { + int res = JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.wannasave"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE); + + if (res == JOptionPane.YES_OPTION) { + saveProperties(); + return true; + } else { + return res == JOptionPane.NO_OPTION; + } + } else { + return true; + } + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jTabbedPane1 = new javax.swing.JTabbedPane(); + jPanelGeneral = new javax.swing.JPanel(); + jPanelLocale = new javax.swing.JPanel(); + jPanelPayment = new javax.swing.JPanel(); + jPanelPeripheral = new javax.swing.JPanel(); + jPanelSystem = new javax.swing.JPanel(); + jPanelTicketSetup = new javax.swing.JPanel(); + jPanelCompany = new javax.swing.JPanel(); + jPanelDatabase = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jbtnRestore = new javax.swing.JButton(); + jbtnExit = new javax.swing.JButton(); + jbtnSave = new javax.swing.JButton(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setMinimumSize(new java.awt.Dimension(0, 0)); + setPreferredSize(new java.awt.Dimension(950, 600)); + + jTabbedPane1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTabbedPane1.setOpaque(true); + jTabbedPane1.setPreferredSize(new java.awt.Dimension(930, 550)); + + jPanelGeneral.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanelGeneral.setPreferredSize(new java.awt.Dimension(0, 400)); + jPanelGeneral.setLayout(new javax.swing.BoxLayout(jPanelGeneral, javax.swing.BoxLayout.LINE_AXIS)); + jTabbedPane1.addTab("General", jPanelGeneral); + + jPanelLocale.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanelLocale.setPreferredSize(new java.awt.Dimension(0, 400)); + jPanelLocale.setLayout(new javax.swing.BoxLayout(jPanelLocale, javax.swing.BoxLayout.LINE_AXIS)); + jTabbedPane1.addTab("Locale", jPanelLocale); + + jPanelPayment.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanelPayment.setPreferredSize(new java.awt.Dimension(0, 400)); + jPanelPayment.setLayout(new javax.swing.BoxLayout(jPanelPayment, javax.swing.BoxLayout.LINE_AXIS)); + jTabbedPane1.addTab("Payment Method", jPanelPayment); + + jPanelPeripheral.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanelPeripheral.setPreferredSize(new java.awt.Dimension(0, 400)); + jPanelPeripheral.setLayout(new javax.swing.BoxLayout(jPanelPeripheral, javax.swing.BoxLayout.LINE_AXIS)); + jTabbedPane1.addTab("Peripherals", jPanelPeripheral); + + jPanelSystem.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanelSystem.setPreferredSize(new java.awt.Dimension(0, 400)); + jPanelSystem.setLayout(new javax.swing.BoxLayout(jPanelSystem, javax.swing.BoxLayout.LINE_AXIS)); + jTabbedPane1.addTab("System Options", jPanelSystem); + + jPanelTicketSetup.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanelTicketSetup.setPreferredSize(new java.awt.Dimension(0, 400)); + jPanelTicketSetup.setLayout(new javax.swing.BoxLayout(jPanelTicketSetup, javax.swing.BoxLayout.LINE_AXIS)); + jTabbedPane1.addTab("Ticket Setup", jPanelTicketSetup); + + jPanelCompany.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanelCompany.setLayout(new javax.swing.BoxLayout(jPanelCompany, javax.swing.BoxLayout.LINE_AXIS)); + jTabbedPane1.addTab("Company", jPanelCompany); + + jPanelDatabase.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanelDatabase.setPreferredSize(new java.awt.Dimension(0, 400)); + jPanelDatabase.setLayout(new javax.swing.BoxLayout(jPanelDatabase, javax.swing.BoxLayout.LINE_AXIS)); + jTabbedPane1.addTab("Database Setup", jPanelDatabase); + + jbtnRestore.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnRestore.setText(AppLocal.getIntString("button.factory")); // NOI18N + jbtnRestore.setMaximumSize(new java.awt.Dimension(103, 33)); + jbtnRestore.setMinimumSize(new java.awt.Dimension(103, 33)); + jbtnRestore.setPreferredSize(new java.awt.Dimension(110, 45)); + jbtnRestore.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnRestoreActionPerformed(evt); + } + }); + + jbtnExit.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnExit.setText(AppLocal.getIntString("Button.Exit")); // NOI18N + jbtnExit.setMaximumSize(new java.awt.Dimension(70, 33)); + jbtnExit.setMinimumSize(new java.awt.Dimension(70, 33)); + jbtnExit.setPreferredSize(new java.awt.Dimension(110, 45)); + jbtnExit.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnExitActionPerformed(evt); + } + }); + + jbtnSave.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnSave.setText(AppLocal.getIntString("button.save")); // NOI18N + jbtnSave.setMaximumSize(new java.awt.Dimension(70, 33)); + jbtnSave.setMinimumSize(new java.awt.Dimension(70, 33)); + jbtnSave.setPreferredSize(new java.awt.Dimension(110, 45)); + jbtnSave.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnSaveActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jbtnSave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jbtnRestore, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jbtnExit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(31, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jbtnRestore, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnExit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnSave, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + private void jbtnRestoreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnRestoreActionPerformed + + if (JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.configfactory"), + AppLocal.getIntString("message.title"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { + restoreProperties(); + } + + }//GEN-LAST:event_jbtnRestoreActionPerformed + + private void jbtnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSaveActionPerformed + + saveProperties(); + + }//GEN-LAST:event_jbtnSaveActionPerformed + + private void jbtnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnExitActionPerformed + deactivate(); + System.exit(0); + }//GEN-LAST:event_jbtnExitActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanelCompany; + private javax.swing.JPanel jPanelDatabase; + private javax.swing.JPanel jPanelGeneral; + private javax.swing.JPanel jPanelLocale; + private javax.swing.JPanel jPanelPayment; + private javax.swing.JPanel jPanelPeripheral; + private javax.swing.JPanel jPanelSystem; + private javax.swing.JPanel jPanelTicketSetup; + private javax.swing.JTabbedPane jTabbedPane1; + private javax.swing.JButton jbtnExit; + private javax.swing.JButton jbtnRestore; + private javax.swing.JButton jbtnSave; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/config/JPanelTicketSetup.form b/src/main/java/com/unicenta/pos/config/JPanelTicketSetup.form new file mode 100644 index 0000000..351aac3 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelTicketSetup.form @@ -0,0 +1,244 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/config/JPanelTicketSetup.java b/src/main/java/com/unicenta/pos/config/JPanelTicketSetup.java new file mode 100644 index 0000000..54b1e0f --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/JPanelTicketSetup.java @@ -0,0 +1,400 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.config; + +import com.unicenta.data.user.DirtyManager; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.AltEncrypter; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import java.awt.*; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; + +/** + * + * @author JG uniCenta + */ +@Slf4j +public class JPanelTicketSetup extends javax.swing.JPanel implements PanelConfig { + + private final DirtyManager dirty = new DirtyManager(); + private String receipt="1"; + private Integer x = 0; + private String receiptSize; + private String pickupSize; + private final Integer ps = 0; + + private Connection conn; + private String sdbmanager; + private String SQL; + private Statement stmt; + + /** + * + */ + public JPanelTicketSetup() { + + initComponents(); + + jReceiptSize.addChangeListener(dirty); + jPickupSize.addChangeListener(dirty); + jTextReceiptPrefix.getDocument().addDocumentListener(dirty); + m_jReceiptPrintOff.addActionListener(dirty); + + jbtnReset.setVisible(true); + } + + + /** + * + * @return + */ + @Override + public boolean hasChanged() { + return dirty.isDirty(); + } + + /** + * + * @return + */ + @Override + public Component getConfigComponent() { + return this; + } + + /** + * + * @param config + */ + @Override + public void loadProperties(AppConfig config) { + + receiptSize =(config.getProperty("till.receiptsize")); + if (receiptSize == null || "".equals(receiptSize)){ + jReceiptSize.setModel(new SpinnerNumberModel(1,1,20,1)); + } else { + jReceiptSize.setModel(new SpinnerNumberModel(Integer.parseInt(receiptSize),1,20,1)); + } + + pickupSize =(config.getProperty("till.pickupsize")); + if (pickupSize == null || "".equals(pickupSize)){ + jPickupSize.setModel(new SpinnerNumberModel(1,1,20,1)); + } else { + jPickupSize.setModel(new SpinnerNumberModel(Integer.parseInt(pickupSize),1,20,1)); + } + + jTextReceiptPrefix.setText(config.getProperty("till.receiptprefix")); +// build the example receipt using the loaded details + receipt=""; + x=1; + while (x < (Integer)jReceiptSize.getValue()){ + receipt += "0"; + x++; + } + + receipt += "1"; + jTicketExample.setText(jTextReceiptPrefix.getText()+receipt); + m_jReceiptPrintOff.setSelected(Boolean.parseBoolean(config.getProperty("till.receiptprintoff"))); + + digitalReceipt.setSelected(Boolean.parseBoolean(config.getProperty("till.digital-receipt"))); + + dirty.setDirty(false); + + + } + + /* + * JG Oct 2017 + * This block to be used for internal SETS/RESETS and external ORDERS sync's + */ + public void loadUp() throws ClassNotFoundException, SQLException { + +/* Add external received order reset block here - + * Get connex to secondary or external system's DB + [params] + * Pref' use is JSON/REST rather than PreparedStatement +*/ + } + + /** + * + * @param config + */ + @Override + public void saveProperties(AppConfig config) { + + config.setProperty("till.receiptprefix", jTextReceiptPrefix.getText()); + config.setProperty("till.receiptsize", jReceiptSize.getValue().toString()); + config.setProperty("till.pickupsize", jPickupSize.getValue().toString()); + config.setProperty("till.receiptprintoff",Boolean.toString(m_jReceiptPrintOff.isSelected())); + config.setProperty("till.digital-receipt", Boolean.toString(digitalReceipt.isSelected())); + + dirty.setDirty(false); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jReceiptSize = new javax.swing.JSpinner(); + jLabel3 = new javax.swing.JLabel(); + jTextReceiptPrefix = new javax.swing.JTextField(); + jTicketExample = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + jPickupSize = new javax.swing.JSpinner(); + m_jReceiptPrintOff = new javax.swing.JCheckBox(); + jbtnReset = new javax.swing.JButton(); + digitalReceipt = new javax.swing.JCheckBox(); + + setBackground(new java.awt.Color(0, 0, 0)); + setOpaque(false); + setPreferredSize(new java.awt.Dimension(700, 500)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLabel1.setText(bundle.getString("label.ticketsetupnumber")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(190, 30)); + + jReceiptSize.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + jReceiptSize.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1)); + jReceiptSize.setPreferredSize(new java.awt.Dimension(50, 30)); + jReceiptSize.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + jReceiptSizeStateChanged(evt); + } + }); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(bundle.getString("label.ticketsetupprefix")); // NOI18N + + jTextReceiptPrefix.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + jTextReceiptPrefix.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jTextReceiptPrefix.setPreferredSize(new java.awt.Dimension(100, 30)); + jTextReceiptPrefix.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyReleased(java.awt.event.KeyEvent evt) { + jTextReceiptPrefixKeyReleased(evt); + } + }); + + jTicketExample.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + jTicketExample.setText("1"); + jTicketExample.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jTicketExample.setEnabled(false); + jTicketExample.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(bundle.getString("label.pickupcodesize")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(190, 30)); + + jPickupSize.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + jPickupSize.setModel(new javax.swing.SpinnerNumberModel(0, 0, null, 1)); + jPickupSize.setToolTipText(""); + jPickupSize.setPreferredSize(new java.awt.Dimension(50, 30)); + jPickupSize.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + jPickupSizeStateChanged(evt); + } + }); + + m_jReceiptPrintOff.setBackground(new java.awt.Color(255, 255, 255)); + m_jReceiptPrintOff.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jReceiptPrintOff.setText(bundle.getString("label.receiptprint")); // NOI18N + m_jReceiptPrintOff.setPreferredSize(new java.awt.Dimension(180, 30)); + m_jReceiptPrintOff.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jReceiptPrintOffActionPerformed(evt); + } + }); + + jbtnReset.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jbtnReset.setText(AppLocal.getIntString("label.resetpickup")); // NOI18N + jbtnReset.setMaximumSize(new java.awt.Dimension(70, 33)); + jbtnReset.setMinimumSize(new java.awt.Dimension(70, 33)); + jbtnReset.setPreferredSize(new java.awt.Dimension(100, 45)); + jbtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnResetActionPerformed(evt); + } + }); + + digitalReceipt.setText("Enable digital email Receipts"); + digitalReceipt.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + digitalReceiptActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jReceiptPrintOff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jPickupSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jbtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jReceiptSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addComponent(jTextReceiptPrefix, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jTicketExample, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addComponent(digitalReceipt)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jReceiptSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextReceiptPrefix, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTicketExample, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(m_jReceiptPrintOff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jPickupSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(digitalReceipt) + .addContainerGap(254, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void jTextReceiptPrefixKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextReceiptPrefixKeyReleased + + jTicketExample.setText(jTextReceiptPrefix.getText()+ receipt); + }//GEN-LAST:event_jTextReceiptPrefixKeyReleased + + private void jReceiptSizeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jReceiptSizeStateChanged + + receipt=""; + x=1; + while (x < (Integer)jReceiptSize.getValue()){ + receipt += "0"; + x++; + } + receipt += "1"; + jTicketExample.setText(jTextReceiptPrefix.getText()+receipt); + + }//GEN-LAST:event_jReceiptSizeStateChanged + + private void jPickupSizeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jPickupSizeStateChanged + + }//GEN-LAST:event_jPickupSizeStateChanged + + private void m_jReceiptPrintOffActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jReceiptPrintOffActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_m_jReceiptPrintOffActionPerformed + + private void jbtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnResetActionPerformed + int response = JOptionPane.showOptionDialog(null, + AppLocal.getIntString("message.resetpickup"), + "Reset", + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE, + null, null, null); + if (response == JOptionPane.YES_OPTION) { + try { + + String db_url = (AppConfig.getInstance().getProperty("db.URL")); + String db_schema = (AppConfig.getInstance().getProperty("db.schema")); + String db_user =(AppConfig.getInstance().getProperty("db.user")); + String db_password = (AppConfig.getInstance().getProperty("db.password")); + + if (db_user != null && db_password != null && db_password.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + db_user); + db_password = cypher.decrypt(db_password.substring(6)); + } + + String url = db_url + db_schema; + + conn = DriverManager.getConnection(url,db_user,db_password); + sdbmanager = conn.getMetaData().getDatabaseProductName(); + stmt = (Statement) conn.createStatement(); + + if ("MySQL".equals(sdbmanager)) { + SQL = "UPDATE pickup_number SET id = 0"; + try { + stmt.executeUpdate(SQL); + } catch (SQLException e){ + System.out.println(e.getMessage()); + } + } else if ("PostgreSQL".equals(sdbmanager)) { + SQL = "ALTER SEQUENCE pickup_number RESTART WITH 1"; + try { + stmt.executeUpdate(SQL); + } catch (SQLException e) { + System.out.println(e.getMessage()); + } + } + } catch (SQLException ex) { log.error(ex.getMessage()); + } + } + }//GEN-LAST:event_jbtnResetActionPerformed + + private void digitalReceiptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_digitalReceiptActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_digitalReceiptActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBox digitalReceipt; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JSpinner jPickupSize; + private javax.swing.JSpinner jReceiptSize; + private javax.swing.JTextField jTextReceiptPrefix; + private javax.swing.JTextField jTicketExample; + private javax.swing.JButton jbtnReset; + private javax.swing.JCheckBox m_jReceiptPrintOff; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/config/LocaleComparator.java b/src/main/java/com/unicenta/pos/config/LocaleComparator.java new file mode 100644 index 0000000..8989ae7 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/LocaleComparator.java @@ -0,0 +1,39 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.config; + +import java.util.Comparator; +import java.util.Locale; + +/** + * + * @author adrianromero + */ +public class LocaleComparator implements Comparator { + + /** Creates a new instance of LocaleComparator */ + public LocaleComparator() { + } + + @Override + public int compare(Locale o1, Locale o2) { + return o1.getDisplayName().compareTo(o2.getDisplayName()); + } +} diff --git a/src/main/java/com/unicenta/pos/config/PanelConfig.java b/src/main/java/com/unicenta/pos/config/PanelConfig.java new file mode 100644 index 0000000..f5c5c5c --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/PanelConfig.java @@ -0,0 +1,54 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.config; + +import com.unicenta.pos.forms.AppConfig; +import java.awt.Component; + +/** + * + * @author adrianromero + */ +public interface PanelConfig { + + /** + * + * @param config + */ + public void loadProperties(AppConfig config); + + /** + * + * @param config + */ + public void saveProperties(AppConfig config); + + /** + * + * @return + */ + public boolean hasChanged(); + + /** + * + * @return + */ + public Component getConfigComponent(); +} diff --git a/src/main/java/com/unicenta/pos/config/ParametersConfig.java b/src/main/java/com/unicenta/pos/config/ParametersConfig.java new file mode 100644 index 0000000..5b53818 --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/ParametersConfig.java @@ -0,0 +1,56 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.config; + +import com.unicenta.data.user.DirtyManager; +import com.unicenta.pos.util.StringParser; +import java.awt.Component; + +/** + * + * @author adrian + */ +public interface ParametersConfig { + + /** + * + * @return + */ + public Component getComponent(); + + /** + * + * @param dirty + */ + public void addDirtyManager(DirtyManager dirty); + + /** + * + * @param p + */ + public void setParameters(StringParser p); + + /** + * + * @return + */ + public String getParameters(); + +} diff --git a/src/main/java/com/unicenta/pos/config/ParametersPrinter.form b/src/main/java/com/unicenta/pos/config/ParametersPrinter.form new file mode 100644 index 0000000..608a9ea --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/ParametersPrinter.form @@ -0,0 +1,70 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/config/ParametersPrinter.java b/src/main/java/com/unicenta/pos/config/ParametersPrinter.java new file mode 100644 index 0000000..e8a357e --- /dev/null +++ b/src/main/java/com/unicenta/pos/config/ParametersPrinter.java @@ -0,0 +1,149 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.config; + +import com.unicenta.data.user.DirtyManager; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.StringParser; +import java.awt.Component; + +/** + * + * @author adrian + */ +public class ParametersPrinter extends javax.swing.JPanel implements ParametersConfig { + + private String othersizename = "standard"; + + /** Creates new form ParametersPrinter + * @param printernames */ + public ParametersPrinter(String [] printernames) { + initComponents(); + + jPrinters.addItem("(Default)"); + jPrinters.addItem("(Show dialog)"); + for (String name : printernames) { + jPrinters.addItem(name); + } + } + + /** + * + * @return + */ + public Component getComponent() { + return this; + } + + /** + * + * @param dirty + */ + public void addDirtyManager(DirtyManager dirty) { + jPrinters.addActionListener(dirty); + jReceiptPrinter.addActionListener(dirty); + } + + /** + * + * @param p + */ + public void setParameters(StringParser p) { + jPrinters.setSelectedItem(p.nextToken(',')); + String sizename = p.nextToken(','); + jReceiptPrinter.setSelected("receipt".equals(sizename)); + othersizename = "receipt".equals(sizename) ? "standard" : sizename; + } + + /** + * + * @return + */ + public String getParameters() { + return comboValue(jPrinters.getSelectedItem()) + "," + boolValue(jReceiptPrinter.isSelected()); + } + + private static String comboValue(Object value) { + return value == null ? "" : value.toString(); + } + + private String boolValue(boolean value) { + return value ? "receipt" : othersizename; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPrinters = new javax.swing.JComboBox(); + jReceiptPrinter = new javax.swing.JCheckBox(); + + setOpaque(false); + + jPrinters.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPrinters.setPreferredSize(new java.awt.Dimension(200, 30)); + jPrinters.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jPrintersActionPerformed(evt); + } + }); + + jReceiptPrinter.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jReceiptPrinter.setSelected(true); + jReceiptPrinter.setText(AppLocal.getIntString("label.receiptprinter")); // NOI18N + jReceiptPrinter.setOpaque(false); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPrinters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jReceiptPrinter) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jPrinters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jReceiptPrinter, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void jPrintersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPrintersActionPerformed + + }//GEN-LAST:event_jPrintersActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox jPrinters; + private javax.swing.JCheckBox jReceiptPrinter; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/customers/CustomerInfo.java b/src/main/java/com/unicenta/pos/customers/CustomerInfo.java new file mode 100644 index 0000000..e5a41c6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/CustomerInfo.java @@ -0,0 +1,171 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.customers; + +import com.unicenta.pos.util.StringUtils; +import java.awt.image.BufferedImage; +import java.io.Serializable; + +/** @author jack gerrard, adrianromero */ + +// JG 20 Sep 12 Extended for Postal +// JG 2 Sep 13 Extended for Phone + Email +public class CustomerInfo implements Serializable { + + private static final long serialVersionUID = 9083257536541L; + + protected String id; + protected String searchkey; + protected String taxid; + protected String name; + protected String postal; + protected String phone; + protected String email; + protected BufferedImage image; + protected Double curdebt; + + + /** Creates a new instance of CustomerInfo + * @param id */ + public CustomerInfo(String id) { + this.id = id; + this.searchkey = null; + this.taxid = null; + this.name = null; + this.postal = null; + this.phone = null; + this.email = null; + this.image = null; + this.curdebt = null; + } + + /** + * + * @return id string + */ + public String getId() { + return id; + } + + /** + * + * @return searchkey string + */ + public String getSearchkey() { + return searchkey; + } + public void setSearchkey(String searchkey) { + this.searchkey = searchkey; + } + + /** + * + * @return taxid string + */ + public String getTaxid() { + return taxid; + } + public void setTaxid(String taxid) { + this.taxid = taxid; + } + + /** + * + * @return name string + */ + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + * + * @return postal/zip code string + */ + public String getPcode() { + return postal; + } + public void setPcode(String postal) { + this.postal = postal; + } + + /** + * + * @return Primary Telephone string + */ + public String getPhone1() { + return phone; + } + public void setPhone1(String phone) { + this.phone = phone; + } + + /** + * + * @return email string + */ + public String getCemail() { + return email; + } + public void setCemail(String email) { + this.email = email; + } + + /** + * + * @return + */ + public String printName() { + return StringUtils.encodeXML(name); + } + + @Override + public String toString() { + return getName(); + } + + /** + * + * @return customer's photograph / image + */ + public BufferedImage getImage() { + return image; + } + /** + * + * @param img + */ + public void setImage(BufferedImage img) { + image = img; + } + + /** + * + * @return name double + */ + public Double getCurDebt() { + return curdebt; + } + public void setCurDebt(Double curdebt) { + this.curdebt = curdebt; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/customers/CustomerInfoExt.java b/src/main/java/com/unicenta/pos/customers/CustomerInfoExt.java new file mode 100644 index 0000000..8ffc707 --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/CustomerInfoExt.java @@ -0,0 +1,467 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.customers; + +import com.unicenta.format.Formats; +import com.unicenta.pos.util.RoundUtils; +import java.awt.image.BufferedImage; +import java.util.Date; + +/** + * + * @author adrianromero + * @author JG uniCenta + */ +public class CustomerInfoExt extends CustomerInfo { + + protected String taxcustomerid; + protected String taxcustcategoryid; + protected String card; + protected Double maxdebt; + protected String address; + protected String address2; + protected String pcode; + protected String city; + protected String region; + protected String country; + protected String firstname; + protected String lastname; + protected String cemail; + protected String phone1; + protected String phone2; + protected String fax; + protected String notes; + protected boolean visible; + protected Date curdate; + protected Double accdebt; + protected BufferedImage m_Image; + protected boolean isvip; + protected Double discount; + protected String prepay; + protected String memodate; + + /** Creates a new instance of UserInfoBasic + * @param id */ + public CustomerInfoExt(String id) { + super(id); + } + + /** + * + * @return customer's tax category + */ + public String getTaxCustCategoryID() { +// return taxcustomerid; + return taxcustcategoryid; + } + public void setTaxCustCategoryID(String taxcustcategoryid) { + this.taxcustcategoryid = taxcustcategoryid; + } + + public String getTaxCustomerID() { + return taxcustomerid; + } + public void setTaxCustomerID(String taxcustomerid) { + this.taxcustomerid = taxcustomerid; + } + public String printTaxCustomerID() { + return Formats.STRING.formatValue(taxcustomerid); + } + + @Override + public String getTaxid() { + return taxid; + } + @Override + public void setTaxid(String taxid) { + this.taxid = taxid; + } + public String printTaxid() { + return Formats.STRING.formatValue(taxid); + } + + + /** + * + * @return notes string + */ + public String getNotes() { + return notes; + } + public void setNotes(String notes) { + this.notes = notes; + } + + + /** + * + * @return Is visible Y/N? boolean + */ + public boolean isVisible() { + return visible; + } + public void setVisible(boolean visible) { + this.visible = visible; + } + + + /** + * + * @return customer's hashed member/loyalty card string + */ + public String getCard() { + return card; + } + public void setCard(String card) { + this.card = card; + } + + /** + * + * @return customer's maximum allowed debt value + */ + public Double getMaxdebt() { + return maxdebt; + } + public void setMaxdebt(Double maxdebt) { + this.maxdebt = maxdebt; + } + public String printMaxDebt() { + return Formats.CURRENCY.formatValue(RoundUtils.getValue(getMaxdebt())); + } + + + /** + * + * @return customer's last ticket transaction date + */ + public Date getCurdate() { + return curdate; + } + public void setCurdate(Date curdate) { + this.curdate = curdate; + } + public String printCurDate() { + return Formats.DATE.formatValue(getCurdate()); + } + + /** + * + * @return customer's current value of account + */ + public Double getAccdebt() { + return accdebt; + } + public void setAccdebt(Double accdebt) { + this.accdebt = accdebt; + } + public String printCurDebt() { + return Formats.CURRENCY.formatValue(RoundUtils.getValue(getAccdebt())); + } + + public String printCurBal() { + String balance = null; + + if (getMaxdebt() != null && getAccdebt() != null) { + balance = Formats.CURRENCY.formatValue(RoundUtils.getValue(getMaxdebt() - getAccdebt())); + } + return balance; + } + + /** + * + * @return prepay string + */ + public String getPrePay() { + return prepay; + } + public void setPrePay(String prepay) { + this.prepay = prepay; + } + + + /** + * + * @param amount + * @param d + */ + public void updateCurDebt(Double amount, Date d) { + + accdebt = accdebt == null ? amount : accdebt + amount; + curdate = (new Date()); + + if (RoundUtils.compare(accdebt, 0.0) > 0) { + if (curdate == null) { + // new date + curdate = d; + } + } else if (RoundUtils.compare(accdebt, 0.0) == 0) { + accdebt = null; + curdate = null; + } else { // < 0 +// curdate = null; + } + } + + /** + * + * @return customer's firstname string + */ + public String getFirstname() { + return firstname; + } + + /** + * + * @param firstname + */ + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + /** + * + * @return customer's lastname string + */ + public String getLastname() { + return lastname; + } + + /** + * + * @param lastname + */ + public void setLastname(String lastname) { + this.lastname = lastname; + } + + /** + * + * @return customer's cemail string + */ + @Override + public String getCemail() { + return cemail; + } + + /** + * + * @param cemail + */ + @Override + public void setCemail(String cemail) { + this.cemail = cemail; + } + + /** + * + * @return customer's Primary telephone string + */ + @Override + public String getPhone1() { + return phone1; + } + @Override + public void setPhone1(String phone1) { + this.phone1 = phone1; + } + public String printPhone1() { + return Formats.STRING.formatValue(phone1); + } + + /** + * + * @return customer's Secondary telephone string + */ + public String getPhone2() { + return phone2; + } + + /** + * + * @param phone2 + */ + public void setPhone2(String phone2) { + this.phone2 = phone2; + } + + /** + * + * @return customer's fax number string + */ + public String getFax() { + return fax; + } + + /** + * + * @param fax + */ + public void setFax(String fax) { + this.fax = fax; + } + + /** + * + * @return customer's address line 1 string + */ + public String getAddress() { + return address; + } + public void setAddress(String address) { + this.address = address; + } + public String printAddress() { + return Formats.STRING.formatValue(address); + } + + /** + * + * @return customer's address line 2 string + */ + public String getAddress2() { + return address2; + } + public void setAddress2(String address2) { + this.address2 = address2; + } + public String printAddress2() { + return Formats.STRING.formatValue(address2); + } + + /** + * + * @return customer's pcode/zip code string + */ + @Override + public String getPcode() { + return pcode; + } + @Override + public void setPcode(String pcode) { + this.pcode = pcode; + } + public String printPostal() { + return Formats.STRING.formatValue(pcode); + } + + /** + * + * @return customer's address city string + */ + public String getCity() { + return city; + } + /** + * + * @param city + */ + public void setCity(String city) { + this.city = city; + } + + /** + * + * @return customer's address region/state/county string + */ + public String getRegion() { + return region; + } + /** + * + * @param region + */ + public void setRegion(String region) { + this.region = region; + } + + /** + * + * @return customer's address country string + */ + public String getCountry() { + return country; + } + /** + * + * @param country + */ + public void setCountry(String country) { + this.country = country; + } + + /** + * + * @return customer's photograph / image + */ + @Override + public BufferedImage getImage() { + return m_Image; + } + /** + * + * @param img + */ + @Override + public void setImage(BufferedImage img) { + this.m_Image = img; + } + + /** + * + * @return Is VIP Y/N? boolean + */ + public boolean isVIP() { + return isvip; + } + public void setisVIP(boolean isvip) { + this.isvip = isvip; + } + + + /** + * + * @return customer's discount allowed + */ + public Double getDiscount() { + return discount; + } + public void setDiscount(Double discount) { + this.discount = discount; + } + public String printDiscount() { + return Formats.CURRENCY.formatValue(RoundUtils.getValue(getDiscount())); + } + + /** + * + * @return memo date string + */ + public String getMemoDate() { + return memodate; + } + public void setMemoDate(String memodate) { + this.memodate = memodate; + } + public String printMemoDate() { + return Formats.STRING.formatValue(memodate); + } + +} diff --git a/src/main/java/com/unicenta/pos/customers/CustomerInfoGlobal.java b/src/main/java/com/unicenta/pos/customers/CustomerInfoGlobal.java new file mode 100644 index 0000000..931deda --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/CustomerInfoGlobal.java @@ -0,0 +1,88 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . +// + +// For BrowseEditableData + +package com.unicenta.pos.customers; + +import com.unicenta.data.user.BrowsableEditableData; + +/** + * + * @author HS uniCenta + */ +public class CustomerInfoGlobal { + + private static CustomerInfoGlobal INSTANCE; + private CustomerInfoExt customerInfoExt; + private BrowsableEditableData editableData; + + //Singleton class + private CustomerInfoGlobal() { + } + + //Singleton constructor + + /** + * + * @return + */ + public static CustomerInfoGlobal getInstance() { + if (INSTANCE == null) { + INSTANCE = new CustomerInfoGlobal(); + } + + return INSTANCE; + } + + /** + * + * @return + */ + public CustomerInfoExt getCustomerInfoExt() { + return customerInfoExt; + } + + /** + * + * @param customerInfoExt + */ + public void setCustomerInfoExt(CustomerInfoExt customerInfoExt) { + this.customerInfoExt = customerInfoExt; + } + + /** + * + * @return + */ + public BrowsableEditableData getEditableData() { + return editableData; +} + + /** + * + * @param editableData + */ + public void setEditableData(BrowsableEditableData editableData) { + this.editableData = editableData; + } + + +} diff --git a/src/main/java/com/unicenta/pos/customers/CustomerRenderer.java b/src/main/java/com/unicenta/pos/customers/CustomerRenderer.java new file mode 100644 index 0000000..a552b43 --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/CustomerRenderer.java @@ -0,0 +1,53 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.customers; + +import java.awt.Component; +import javax.swing.DefaultListCellRenderer; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JList; + +/** + * + * @author JG uniCenta + */ +public class CustomerRenderer extends DefaultListCellRenderer { + + private final Icon icocustomer; + + /** Creates a new instance of CustomerRenderer */ + public CustomerRenderer() { + + icocustomer = new ImageIcon(getClass().getClassLoader().getResource("com/unicenta/images/customer_sml.png")); + + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, null, index, isSelected, cellHasFocus); + + setIcon(icocustomer); + setText(value.toString()); + + return this; + } +} diff --git a/src/main/java/com/unicenta/pos/customers/CustomerTransaction.java b/src/main/java/com/unicenta/pos/customers/CustomerTransaction.java new file mode 100644 index 0000000..7fd05b2 --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/CustomerTransaction.java @@ -0,0 +1,209 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.customers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.SerializerRead; +import lombok.extern.slf4j.Slf4j; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * @author JG uniCenta Gerrard 1 Nov 12 + * Used in Customer's transactions tab to display all this Customer's + * ticketline values + */ +@Slf4j +public class CustomerTransaction { + + String ticketId; + String productName; + String unit; + Double amount; + Double total; + Date transactionDate; + String customerId; + + /** + * Main method to return all customer's transactions + */ + public CustomerTransaction() { + } + + /** + * @param ticketId + * @param productName + * @param unit + * @param amount + * @param total + * @param transactionDate + * @param cId + */ + public CustomerTransaction(String ticketId, String productName, String unit, Double amount, Double total, Date transactionDate, String cId) { + this.ticketId = ticketId; + this.productName = productName; + this.unit = unit; + this.amount = amount; + this.total = total; + this.transactionDate = transactionDate; +// this.customerName = name; + this.customerId = cId; + } + + /** + * @return ticket id string + */ + public String getTicketId() { + return ticketId; + } + + /** + * @param ticketId + */ + public void setTicketId(String ticketId) { + this.ticketId = ticketId; + } + + /** + * @return ticket amount value + */ + public Double getAmount() { + return amount; + } + + /** + * @param amount + */ + public void setAmount(Double amount) { + this.amount = amount; + } + + /** + * @param total + */ + public void setTotal(Double total) { + this.total = total; + } + + /** + * @return ticketline value + */ + public Double getTotal() { + return total; + } + + /** + * @return ticketline's product name string + */ + public String getProductName() { + return productName; + } + + /** + * @param productName + */ + public void setProductName(String productName) { + this.productName = productName; + } + + /** + * @return ticket's transaction date + */ + public Date getTransactionDate() { + return transactionDate; + } + + /** + * @param transactionDate + */ + public void setTransactionDate(Date transactionDate) { + this.transactionDate = transactionDate; + } + + /** + * @return ticketline's quantity string value + */ + public String getUnit() { + return unit; + } + + /** + * @param unit + */ + public void setUnit(String unit) { + this.unit = unit; + } + + /** + * + * @return customer's account name string + public String getCustomerName() { + return customerName; + } + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + */ + + /** + * @return customer's account name string + */ + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + + /** + * @return ticketlines for this customer + */ + public static SerializerRead getSerializerRead() { + return new SerializerRead() { + + @Override + public Object readValues(DataRead dr) throws BasicException { + + String ticketId = dr.getString(1); + String productName = dr.getString(2); + String unit = dr.getString(3); + Double amount = dr.getDouble(4); + Double total = dr.getDouble(5); + String dateValue = dr.getString(6); + String customerId = dr.getString(7); + + + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + Date date = null; + try { + date = formatter.parse(dateValue); + } catch (ParseException ex) { + log.error(ex.getMessage()); + } + return new CustomerTransaction(ticketId, productName, unit, amount, total, date, customerId); + } + }; + } +} diff --git a/src/main/java/com/unicenta/pos/customers/CustomersPanel.java b/src/main/java/com/unicenta/pos/customers/CustomersPanel.java new file mode 100644 index 0000000..da69e54 --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/CustomersPanel.java @@ -0,0 +1,135 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.customers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +/** + * + * @author adrianromero + */ +public class CustomersPanel extends JPanelTable { + + private TableDefinition tcustomers; + private CustomersView jeditor; + + /** Creates a new instance of CustomersPanel */ + public CustomersPanel() { +// CustomerInfoGlobal.getInstance().setEditableData(bd); + } + + /** + * + */ + @Override + protected void init() { + DataLogicCustomers dlCustomers = (DataLogicCustomers) app.getBean("com.unicenta.pos.customers.DataLogicCustomers"); + tcustomers = dlCustomers.getTableCustomers(); + jeditor = new CustomersView(app, dirty); +// System.out.println(tcustomers.getListSQL()); + + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + jeditor.activate(); + super.activate(); + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return new ListProviderCreator(tcustomers); + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(tcustomers, new int[] { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26}); + } + + /** + * + * @return + */ + @Override + public Vectorer getVectorer() { + return tcustomers.getVectorerBasic(new int[]{1, 2, 3, 4}); + } + + /** + * + * @return + */ + @Override + public ComparatorCreator getComparatorCreator() { + return tcustomers.getComparatorCreator(new int[] {1, 2, 3, 4}); + } + + /** + * + * @return + */ + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(tcustomers.getRenderStringBasic(new int[]{3})); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.CustomersManagement"); + } +} diff --git a/src/main/java/com/unicenta/pos/customers/CustomersPayment.form b/src/main/java/com/unicenta/pos/customers/CustomersPayment.form new file mode 100644 index 0000000..d38b567 --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/CustomersPayment.form @@ -0,0 +1,572 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/unicenta/pos/customers/CustomersPayment.java b/src/main/java/com/unicenta/pos/customers/CustomersPayment.java new file mode 100644 index 0000000..4c100b5 --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/CustomersPayment.java @@ -0,0 +1,793 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +package com.unicenta.pos.customers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.*; +import com.unicenta.pos.payment.JPaymentSelect; +import com.unicenta.pos.payment.JPaymentSelectCustomer; +import com.unicenta.pos.payment.PaymentInfo; +import com.unicenta.pos.payment.PaymentInfoTicket; +import com.unicenta.pos.printer.TicketParser; +import com.unicenta.pos.printer.TicketPrinterException; +import com.unicenta.pos.scripting.ScriptEngine; +import com.unicenta.pos.scripting.ScriptException; +import com.unicenta.pos.scripting.ScriptFactory; +import com.unicenta.pos.ticket.TicketInfo; +import com.unicenta.pos.util.RoundUtils; +import java.util.Date; +import java.util.List; +import javax.swing.JComponent; +import javax.swing.JOptionPane; + +/** + * + * @author adrianromero + */ +public class CustomersPayment extends javax.swing.JPanel implements JPanelView, BeanFactoryApp { + + private AppView app; + private DataLogicCustomers dlcustomers; + private DataLogicSales dlsales; + private DataLogicSystem dlsystem; + private TicketParser ttp; + private JPaymentSelect paymentdialog; + + private CustomerInfoExt customerext; + private DirtyManager dirty; + + /** Creates new form CustomersPayment */ + public CustomersPayment() { + + initComponents(); + + editorcard.addEditorKeys(m_jKeys); + txtNotes.addEditorKeys(m_jKeys); + txtPrePay.addEditorKeys(m_jKeys); + + dirty = new DirtyManager(); + txtNotes.addPropertyChangeListener("Text", dirty); + txtPrePay.addPropertyChangeListener("Number", dirty); + } + + /** + * + * @param app + * @throws BeanFactoryException + */ + @Override + public void init(AppView app) throws BeanFactoryException { + + this.app = app; + dlcustomers = (DataLogicCustomers) app.getBean("com.unicenta.pos.customers.DataLogicCustomers"); + dlsales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + dlsystem = (DataLogicSystem) app.getBean("com.unicenta.pos.forms.DataLogicSystem"); + ttp = new TicketParser(app.getDeviceTicket(), dlsystem); + } + + /** + * + * @return + */ + @Override + public Object getBean() { + return this; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.CustomersPayment"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + paymentdialog = JPaymentSelectCustomer.getDialog(this); + paymentdialog.init(app); + + resetCustomer(); + + editorcard.reset(); + editorcard.activate(); + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + if (dirty.isDirty()) { + int res = JOptionPane.showConfirmDialog(this, AppLocal.getIntString("message.wannasave"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE); + + if (res == JOptionPane.YES_OPTION) { + save(); + return true; + } else { + return res == JOptionPane.NO_OPTION; + } + } else { + return true; + } + } + + /** + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + private void editCustomer(CustomerInfoExt customer) { + + customerext = customer; + + txtTaxId.setText(customer.getTaxid()); + txtName.setText(customer.getName()); + txtCard.setText(customer.getCard()); + txtNotes.reset(); + txtNotes.setText(customer.getNotes()); + txtMaxdebt.setText(Formats.CURRENCY.formatValue(customer.getMaxdebt())); + txtCurdebt.setText(Formats.CURRENCY.formatValue(customer.getAccdebt())); + txtCurdate.setText(Formats.DATE.formatValue(customer.getCurdate())); + txtPrePay.setText(null); + + txtNotes.setEnabled(true); + txtPrePay.setEnabled(true); + + dirty.setDirty(false); + + btnSave.setEnabled(true); + btnPay.setEnabled(true); + btnPrePay.setEnabled(true); + +// btnPay.setEnabled(customer.getCurdebt() != null && customer.getCurdebt().doubleValue() > 0.0); + + } + + private void resetCustomer() { + + customerext = null; + + txtTaxId.setText(null); + txtName.setText(null); + txtCard.setText(null); + txtNotes.reset(); + txtMaxdebt.setText(null); + txtCurdebt.setText(null); + txtCurdate.setText(null); + txtPrePay.setText(null); + + txtNotes.setEnabled(false); + txtPrePay.setEnabled(false); + + dirty.setDirty(false); + + btnSave.setEnabled(false); + btnPay.setEnabled(false); + btnPrePay.setEnabled(false); + + } + + private void readCustomer() { + + try { + CustomerInfoExt customer = dlsales.findCustomerExt(editorcard.getText()); + if (customer == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer")); + msg.show(this); + } else { + editCustomer(customer); + } + + } catch (BasicException ex) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex); + msg.show(this); + } + + editorcard.reset(); + editorcard.activate(); + } + + private void save() { + + customerext.setNotes(txtNotes.getText()); + customerext.setPrePay(txtPrePay.getText()); + + try { + dlcustomers.updateCustomerExt(customerext); + editCustomer(customerext); + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosave"), e); + msg.show(this); + } + + } + + private void printTicket(String resname, TicketInfo ticket, CustomerInfoExt customer) { + + String resource = dlsystem.getResourceAsXML(resname); + if (resource == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket")); + msg.show(this); + } else { + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); + script.put("ticket", ticket); + script.put("customer", customer); + ttp.printTicket(script.eval(resource).toString()); +// JG 6 May use multicatch + } catch ( ScriptException | TicketPrinterException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), e); + msg.show(this); + } + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + jPanel2 = new javax.swing.JPanel(); + jPanel6 = new javax.swing.JPanel(); + btnCustomer = new javax.swing.JButton(); + btnSave = new javax.swing.JButton(); + jSeparator1 = new javax.swing.JSeparator(); + btnPay = new javax.swing.JButton(); + btnPrePay = new javax.swing.JButton(); + jPanel3 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel5 = new javax.swing.JPanel(); + editorcard = new com.unicenta.editor.JEditorString(); + jButton1 = new javax.swing.JButton(); + jPanel1 = new javax.swing.JPanel(); + jLabel3 = new javax.swing.JLabel(); + jLabel12 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + txtCard = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + txtCurdebt = new javax.swing.JTextField(); + txtCurdate = new javax.swing.JTextField(); + jLabel6 = new javax.swing.JLabel(); + txtName = new javax.swing.JTextField(); + txtMaxdebt = new javax.swing.JTextField(); + txtPrePay = new com.unicenta.editor.JEditorString(); + txtTaxId = new javax.swing.JTextField(); + jLabel7 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + txtNotes = new com.unicenta.editor.JEditorString(); + + setLayout(new java.awt.BorderLayout()); + + jPanel2.setLayout(new java.awt.BorderLayout()); + + btnCustomer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer_sml.png"))); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + btnCustomer.setToolTipText(bundle.getString("tooltip.customerpay.customer")); // NOI18N + btnCustomer.setFocusPainted(false); + btnCustomer.setFocusable(false); + btnCustomer.setMargin(new java.awt.Insets(8, 14, 8, 14)); + btnCustomer.setPreferredSize(new java.awt.Dimension(110, 45)); + btnCustomer.setRequestFocusEnabled(false); + btnCustomer.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCustomerActionPerformed(evt); + } + }); + jPanel6.add(btnCustomer); + + btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/filesave.png"))); // NOI18N + btnSave.setToolTipText(bundle.getString("tootltip.save")); // NOI18N + btnSave.setFocusPainted(false); + btnSave.setFocusable(false); + btnSave.setMargin(new java.awt.Insets(8, 14, 8, 14)); + btnSave.setPreferredSize(new java.awt.Dimension(110, 45)); + btnSave.setRequestFocusEnabled(false); + btnSave.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnSaveActionPerformed(evt); + } + }); + jPanel6.add(btnSave); + jPanel6.add(jSeparator1); + + btnPay.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + btnPay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/pay.png"))); // NOI18N + btnPay.setText(AppLocal.getIntString("button.pay")); // NOI18N + btnPay.setToolTipText(bundle.getString("tooltip.customerpay.pay")); // NOI18N + btnPay.setFocusPainted(false); + btnPay.setFocusable(false); + btnPay.setMargin(new java.awt.Insets(8, 14, 8, 14)); + btnPay.setMaximumSize(new java.awt.Dimension(110, 44)); + btnPay.setMinimumSize(new java.awt.Dimension(110, 44)); + btnPay.setPreferredSize(new java.awt.Dimension(110, 45)); + btnPay.setRequestFocusEnabled(false); + btnPay.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnPayActionPerformed(evt); + } + }); + jPanel6.add(btnPay); + + btnPrePay.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + btnPrePay.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer_add_sml.png"))); // NOI18N + btnPrePay.setText(AppLocal.getIntString("button.prepay")); // NOI18N + btnPrePay.setToolTipText(bundle.getString("tooltip.prepay")); // NOI18N + btnPrePay.setFocusPainted(false); + btnPrePay.setFocusable(false); + btnPrePay.setMargin(new java.awt.Insets(8, 14, 8, 14)); + btnPrePay.setMaximumSize(new java.awt.Dimension(110, 44)); + btnPrePay.setMinimumSize(new java.awt.Dimension(110, 44)); + btnPrePay.setPreferredSize(new java.awt.Dimension(110, 45)); + btnPrePay.setRequestFocusEnabled(false); + btnPrePay.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnPrePayActionPerformed(evt); + } + }); + jPanel6.add(btnPrePay); + + jPanel2.add(jPanel6, java.awt.BorderLayout.LINE_START); + + add(jPanel2, java.awt.BorderLayout.PAGE_START); + + jPanel3.setLayout(new java.awt.BorderLayout()); + + jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS)); + + m_jKeys.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jKeysActionPerformed(evt); + } + }); + jPanel4.add(m_jKeys); + + jPanel5.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel5.setLayout(new java.awt.GridBagLayout()); + + editorcard.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + editorcard.setPreferredSize(new java.awt.Dimension(200, 30)); + jPanel5.add(editorcard, new java.awt.GridBagConstraints()); + + jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jButton1.setFocusPainted(false); + jButton1.setFocusable(false); + jButton1.setMargin(new java.awt.Insets(8, 14, 8, 14)); + jButton1.setPreferredSize(new java.awt.Dimension(110, 45)); + jButton1.setRequestFocusEnabled(false); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); + jPanel5.add(jButton1, gridBagConstraints); + + jPanel4.add(jPanel5); + + jPanel3.add(jPanel4, java.awt.BorderLayout.NORTH); + + add(jPanel3, java.awt.BorderLayout.LINE_END); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.name")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel12.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel12.setText(AppLocal.getIntString("label.notes")); // NOI18N + jLabel12.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.card")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtCard.setEditable(false); + txtCard.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCard.setFocusable(false); + txtCard.setPreferredSize(new java.awt.Dimension(0, 30)); + txtCard.setRequestFocusEnabled(false); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setText(AppLocal.getIntString("label.maxdebt")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(120, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel2.setText(AppLocal.getIntString("label.curdebt")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(120, 30)); + + txtCurdebt.setEditable(false); + txtCurdebt.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCurdebt.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + txtCurdebt.setFocusable(false); + txtCurdebt.setPreferredSize(new java.awt.Dimension(120, 30)); + txtCurdebt.setRequestFocusEnabled(false); + + txtCurdate.setEditable(false); + txtCurdate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCurdate.setHorizontalAlignment(javax.swing.JTextField.CENTER); + txtCurdate.setFocusable(false); + txtCurdate.setPreferredSize(new java.awt.Dimension(120, 30)); + txtCurdate.setRequestFocusEnabled(false); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel6.setText(AppLocal.getIntString("label.curdate")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(120, 30)); + + txtName.setEditable(false); + txtName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtName.setFocusable(false); + txtName.setPreferredSize(new java.awt.Dimension(0, 30)); + txtName.setRequestFocusEnabled(false); + + txtMaxdebt.setEditable(false); + txtMaxdebt.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtMaxdebt.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + txtMaxdebt.setFocusable(false); + txtMaxdebt.setPreferredSize(new java.awt.Dimension(120, 30)); + txtMaxdebt.setRequestFocusEnabled(false); + + txtPrePay.setForeground(new java.awt.Color(0, 204, 255)); + txtPrePay.setToolTipText(bundle.getString("tooltip.customerpay.prepay")); // NOI18N + txtPrePay.setEnabled(false); + txtPrePay.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + txtPrePay.setPreferredSize(new java.awt.Dimension(200, 30)); + + txtTaxId.setEditable(false); + txtTaxId.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtTaxId.setFocusable(false); + txtTaxId.setPreferredSize(new java.awt.Dimension(150, 30)); + txtTaxId.setRequestFocusEnabled(false); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.taxid")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.prepay")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(120, 30)); + + txtNotes.setToolTipText(bundle.getString("tooltip.customerpay.notes")); // NOI18N + txtNotes.setEnabled(false); + txtNotes.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtNotes.setPreferredSize(new java.awt.Dimension(250, 100)); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(txtCard, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(txtTaxId, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtPrePay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtNotes, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(txtMaxdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(txtCurdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtCurdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtTaxId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtNotes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPrePay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(30, 30, 30) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtCurdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtMaxdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtCurdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + add(jPanel1, java.awt.BorderLayout.CENTER); + }// //GEN-END:initComponents + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + + readCustomer(); + + }//GEN-LAST:event_jButton1ActionPerformed + + private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed + + readCustomer(); + + }//GEN-LAST:event_m_jKeysActionPerformed + + private void btnCustomerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCustomerActionPerformed + + JCustomerFinder finder = JCustomerFinder.getCustomerFinder(this, dlcustomers); + finder.search(null); + finder.setVisible(true); + CustomerInfo customer = finder.getSelectedCustomer(); + if (customer != null) { + try { + CustomerInfoExt c = dlsales.loadCustomerExt(customer.getId()); + if (c == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer")); + msg.show(this); + } else { + editCustomer(c); + } + } catch (BasicException ex) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex); + msg.show(this); + } + } + editorcard.reset(); + editorcard.activate(); + +}//GEN-LAST:event_btnCustomerActionPerformed + + private void btnPayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPayActionPerformed + + paymentdialog.setPrintSelected(true); + + if (paymentdialog.showDialog(customerext.getAccdebt(), null)) { + + // Save the ticket + TicketInfo ticket = new TicketInfo(); + ticket.setTicketType(TicketInfo.RECEIPT_PAYMENT); + + List payments = paymentdialog.getSelectedPayments(); + + double total = 0.0; + for (PaymentInfo p : payments) { + total += p.getTotal(); + } + + payments.add(new PaymentInfoTicket(-total, "debtpaid")); + + ticket.setPayments(payments); + + ticket.setUser(app.getAppUserView().getUser().getUserInfo()); + ticket.setActiveCash(app.getActiveCashIndex()); + ticket.setDate(new Date()); + ticket.setCustomer(customerext); + + try { + dlsales.saveTicket(ticket, app.getInventoryLocation()); + } catch (BasicException eData) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData); + msg.show(this); + } + + + // reload customer + CustomerInfoExt c; + try { + c = dlsales.loadCustomerExt(customerext.getId()); + if (c == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer")); + msg.show(this); + } else { + editCustomer(c); + } + } catch (BasicException ex) { + c = null; + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex); + msg.show(this); + } + + printTicket(paymentdialog.isPrintSelected() + ? "Printer.CustomerPaid" + : "Printer.CustomerPaid2", + ticket, c); + } + + editorcard.reset(); + editorcard.activate(); + +}//GEN-LAST:event_btnPayActionPerformed + + private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed + + if (dirty.isDirty()) { + save(); + + editorcard.reset(); + editorcard.activate(); + } + +}//GEN-LAST:event_btnSaveActionPerformed + + private void btnPrePayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrePayActionPerformed + + txtPrePay.setFocusable(true); + txtPrePay.requestFocusInWindow(); + + if (txtPrePay.getText() != null) { + double prepay = Double.parseDouble(txtPrePay.getText()); + Formats.CURRENCY.formatValue(RoundUtils.getValue(prepay)); + paymentdialog.setPrintSelected(true); + + if (paymentdialog.showDialog(prepay, null)) { + + TicketInfo ticket = new TicketInfo(); + ticket.setTicketType(TicketInfo.RECEIPT_PAYMENT); + List payments = paymentdialog.getSelectedPayments(); + + double total = 0.0; + for (PaymentInfo p : payments) { + total += p.getTotal(); + } + + total = Double.parseDouble(txtPrePay.getText()); + + payments.add(new PaymentInfoTicket(-total, "debtpaid")); + + ticket.setPayments(payments); + + ticket.setUser(app.getAppUserView().getUser().getUserInfo()); + ticket.setActiveCash(app.getActiveCashIndex()); + ticket.setDate(new Date()); + ticket.setCustomer(customerext); + + try { + dlsales.saveTicket(ticket, app.getInventoryLocation()); + } catch (BasicException eData) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData); + msg.show(this); + } + + CustomerInfoExt c; + try { + c = dlsales.loadCustomerExt(customerext.getId()); + if (c == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer")); + msg.show(this); + } else { + editCustomer(c); + } + } catch (BasicException ex) { + c = null; + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), ex); + msg.show(this); + } + + printTicket(paymentdialog.isPrintSelected() + ? "Printer.CustomerPaid" + : "Printer.CustomerPaid2", + ticket, c); + } + + editorcard.reset(); + editorcard.activate(); + } + }//GEN-LAST:event_btnPrePayActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCustomer; + private javax.swing.JButton btnPay; + private javax.swing.JButton btnPrePay; + private javax.swing.JButton btnSave; + private com.unicenta.editor.JEditorString editorcard; + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JSeparator jSeparator1; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JTextField txtCard; + private javax.swing.JTextField txtCurdate; + private javax.swing.JTextField txtCurdebt; + private javax.swing.JTextField txtMaxdebt; + private javax.swing.JTextField txtName; + private com.unicenta.editor.JEditorString txtNotes; + private com.unicenta.editor.JEditorString txtPrePay; + private javax.swing.JTextField txtTaxId; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/customers/CustomersView.form b/src/main/java/com/unicenta/pos/customers/CustomersView.form new file mode 100644 index 0000000..9810dc5 --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/CustomersView.form @@ -0,0 +1,1373 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="gridColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="cc" red="66" type="rgb"/> + </Property> + <Property name="opaque" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[375, 500]"/> + </Property> + <Property name="rowHeight" type="int" value="25"/> + <Property name="showVerticalLines" type="boolean" value="false"/> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="true" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLblTranCount"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> + <JTabbedPaneConstraints tabName="Photo"> + <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.photo" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </JTabbedPaneConstraints> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel34" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="86" max="-2" attributes="0"/> + <Component id="m_jImage" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace pref="135" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jImage" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="jLabel34" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="com.unicenta.data.gui.JImageEditor" name="m_jImage"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 250]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel34"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.imagesize" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> + <JTabbedPaneConstraints tabName="Notes"> + <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.notes" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </JTabbedPaneConstraints> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jScrollPane1" min="-2" pref="458" max="-2" attributes="0"/> + <EmptySpace pref="177" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jScrollPane1" pref="247" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="m_jNotes"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 0]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLblVIP"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.vip" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="m_jVip"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="f3" green="bc" red="0" type="rgb"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[21, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="m_jVipnone"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jVipActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLblDiscount"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.discount" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtDiscount"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblDiscountpercent"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="%"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[15, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="m_jbtndate"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/date.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Open Calendar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtndateActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jdate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel10"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.customerdate" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="verticalAlignment" type="int" value="3"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/customers/CustomersView.java b/src/main/java/com/unicenta/pos/customers/CustomersView.java new file mode 100644 index 0000000..fc65288 --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/CustomersView.java @@ -0,0 +1,1639 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.customers; + +import com.unicenta.basic.BasicException; +import com.unicenta.beans.JCalendarDialog; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.BeanFactoryException; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.util.StringUtils; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.JTableHeader; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +/** + * + * @author Jack Gerrard + */ +@Slf4j +public final class CustomersView extends javax.swing.JPanel implements EditorRecord { + + private static final long serialVersionUID = 1L; + private Object m_oId; + + private SentenceList m_sentcat; + private List<CustomerTransaction> customerTransactionList; + private TransactionTableModel transactionModel; + private ComboBoxValModel m_CategoryModel; + + private DirtyManager m_Dirty; + private DataLogicSales dlSales; + + //HS updates to get last added Customer 06.03.2014 + private AppView appView; + private CustomerInfo customerInfo; + + /** Creates new form CustomersView + * @param app + * @param dirty */ + public CustomersView(AppView app, DirtyManager dirty) { + try { + setAppView(app); + dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + + initComponents(); + + m_sentcat = dlSales.getTaxCustCategoriesList(); + m_CategoryModel = new ComboBoxValModel(); + + m_Dirty = dirty; + m_jTaxID.getDocument().addDocumentListener(dirty); + m_jSearchkey.getDocument().addDocumentListener(dirty); + m_jName.getDocument().addDocumentListener(dirty); + m_jCategory.addActionListener(dirty); + m_jNotes.getDocument().addDocumentListener(dirty); + txtMaxdebt.getDocument().addDocumentListener(dirty); + txtCurdebt.getDocument().addDocumentListener(dirty); + txtCurdate.getDocument().addDocumentListener(dirty); + m_jVisible.addActionListener(dirty); + m_jVip.addActionListener(dirty); + txtDiscount.getDocument().addDocumentListener(dirty); + + txtFirstName.getDocument().addDocumentListener(dirty); + txtLastName.getDocument().addDocumentListener(dirty); + txtEmail.getDocument().addDocumentListener(dirty); + txtPhone.getDocument().addDocumentListener(dirty); + txtPhone2.getDocument().addDocumentListener(dirty); + txtFax.getDocument().addDocumentListener(dirty); + m_jImage.addPropertyChangeListener(dirty); + + txtAddress.getDocument().addDocumentListener(dirty); + txtAddress2.getDocument().addDocumentListener(dirty); + txtPostal.getDocument().addDocumentListener(dirty); + txtCity.getDocument().addDocumentListener(dirty); + txtRegion.getDocument().addDocumentListener(dirty); + txtCountry.getDocument().addDocumentListener(dirty); + + m_jdate.getDocument().addDocumentListener(dirty); + + init(); + } catch (BeanFactoryException ex) { + log.error(ex.getMessage()); + } + } + + private void init() { + writeValueEOF(); + } + + /** + * Instantiate object + * @throws BasicException + */ + @SuppressWarnings("unchecked") + public void activate() throws BasicException { + + List a = m_sentcat.list(); + a.add(0, null); // The null item + m_CategoryModel = new ComboBoxValModel(a); + m_jCategory.setModel(m_CategoryModel); + String cId = null; + } + + /** + * Refresh object + */ + @Override + public void refresh() { + jLblTranCount.setText(null); + } + + /** + * Write EOF + */ + @Override + public void writeValueEOF() { + m_oId = null; + m_jTaxID.setText(null); + m_jSearchkey.setText(null); + m_jName.setText(null); + m_CategoryModel.setSelectedKey(null); + m_jNotes.setText(null); + + txtMaxdebt.setText(null); + txtCurdebt.setText(null); + txtCurdate.setText(null); + m_jVisible.setSelected(false); + m_jVip.setSelected(false); + txtDiscount.setText(null); + jcard.setText(null); + + txtFirstName.setText(null); + txtLastName.setText(null); + txtEmail.setText(null); + txtPhone.setText(null); + txtPhone2.setText(null); + txtFax.setText(null); + m_jImage.setImage(null); + + txtAddress.setText(null); + txtAddress2.setText(null); + txtPostal.setText(null); + txtCity.setText(null); + txtRegion.setText(null); + txtCountry.setText(null); + + m_jdate.setText(null); + + m_jTaxID.setEnabled(false); + m_jSearchkey.setEnabled(false); + m_jName.setEnabled(false); + m_jCategory.setEnabled(false); + m_jNotes.setEnabled(false); + txtMaxdebt.setEnabled(false); + txtCurdebt.setEnabled(false); + txtCurdate.setEnabled(false); + m_jVisible.setEnabled(false); + m_jVip.setEnabled(false); + txtDiscount.setEnabled(false); + jcard.setEnabled(false); + + txtFirstName.setEnabled(false); + txtLastName.setEnabled(false); + txtEmail.setEnabled(false); + txtPhone.setEnabled(false); + txtPhone2.setEnabled(false); + txtFax.setEnabled(false); + m_jImage.setEnabled(false); + + txtAddress.setEnabled(false); + txtAddress2.setEnabled(false); + txtPostal.setEnabled(false); + txtCity.setEnabled(false); + txtRegion.setEnabled(false); + txtCountry.setEnabled(false); + + jBtnCreateCard.setEnabled(false); + jBtnClearCard.setEnabled(false); + + m_jdate.setEnabled(false); + m_jbtndate.setEnabled(false); + + jTableCustomerTransactions.setEnabled(false); + + repaint(); + refresh(); + } + + @Override + public void writeValueInsert() { + + m_oId = null; + m_jTaxID.setText(null); + m_jSearchkey.setText(null); + m_jName.setText(null); + txtPhone.setText(null); + txtEmail.setText(null); + + m_CategoryModel.setSelectedKey(null); + m_jNotes.setText(null); + txtMaxdebt.setText(null); + txtCurdebt.setText(null); + txtCurdate.setText(null); + m_jVisible.setSelected(true); + m_jVip.setSelected(false); + txtDiscount.setText(null); + jcard.setText(null); + + txtFirstName.setText(null); + txtLastName.setText(null); + txtPhone2.setText(null); + txtFax.setText(null); + m_jImage.setImage(null); + + txtAddress.setText(null); + txtAddress2.setText(null); + txtPostal.setText(null); + txtCity.setText(null); + txtRegion.setText(null); + txtCountry.setText(null); + + m_jdate.setText(null); + + m_jTaxID.setEnabled(true); + m_jSearchkey.setEnabled(true); + m_jName.setEnabled(true); + m_jCategory.setEnabled(true); + m_jNotes.setEnabled(true); + txtMaxdebt.setEnabled(true); + txtCurdebt.setEnabled(true); + txtCurdate.setEnabled(true); + m_jVisible.setEnabled(true); + m_jVip.setEnabled(true); + txtDiscount.setEnabled(true); + jcard.setEnabled(true); + + txtFirstName.setEnabled(true); + txtLastName.setEnabled(true); + txtEmail.setEnabled(true); + webBtnMail.setEnabled(true); + txtPhone.setEnabled(true); + txtPhone2.setEnabled(true); + txtFax.setEnabled(true); + m_jImage.setEnabled(true); + + txtAddress.setEnabled(true); + txtAddress2.setEnabled(true); + txtPostal.setEnabled(true); + txtCity.setEnabled(true); + txtRegion.setEnabled(true); + txtCountry.setEnabled(true); + + jBtnCreateCard.setEnabled(true); + jBtnClearCard.setEnabled(true); + + jTableCustomerTransactions.setEnabled(false); + + m_jdate.setEnabled(true); + m_jbtndate.setEnabled(true); + + repaint(); + refresh(); + } + + /** + * Delete from object + * @param value + */ + @Override + public void writeValueDelete(Object value) { + + Object[] customer = (Object[]) value; + m_oId = customer[0]; + m_jSearchkey.setText((String) customer[1]); + m_jTaxID.setText((String) customer[2]); + m_jName.setText((String) customer[3]); + m_CategoryModel.setSelectedKey(customer[4]); + jcard.setText((String) customer[5]); + txtMaxdebt.setText(Formats.CURRENCY.formatValue(customer[6])); + txtAddress.setText(Formats.STRING.formatValue(customer[7])); + txtAddress2.setText(Formats.STRING.formatValue(customer[8])); + txtPostal.setText(Formats.STRING.formatValue(customer[9])); + txtCity.setText(Formats.STRING.formatValue(customer[10])); + txtRegion.setText(Formats.STRING.formatValue(customer[11])); + txtCountry.setText(Formats.STRING.formatValue(customer[12])); + txtFirstName.setText(Formats.STRING.formatValue(customer[13])); + txtLastName.setText(Formats.STRING.formatValue(customer[14])); + txtEmail.setText(Formats.STRING.formatValue(customer[15])); + txtPhone.setText(Formats.STRING.formatValue(customer[16])); + txtPhone2.setText(Formats.STRING.formatValue(customer[17])); + txtFax.setText(Formats.STRING.formatValue(customer[18])); + m_jNotes.setText((String) customer[19]); + m_jVisible.setSelected(((Boolean) customer[20])); + txtCurdate.setText(Formats.DATE.formatValue(customer[21])); + txtCurdebt.setText(Formats.CURRENCY.formatValue(customer[22])); + m_jImage.setImage((BufferedImage) customer[23]); + m_jVip.setSelected(((Boolean) customer[24])); + txtDiscount.setText(Formats.DOUBLE.formatValue(customer[25])); + m_jdate.setText(Formats.DATE.formatValue(customer[26])); + + m_jTaxID.setEnabled(false); + m_jSearchkey.setEnabled(false); + m_jName.setEnabled(false); + m_jNotes.setEnabled(false); + txtMaxdebt.setEnabled(false); + txtCurdebt.setEnabled(false); + txtCurdate.setEnabled(false); + m_jVisible.setEnabled(false); + m_jVip.setEnabled(false); + txtDiscount.setEnabled(false); + jcard.setEnabled(false); + + txtFirstName.setEnabled(false); + txtLastName.setEnabled(false); + txtEmail.setEnabled(false); + webBtnMail.setEnabled(false); + txtPhone.setEnabled(false); + txtPhone2.setEnabled(false); + txtFax.setEnabled(false); + m_jImage.setEnabled(true); + + txtAddress.setEnabled(false); + txtAddress2.setEnabled(false); + txtPostal.setEnabled(false); + txtCity.setEnabled(false); + txtRegion.setEnabled(false); + txtCountry.setEnabled(false); + + m_jCategory.setEnabled(false); + + jBtnCreateCard.setEnabled(false); + jBtnClearCard.setEnabled(false); + +// JG 3 Oct 2013 - for Transaction List table + transactionModel = new TransactionTableModel(getTransactionOfName((String) m_oId)); + jTableCustomerTransactions.setModel(transactionModel); + jTableCustomerTransactions.setEnabled(false); + + m_jdate.setEnabled(false); + m_jbtndate.setEnabled(false); + + repaint(); + refresh(); + } + + /** + * Edit object + * @param value + */ + @Override + public void writeValueEdit(Object value) { + Object[] customer = (Object[]) value; + m_oId = customer[0]; + m_jSearchkey.setText((String) customer[1]); + m_jTaxID.setText((String) customer[2]); + m_jName.setText((String) customer[3]); + m_CategoryModel.setSelectedKey(customer[4]); + jcard.setText((String) customer[5]); + txtMaxdebt.setText(Formats.CURRENCY.formatValue(customer[6])); + txtAddress.setText(Formats.STRING.formatValue(customer[7])); + txtAddress2.setText(Formats.STRING.formatValue(customer[8])); + txtPostal.setText(Formats.STRING.formatValue(customer[9])); + txtCity.setText(Formats.STRING.formatValue(customer[10])); + txtRegion.setText(Formats.STRING.formatValue(customer[11])); + txtCountry.setText(Formats.STRING.formatValue(customer[12])); + txtFirstName.setText(Formats.STRING.formatValue(customer[13])); + txtLastName.setText(Formats.STRING.formatValue(customer[14])); + txtEmail.setText(Formats.STRING.formatValue(customer[15])); + txtPhone.setText(Formats.STRING.formatValue(customer[16])); + txtPhone2.setText(Formats.STRING.formatValue(customer[17])); + txtFax.setText(Formats.STRING.formatValue(customer[18])); + m_jNotes.setText((String) customer[19]); + m_jVisible.setSelected(((Boolean) customer[20])); + txtCurdate.setText(Formats.DATE.formatValue(customer[21])); + txtCurdebt.setText(Formats.CURRENCY.formatValue(customer[22])); + m_jImage.setImage((BufferedImage) customer[23]); + m_jVip.setSelected(((Boolean) customer[24])); + txtDiscount.setText(Formats.DOUBLE.formatValue(customer[25])); + + m_jdate.setText(Formats.DATE.formatValue(customer[26])); + + m_jTaxID.setEnabled(true); + m_jSearchkey.setEnabled(true); + m_jName.setEnabled(true); + m_jNotes.setEnabled(true); + txtMaxdebt.setEnabled(true); + txtCurdebt.setEnabled(true); + txtCurdate.setEnabled(true); + m_jVisible.setEnabled(true); + m_jVip.setEnabled(true); + txtDiscount.setEnabled(true); + jcard.setEnabled(true); + + txtFirstName.setEnabled(true); + txtLastName.setEnabled(true); + txtEmail.setEnabled(true); + webBtnMail.setEnabled(true); + txtPhone.setEnabled(true); + txtPhone2.setEnabled(true); + txtFax.setEnabled(true); + m_jImage.setEnabled(true); + + txtAddress.setEnabled(true); + txtAddress2.setEnabled(true); + txtPostal.setEnabled(true); + txtCity.setEnabled(true); + txtRegion.setEnabled(true); + txtCountry.setEnabled(true); + + m_jCategory.setEnabled(true); + + m_jdate.setEnabled(true); + m_jbtndate.setEnabled(true); + + jBtnCreateCard.setEnabled(true); + jBtnClearCard.setEnabled(true); + + jTableCustomerTransactions.setVisible(false); + jTableCustomerTransactions.setEnabled(true); + resetTranxTable(); + + jTableCustomerTransactions.repaint(); + repaint(); + refresh(); + } + +public void resetTranxTable() { + + jTableCustomerTransactions.getColumnModel().getColumn(0).setPreferredWidth(50); + jTableCustomerTransactions.getColumnModel().getColumn(1).setPreferredWidth(70); + jTableCustomerTransactions.getColumnModel().getColumn(2).setPreferredWidth(280); + jTableCustomerTransactions.getColumnModel().getColumn(3).setPreferredWidth(30); + jTableCustomerTransactions.getColumnModel().getColumn(4).setPreferredWidth(50); + + // set font for headers + Font f = new Font("Arial", Font.BOLD, 14); + JTableHeader header = jTableCustomerTransactions.getTableHeader(); + header.setFont(f); + + jTableCustomerTransactions.getTableHeader().setReorderingAllowed(true); + jTableCustomerTransactions.setAutoCreateRowSorter(true); + jTableCustomerTransactions.repaint(); + + +} + + + /** + * Create object + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] customer = new Object[28]; + + customer[0] = m_oId == null ? UUID.randomUUID().toString() : m_oId; + customer[1] = m_jSearchkey.getText(); + customer[2] = m_jTaxID.getText(); + customer[3] = m_jName.getText(); + customer[4] = m_CategoryModel.getSelectedKey(); + customer[5] = Formats.STRING.parseValue(jcard.getText()); // Format to manage NULL values + customer[6] = Formats.CURRENCY.parseValue(txtMaxdebt.getText(), 0.0); + customer[7] = Formats.STRING.parseValue(txtAddress.getText()); + customer[8] = Formats.STRING.parseValue(txtAddress2.getText()); + customer[9] = Formats.STRING.parseValue(txtPostal.getText()); + customer[10] = Formats.STRING.parseValue(txtCity.getText()); + customer[11] = Formats.STRING.parseValue(txtRegion.getText()); + customer[12] = Formats.STRING.parseValue(txtCountry.getText()); + customer[13] = Formats.STRING.parseValue(txtFirstName.getText()); + customer[14] = Formats.STRING.parseValue(txtLastName.getText()); + customer[15] = Formats.STRING.parseValue(txtEmail.getText()); + customer[16] = Formats.STRING.parseValue(txtPhone.getText()); + customer[17] = Formats.STRING.parseValue(txtPhone2.getText()); + customer[18] = Formats.STRING.parseValue(txtFax.getText()); + customer[19] = m_jNotes.getText(); + customer[20] = m_jVisible.isSelected(); + customer[21] = Formats.TIMESTAMP.parseValue(txtCurdate.getText()); // not saved + customer[22] = Formats.CURRENCY.parseValue(txtCurdebt.getText()); // not saved + customer[23] = m_jImage.getImage(); + customer[24] = m_jVip.isSelected(); + customer[25] = Formats.CURRENCY.parseValue(txtDiscount.getText(), 0.0); + customer[26] = Formats.TIMESTAMP.parseValue(m_jdate.getText()); + customer[27] = (Object)getAppView(); + + if (m_jName.getText().contains("&")) { + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.ampersand")); + } + + return customer; + } + + //HS New methods to get last customer saved 06.03.2014 + public AppView getAppView() { + return appView; + } + + public void setAppView(AppView appView) { + this.appView = appView; + } + + @Override + public Component getComponent() { + return this; + } + +// JG 3 Oct 2013 - Customer Transaction List +// JG 10 April 2016 - Revision + private List<CustomerTransaction> getTransactionOfName(String cId) { + + try { + customerTransactionList = dlSales.getCustomersTransactionList(cId); + + + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + + List<CustomerTransaction> customerList = new ArrayList<>(); + + for (CustomerTransaction customerTransaction : customerTransactionList) { + String customerId = customerTransaction.getCustomerId(); + if (customerId.equals(cId)) { + customerList.add(customerTransaction); + } + } + + txtCurdate.repaint(); + txtCurdebt.repaint(); + + repaint(); + refresh(); + + return customerList; + } + + class TransactionTableModel extends AbstractTableModel { + String tkt = AppLocal.getIntString("label.tblHeaderCol1"); + String dte = AppLocal.getIntString("label.tblHeaderCol2"); + String prd = AppLocal.getIntString("label.tblHeaderCol3"); + String qty = AppLocal.getIntString("label.tblHeaderCol4"); + String ttl = AppLocal.getIntString("label.tblHeaderCol5"); + + + List<CustomerTransaction> transactionList; + String[] columnNames = {tkt, dte, prd, qty, ttl}; + public Double Tamount; + + public TransactionTableModel(List<CustomerTransaction> list) { + transactionList = list; + } + + @Override + public int getColumnCount() { + return 5; + } + + @Override + public int getRowCount() { + return transactionList.size(); + } + + // this method is called to set the value of each cell + @Override + public Object getValueAt(int row, int column) { + CustomerTransaction customerTransaction = transactionList.get(row); + + jTableCustomerTransactions.setRowHeight(25); + + switch (column) { + + case 0: + return customerTransaction.getTicketId(); + case 1: + Date transactionDate = customerTransaction.getTransactionDate(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + String formattedDate = sdf.format(transactionDate); + return formattedDate; + case 2: + return customerTransaction.getProductName(); + case 3: + return customerTransaction.getUnit(); + case 4: + Double amount = customerTransaction.getTotal(); + DecimalFormat df = new DecimalFormat("#.##"); + String formattedAmount = df.format(amount); + return formattedAmount; + default: + return ""; + + } + } + + @Override + public String getColumnName(int col) { + return columnNames[col]; + } + } + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel7 = new javax.swing.JLabel(); + m_jTaxID = new javax.swing.JTextField(); + jLabel8 = new javax.swing.JLabel(); + m_jSearchkey = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + jLabel5 = new javax.swing.JLabel(); + jcard = new javax.swing.JTextField(); + jBtnCreateCard = new javax.swing.JButton(); + jBtnClearCard = new javax.swing.JButton(); + jLabel9 = new javax.swing.JLabel(); + m_jCategory = new javax.swing.JComboBox(); + jLabel4 = new javax.swing.JLabel(); + m_jVisible = new javax.swing.JCheckBox(); + jLabel1 = new javax.swing.JLabel(); + txtMaxdebt = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + txtCurdebt = new javax.swing.JTextField(); + jLabel6 = new javax.swing.JLabel(); + txtCurdate = new javax.swing.JTextField(); + jTabbedPane1 = new javax.swing.JTabbedPane(); + jPanel1 = new javax.swing.JPanel(); + jLabel19 = new javax.swing.JLabel(); + txtFirstName = new javax.swing.JTextField(); + jLabel15 = new javax.swing.JLabel(); + txtLastName = new javax.swing.JTextField(); + jLabel16 = new javax.swing.JLabel(); + txtEmail = new javax.swing.JTextField(); + jLabel17 = new javax.swing.JLabel(); + txtPhone = new javax.swing.JTextField(); + jLabel18 = new javax.swing.JLabel(); + txtPhone2 = new javax.swing.JTextField(); + jLabel14 = new javax.swing.JLabel(); + txtFax = new javax.swing.JTextField(); + webBtnMail = new com.alee.laf.button.WebButton(); + jPanel2 = new javax.swing.JPanel(); + jLabel13 = new javax.swing.JLabel(); + txtAddress = new javax.swing.JTextField(); + jLabel20 = new javax.swing.JLabel(); + txtCountry = new javax.swing.JTextField(); + jLabel21 = new javax.swing.JLabel(); + txtAddress2 = new javax.swing.JTextField(); + jLabel22 = new javax.swing.JLabel(); + txtPostal = new javax.swing.JTextField(); + jLabel23 = new javax.swing.JLabel(); + txtCity = new javax.swing.JTextField(); + jLabel24 = new javax.swing.JLabel(); + txtRegion = new javax.swing.JTextField(); + jPanel4 = new javax.swing.JPanel(); + jBtnShowTrans = new javax.swing.JButton(); + jScrollPane3 = new javax.swing.JScrollPane(); + jTableCustomerTransactions = new javax.swing.JTable(); + jLblTranCount = new javax.swing.JLabel(); + jPanel5 = new javax.swing.JPanel(); + m_jImage = new com.unicenta.data.gui.JImageEditor(); + jLabel34 = new javax.swing.JLabel(); + jPanel3 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + m_jNotes = new javax.swing.JTextArea(); + jLblVIP = new javax.swing.JLabel(); + m_jVip = new javax.swing.JCheckBox(); + jLblDiscount = new javax.swing.JLabel(); + txtDiscount = new javax.swing.JTextField(); + jLblDiscountpercent = new javax.swing.JLabel(); + m_jbtndate = new javax.swing.JButton(); + m_jdate = new javax.swing.JTextField(); + jLabel10 = new javax.swing.JLabel(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setPreferredSize(new java.awt.Dimension(1000, 600)); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/info.png"))); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.taxid")); // NOI18N + jLabel7.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel7.setMinimumSize(new java.awt.Dimension(140, 25)); + jLabel7.setPreferredSize(new java.awt.Dimension(150, 30)); + jLabel7.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel7MouseClicked(evt); + } + }); + + m_jTaxID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTaxID.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.searchkeym")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jSearchkey.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSearchkey.setPreferredSize(new java.awt.Dimension(140, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.namem")); // NOI18N + jLabel3.setMaximumSize(new java.awt.Dimension(140, 25)); + jLabel3.setMinimumSize(new java.awt.Dimension(140, 25)); + jLabel3.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(410, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.card")); // NOI18N + jLabel5.setMaximumSize(new java.awt.Dimension(140, 25)); + jLabel5.setMinimumSize(new java.awt.Dimension(140, 25)); + jLabel5.setPreferredSize(new java.awt.Dimension(150, 30)); + + jcard.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcard.setPreferredSize(new java.awt.Dimension(150, 30)); + + jBtnCreateCard.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/encrypted.png"))); // NOI18N + jBtnCreateCard.setToolTipText("Create Key"); + jBtnCreateCard.setMaximumSize(new java.awt.Dimension(64, 32)); + jBtnCreateCard.setMinimumSize(new java.awt.Dimension(64, 32)); + jBtnCreateCard.setPreferredSize(new java.awt.Dimension(40, 35)); + jBtnCreateCard.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnCreateCardActionPerformed(evt); + } + }); + + jBtnClearCard.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/fileclose.png"))); // NOI18N + jBtnClearCard.setToolTipText("Clear Key"); + jBtnClearCard.setMaximumSize(new java.awt.Dimension(64, 32)); + jBtnClearCard.setMinimumSize(new java.awt.Dimension(64, 32)); + jBtnClearCard.setPreferredSize(new java.awt.Dimension(40, 35)); + jBtnClearCard.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnClearCardActionPerformed(evt); + } + }); + + jLabel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel9.setText(AppLocal.getIntString("label.custtaxcategory")); // NOI18N + jLabel9.setMaximumSize(new java.awt.Dimension(140, 25)); + jLabel9.setMinimumSize(new java.awt.Dimension(140, 25)); + jLabel9.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCategory.setPreferredSize(new java.awt.Dimension(180, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.visible")); // NOI18N + jLabel4.setMaximumSize(new java.awt.Dimension(140, 25)); + jLabel4.setMinimumSize(new java.awt.Dimension(140, 25)); + jLabel4.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jVisible.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jVisible.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jVisible.setPreferredSize(new java.awt.Dimension(30, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setText(AppLocal.getIntString("label.maxdebt")); // NOI18N + jLabel1.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); + jLabel1.setMaximumSize(new java.awt.Dimension(140, 25)); + jLabel1.setMinimumSize(new java.awt.Dimension(120, 25)); + jLabel1.setPreferredSize(new java.awt.Dimension(130, 30)); + + txtMaxdebt.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtMaxdebt.setHorizontalAlignment(javax.swing.JTextField.CENTER); + txtMaxdebt.setPreferredSize(new java.awt.Dimension(130, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel2.setText(AppLocal.getIntString("label.curdebt")); // NOI18N + jLabel2.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); + jLabel2.setMaximumSize(new java.awt.Dimension(140, 25)); + jLabel2.setMinimumSize(new java.awt.Dimension(120, 25)); + jLabel2.setPreferredSize(new java.awt.Dimension(130, 30)); + + txtCurdebt.setEditable(false); + txtCurdebt.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCurdebt.setHorizontalAlignment(javax.swing.JTextField.CENTER); + txtCurdebt.setPreferredSize(new java.awt.Dimension(130, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel6.setText(AppLocal.getIntString("label.curdate")); // NOI18N + jLabel6.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); + jLabel6.setPreferredSize(new java.awt.Dimension(130, 30)); + + txtCurdate.setEditable(false); + txtCurdate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCurdate.setHorizontalAlignment(javax.swing.JTextField.CENTER); + txtCurdate.setPreferredSize(new java.awt.Dimension(130, 30)); + + jTabbedPane1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTabbedPane1.setPreferredSize(new java.awt.Dimension(650, 300)); + + jPanel1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + jLabel19.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel19.setText(AppLocal.getIntString("label.firstname")); // NOI18N + jLabel19.setAlignmentX(0.5F); + jLabel19.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtFirstName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtFirstName.setPreferredSize(new java.awt.Dimension(300, 30)); + + jLabel15.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel15.setText(AppLocal.getIntString("label.lastname")); // NOI18N + jLabel15.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtLastName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtLastName.setPreferredSize(new java.awt.Dimension(300, 30)); + + jLabel16.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel16.setText(AppLocal.getIntString("label.email")); // NOI18N + jLabel16.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtEmail.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtEmail.setPreferredSize(new java.awt.Dimension(300, 30)); + + jLabel17.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel17.setText(AppLocal.getIntString("label.phone")); // NOI18N + jLabel17.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtPhone.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtPhone.setPreferredSize(new java.awt.Dimension(300, 30)); + + jLabel18.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel18.setText(AppLocal.getIntString("label.phone2")); // NOI18N + jLabel18.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtPhone2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtPhone2.setPreferredSize(new java.awt.Dimension(300, 30)); + + jLabel14.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel14.setText(AppLocal.getIntString("label.fax")); // NOI18N + jLabel14.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtFax.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtFax.setPreferredSize(new java.awt.Dimension(300, 30)); + + webBtnMail.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/mail24.png"))); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + webBtnMail.setText(bundle.getString("button.email")); // NOI18N + webBtnMail.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + webBtnMail.setPreferredSize(new java.awt.Dimension(90, 30)); + webBtnMail.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + webBtnMailActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(txtLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(txtFax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPhone2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(txtFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(webBtnMail, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(76, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webBtnMail, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPhone2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtFax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(57, 57, 57)) + ); + + jTabbedPane1.addTab(AppLocal.getIntString("label.contact"), jPanel1); // NOI18N + + jPanel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + jLabel13.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel13.setText(AppLocal.getIntString("label.address")); // NOI18N + jLabel13.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtAddress.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtAddress.setPreferredSize(new java.awt.Dimension(300, 30)); + + jLabel20.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel20.setText(AppLocal.getIntString("label.country")); // NOI18N + jLabel20.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtCountry.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCountry.setPreferredSize(new java.awt.Dimension(300, 30)); + + jLabel21.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel21.setText(AppLocal.getIntString("label.address2")); // NOI18N + jLabel21.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtAddress2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtAddress2.setPreferredSize(new java.awt.Dimension(300, 30)); + + jLabel22.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel22.setText(AppLocal.getIntString("label.postal")); // NOI18N + jLabel22.setPreferredSize(new java.awt.Dimension(110, 30)); + + txtPostal.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtPostal.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel23.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel23.setText(AppLocal.getIntString("label.city")); // NOI18N + jLabel23.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtCity.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCity.setPreferredSize(new java.awt.Dimension(300, 30)); + + jLabel24.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel24.setText(AppLocal.getIntString("label.region")); // NOI18N + jLabel24.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtRegion.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtRegion.setPreferredSize(new java.awt.Dimension(300, 30)); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(txtCity, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(txtAddress, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(txtAddress2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(txtRegion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(txtCountry, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(18, 18, 18) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtPostal, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtAddress2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtCity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtRegion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtCountry, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + jTabbedPane1.addTab(AppLocal.getIntString("label.locationaddress"), jPanel2); // NOI18N + + jPanel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel4.setPreferredSize(new java.awt.Dimension(535, 0)); + + jBtnShowTrans.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jBtnShowTrans.setText(bundle.getString("button.CustomerTrans")); // NOI18N + jBtnShowTrans.setToolTipText(""); + jBtnShowTrans.setPreferredSize(new java.awt.Dimension(140, 30)); + jBtnShowTrans.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnShowTransActionPerformed(evt); + } + }); + + jScrollPane3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jScrollPane3.setPreferredSize(new java.awt.Dimension(620, 500)); + + jTableCustomerTransactions.setAutoCreateRowSorter(true); + jTableCustomerTransactions.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTableCustomerTransactions.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null} + }, + new String [] { + "TicketID", "Date", "Product", "Qty", "Total" + } + )); + jTableCustomerTransactions.setGridColor(new java.awt.Color(102, 204, 255)); + jTableCustomerTransactions.setOpaque(false); + jTableCustomerTransactions.setPreferredSize(new java.awt.Dimension(375, 500)); + jTableCustomerTransactions.setRowHeight(25); + jTableCustomerTransactions.setShowVerticalLines(false); + jScrollPane3.setViewportView(jTableCustomerTransactions); + + jLblTranCount.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblTranCount.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLblTranCount.setOpaque(true); + jLblTranCount.setPreferredSize(new java.awt.Dimension(50, 30)); + + javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(jBtnShowTrans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jLblTranCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(424, 424, 424)) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) + ); + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jBtnShowTrans, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLblTranCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)) + ); + + jTabbedPane1.addTab(bundle.getString("label.Transactions"), jPanel4); // NOI18N + + m_jImage.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jImage.setPreferredSize(new java.awt.Dimension(300, 250)); + + jLabel34.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel34.setText(bundle.getString("label.imagesize")); // NOI18N + jLabel34.setPreferredSize(new java.awt.Dimension(500, 30)); + + javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); + jPanel5.setLayout(jPanel5Layout); + jPanel5Layout.setHorizontalGroup( + jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel5Layout.createSequentialGroup() + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel5Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel34, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel5Layout.createSequentialGroup() + .addGap(86, 86, 86) + .addComponent(m_jImage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(135, Short.MAX_VALUE)) + ); + jPanel5Layout.setVerticalGroup( + jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup() + .addContainerGap() + .addComponent(m_jImage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel34, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + jTabbedPane1.addTab(bundle.getString("label.photo"), jPanel5); // NOI18N + + jPanel3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + m_jNotes.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jNotes.setPreferredSize(new java.awt.Dimension(0, 0)); + jScrollPane1.setViewportView(m_jNotes); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 458, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(177, Short.MAX_VALUE)) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 247, Short.MAX_VALUE) + .addContainerGap()) + ); + + jTabbedPane1.addTab(AppLocal.getIntString("label.notes"), jPanel3); // NOI18N + + jLblVIP.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblVIP.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + jLblVIP.setText(AppLocal.getIntString("label.vip")); // NOI18N + jLblVIP.setPreferredSize(new java.awt.Dimension(50, 30)); + + m_jVip.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jVip.setForeground(new java.awt.Color(0, 188, 243)); + m_jVip.setPreferredSize(new java.awt.Dimension(21, 30)); + m_jVip.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + m_jVipnone(evt); + } + }); + m_jVip.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jVipActionPerformed(evt); + } + }); + + jLblDiscount.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblDiscount.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + jLblDiscount.setText(AppLocal.getIntString("label.discount")); // NOI18N + jLblDiscount.setPreferredSize(new java.awt.Dimension(70, 30)); + + txtDiscount.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtDiscount.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + txtDiscount.setPreferredSize(new java.awt.Dimension(50, 30)); + + jLblDiscountpercent.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblDiscountpercent.setText("%"); + jLblDiscountpercent.setPreferredSize(new java.awt.Dimension(15, 30)); + + m_jbtndate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/date.png"))); // NOI18N + m_jbtndate.setToolTipText("Open Calendar"); + m_jbtndate.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtndateActionPerformed(evt); + } + }); + + m_jdate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jdate.setPreferredSize(new java.awt.Dimension(130, 30)); + + jLabel10.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel10.setText(bundle.getString("label.customerdate")); // NOI18N + jLabel10.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); + jLabel10.setPreferredSize(new java.awt.Dimension(130, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLblVIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jVip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLblDiscount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(txtDiscount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLblDiscountpercent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(m_jName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jcard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jVisible, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jSearchkey, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(jBtnCreateCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jBtnClearCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))))) + .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(txtMaxdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(txtCurdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(txtCurdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jbtndate, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSearchkey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jBtnCreateCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jcard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jBtnClearCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jVisible, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblDiscount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtDiscount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblDiscountpercent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jVip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblVIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(35, 35, 35) + .addComponent(txtMaxdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtCurdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtCurdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(m_jbtndate, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jBtnCreateCardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnCreateCardActionPerformed + if (JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.cardnew"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { + jcard.setText("c" + StringUtils.getCardNumber()); + m_Dirty.setDirty(true); + } + }//GEN-LAST:event_jBtnCreateCardActionPerformed + + private void jBtnClearCardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnClearCardActionPerformed + if (JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.cardremove"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { + jcard.setText(null); + m_Dirty.setDirty(true); + } + }//GEN-LAST:event_jBtnClearCardActionPerformed + + private void webBtnMailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_webBtnMailActionPerformed + + if(!"".equals(txtEmail.getText())) { + Desktop desktop; + + if (Desktop.isDesktopSupported() + && (desktop = Desktop.getDesktop()).isSupported(Desktop.Action.MAIL)) { + URI mailto = null; + try { + mailto = new URI("mailto:" + + txtEmail.getText()); + } catch (URISyntaxException ex) { + log.error(ex.getMessage()); + } + try { + desktop.mail(mailto); + } catch (IOException ex) { + log.error(ex.getMessage()); + } + } else { + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.email"), + "Email", JOptionPane.INFORMATION_MESSAGE); + } + } + + }//GEN-LAST:event_webBtnMailActionPerformed + + private void jBtnShowTransActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnShowTransActionPerformed + String cId = m_oId.toString(); + if (cId != null) { + transactionModel = new TransactionTableModel(getTransactionOfName(cId)); + jTableCustomerTransactions.setModel(transactionModel); + if (transactionModel.getRowCount()> 0){ + jTableCustomerTransactions.setVisible(true); + String TranCount = String.valueOf(transactionModel.getRowCount()); + jLblTranCount.setText(TranCount + " for " + m_jName.getText()); + }else{ + jTableCustomerTransactions.setVisible(false); + JOptionPane.showMessageDialog(null, "No Transactions for this Customer", "Transactions", JOptionPane.INFORMATION_MESSAGE); + } + resetTranxTable(); + } + }//GEN-LAST:event_jBtnShowTransActionPerformed + + private void m_jVipnone(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_m_jVipnone + + }//GEN-LAST:event_m_jVipnone + + private void m_jVipActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jVipActionPerformed + +// AbstractButton abstractButton = (AbstractButton)evt.getSource(); +// boolean selected = abstractButton.getModel().isSelected(); +// jLblDiscountpercent.setVisible(selected); +// txtDiscount.setVisible(selected); +// jLblDiscount.setVisible(selected); + + }//GEN-LAST:event_m_jVipActionPerformed + + private void m_jbtndateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtndateActionPerformed + + Date date; + try { + date = (Date) Formats.TIMESTAMP.parseValue(m_jdate.getText()); + } catch (BasicException e) { + date = null; + } + date = JCalendarDialog.showCalendarTime(this, date); + if (date != null) { + m_jdate.setText(Formats.TIMESTAMP.formatValue(date)); + } + }//GEN-LAST:event_m_jbtndateActionPerformed + + private void jLabel7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel7MouseClicked + + if (evt.getClickCount() == 2) { + String uuidString = m_oId.toString(); + StringSelection stringSelection = new StringSelection(uuidString); + Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); + clpbrd.setContents(stringSelection, null); + + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.uuidcopy")); + } + }//GEN-LAST:event_jLabel7MouseClicked + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jBtnClearCard; + private javax.swing.JButton jBtnCreateCard; + private javax.swing.JButton jBtnShowTrans; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel15; + private javax.swing.JLabel jLabel16; + private javax.swing.JLabel jLabel17; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel19; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel20; + private javax.swing.JLabel jLabel21; + private javax.swing.JLabel jLabel22; + private javax.swing.JLabel jLabel23; + private javax.swing.JLabel jLabel24; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel34; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JLabel jLblDiscount; + private javax.swing.JLabel jLblDiscountpercent; + private javax.swing.JLabel jLblTranCount; + private javax.swing.JLabel jLblVIP; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane3; + private javax.swing.JTabbedPane jTabbedPane1; + private javax.swing.JTable jTableCustomerTransactions; + private javax.swing.JTextField jcard; + private javax.swing.JComboBox m_jCategory; + private com.unicenta.data.gui.JImageEditor m_jImage; + private javax.swing.JTextField m_jName; + private javax.swing.JTextArea m_jNotes; + private javax.swing.JTextField m_jSearchkey; + private javax.swing.JTextField m_jTaxID; + private javax.swing.JCheckBox m_jVip; + private javax.swing.JCheckBox m_jVisible; + private javax.swing.JButton m_jbtndate; + private javax.swing.JTextField m_jdate; + private javax.swing.JTextField txtAddress; + private javax.swing.JTextField txtAddress2; + private javax.swing.JTextField txtCity; + private javax.swing.JTextField txtCountry; + private javax.swing.JTextField txtCurdate; + private javax.swing.JTextField txtCurdebt; + private javax.swing.JTextField txtDiscount; + private javax.swing.JTextField txtEmail; + private javax.swing.JTextField txtFax; + private javax.swing.JTextField txtFirstName; + private javax.swing.JTextField txtLastName; + private javax.swing.JTextField txtMaxdebt; + private javax.swing.JTextField txtPhone; + private javax.swing.JTextField txtPhone2; + private javax.swing.JTextField txtPostal; + private javax.swing.JTextField txtRegion; + private com.alee.laf.button.WebButton webBtnMail; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/customers/DataLogicCustomers.java b/src/main/java/com/unicenta/pos/customers/DataLogicCustomers.java new file mode 100644 index 0000000..4d473d9 --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/DataLogicCustomers.java @@ -0,0 +1,381 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.customers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.*; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.BeanFactoryDataSingle; +import com.unicenta.pos.voucher.VoucherInfo; + +/** + * @author JG uniCenta + * @author adrianromero + */ +public class DataLogicCustomers extends BeanFactoryDataSingle { + + /** + * Main Method for customer object + */ + protected Session s; + private TableDefinition tcustomers; + private static final Datas[] customerdatas = new Datas[] { + Datas.STRING, + Datas.TIMESTAMP, + Datas.TIMESTAMP, + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.INT, + Datas.BOOLEAN, + Datas.STRING}; + + /** + * + * @param s + */ + @Override + public void init(Session s){ +// JG 03 Oct - Added Customer Image + this.s = s; + tcustomers = new TableDefinition(s + , "customers" + , new String[] { + "ID", + "SEARCHKEY", + "TAXID", + "NAME", + "TAXCATEGORY", + "CARD", + "MAXDEBT", + "ADDRESS", + "ADDRESS2", + "POSTAL", + "CITY", + "REGION", + "COUNTRY", + "FIRSTNAME", + "LASTNAME", + "EMAIL", + "PHONE", + "PHONE2", + "FAX", + "NOTES", + "VISIBLE", + "CURDATE", + "CURDEBT", + "IMAGE", + "ISVIP", + "DISCOUNT", + "MEMODATE" + } + , new String[] { + "ID", + AppLocal.getIntString("label.searchkey"), + AppLocal.getIntString("label.taxid"), + AppLocal.getIntString("label.name"), + "TAXCATEGORY", + "CARD", + AppLocal.getIntString("label.maxdebt"), + AppLocal.getIntString("label.address"), + AppLocal.getIntString("label.address2"), + AppLocal.getIntString("label.postal"), + AppLocal.getIntString("label.city"), + AppLocal.getIntString("label.region"), + AppLocal.getIntString("label.country"), + AppLocal.getIntString("label.firstname"), + AppLocal.getIntString("label.lastname"), + AppLocal.getIntString("label.email"), + AppLocal.getIntString("label.phone"), + AppLocal.getIntString("label.phone2"), + AppLocal.getIntString("label.fax"), + AppLocal.getIntString("label.notes"), + "VISIBLE", + AppLocal.getIntString("label.curdate"), + AppLocal.getIntString("label.curdebt"), + "IMAGE", + "ISVIP", + "DISCOUNT", + "MEMODATE" + } + , new Datas[] { + Datas.STRING, //id + Datas.STRING, //searchkey + Datas.STRING, //taxid + Datas.STRING, //name + Datas.STRING, //taxcat + Datas.STRING, //card + Datas.DOUBLE, //maxdebt + Datas.STRING, //add + Datas.STRING, //add2 + Datas.STRING, //postal + Datas.STRING, //city + Datas.STRING, //region + Datas.STRING, //cntry + Datas.STRING, //fname + Datas.STRING, //lname + Datas.STRING, //email + Datas.STRING, //phone + Datas.STRING, //phone2 + Datas.STRING, //fax + Datas.STRING, //notes + Datas.BOOLEAN, //visible + Datas.TIMESTAMP, //curdate + Datas.DOUBLE, //curdebt + Datas.IMAGE, //image + Datas.BOOLEAN, //isvip + Datas.DOUBLE, //discount + Datas.TIMESTAMP //memodate + } + , new Formats[] { + Formats.STRING, //id + Formats.STRING, //searchkey + Formats.STRING, //taxid + Formats.STRING, //name + Formats.STRING, //taxcat + Formats.STRING, //card + Formats.CURRENCY, //maxdebt + Formats.STRING, //add + Formats.STRING, //add2 + Formats.STRING, //postal + Formats.STRING, //city + Formats.STRING, //region + Formats.STRING, //cntry + Formats.STRING, //fname + Formats.STRING, //lname + Formats.STRING, //email + Formats.STRING, //phone + Formats.STRING, //phone2 + Formats.STRING, //fax + Formats.STRING, //notes + Formats.BOOLEAN, //visible + Formats.TIMESTAMP, //curdate + Formats.CURRENCY, //curdebt + Formats.NULL, //image + Formats.BOOLEAN, //isvip + Formats.DOUBLE, //discount + Formats.TIMESTAMP //memodate + } + , new int[] {0} + ); + } + + /** + * called from Find Customer + * @return customer data + */ + public SentenceList getCustomerList() { + return new StaticSentence(s + , new QBFBuilder("SELECT " + + "ID, TAXID, SEARCHKEY, NAME, " + + "POSTAL, EMAIL, PHONE, IMAGE " + + "FROM customers " + + "WHERE VISIBLE = " + s.DB.TRUE() + " AND ?(QBF_FILTER) ORDER BY NAME" + , new String[] {"TAXID", "SEARCHKEY", "NAME", "POSTAL", "PHONE", "EMAIL"}) + , new SerializerWriteBasic(new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING}) + , (DataRead dr) -> { + CustomerInfo c = new CustomerInfo(dr.getString(1)); + c.setTaxid(dr.getString(2)); + c.setSearchkey(dr.getString(3)); + c.setName(dr.getString(4)); + c.setPcode(dr.getString(5)); + c.setPhone1(dr.getString(6)); + c.setCemail(dr.getString(7)); + c.setImage(ImageUtils.readImage(dr.getBytes(8))); +// c.setCurDebt(dr.getDouble(9)); + + return c; + }); + } + + public final CustomerInfo getCustomerInfo(String id) throws BasicException { + return (CustomerInfo) new PreparedSentence(s + ,"SELECT " + + "ID, TAXID, SEARCHKEY, NAME, POSTAL " + + "FROM customers WHERE VISIBLE = " + s.DB.TRUE() + " " + + "AND ID = ?" + , SerializerWriteString.INSTANCE , (DataRead dr) -> { + CustomerInfo c = new CustomerInfo(dr.getString(1)); + c.setTaxid(dr.getString(2)); + c.setSearchkey(dr.getString(3)); + c.setName(dr.getString(4)); + c.setPcode(dr.getString(5)); +// c.setisVip(dr.getBoolean(6)); +// c.setDiscount(dr.getDouble(7)); + return c; + }).find(id); + } + + /** + * + * @param customer + * @return + * @throws BasicException + */ + public int updateCustomerExt(final CustomerInfoExt customer) throws BasicException { + + return new PreparedSentence(s + , "UPDATE customers SET NOTES = ? WHERE ID = ?" + , SerializerWriteParams.INSTANCE + ).exec(new DataParams() {@Override + public void writeValues() throws BasicException { + setString(1, customer.getNotes()); + setString(2, customer.getId()); + }}); + } + + /** + * + * @return customer's existing reservation (restaurant mode) + */ + public final SentenceList getReservationsList() { + return new PreparedSentence(s + , "SELECT R.ID, R.CREATED, R.DATENEW, C.CUSTOMER, customers.TAXID, customers.SEARCHKEY, COALESCE(customers.NAME, R.TITLE), R.CHAIRS, R.ISDONE, R.DESCRIPTION " + + "FROM reservations R LEFT OUTER JOIN reservation_customers C ON R.ID = C.ID LEFT OUTER JOIN customers ON C.CUSTOMER = customers.ID " + + "WHERE R.DATENEW >= ? AND R.DATENEW < ?" + , new SerializerWriteBasic(new Datas[] {Datas.TIMESTAMP, Datas.TIMESTAMP}) + , new SerializerReadBasic(customerdatas)); + } + + /** + * + * @return create/update customer reservation (restaurant mode) + */ + public final SentenceExec getReservationsUpdate() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + + new PreparedSentence(s + , "DELETE FROM reservation_customers WHERE ID = ?" + , new SerializerWriteBasicExt(customerdatas, new int[]{0})).exec(params); + if (((Object[]) params)[3] != null) { + new PreparedSentence(s + , "INSERT INTO reservation_customers (ID, CUSTOMER) VALUES (?, ?)" + , new SerializerWriteBasicExt(customerdatas, new int[]{0, 3})).exec(params); + } + return new PreparedSentence(s + , "UPDATE reservations SET ID = ?, CREATED = ?, DATENEW = ?, TITLE = ?, CHAIRS = ?, ISDONE = ?, DESCRIPTION = ? WHERE ID = ?" + , new SerializerWriteBasicExt(customerdatas, new int[]{0, 1, 2, 6, 7, 8, 9, 0})).exec(params); + } + }; + } + + /** + * + * @return delete customer reservation (restaurant mode) + */ + public final SentenceExec getReservationsDelete() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + + new PreparedSentence(s + , "DELETE FROM reservation_customers WHERE ID = ?" + , new SerializerWriteBasicExt(customerdatas, new int[]{0})).exec(params); + return new PreparedSentence(s + , "DELETE FROM reservations WHERE ID = ?" + , new SerializerWriteBasicExt(customerdatas, new int[]{0})).exec(params); + } + }; + } + + /** + * + * @return insert a new customer reservation (restaurant mode) + */ + public final SentenceExec getReservationsInsert() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + + int i = new PreparedSentence(s + , "INSERT INTO reservations (ID, CREATED, DATENEW, TITLE, CHAIRS, ISDONE, DESCRIPTION) VALUES (?, ?, ?, ?, ?, ?, ?)" + , new SerializerWriteBasicExt(customerdatas, new int[]{0, 1, 2, 6, 7, 8, 9})).exec(params); + + if (((Object[]) params)[3] != null) { + new PreparedSentence(s + , "INSERT INTO reservation_customers (ID, CUSTOMER) VALUES (?, ?)" + , new SerializerWriteBasicExt(customerdatas, new int[]{0, 3})).exec(params); + } + return i; + } + }; + } + + /** + * + * @return customer table + */ + public final TableDefinition getTableCustomers() { + return tcustomers; + } + + public final PreparedSentence getVoucherNumber() { + return new PreparedSentence(s, + "SELECT SUBSTRING(MAX(VOUCHER_NUMBER),10,3) AS LAST_NUMBER FROM vouchers " + + "WHERE SUBSTRING(VOUCHER_NUMBER,1,8) = ?" + , SerializerWriteString.INSTANCE + , (DataRead dr) -> dr.getString(1)); + } + + +/* public final VoucherInfo getVoucherInfo(String id) throws BasicException { + return (VoucherInfo) new PreparedSentence(s + , "SELECT vouchers.ID, VOUCHER_NUMBER, CUSTOMER, " + + "customers.NAME, AMOUNT, STATUS " + + "FROM vouchers " + + "JOIN customers ON customers.id = vouchers.CUSTOMER " + + "WHERE STATUS='A' AND vouchers.ID=?" +// "WHERE STATUS='A' " + , SerializerWriteString.INSTANCE + , VoucherInfo.getSerializerRead()).find(id); + } +*/ + + public final VoucherInfo getVoucherInfo(String id) throws BasicException { + return (VoucherInfo) new PreparedSentence(s + , "SELECT vouchers.ID, VOUCHER_NUMBER, CUSTOMER, AMOUNT, STATUS " + + "FROM vouchers " + + "WHERE STATUS='A' AND vouchers.ID=?" + , SerializerWriteString.INSTANCE + , VoucherInfo.getSerializerRead()).find(id); + } + + public final VoucherInfo getVoucherInfoAll(String id) throws BasicException { + return (VoucherInfo) new PreparedSentence(s + , "SELECT vouchers.ID, VOUCHER_NUMBER, CUSTOMER, " + + "customers.NAME, AMOUNT, STATUS " + + "FROM vouchers " + + "JOIN customers ON customers.id = vouchers.CUSTOMER " + + "WHERE vouchers.ID=?" + , SerializerWriteString.INSTANCE + , VoucherInfo.getSerializerRead()).find(id); + } + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/customers/JCustomerFinder.form b/src/main/java/com/unicenta/pos/customers/JCustomerFinder.form new file mode 100644 index 0000000..3e33c67 --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/JCustomerFinder.form @@ -0,0 +1,551 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="form.customertitle" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Default Cursor"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[750, 600]"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,122,0,0,2,-10"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Default Cursor"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JCustomerFinder_m_jKeys"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jPanel8"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Last"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jcmdCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.Cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jcmdOK"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[103, 44]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[103, 44]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Component class="com.unicenta.data.gui.JImageViewerCustomer" name="jImageViewerCustomer"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="First"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel7"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblName" min="-2" max="-2" attributes="0"/> + <Component id="jLblSearchKey" min="-2" max="-2" attributes="0"/> + <Component id="jLblPostal" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jtxtSearchKey" min="-2" max="-2" attributes="0"/> + <Component id="m_jtxtPostal" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="m_jtxtName" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLblTaxID" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jtxtTaxID" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="1" max="-2" attributes="0"> + <Component id="jLblEmail" max="-2" attributes="0"/> + <Component id="jLblPhone" alignment="0" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jtxtPhone" min="-2" max="-2" attributes="0"/> + <Component id="m_jtxtName2" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jtxtTaxID" min="-2" max="-2" attributes="0"/> + <Component id="jLblTaxID" alignment="1" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jtxtSearchKey" min="-2" max="-2" attributes="0"/> + <Component id="jLblSearchKey" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblPostal" min="-2" max="-2" attributes="0"/> + <Component id="m_jtxtPostal" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jtxtName" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jLblName" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jtxtPhone" min="-2" max="-2" attributes="0"/> + <Component id="jLblPhone" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblEmail" min="-2" max="-2" attributes="0"/> + <Component id="m_jtxtName2" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLblTaxID"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.taxid" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtTaxID"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblSearchKey"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.searchkey" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtSearchKey"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblPostal"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Postal"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JCustomerFinder_jLblPostal"/> + </AuxValues> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtPostal"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JCustomerFinder_m_jtxtPostal"/> + </AuxValues> + </Component> + <Component class="javax.swing.JLabel" name="jLblName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleName" type="java.lang.String" value=""/> + </AccessibilityProperties> + </Component> + <Component class="javax.swing.JLabel" name="jLblPhone"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.companytelephone" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblEmail"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.companyemail" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtPhone"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtName2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 140]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 147]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="jListCustomers"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jListCustomersMouseClicked"/> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="jListCustomersValueChanged"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel6"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="First"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jbtnReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.reset" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Clear Filter"/> + <Property name="actionCommand" type="java.lang.String" value="Reset "/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" value=""/> + </AccessibilityProperties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnResetActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jbtnExecute"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.executefilter" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Execute Filter"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" value=""/> + </AccessibilityProperties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnExecuteActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/customers/JCustomerFinder.java b/src/main/java/com/unicenta/pos/customers/JCustomerFinder.java new file mode 100644 index 0000000..9ebb65c --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/JCustomerFinder.java @@ -0,0 +1,699 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.customers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.user.EditorCreator; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import java.awt.*; +import java.util.ArrayList; +import javax.swing.JFrame; +import javax.swing.*; + +import java.awt.event.KeyEvent; //Jack + +/** + * + * @author adrianromero + */ +public class JCustomerFinder extends javax.swing.JDialog implements EditorCreator { + + private CustomerInfo m_ReturnCustomer; + private ListProvider lpr; + private AppView appView; + + public class Global { +// public static String s = "(new SearchKey)"; +// public static String n = m_jtxtName; + + } + + /* Keyboard Events + */ + + public void searchKey() { + jbtnExecute.setMnemonic(KeyEvent.VK_E); // Jack + executeSearch(); + + + } + + public void resetKey() { + jbtnReset.setMnemonic(KeyEvent.VK_R); // Jack + m_jtxtTaxID.reset(); + m_jtxtSearchKey.reset(); + m_jtxtName.reset(); + m_jtxtPostal.reset(); + m_jtxtPhone.reset(); + m_jtxtName2.reset(); + + m_jtxtTaxID.activate(); + + cleanSearch(); + + } + + public void setAppView(AppView appView) { + this.appView = appView; + } + + /** Creates new form JCustomerFinder */ + private JCustomerFinder(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + + /** + * Creates new form JCustomerFinder + */ + private JCustomerFinder(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + /** + * + * @param parent + * @param dlCustomers + * @return + */ + public static JCustomerFinder getCustomerFinder(Component parent, DataLogicCustomers dlCustomers) { + Window window = getWindow(parent); + + JCustomerFinder myMsg; + if (window instanceof Frame) { + myMsg = new JCustomerFinder((Frame) window, true); + } else { + myMsg = new JCustomerFinder((Dialog) window, true); + } + myMsg.init(dlCustomers); + myMsg.applyComponentOrientation(parent.getComponentOrientation()); + + return myMsg; + } + + /** + * + * @return + */ + public CustomerInfo getSelectedCustomer() { + return m_ReturnCustomer; + } + + private void init(DataLogicCustomers dlCustomers) { + + initComponents(); + + jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); + + m_jtxtTaxID.addEditorKeys(m_jKeys); + m_jtxtSearchKey.addEditorKeys(m_jKeys); + m_jtxtName.addEditorKeys(m_jKeys); + m_jtxtPostal.addEditorKeys(m_jKeys); + m_jtxtPhone.addEditorKeys(m_jKeys); + m_jtxtName2.addEditorKeys(m_jKeys); + + m_jtxtTaxID.reset(); + m_jtxtSearchKey.reset(); + m_jtxtName.reset(); + m_jtxtPostal.reset(); + m_jtxtPhone.reset(); + m_jtxtName2.reset(); + + m_jtxtTaxID.activate(); + + lpr = new ListProviderCreator(dlCustomers.getCustomerList(), this); + + jListCustomers.setCellRenderer(new CustomerRenderer()); + + getRootPane().setDefaultButton(jcmdOK); + + m_ReturnCustomer = null; + m_jKeys.setCustomerFinder(this); + + } + + /** + * + * @param customer + */ + public void search(CustomerInfo customer) { + + if (customer == null || customer.getName() == null || customer.getName().equals("")) { + + m_jtxtTaxID.reset(); + m_jtxtSearchKey.reset(); + m_jtxtName.reset(); + m_jtxtPostal.reset(); + m_jtxtPhone.reset(); + m_jtxtName2.reset(); + + m_jtxtTaxID.activate(); + + cleanSearch(); + } else { + + m_jtxtTaxID.setText(customer.getTaxid()); + m_jtxtSearchKey.setText(customer.getSearchkey()); + m_jtxtName.setText(customer.getName()); + m_jtxtPostal.setText(customer.getPcode()); + m_jtxtPhone.setText(customer.getPhone1()); + m_jtxtName2.setText(customer.getCemail()); + + m_jtxtTaxID.activate(); + + executeSearch(); + } + } + + private void cleanSearch() { + m_jtxtTaxID.setText(""); + m_jtxtSearchKey.setText(""); + m_jtxtName.setText(""); + m_jtxtPostal.setText(""); + m_jtxtPhone.setText(""); + m_jtxtName2.setText(""); + + jListCustomers.setModel(new MyListData(new ArrayList())); + } + + /** + * This method actions the customer data search + */ + public void executeSearch() { + + try { + jListCustomers.setModel(new MyListData(lpr.loadData())); + if (jListCustomers.getModel().getSize() > 0) { + jListCustomers.setSelectedIndex(0); + } else { + if(!m_jtxtName.getText().equals("")) { + + int n = JOptionPane.showConfirmDialog( + null, + AppLocal.getIntString("message.customernotfound"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION); + + if (n != 1) { + CustomerInfoGlobal customerInfoGlobal = CustomerInfoGlobal.getInstance(); + CustomerInfoExt customerInfoExt = customerInfoGlobal.getCustomerInfoExt(); + this.setVisible(false); + appView.getAppUserView().showTask("com.unicenta.pos.customers.CustomersPanel"); + JOptionPane.showMessageDialog(null, + "You must complete Account and Search Key Then Save to add to Ticket", + "Create Customer",JOptionPane.OK_OPTION); + } + } + } + } catch (BasicException e) { + } + } + + /** + * + * @return creates object for search method + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] afilter = new Object[12]; + + // TaxID + if (m_jtxtTaxID.getText() == null || m_jtxtTaxID.getText().equals("")) { + afilter[0] = QBFCompareEnum.COMP_NONE; + afilter[1] = null; + } else { + afilter[0] = QBFCompareEnum.COMP_RE; + afilter[1] = "%" + m_jtxtTaxID.getText() + "%"; + } + + // SearchKey + if (m_jtxtSearchKey.getText() == null || m_jtxtSearchKey.getText().equals("")) { + afilter[2] = QBFCompareEnum.COMP_NONE; + afilter[3] = null; + } else { + afilter[2] = QBFCompareEnum.COMP_RE; + afilter[3] = "%" + m_jtxtSearchKey.getText() + "%"; + } + + // Name + if (m_jtxtName.getText() == null || m_jtxtName.getText().equals("")) { + afilter[4] = QBFCompareEnum.COMP_NONE; + afilter[5] = null; + } else { + afilter[4] = QBFCompareEnum.COMP_RE; + afilter[5] = "%" + m_jtxtName.getText() + "%"; + } + +// Added JG 20 Sept 12 + // Postal + if (m_jtxtPostal.getText() == null || m_jtxtPostal.getText().equals("")) { + afilter[6] = QBFCompareEnum.COMP_NONE; + afilter[7] = null; + } else { + afilter[6] = QBFCompareEnum.COMP_RE; + afilter[7] = "%" + m_jtxtPostal.getText() + "%"; + } + +// Added JG 20 Sept 12 + // Phone + if (m_jtxtPhone.getText() == null || m_jtxtPhone.getText().equals("")) { + afilter[8] = QBFCompareEnum.COMP_NONE; + afilter[9] = null; + } else { + afilter[8] = QBFCompareEnum.COMP_RE; + afilter[9] = "%" + m_jtxtPhone.getText() + "%"; + } + +// Added JG 20 Sept 12 + // Email + if (m_jtxtName2.getText() == null || m_jtxtName2.getText().equals("")) { + afilter[10] = QBFCompareEnum.COMP_NONE; + afilter[11] = null; + } else { + afilter[10] = QBFCompareEnum.COMP_RE; + afilter[11] = "%" + m_jtxtName2.getText() + "%"; + } + + return afilter; + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window) parent; + } else { + return getWindow(parent.getParent()); + } + } + + private static class MyListData extends javax.swing.AbstractListModel { + + private final java.util.List m_data; + + public MyListData(java.util.List data) { + m_data = data; + } + + @Override + public Object getElementAt(int index) { + return m_data.get(index); + } + + @Override + public int getSize() { + return m_data.size(); + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel2 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel8 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jcmdCancel = new javax.swing.JButton(); + jcmdOK = new javax.swing.JButton(); + jImageViewerCustomer = new com.unicenta.data.gui.JImageViewerCustomer(); + jPanel3 = new javax.swing.JPanel(); + jPanel5 = new javax.swing.JPanel(); + jPanel7 = new javax.swing.JPanel(); + jLblTaxID = new javax.swing.JLabel(); + m_jtxtTaxID = new com.unicenta.editor.JEditorString(); + jLblSearchKey = new javax.swing.JLabel(); + m_jtxtSearchKey = new com.unicenta.editor.JEditorString(); + jLblPostal = new javax.swing.JLabel(); + m_jtxtPostal = new com.unicenta.editor.JEditorString(); + jLblName = new javax.swing.JLabel(); + m_jtxtName = new com.unicenta.editor.JEditorString(); + jLblPhone = new javax.swing.JLabel(); + jLblEmail = new javax.swing.JLabel(); + m_jtxtPhone = new com.unicenta.editor.JEditorString(); + m_jtxtName2 = new com.unicenta.editor.JEditorString(); + jPanel4 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jListCustomers = new javax.swing.JList(); + jPanel6 = new javax.swing.JPanel(); + jbtnReset = new javax.swing.JButton(); + jbtnExecute = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("form.customertitle")); // NOI18N + setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + setPreferredSize(new java.awt.Dimension(750, 600)); + + jPanel2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jPanel2.setLayout(new java.awt.BorderLayout()); + jPanel2.add(m_jKeys, java.awt.BorderLayout.NORTH); + + jPanel8.setLayout(new java.awt.BorderLayout()); + + jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setText(AppLocal.getIntString("button.Cancel")); // NOI18N + jcmdCancel.setFocusPainted(false); + jcmdCancel.setFocusable(false); + jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdCancel.setRequestFocusEnabled(false); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel1.add(jcmdCancel); + + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + jcmdOK.setEnabled(false); + jcmdOK.setFocusPainted(false); + jcmdOK.setFocusable(false); + jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdOK.setMaximumSize(new java.awt.Dimension(103, 44)); + jcmdOK.setMinimumSize(new java.awt.Dimension(103, 44)); + jcmdOK.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdOK.setRequestFocusEnabled(false); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel1.add(jcmdOK); + + jPanel8.add(jPanel1, java.awt.BorderLayout.LINE_END); + + jPanel2.add(jPanel8, java.awt.BorderLayout.PAGE_END); + jPanel2.add(jImageViewerCustomer, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel2, java.awt.BorderLayout.LINE_END); + + jPanel3.setPreferredSize(new java.awt.Dimension(450, 0)); + jPanel3.setLayout(new java.awt.BorderLayout()); + + jPanel5.setLayout(new java.awt.BorderLayout()); + + jLblTaxID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblTaxID.setText(AppLocal.getIntString("label.taxid")); // NOI18N + jLblTaxID.setMaximumSize(new java.awt.Dimension(60, 15)); + jLblTaxID.setMinimumSize(new java.awt.Dimension(60, 15)); + jLblTaxID.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jtxtTaxID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtTaxID.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLblSearchKey.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblSearchKey.setText(AppLocal.getIntString("label.searchkey")); // NOI18N + jLblSearchKey.setMaximumSize(new java.awt.Dimension(60, 15)); + jLblSearchKey.setMinimumSize(new java.awt.Dimension(60, 15)); + jLblSearchKey.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jtxtSearchKey.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtSearchKey.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLblPostal.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblPostal.setText("Postal"); + jLblPostal.setMaximumSize(new java.awt.Dimension(60, 15)); + jLblPostal.setMinimumSize(new java.awt.Dimension(60, 15)); + jLblPostal.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jtxtPostal.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtPostal.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLblName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblName.setText(AppLocal.getIntString("label.prodname")); // NOI18N + jLblName.setMaximumSize(new java.awt.Dimension(60, 15)); + jLblName.setMinimumSize(new java.awt.Dimension(60, 15)); + jLblName.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jtxtName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtName.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLblPhone.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLblPhone.setText(bundle.getString("label.companytelephone")); // NOI18N + jLblPhone.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLblEmail.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblEmail.setText(bundle.getString("label.companyemail")); // NOI18N + jLblEmail.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jtxtPhone.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtPhone.setMinimumSize(new java.awt.Dimension(150, 30)); + m_jtxtPhone.setPreferredSize(new java.awt.Dimension(250, 30)); + + m_jtxtName2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtName2.setMinimumSize(new java.awt.Dimension(150, 30)); + m_jtxtName2.setPreferredSize(new java.awt.Dimension(250, 30)); + + javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); + jPanel7.setLayout(jPanel7Layout); + jPanel7Layout.setHorizontalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblSearchKey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jtxtSearchKey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel7Layout.createSequentialGroup() + .addComponent(jLblTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel7Layout.createSequentialGroup() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jLblEmail, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblPhone, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jtxtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtName2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap()) + ); + jPanel7Layout.setVerticalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jtxtTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblTaxID, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jtxtSearchKey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblSearchKey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLblName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jtxtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtName2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + m_jtxtName.getAccessibleContext().setAccessibleName(""); + + jPanel5.add(jPanel7, java.awt.BorderLayout.CENTER); + + jPanel3.add(jPanel5, java.awt.BorderLayout.PAGE_START); + + jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel4.setPreferredSize(new java.awt.Dimension(450, 140)); + jPanel4.setLayout(new java.awt.BorderLayout()); + + jScrollPane1.setPreferredSize(new java.awt.Dimension(400, 147)); + + jListCustomers.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jListCustomers.setFocusable(false); + jListCustomers.setRequestFocusEnabled(false); + jListCustomers.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jListCustomersMouseClicked(evt); + } + }); + jListCustomers.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + jListCustomersValueChanged(evt); + } + }); + jScrollPane1.setViewportView(jListCustomers); + + jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + jbtnReset.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jbtnReset.setText(bundle.getString("button.reset")); // NOI18N + jbtnReset.setToolTipText("Clear Filter"); + jbtnReset.setActionCommand("Reset "); + jbtnReset.setFocusable(false); + jbtnReset.setPreferredSize(new java.awt.Dimension(110, 45)); + jbtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnResetActionPerformed(evt); + } + }); + jPanel6.add(jbtnReset); + jbtnReset.getAccessibleContext().setAccessibleDescription(""); + + jbtnExecute.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnExecute.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jbtnExecute.setText(AppLocal.getIntString("button.executefilter")); // NOI18N + jbtnExecute.setToolTipText("Execute Filter"); + jbtnExecute.setFocusPainted(false); + jbtnExecute.setPreferredSize(new java.awt.Dimension(110, 45)); + jbtnExecute.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnExecuteActionPerformed(evt); + } + }); + jPanel6.add(jbtnExecute); + jbtnExecute.getAccessibleContext().setAccessibleDescription(""); + + jPanel4.add(jPanel6, java.awt.BorderLayout.PAGE_START); + + jPanel3.add(jPanel4, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER); + + setSize(new java.awt.Dimension(758, 634)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + m_ReturnCustomer = (CustomerInfo) jListCustomers.getSelectedValue(); + dispose(); + + }//GEN-LAST:event_jcmdOKActionPerformed + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_jcmdCancelActionPerformed + + private void jbtnExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnExecuteActionPerformed + + m_ReturnCustomer=null; + executeSearch(); + + }//GEN-LAST:event_jbtnExecuteActionPerformed + + private void jListCustomersValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListCustomersValueChanged + + m_ReturnCustomer = (CustomerInfo) jListCustomers.getSelectedValue(); + + if (m_ReturnCustomer != null) { + m_ReturnCustomer = (CustomerInfo) jListCustomers.getSelectedValue(); + + if (m_ReturnCustomer != null) { + jImageViewerCustomer.setImage(m_ReturnCustomer.getImage()); + } + } + + jcmdOK.setEnabled(jListCustomers.getSelectedValue() != null); + + }//GEN-LAST:event_jListCustomersValueChanged + + private void jListCustomersMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListCustomersMouseClicked + + m_ReturnCustomer = (CustomerInfo) jListCustomers.getSelectedValue(); + + if (m_ReturnCustomer != null) { + m_ReturnCustomer = (CustomerInfo) jListCustomers.getSelectedValue(); + + if (m_ReturnCustomer != null) { + jImageViewerCustomer.setImage(m_ReturnCustomer.getImage()); + } + } + + }//GEN-LAST:event_jListCustomersMouseClicked + +private void jbtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnResetActionPerformed + + m_jtxtTaxID.reset(); + m_jtxtSearchKey.reset(); + m_jtxtName.reset(); + m_jtxtPostal.reset(); + m_jtxtPhone.reset(); + m_jtxtName2.reset(); + + m_jtxtTaxID.activate(); + + cleanSearch(); +}//GEN-LAST:event_jbtnResetActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private com.unicenta.data.gui.JImageViewerCustomer jImageViewerCustomer; + private javax.swing.JLabel jLblEmail; + private javax.swing.JLabel jLblName; + private javax.swing.JLabel jLblPhone; + private javax.swing.JLabel jLblPostal; + private javax.swing.JLabel jLblSearchKey; + private javax.swing.JLabel jLblTaxID; + private javax.swing.JList jListCustomers; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JPanel jPanel7; + private javax.swing.JPanel jPanel8; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton jbtnExecute; + private javax.swing.JButton jbtnReset; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + private com.unicenta.editor.JEditorKeys m_jKeys; + private com.unicenta.editor.JEditorString m_jtxtName; + private com.unicenta.editor.JEditorString m_jtxtName2; + private com.unicenta.editor.JEditorString m_jtxtPhone; + private com.unicenta.editor.JEditorString m_jtxtPostal; + private com.unicenta.editor.JEditorString m_jtxtSearchKey; + private com.unicenta.editor.JEditorString m_jtxtTaxID; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/customers/JDialogNewCustomer.form b/src/main/java/com/unicenta/pos/customers/JDialogNewCustomer.form new file mode 100644 index 0000000..7fd5b30 --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/JDialogNewCustomer.form @@ -0,0 +1,582 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.customer" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[610, 430]"/> + </Property> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-57,0,0,2,-117"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleName" type="java.lang.String" value=""/> + </AccessibilityProperties> + <AuxValues> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,26,0,0,4,11"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblEmail" alignment="0" max="-2" attributes="1"/> + <Component id="jLblTelephone1" alignment="0" max="-2" attributes="1"/> + <Component id="jLblTelephone2" alignment="1" max="-2" attributes="1"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="txtEmail" alignment="0" max="-2" attributes="2"/> + <Component id="txtPhone" max="-2" attributes="2"/> + <Component id="txtPhone2" max="-2" attributes="1"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblFirstName" max="-2" attributes="1"/> + <Component id="jLblLastName" alignment="1" max="-2" attributes="1"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="txtLastName" max="-2" attributes="2"/> + <Component id="txtFirstName" max="-2" attributes="1"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="1" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLblName" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jName" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblCustTaxCat" min="-2" max="-2" attributes="0"/> + <Component id="jLblVIP" alignment="1" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jCategory" alignment="0" min="-2" pref="163" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="m_jVip" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jLblDiscount" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="txtDiscount" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLblDiscountpercent" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="m_jSearchkey" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Component id="jLblSearchkey" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" max="-2" attributes="0"> + <Component id="jLabel1" alignment="0" pref="0" max="32767" attributes="1"/> + <Component id="jLblTaxID" alignment="0" pref="140" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jTaxID" min="-2" max="-2" attributes="0"/> + <Component id="txtMaxdebt" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace min="62" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLblName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLblSearchkey" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jSearchkey" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblTaxID" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jTaxID" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLblCustTaxCat" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCategory" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtMaxdebt" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="0" attributes="0"> + <Component id="jLblVIP" min="-2" max="-2" attributes="0"/> + <Group type="103" alignment="1" groupAlignment="3" attributes="0"> + <Component id="jLblDiscount" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtDiscount" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblDiscountpercent" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Component id="m_jVip" min="-2" pref="25" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="txtFirstName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblFirstName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLblLastName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtLastName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLblEmail" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtEmail" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLblTelephone1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtPhone" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLblTelephone2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtPhone2" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLblName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.namem" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblSearchkey"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.searchkeym" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jSearchkey"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblTaxID"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.taxid" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jTaxID"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="CustomersView_m_jTaxID"/> + </AuxValues> + </Component> + <Component class="javax.swing.JLabel" name="jLblCustTaxCat"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.custtaxcategory" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblVIP"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.vip" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="m_jVip"> + <Properties> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="f3" green="bc" red="0" type="rgb"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[21, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="m_jVipnone"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLblDiscount"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.discount" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[55, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtDiscount"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblDiscountpercent"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="%"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[12, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblFirstName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.firstname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="alignmentX" type="float" value="0.5"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtFirstName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblLastName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.lastname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtLastName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblEmail"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.email" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtEmail"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblTelephone1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.phone" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtPhone"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblTelephone2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.phone2" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtPhone2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.maxdebt" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtMaxdebt"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="2"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jBtnOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="Button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBtnOKActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jBtnCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="Button.Cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBtnCancelActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/customers/JDialogNewCustomer.java b/src/main/java/com/unicenta/pos/customers/JDialogNewCustomer.java new file mode 100644 index 0000000..a580664 --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/JDialogNewCustomer.java @@ -0,0 +1,520 @@ +package com.unicenta.pos.customers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.LocalRes; +import com.unicenta.data.loader.SentenceExec; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Window; +import java.util.List; +import java.util.UUID; +import javax.swing.JFrame; +import javax.swing.JOptionPane; + +public class JDialogNewCustomer extends javax.swing.JDialog { + + private DataLogicCustomers dlCustomer; + private DataLogicSales dlSales; + private ComboBoxValModel m_CategoryModel; + private SentenceList m_sentcat; + private SentenceExec m_sentinsert; + private TableDefinition tcustomers; + private CustomerInfoExt selectedCustomer; + private Object m_oId; + + /** Creates new form quick New Customer + * @param parent */ + protected JDialogNewCustomer(java.awt.Frame parent) { + super(parent, true); + } + + /** Creates new form quick New Customer + * @param parent */ + protected JDialogNewCustomer(java.awt.Dialog parent) { + super(parent, true); + } + + private void init(AppView app) { + + try { + dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + dlCustomer = (DataLogicCustomers) app.getBean("com.unicenta.pos.customers.DataLogicCustomers"); + m_sentcat = dlSales.getTaxCustCategoriesList(); + tcustomers = dlCustomer.getTableCustomers(); + + initComponents(); + + m_CategoryModel = new ComboBoxValModel(); + List a = m_sentcat.list(); + a.add(0, null); + + m_CategoryModel = new ComboBoxValModel(a); + m_jCategory.setModel(m_CategoryModel); + + getRootPane().setDefaultButton(m_jBtnOK); + } catch (BasicException ex) { + } + } + + + public Object createValue() throws BasicException { + Object[] customer = new Object[27]; + customer[0] = m_oId; + customer[1] = m_jSearchkey.getText(); + customer[2] = m_jTaxID.getText(); + customer[3] = m_jName.getText(); + customer[4] = m_CategoryModel.getSelectedKey(); + customer[5] = null; + customer[6] = Formats.CURRENCY.parseValue(txtMaxdebt.getText(), 0.0); + customer[7] = null; + customer[8] = null; + customer[9] = null; + customer[10] = null; + customer[11] = null; + customer[12] = null; + customer[13] = Formats.STRING.parseValue(txtFirstName.getText()); + customer[14] = Formats.STRING.parseValue(txtLastName.getText()); + customer[15] = Formats.STRING.parseValue(txtEmail.getText()); + customer[16] = Formats.STRING.parseValue(txtPhone.getText()); + customer[17] = Formats.STRING.parseValue(txtPhone2.getText()); + customer[18] = null; + customer[19] = null; + customer[20] = true; + customer[21] = null; + customer[22] = 0.0; + customer[23] = null; + customer[24] = m_jVip.isSelected(); + customer[25] = Formats.DOUBLE.parseValue(txtDiscount.getText()); + customer[26] = null; + + return customer; + } + + + private void selectedVip(boolean value){ + m_jVip.setSelected(value); + jLblDiscountpercent.setVisible(value); + txtDiscount.setVisible(value); + + } + + public static JDialogNewCustomer getDialog(Component parent,AppView app) { + + Window window = getWindow(parent); + + JDialogNewCustomer quicknewcustomer; + + if (window instanceof Frame) { + quicknewcustomer = new JDialogNewCustomer((Frame) window); + } else { + quicknewcustomer = new JDialogNewCustomer((Dialog) window); + } + + quicknewcustomer.init(app); + + return quicknewcustomer; + } + + protected static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window)parent; + } else { + return getWindow(parent.getParent()); + } + } + + public CustomerInfoExt getSelectedCustomer() { + return selectedCustomer; + } + + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel3 = new javax.swing.JPanel(); + jLblName = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + jLblSearchkey = new javax.swing.JLabel(); + m_jSearchkey = new javax.swing.JTextField(); + jLblTaxID = new javax.swing.JLabel(); + m_jTaxID = new javax.swing.JTextField(); + jLblCustTaxCat = new javax.swing.JLabel(); + m_jCategory = new javax.swing.JComboBox(); + jLblVIP = new javax.swing.JLabel(); + m_jVip = new javax.swing.JCheckBox(); + jLblDiscount = new javax.swing.JLabel(); + txtDiscount = new javax.swing.JTextField(); + jLblDiscountpercent = new javax.swing.JLabel(); + jLblFirstName = new javax.swing.JLabel(); + txtFirstName = new javax.swing.JTextField(); + jLblLastName = new javax.swing.JLabel(); + txtLastName = new javax.swing.JTextField(); + jLblEmail = new javax.swing.JLabel(); + txtEmail = new javax.swing.JTextField(); + jLblTelephone1 = new javax.swing.JLabel(); + txtPhone = new javax.swing.JTextField(); + jLblTelephone2 = new javax.swing.JLabel(); + txtPhone2 = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + txtMaxdebt = new javax.swing.JTextField(); + jPanel2 = new javax.swing.JPanel(); + m_jBtnOK = new javax.swing.JButton(); + m_jBtnCancel = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("label.customer")); // NOI18N + setPreferredSize(new java.awt.Dimension(610, 430)); + setResizable(false); + + jPanel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + + jLblName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblName.setText(AppLocal.getIntString("label.namem")); // NOI18N + jLblName.setMaximumSize(new java.awt.Dimension(140, 25)); + jLblName.setMinimumSize(new java.awt.Dimension(140, 25)); + jLblName.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(300, 30)); + + jLblSearchkey.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblSearchkey.setText(AppLocal.getIntString("label.searchkeym")); // NOI18N + jLblSearchkey.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jSearchkey.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSearchkey.setHorizontalAlignment(javax.swing.JTextField.LEFT); + m_jSearchkey.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLblTaxID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblTaxID.setText(AppLocal.getIntString("label.taxid")); // NOI18N + jLblTaxID.setMaximumSize(new java.awt.Dimension(150, 30)); + jLblTaxID.setMinimumSize(new java.awt.Dimension(140, 25)); + jLblTaxID.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jTaxID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTaxID.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLblCustTaxCat.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblCustTaxCat.setText(AppLocal.getIntString("label.custtaxcategory")); // NOI18N + jLblCustTaxCat.setMaximumSize(new java.awt.Dimension(140, 25)); + jLblCustTaxCat.setMinimumSize(new java.awt.Dimension(140, 25)); + jLblCustTaxCat.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCategory.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLblVIP.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblVIP.setText(AppLocal.getIntString("label.vip")); // NOI18N + jLblVIP.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jVip.setForeground(new java.awt.Color(0, 188, 243)); + m_jVip.setPreferredSize(new java.awt.Dimension(21, 30)); + m_jVip.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + m_jVipnone(evt); + } + }); + + jLblDiscount.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblDiscount.setText(AppLocal.getIntString("label.discount")); // NOI18N + jLblDiscount.setPreferredSize(new java.awt.Dimension(55, 30)); + + txtDiscount.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtDiscount.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + txtDiscount.setPreferredSize(new java.awt.Dimension(50, 30)); + + jLblDiscountpercent.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblDiscountpercent.setText("%"); + jLblDiscountpercent.setPreferredSize(new java.awt.Dimension(12, 30)); + + jLblFirstName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblFirstName.setText(AppLocal.getIntString("label.firstname")); // NOI18N + jLblFirstName.setAlignmentX(0.5F); + jLblFirstName.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtFirstName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtFirstName.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLblLastName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblLastName.setText(AppLocal.getIntString("label.lastname")); // NOI18N + jLblLastName.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtLastName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtLastName.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLblEmail.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblEmail.setText(AppLocal.getIntString("label.email")); // NOI18N + jLblEmail.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtEmail.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtEmail.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLblTelephone1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblTelephone1.setText(AppLocal.getIntString("label.phone")); // NOI18N + jLblTelephone1.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtPhone.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtPhone.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLblTelephone2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblTelephone2.setText(AppLocal.getIntString("label.phone2")); // NOI18N + jLblTelephone2.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtPhone2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtPhone2.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.maxdebt")); // NOI18N + jLabel1.setMaximumSize(new java.awt.Dimension(140, 25)); + jLabel1.setMinimumSize(new java.awt.Dimension(140, 25)); + jLabel1.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtMaxdebt.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtMaxdebt.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + txtMaxdebt.setPreferredSize(new java.awt.Dimension(100, 30)); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblEmail, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblTelephone1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblTelephone2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtEmail, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPhone, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPhone2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblFirstName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblLastName, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtLastName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtFirstName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup() + .addComponent(jLblName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblCustTaxCat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblVIP, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel3Layout.createSequentialGroup() + .addComponent(m_jVip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLblDiscount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(txtDiscount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLblDiscountpercent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jSearchkey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(jLblSearchkey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE) + .addComponent(jLblTaxID, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtMaxdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblSearchkey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSearchkey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblCustTaxCat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtMaxdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblVIP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblDiscount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtDiscount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblDiscountpercent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(m_jVip, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblTelephone1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblTelephone2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPhone2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + ); + + getContentPane().add(jPanel3, java.awt.BorderLayout.NORTH); + jPanel3.getAccessibleContext().setAccessibleName(""); + + jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + m_jBtnOK.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jBtnOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + m_jBtnOK.setText(AppLocal.getIntString("Button.OK")); // NOI18N + m_jBtnOK.setFocusPainted(false); + m_jBtnOK.setFocusable(false); + m_jBtnOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jBtnOK.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jBtnOK.setRequestFocusEnabled(false); + m_jBtnOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBtnOKActionPerformed(evt); + } + }); + jPanel2.add(m_jBtnOK); + + m_jBtnCancel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jBtnCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + m_jBtnCancel.setText(AppLocal.getIntString("Button.Cancel")); // NOI18N + m_jBtnCancel.setFocusPainted(false); + m_jBtnCancel.setFocusable(false); + m_jBtnCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jBtnCancel.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jBtnCancel.setRequestFocusEnabled(false); + m_jBtnCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBtnCancelActionPerformed(evt); + } + }); + jPanel2.add(m_jBtnCancel); + + getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); + + setSize(new java.awt.Dimension(651, 455)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void m_jBtnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBtnOKActionPerformed + + if ("".equals(m_jSearchkey.getText()) + || "".equals(m_jName.getText())) { + JOptionPane.showMessageDialog( + null, + AppLocal.getIntString("message.customercheck"), + "Customer check", + JOptionPane.ERROR_MESSAGE); + } else { + try { + m_oId = UUID.randomUUID().toString(); + Object customer = createValue(); + + int status = tcustomers.getInsertSentence().exec(customer); + + if (status>0){ + selectedCustomer = dlSales.loadCustomerExt(m_oId.toString()); + dispose(); + } else { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, + LocalRes.getIntString("message.nosave"), "Error save"); + msg.show(this); + } + + } catch (BasicException ex) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, + LocalRes.getIntString("message.nosave"), ex); + msg.show(this); + } + } + }//GEN-LAST:event_m_jBtnOKActionPerformed + + private void m_jBtnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBtnCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_m_jBtnCancelActionPerformed + +private void m_jVipnone(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_m_jVipnone + +}//GEN-LAST:event_m_jVipnone + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLblCustTaxCat; + private javax.swing.JLabel jLblDiscount; + private javax.swing.JLabel jLblDiscountpercent; + private javax.swing.JLabel jLblEmail; + private javax.swing.JLabel jLblFirstName; + private javax.swing.JLabel jLblLastName; + private javax.swing.JLabel jLblName; + private javax.swing.JLabel jLblSearchkey; + private javax.swing.JLabel jLblTaxID; + private javax.swing.JLabel jLblTelephone1; + private javax.swing.JLabel jLblTelephone2; + private javax.swing.JLabel jLblVIP; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JButton m_jBtnCancel; + private javax.swing.JButton m_jBtnOK; + private javax.swing.JComboBox m_jCategory; + private javax.swing.JTextField m_jName; + private javax.swing.JTextField m_jSearchkey; + private javax.swing.JTextField m_jTaxID; + private javax.swing.JCheckBox m_jVip; + private javax.swing.JTextField txtDiscount; + private javax.swing.JTextField txtEmail; + private javax.swing.JTextField txtFirstName; + private javax.swing.JTextField txtLastName; + private javax.swing.JTextField txtMaxdebt; + private javax.swing.JTextField txtPhone; + private javax.swing.JTextField txtPhone2; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/customers/OrderCustomerList.form b/src/main/java/com/unicenta/pos/customers/OrderCustomerList.form new file mode 100644 index 0000000..739a009 --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/OrderCustomerList.form @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[256, 560]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[256, 560]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,88,0,0,1,44"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanelCustomers"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/customers/OrderCustomerList.java b/src/main/java/com/unicenta/pos/customers/OrderCustomerList.java new file mode 100644 index 0000000..22f651a --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/OrderCustomerList.java @@ -0,0 +1,360 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.customers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.pos.catalog.JCatalogTab; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.sales.DataLogicReceipts; +import com.unicenta.pos.sales.SharedTicketInfo; +import com.unicenta.pos.sales.TicketsEditor; +import com.unicenta.pos.ticket.TicketInfo; +import com.unicenta.pos.util.ThumbNailBuilder; +import lombok.extern.slf4j.Slf4j; + +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.event.EventListenerList; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.*; + +/** + * @author JG uniCenta - outline/prep for uniCenta mobile + eCommerce connector + */ +@Slf4j +public class OrderCustomerList extends JPanel implements TicketSelector { + + /** + * Source origin and Ticket + */ + protected AppView application; + private String currentTicket; + + /** + * This instance interface + */ + protected TicketsEditor panelticket; + + /** + * Set listeners for new/change Customer/Receipt events + */ + protected EventListenerList listeners = new EventListenerList(); + private final DataLogicCustomers dataLogicCustomers; + private final DataLogicReceipts dataLogicReceipts; + private final ThumbNailBuilder tnbbutton; + + /** + * Creates new form CustomersList + * + * @param dlCustomers + * @param app + * @param panelticket + */ + public OrderCustomerList(DataLogicCustomers dlCustomers, AppView app, TicketsEditor panelticket) { + this.application = app; + this.panelticket = panelticket; + this.dataLogicCustomers = dlCustomers; + this.dataLogicReceipts = (DataLogicReceipts) application.getBean("com.unicenta.pos.sales.DataLogicReceipts"); + tnbbutton = new ThumbNailBuilder(90, 98); + +// orderSynchroniseHelper = new OrdersSynchroniseHelper(application, dataLogicReceipts, panelticket.getActiveTicket()); + + initComponents(); + } + + /** + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * @throws BasicException + */ + public void reloadCustomers() throws BasicException { +// synchroniseData(); + loadCustomers(); + } + + /** + * @throws BasicException + */ + @Override + public void loadCustomers() throws BasicException { + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + long time = System.currentTimeMillis(); + jPanelCustomers.removeAll(); + + JCatalogTab flowTab = new JCatalogTab(); + jPanelCustomers.add(flowTab); + + List<CustomerInfoExt> customers = null; + List<SharedTicketInfo> ticketList = null; + try { + +// customers = dataLogicCustomers.getCustomers(); + log.info("Time of getCustomersWithOutImage {}", (System.currentTimeMillis() - time)); + time = System.currentTimeMillis(); + + ticketList = dataLogicReceipts.getSharedTicketList(); + log.info("Time of getSharedTicketList {}", (System.currentTimeMillis() - time)); + time = System.currentTimeMillis(); + + + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + HashMap<SharedTicketInfo, CustomerInfoExt> orderMap = new HashMap<>(); + + for (SharedTicketInfo sharedTicketInfo : ticketList) { + + String ticketName = sharedTicketInfo.getName().trim(); + + if (ticketName.contains("[") && ticketName.contains("]")) { + + // found order + if (ticketName.startsWith("[")) { + // order without customer + orderMap.put(sharedTicketInfo, null); + } else if (!customers.isEmpty()) { + // find customer to ticket + for (CustomerInfoExt customer : customers) { + if (customer != null) { + String name = customer.getName().trim(); + if (ticketName.startsWith(name)) { + orderMap.put(sharedTicketInfo, customer); + break; + } + } + } + } + } + } + // sort + CustomerComparator bvc = new CustomerComparator(orderMap); + TreeMap<SharedTicketInfo, CustomerInfoExt> sortedMap = new TreeMap<>(bvc); + sortedMap.putAll(orderMap); + + log.info("Time of orderMap {}", (System.currentTimeMillis() - time)); + time = System.currentTimeMillis(); + + // set button list + for (Map.Entry<SharedTicketInfo, CustomerInfoExt> entry : sortedMap.entrySet()) { + SharedTicketInfo ticket = entry.getKey(); + CustomerInfoExt customer = entry.getValue(); + + String name = ticket.getName(); + BufferedImage image = null; + +// if (customer != null) { +// try { +// image = dataLogicCustomers.getCustomerImage(customer.getId()); +// } catch (BasicException ex) { +// +// } +// } + if (image == null) { + try { + InputStream is = getClass().getResourceAsStream("/com/unicenta/images/no_image.png"); + if (is != null) { + image = ImageIO.read(is); + } + } catch (IOException ex) { + log.error(ex.getMessage()); + } + } + String username; + if (name.indexOf("[") != 0) { + username = name.substring(0, name.indexOf("[") - 1); + username = username.replace("-", ""); + } else { + username = "unknown"; + } + String orderId = name.substring(name.indexOf("["), name.indexOf("]") + 1); + String text = "<html><center>" + username.trim() + "<br/>" + orderId.trim() + "</center></html>"; + + ImageIcon icon = new ImageIcon(tnbbutton.getThumbNailText(image, text)); +// flowTab.addButton(icon, new SelectedCustomerAction(ticket.getId())); + } + log.info("Time of finished loadCustomerOrders {}", (System.currentTimeMillis() - time)); + } + }); + } + + /** + * @param value + */ + @Override + public void setComponentEnabled(boolean value) { + jPanelCustomers.setEnabled(value); + + synchronized (jPanelCustomers.getTreeLock()) { + int compCount = jPanelCustomers.getComponentCount(); + for (int i = 0; i < compCount; i++) { + jPanelCustomers.getComponent(i).setEnabled(value); + } + } + this.setEnabled(value); + } + + /** + * @param l + */ + @Override + public void addActionListener(ActionListener l) { + listeners.add(ActionListener.class, l); + } + + /** + * @param l + */ + @Override + public void removeActionListener(ActionListener l) { + listeners.remove(ActionListener.class, l); + } + + private void setActiveTicket(String id) throws BasicException { + + currentTicket = panelticket.getActiveTicket().getId(); + + // save current ticket +// if (currentTicket != null) { +// try { +// dataLogicReceipts.insertSharedTicket(currentTicket, panelticket.getActiveTicket()); +// } catch (BasicException e) { +// new MessageInf(e).show(this); +// } +// } + // set ticket + // BEGIN TRANSACTION + TicketInfo ticket = dataLogicReceipts.getSharedTicket(id); + if (ticket == null) { + // Does not exists ??? + throw new BasicException(AppLocal.getIntString("message.noticket")); + } else { + dataLogicReceipts.deleteSharedTicket(id); + currentTicket = id; + panelticket.setActiveTicket(ticket, null); + fireTicketSelectionChanged(ticket.getId()); + } + // END TRANSACTION + } + +// private void synchroniseData() { +// try { + // get tickets only from selected customer or show all + // add newest tickets from provider +// orderSynchroniseHelper.synchSharedTickets(panelticket.getActiveTicket()); +// } catch (Exception e) { +// } +// } + + private void fireTicketSelectionChanged(String ticketId) { + EventListener[] l = listeners.getListeners(ActionListener.class); + ActionEvent e = null; + for (EventListener l1 : l) { + if (e == null) { + e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, ticketId); + } + ((ActionListener) l1).actionPerformed(e); + } + } + + private class SelectedCustomerAction implements ActionListener { + + private final String ticketId; + + public SelectedCustomerAction(String ticketId) { + this.ticketId = ticketId; + } + + @Override + public void actionPerformed(ActionEvent e) { + try { + if (ticketId != null) { + setActiveTicket(ticketId); + } + } catch (BasicException ex) { + new MessageInf(ex).show(OrderCustomerList.this); + } + } + } + + class CustomerComparator implements Comparator<SharedTicketInfo> { + + Map<SharedTicketInfo, CustomerInfoExt> base; + + public CustomerComparator(Map<SharedTicketInfo, CustomerInfoExt> base) { + this.base = base; + } + + // Note: this comparator imposes orderings that are inconsistent with equals. + @Override + public int compare(SharedTicketInfo a, SharedTicketInfo b) { + String nameA = base.get(a).getName(); + String nameB = base.get(b).getName(); + + if (nameA.compareToIgnoreCase(nameB) < 0) { + return -1; + } else { + return 1; + } + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanelCustomers = new javax.swing.JPanel(); + + setMinimumSize(new java.awt.Dimension(256, 560)); + setPreferredSize(new java.awt.Dimension(256, 560)); + setLayout(new java.awt.BorderLayout()); + + jPanelCustomers.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanelCustomers.setLayout(new java.awt.CardLayout()); + add(jPanelCustomers, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanelCustomers; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/customers/TicketSelector.java b/src/main/java/com/unicenta/pos/customers/TicketSelector.java new file mode 100644 index 0000000..b4a2f1a --- /dev/null +++ b/src/main/java/com/unicenta/pos/customers/TicketSelector.java @@ -0,0 +1,46 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.customers; + +import com.unicenta.basic.BasicException; +import java.awt.Component; +import java.awt.event.ActionListener; + +/** + * + * @author JG uniCenta - outline/prep for uniCenta mobile + eCommerce connector + */ +public interface TicketSelector { + + /** + * + * @throws BasicException + */ + public void loadCustomers() throws BasicException; + + /** + * + * @param value + */ + public void setComponentEnabled(boolean value); + + /** + * + * @return + */ + public Component getComponent(); + + /** + * + * @param l + */ + public void addActionListener(ActionListener l); + + /** + * + * @param l + */ + public void removeActionListener(ActionListener l); +} diff --git a/src/main/java/com/unicenta/pos/epm/Break.java b/src/main/java/com/unicenta/pos/epm/Break.java new file mode 100644 index 0000000..f07e8d3 --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/Break.java @@ -0,0 +1,110 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.epm; + +/** + * + * @author Ali Safdar and Aneeqa Baber + */ +public class Break { + + private String m_sId; + private String m_sName; + private String m_sNotes; + private boolean m_sVisible; + + /** + * + * @param id + * @param name + * @param notes + * @param visible + */ + public Break(String id, String name, String notes, boolean visible) { + m_sId = id; + m_sName = name; + m_sNotes = notes; + m_sVisible = visible; + } + + /** + * + * @return + */ + public String getId() { + return m_sId; + } + + /** + * + * @param Id + */ + public void setId(String Id) { + this.m_sId = Id; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + + /** + * + * @param Name + */ + public void setName(String Name) { + this.m_sName = Name; + } + + /** + * + * @return + */ + public String getNotes() { + return m_sNotes; + } + + /** + * + * @param Notes + */ + public void setNotes(String Notes) { + this.m_sNotes = Notes; + } + + /** + * + * @return + */ + public boolean isVisible() { + return m_sVisible; + } + + /** + * + * @param Visible + */ + public void setVisible(boolean Visible) { + this.m_sVisible = Visible; + } +} diff --git a/src/main/java/com/unicenta/pos/epm/BreaksInfo.java b/src/main/java/com/unicenta/pos/epm/BreaksInfo.java new file mode 100644 index 0000000..a1873f1 --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/BreaksInfo.java @@ -0,0 +1,89 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.epm; + +import com.unicenta.data.loader.IKeyed; + +/** + * + * @author Ali Safdar and Aneeqa Baber + */ +public class BreaksInfo implements IKeyed { + + private static final long serialVersionUID = 8936482715929L; + private String m_sID; + private String m_sName; + + /** + * + * @param id + * @param name + */ + public BreaksInfo(String id, String name) { + m_sID = id; + m_sName = name; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return m_sID; + } + + /** + * + * @param sID + */ + public void setID(String sID) { + m_sID = sID; + } + + /** + * + * @return + */ + public String getID() { + return m_sID; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + + /** + * + * @param sName + */ + public void setName(String sName) { + m_sName = sName; + } + + @Override + public String toString(){ + return m_sName; + } +} diff --git a/src/main/java/com/unicenta/pos/epm/BreaksPanel.java b/src/main/java/com/unicenta/pos/epm/BreaksPanel.java new file mode 100644 index 0000000..6646807 --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/BreaksPanel.java @@ -0,0 +1,133 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.epm; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +/** + * + * @author Ali Safdar and Aneeqa Baber + */ +public class BreaksPanel extends JPanelTable { + + private TableDefinition tbreaks; + private BreaksView jeditor; + + /** + * + */ + public BreaksPanel() { + } + + /** + * + */ + @Override + protected void init() { + DataLogicPresenceManagement dlPresenceManagement = (DataLogicPresenceManagement) app.getBean("com.unicenta.pos.epm.DataLogicPresenceManagement"); + tbreaks = dlPresenceManagement.getTableBreaks(); + jeditor = new BreaksView(app, dirty); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + jeditor.activate(); + super.activate(); + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return new ListProviderCreator(tbreaks); + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(tbreaks, new int[] {0, 1, 2, 3}); + } + + /** + * + * @return + */ + @Override + public Vectorer getVectorer() { + return tbreaks.getVectorerBasic(new int[]{1, 2}); + } + + /** + * + * @return + */ + @Override + public ComparatorCreator getComparatorCreator() { + return tbreaks.getComparatorCreator(new int[] {1, 2}); + } + + /** + * + * @return + */ + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(tbreaks.getRenderStringBasic(new int[]{1})); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Breaks"); + } +} diff --git a/src/main/java/com/unicenta/pos/epm/BreaksView.form b/src/main/java/com/unicenta/pos/epm/BreaksView.form new file mode 100644 index 0000000..2def88c --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/BreaksView.form @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="jLabel1" alignment="0" pref="126" max="32767" attributes="1"/> + <Component id="m_Name3" alignment="0" pref="126" max="32767" attributes="1"/> + <Component id="m_Ncx" alignment="0" pref="126" max="32767" attributes="1"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="m_jVisible" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="m_jBreakName" alignment="0" max="32767" attributes="1"/> + <Component id="jScrollPane1" alignment="0" min="-2" pref="223" max="-2" attributes="1"/> + </Group> + <EmptySpace min="-2" pref="214" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jBreakName" alignment="3" min="-2" pref="25" max="-2" attributes="0"/> + <Component id="jLabel1" alignment="3" min="-2" pref="25" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="m_Ncx" min="-2" pref="25" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_Name3" min="-2" pref="25" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="m_jVisible" min="-2" pref="25" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jScrollPane1" min="-2" pref="138" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace pref="35" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JTextField" name="m_jBreakName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="m_jBreakDescription"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="lineWrap" type="boolean" value="true"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JCheckBox" name="m_jVisible"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_Ncx"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.epm.visible" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_Name3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.epm.notes" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.epm.employee" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/epm/BreaksView.java b/src/main/java/com/unicenta/pos/epm/BreaksView.java new file mode 100644 index 0000000..ee12d4c --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/BreaksView.java @@ -0,0 +1,239 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.epm; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import java.awt.Component; +import java.util.List; +import java.util.UUID; + +/** + * + * @author Ali Safdar and Aneeqa Baber + */ +public final class BreaksView extends javax.swing.JPanel implements EditorRecord { + + private Object m_oId; + private SentenceList m_sentcat; + private DirtyManager m_Dirty; + + /** Creates new form BreaksView + * @param app + * @param dirty */ + public BreaksView(AppView app, DirtyManager dirty) { + + DataLogicPresenceManagement dlPresenceManagement = (DataLogicPresenceManagement) app.getBean("com.unicenta.pos.epm.DataLogicPresenceManagement"); + initComponents(); + m_sentcat = dlPresenceManagement.getBreaksList(); + m_Dirty = dirty; + m_jBreakName.getDocument().addDocumentListener(dirty); + m_jVisible.addActionListener(dirty); + m_jBreakDescription.getDocument().addDocumentListener(dirty); + writeValueEOF(); + } + + void activate() throws BasicException { + List a = m_sentcat.list(); + a.add(0, null); + } + + /** + * + */ + @Override + public void writeValueEOF() { + m_oId = null; + m_jBreakName.setText(null); + m_jBreakDescription.setText(null); + m_jVisible.setSelected(false); + m_jBreakName.setEditable(false); + m_jBreakDescription.setEnabled(false); + m_jVisible.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + m_oId = null; + m_jBreakName.setText(null); + m_jBreakDescription.setText(null); + m_jVisible.setSelected(true); + m_jBreakName.setEditable(true); + m_jBreakDescription.setEnabled(true); + m_jVisible.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + Object[] breaks = (Object[]) value; + m_oId = breaks[0]; + m_jBreakName.setText((String) breaks[1]); + m_jBreakDescription.setText((String) breaks[2]); + m_jVisible.setSelected(((Boolean) breaks[3]).booleanValue()); + m_jBreakName.setEditable(true); + m_jBreakDescription.setEnabled(true); + m_jVisible.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + Object[] breaks = (Object[]) value; + m_oId = breaks[0]; + m_jBreakName.setText((String) breaks[1]); + m_jBreakDescription.setText((String) breaks[2]); + m_jVisible.setSelected(((Boolean) breaks[3]).booleanValue()); + m_jBreakName.setEditable(false); + m_jBreakDescription.setEnabled(false); + m_jVisible.setEnabled(false); + } + + /** + * + */ + @Override + public void refresh() { + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + Object[] breaks = new Object[4]; + breaks[0] = m_oId == null ? UUID.randomUUID().toString() : m_oId; + breaks[1] = m_jBreakName.getText(); + breaks[2] = m_jBreakDescription.getText(); + breaks[3] = Boolean.valueOf(m_jVisible.isSelected()); + + return breaks; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jBreakName = new javax.swing.JTextField(); + jScrollPane1 = new javax.swing.JScrollPane(); + m_jBreakDescription = new javax.swing.JTextArea(); + m_jVisible = new javax.swing.JCheckBox(); + m_Ncx = new javax.swing.JLabel(); + m_Name3 = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + + m_jBreakName.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + m_jBreakDescription.setColumns(20); + m_jBreakDescription.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jBreakDescription.setLineWrap(true); + m_jBreakDescription.setRows(5); + jScrollPane1.setViewportView(m_jBreakDescription); + + m_jVisible.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + m_Ncx.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_Ncx.setText(AppLocal.getIntString("label.epm.visible")); // NOI18N + + m_Name3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_Name3.setText(AppLocal.getIntString("label.epm.notes")); // NOI18N + + jLabel1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLabel1.setText(bundle.getString("label.epm.employee")); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE) + .addComponent(m_Name3, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE) + .addComponent(m_Ncx, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(m_jVisible) + .addComponent(m_jBreakName) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(214, 214, 214)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jBreakName, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(m_Ncx, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_Name3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(m_jVisible, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(35, Short.MAX_VALUE)) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JLabel m_Name3; + private javax.swing.JLabel m_Ncx; + private javax.swing.JTextArea m_jBreakDescription; + private javax.swing.JTextField m_jBreakName; + private javax.swing.JCheckBox m_jVisible; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/epm/DataLogicPresenceManagement.java b/src/main/java/com/unicenta/pos/epm/DataLogicPresenceManagement.java new file mode 100644 index 0000000..70642a6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/DataLogicPresenceManagement.java @@ -0,0 +1,450 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.epm; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.*; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.BeanFactoryDataSingle; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +/** + * + * @author Ali Safdar and Aneeqa Baber + */ +public class DataLogicPresenceManagement extends BeanFactoryDataSingle { + + /** + * + */ + protected Session s; + + private SentenceExec m_checkin; + private SentenceExec m_checkout; + private SentenceFind m_checkdate; + + private SentenceList m_breaksvisible; + private SentenceExec m_startbreak; + private SentenceExec m_endbreak; + + private SentenceFind m_isonbreak; + private SentenceFind m_isonleave; + private SentenceFind m_shiftid; + + private SentenceFind m_lastcheckin; + private SentenceFind m_lastcheckout; + private SentenceFind m_startbreaktime; + + private SentenceFind m_lastbreakid; + private SentenceFind m_breakname; + + private SerializerRead breakread; + private TableDefinition tbreaks; + private TableDefinition tleaves; + + /** + * + */ + public DataLogicPresenceManagement() { + } + + /** + * + * @param s + */ + @Override + public void init(Session s){ + + this.s = s; + breakread = new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + return new Break( + dr.getString(1), + dr.getString(2), + dr.getString(3), + dr.getBoolean(4)); + } + }; + + tbreaks = new TableDefinition(s + , "breaks" + , new String[] { "ID", "NAME", "NOTES", "VISIBLE"} + , new String[] { "ID", AppLocal.getIntString("label.epm.employee"), AppLocal.getIntString("label.epm.notes"), "VISIBLE"} + , new Datas[] { Datas.STRING, Datas.STRING, Datas.STRING, Datas.BOOLEAN} + , new Formats[] { Formats.STRING, Formats.STRING, Formats.STRING, Formats.BOOLEAN} + , new int[] {0} + ); + + tleaves = new TableDefinition(s + , "leaves" + , new String[] { "ID", "PPLID", "NAME", "STARTDATE", "ENDDATE", "NOTES"} + , new String[] { "ID", AppLocal.getIntString("label.epm.employee.id"), AppLocal.getIntString("label.epm.employee"), AppLocal.getIntString("label.StartDate"), AppLocal.getIntString("label.EndDate"), AppLocal.getIntString("label.notes")} + , new Datas[] { Datas.STRING, Datas.STRING, Datas.STRING, Datas.TIMESTAMP, Datas.TIMESTAMP, Datas.STRING} + , new Formats[] { Formats.STRING, Formats.STRING, Formats.STRING, Formats.TIMESTAMP, Formats.TIMESTAMP, Formats.STRING} + , new int[] {0} + ); + + m_breaksvisible = new StaticSentence(s + , "SELECT ID, NAME, NOTES, VISIBLE FROM breaks WHERE VISIBLE = " + s.DB.TRUE() + , null + , breakread); + + m_checkin = new PreparedSentence(s + , "INSERT INTO shifts(ID, STARTSHIFT, PPLID) VALUES (?, ?, ?)" + , new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.TIMESTAMP, Datas.STRING})); + + m_checkout = new StaticSentence(s + , "UPDATE shifts SET ENDSHIFT = ? WHERE ENDSHIFT IS NULL AND PPLID = ?" + ,new SerializerWriteBasic(new Datas[] {Datas.TIMESTAMP, Datas.STRING})); + + m_checkdate = new StaticSentence(s + , "SELECT COUNT(*) FROM shifts WHERE ENDSHIFT IS NULL AND PPLID = ?" + , SerializerWriteString.INSTANCE + , SerializerReadString.INSTANCE); + + m_startbreak = new PreparedSentence(s + , "INSERT INTO shift_breaks(ID, SHIFTID, BREAKID, STARTTIME) VALUES (?, ?, ?, ?)" + , new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING, Datas.STRING, Datas.TIMESTAMP})); + + m_endbreak = new StaticSentence(s + , "UPDATE shift_breaks SET ENDTIME = ? WHERE ENDTIME IS NULL AND SHIFTID = ?" + ,new SerializerWriteBasic(new Datas[] {Datas.TIMESTAMP, Datas.STRING})); + + m_isonbreak = new StaticSentence(s +// , "SELECT COUNT(*) FROM shift_breaks WHERE ENDTIME IS NULL AND SHIFTID = ?" + , "SELECT COUNT(*) FROM shift_breaks WHERE ENDTIME IS NULL" + , SerializerWriteString.INSTANCE + , SerializerReadString.INSTANCE); + + m_shiftid = new StaticSentence(s + , "SELECT ID FROM shifts WHERE ENDSHIFT IS NULL AND PPLID = ?" + , SerializerWriteString.INSTANCE + , SerializerReadString.INSTANCE); + + m_isonleave = new StaticSentence(s + , "SELECT COUNT(*) FROM leaves WHERE STARTDATE < ? AND ENDDATE > ? AND PPLID = ?" + , new SerializerWriteBasic(new Datas[] {Datas.TIMESTAMP, Datas.TIMESTAMP, Datas.STRING}) + , SerializerReadString.INSTANCE); + + m_lastcheckin = new StaticSentence(s + , "SELECT STARTSHIFT FROM shifts WHERE ENDSHIFT IS NULL AND PPLID = ?" + , SerializerWriteString.INSTANCE + , SerializerReadDate.INSTANCE); + + m_lastcheckout = new StaticSentence(s + , "SELECT MAX(ENDSHIFT) FROM shifts WHERE PPLID = ?" + , SerializerWriteString.INSTANCE + , SerializerReadDate.INSTANCE); + + m_startbreaktime = new StaticSentence(s + , "SELECT STARTTIME FROM shift_breaks WHERE ENDTIME IS NULL AND SHIFTID = ?" + , SerializerWriteString.INSTANCE + , SerializerReadDate.INSTANCE); + + m_lastbreakid = new StaticSentence(s + , "SELECT BREAKID FROM shift_breaks WHERE ENDTIME IS NULL AND SHIFTID = ?" + , SerializerWriteString.INSTANCE + , SerializerReadString.INSTANCE); + + m_breakname = new StaticSentence(s + , "SELECT NAME FROM breaks WHERE ID = ?" + , SerializerWriteString.INSTANCE + , SerializerReadString.INSTANCE); + } + + /** + * + * @return + */ + public final SentenceList getBreaksList() { + return new StaticSentence(s + , "SELECT ID, NAME FROM breaks ORDER BY NAME" + , null + , new SerializerRead() {@Override + public Object readValues(DataRead dr) throws BasicException { + return new BreaksInfo(dr.getString(1), dr.getString(2)); + }}); + } + + /** + * + * @return + */ + public final SentenceList getLeavesList() { + return new StaticSentence(s + , "SELECT ID, PPLID, NAME, STARTDATE, ENDDATE, NOTES FROM leaves ORDER BY NAME" + , null + , new SerializerRead() {@Override + public Object readValues(DataRead dr) throws BasicException { + return new LeavesInfo(dr.getString(1), dr.getString(2), dr.getString(3), dr.getString(4), dr.getString(5), dr.getString(6)); + }}); + } + + /** + * + * @return + * @throws BasicException + */ + public final List listBreaksVisible()throws BasicException { + return m_breaksvisible.list(); + } + + /** + * + * @param user + * @throws BasicException + */ + public final void CheckIn(String user) throws BasicException { + Object[] value = new Object[] {UUID.randomUUID().toString(), new Date(), user}; + m_checkin.exec(value); + } + + /** + * + * @param user + * @throws BasicException + */ + public final void CheckOut(String user) throws BasicException { + Object[] value = new Object[] {new Date(), user}; + m_checkout.exec(value); + } + + /** + * + * @param user + * @return + * @throws BasicException + */ + public final boolean IsCheckedIn(String user) throws BasicException { + String Data = (String) m_checkdate.find(user); + // "0" rows shows user is not checked in + if (Data.equals("0")) { + return false; + } + return true; + } + + /** + * + * @param UserID + * @param BreakID + * @throws BasicException + */ + public final void StartBreak(String UserID, String BreakID) throws BasicException { + String ShiftID = GetShiftID(UserID); + Object[] value = new Object[] {UUID.randomUUID().toString(), ShiftID, BreakID, new Date()}; + m_startbreak.exec(value); + } + + /** + * + * @param UserID + * @throws BasicException + */ + public final void EndBreak(String UserID) throws BasicException { + String ShiftID = GetShiftID(UserID); + Object[] value = new Object[] {new Date(), ShiftID}; + m_endbreak.exec(value); + } + + /** + * + * @param user + * @return + * @throws BasicException + */ + public final boolean IsOnBreak(String user) throws BasicException { + String ShiftID = GetShiftID(user); + String Data = (String) m_isonbreak.find(ShiftID); + // "0" rows shows user is not on break + if (Data.equals("0")) { + return false; + } + return true; + } + + /** + * + * @param user + * @return + * @throws BasicException + */ + public final String GetShiftID(String user) throws BasicException { + return (String) m_shiftid.find(user); + } + + /** + * + * @param user + * @return + * @throws BasicException + */ + public final Date GetLastCheckIn(String user) throws BasicException { + return (Date) m_lastcheckin.find(user); + } + + /** + * + * @param user + * @return + * @throws BasicException + */ + public final Date GetLastCheckOut(String user) throws BasicException { + return (Date) m_lastcheckout.find(user); + } + + /** + * + * @param ShiftID + * @return + * @throws BasicException + */ + public final Date GetStartBreakTime(String ShiftID) throws BasicException { + return (Date) m_startbreaktime.find(ShiftID); + } + + /** + * + * @param ShiftID + * @return + * @throws BasicException + */ + public final String GetLastBreakID(String ShiftID) throws BasicException { + return (String) m_lastbreakid.find(ShiftID); + } + + /** + * + * @param ShiftID + * @return + * @throws BasicException + */ + public final String GetLastBreakName(String ShiftID) throws BasicException { + String BreakID = GetLastBreakID(ShiftID); + return (String) m_breakname.find(BreakID); + } + + /** + * + * @param user + * @return + * @throws BasicException + */ + public final Object [] GetLastBreak(String user) throws BasicException { + String ShiftID = GetShiftID(user); + Date StartBreakTime = GetStartBreakTime(ShiftID); + String BreakName = GetLastBreakName(ShiftID); + return new Object[] {BreakName, StartBreakTime}; + } + + /** + * + * @param user + * @return + * @throws BasicException + */ + public final boolean IsOnLeave(String user) throws BasicException { + Object[] value = new Object[] {new Date(), new Date(), user}; + String Data = (String) m_isonleave.find(value); + // "0" rows shows user is not on leave + if (Data.equals("0")) { + return false; + } + return true; + } + + // EmployeeList list + // Changed ='4' to !='0' --it lists all the users except admin who doesn´t clock in + + /** + * + * @return + */ + public SentenceList getEmployeeList() { + return new StaticSentence(s + , new QBFBuilder("SELECT ID, NAME FROM people WHERE ROLE != '0' AND VISIBLE = " + s.DB.TRUE() + " AND ?(QBF_FILTER) ORDER BY NAME", new String[] {"NAME"}) + , new SerializerWriteBasic(new Datas[] {Datas.OBJECT, Datas.STRING}) + , new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + EmployeeInfo c = new EmployeeInfo(dr.getString(1)); + c.setName(dr.getString(2)); + return c; + } + }); + } + + /** + * + * @param user + * @throws BasicException + */ + public void BlockEmployee(String user) throws BasicException { + boolean isOnBreak = IsOnBreak(user); + if (isOnBreak) { + EndBreak(user); + } + CheckOut(user); + } + + TableDefinition getTableBreaks() { + return tbreaks; + } + + TableDefinition getTableLeaves() { + return tleaves; + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public EmployeeInfoExt loadEmployeeExt(String id) throws BasicException { + return (EmployeeInfoExt) new PreparedSentence(s + , "SELECT ID, NAME FROM people WHERE ID = ?" + , SerializerWriteString.INSTANCE + , new EmployeeExtRead()).find(id); + } + + /** + * + */ + protected static class EmployeeExtRead implements SerializerRead { + + /** + * + * @param dr + * @return + * @throws BasicException + */ + @Override + public Object readValues(DataRead dr) throws BasicException { + EmployeeInfoExt c = new EmployeeInfoExt(dr.getString(1)); + c.setName(dr.getString(2)); + return c; + } + } +} diff --git a/src/main/java/com/unicenta/pos/epm/EmployeeInfo.java b/src/main/java/com/unicenta/pos/epm/EmployeeInfo.java new file mode 100644 index 0000000..f06c6cd --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/EmployeeInfo.java @@ -0,0 +1,87 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.epm; + +import com.unicenta.pos.util.StringUtils; +import java.io.Serializable; + +/** + * + * @author Ali Safdar and Aneeqa Baber + */ +public class EmployeeInfo implements Serializable { + + private static final long serialVersionUID = 9083257536541L; + + /** + * + */ + protected String id; + + /** + * + */ + protected String name; + + /** Creates a new instance of EmployeeInfo + * @param id */ + public EmployeeInfo(String id) { + this.id = id; + this.name = null; + } + + /** + * + * @return + */ + public String getId() { + return id; + } + + /** + * + * @return + */ + public String getName() { + return name; + } + + /** + * + * @param name + */ + public void setName(String name) { + this.name = name; + } + + /** + * + * @return + */ + public String printName() { + return StringUtils.encodeXML(name); + } + + @Override + public String toString() { + return getName(); + } +} + diff --git a/src/main/java/com/unicenta/pos/epm/EmployeeInfoExt.java b/src/main/java/com/unicenta/pos/epm/EmployeeInfoExt.java new file mode 100644 index 0000000..f9ff965 --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/EmployeeInfoExt.java @@ -0,0 +1,54 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.epm; + +/** + * + * @author Ali Safadr and Aneeqa Baber + */ +public class EmployeeInfoExt extends EmployeeInfo { + + /** + * + */ + protected boolean visible; + + /** Creates a new instance of EmployeeInfoExt + * @param id */ + public EmployeeInfoExt(String id) { + super(id); + } + + /** + * + * @return + */ + public boolean isVisible() { + return visible; + } + + /** + * + * @param visible + */ + public void setVisible(boolean visible) { + this.visible = visible; + } +} diff --git a/src/main/java/com/unicenta/pos/epm/EmployeeRenderer.java b/src/main/java/com/unicenta/pos/epm/EmployeeRenderer.java new file mode 100644 index 0000000..08f5823 --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/EmployeeRenderer.java @@ -0,0 +1,48 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.epm; + +import java.awt.Component; +import javax.swing.DefaultListCellRenderer; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JList; + +/** + * + * @author Ali Safdar and Aneeqa Baber + */ +public class EmployeeRenderer extends DefaultListCellRenderer { + + private Icon icoemployee; + + /** Creates a new instance of EmployeeRenderer */ + public EmployeeRenderer() { + icoemployee = new ImageIcon(getClass().getClassLoader().getResource("com/unicenta/images/user.png")); + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, null, index, isSelected, cellHasFocus); + setText(value.toString()); + setIcon(icoemployee); + return this; + } +} diff --git a/src/main/java/com/unicenta/pos/epm/JEmployeeFinder.form b/src/main/java/com/unicenta/pos/epm/JEmployeeFinder.form new file mode 100644 index 0000000..753d1c5 --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/JEmployeeFinder.form @@ -0,0 +1,288 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="form.customertitle" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-17,0,0,2,-85"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Last"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jcmdCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="Button.Cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jcmdOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="Button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="First"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel7"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel5" min="-2" pref="126" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="m_jtxtName" min="-2" pref="220" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel5" alignment="0" min="-2" pref="25" max="-2" attributes="0"/> + <Component id="m_jtxtName" alignment="0" min="-2" pref="25" max="-2" attributes="0"/> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.epm.employee" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel6"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.clean" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jButton3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.executefilter" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton3ActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="jListEmployees"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jListEmployeesMouseClicked"/> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="jListEmployeesValueChanged"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel8"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/epm/JEmployeeFinder.java b/src/main/java/com/unicenta/pos/epm/JEmployeeFinder.java new file mode 100644 index 0000000..c6e4509 --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/JEmployeeFinder.java @@ -0,0 +1,383 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.epm; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.user.EditorCreator; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.pos.forms.AppLocal; +import java.awt.*; +import java.util.ArrayList; +import javax.swing.JFrame; + +/** + * + * @author Ali Safdar and Aneeqa Baber + */ +public class JEmployeeFinder extends javax.swing.JDialog implements EditorCreator { + + private EmployeeInfo selectedEmployee; + private ListProvider lpr; + + /** Creates new form JEmployeeFinder */ + private JEmployeeFinder(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + + /** Creates new form JEmployeeFinder */ + private JEmployeeFinder(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + /** + * + * @param parent + * @param dlPresenceManagement + * @return + */ + public static JEmployeeFinder getEmployeeFinder(Component parent, DataLogicPresenceManagement dlPresenceManagement) { + Window window = getWindow(parent); + JEmployeeFinder myMsg; + if (window instanceof Frame) { + myMsg = new JEmployeeFinder((Frame) window, true); + } else { + myMsg = new JEmployeeFinder((Dialog) window, true); + } + myMsg.init(dlPresenceManagement); + myMsg.applyComponentOrientation(parent.getComponentOrientation()); + return myMsg; + } + + /** + * + * @return + */ + public EmployeeInfo getSelectedEmployee() { + return selectedEmployee; + } + + private void init(DataLogicPresenceManagement dlPresenceManagement) { + initComponents(); + jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); + m_jtxtName.addEditorKeys(m_jKeys); + m_jtxtName.reset(); + lpr = new ListProviderCreator(dlPresenceManagement.getEmployeeList(), this); + jListEmployees.setCellRenderer(new EmployeeRenderer()); + getRootPane().setDefaultButton(jcmdOK); + selectedEmployee = null; + } + + /** + * + * @param employee + */ + public void search(EmployeeInfo employee) { + if (employee == null || employee.getName() == null || employee.getName().equals("")) { + m_jtxtName.reset(); + cleanSearch(); + } else { + m_jtxtName.setText(employee.getName()); + executeSearch(); + } + } + + private void cleanSearch() { + jListEmployees.setModel(new MyListData(new ArrayList())); + } + + /** + * + */ + public void executeSearch() { + try { + jListEmployees.setModel(new MyListData(lpr.loadData())); + if (jListEmployees.getModel().getSize() > 0) { + jListEmployees.setSelectedIndex(0); + } + } catch (BasicException e) { + } + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + Object[] afilter = new Object[2]; + // Name + if (m_jtxtName.getText() == null || m_jtxtName.getText().equals("")) { + afilter[0] = QBFCompareEnum.COMP_NONE; + afilter[1] = null; + } else { + afilter[0] = QBFCompareEnum.COMP_RE; + afilter[1] = "%" + m_jtxtName.getText() + "%"; + } + return afilter; + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window) parent; + } else { + return getWindow(parent.getParent()); + } + } + + private static class MyListData extends javax.swing.AbstractListModel { + private java.util.List m_data; + public MyListData(java.util.List data) { + m_data = data; + } + + @Override + public Object getElementAt(int index) { + return m_data.get(index); + } + + @Override + public int getSize() { + return m_data.size(); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel2 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel1 = new javax.swing.JPanel(); + jcmdCancel = new javax.swing.JButton(); + jcmdOK = new javax.swing.JButton(); + jPanel3 = new javax.swing.JPanel(); + jPanel5 = new javax.swing.JPanel(); + jPanel7 = new javax.swing.JPanel(); + jLabel5 = new javax.swing.JLabel(); + m_jtxtName = new com.unicenta.editor.JEditorString(); + jPanel6 = new javax.swing.JPanel(); + jButton1 = new javax.swing.JButton(); + jButton3 = new javax.swing.JButton(); + jPanel4 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jListEmployees = new javax.swing.JList(); + jPanel8 = new javax.swing.JPanel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("form.customertitle")); // NOI18N + + jPanel2.setLayout(new java.awt.BorderLayout()); + jPanel2.add(m_jKeys, java.awt.BorderLayout.NORTH); + + jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N + jcmdCancel.setFocusPainted(false); + jcmdCancel.setFocusable(false); + jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdCancel.setRequestFocusEnabled(false); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel1.add(jcmdCancel); + + jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + jcmdOK.setEnabled(false); + jcmdOK.setFocusPainted(false); + jcmdOK.setFocusable(false); + jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdOK.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdOK.setRequestFocusEnabled(false); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel1.add(jcmdOK); + + jPanel2.add(jPanel1, java.awt.BorderLayout.PAGE_END); + + getContentPane().add(jPanel2, java.awt.BorderLayout.LINE_END); + + jPanel3.setLayout(new java.awt.BorderLayout()); + + jPanel5.setLayout(new java.awt.BorderLayout()); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.epm.employee")); // NOI18N + + m_jtxtName.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); + jPanel7.setLayout(jPanel7Layout); + jPanel7Layout.setHorizontalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel7Layout.setVerticalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + jPanel5.add(jPanel7, java.awt.BorderLayout.CENTER); + + jButton1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jButton1.setText(AppLocal.getIntString("button.clean")); // NOI18N + jButton1.setPreferredSize(new java.awt.Dimension(110, 45)); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + jPanel6.add(jButton1); + + jButton3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jButton3.setText(AppLocal.getIntString("button.executefilter")); // NOI18N + jButton3.setFocusPainted(false); + jButton3.setFocusable(false); + jButton3.setPreferredSize(new java.awt.Dimension(110, 45)); + jButton3.setRequestFocusEnabled(false); + jButton3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton3ActionPerformed(evt); + } + }); + jPanel6.add(jButton3); + + jPanel5.add(jPanel6, java.awt.BorderLayout.SOUTH); + + jPanel3.add(jPanel5, java.awt.BorderLayout.PAGE_START); + + jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel4.setLayout(new java.awt.BorderLayout()); + + jListEmployees.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jListEmployees.setFocusable(false); + jListEmployees.setRequestFocusEnabled(false); + jListEmployees.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jListEmployeesMouseClicked(evt); + } + }); + jListEmployees.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + jListEmployeesValueChanged(evt); + } + }); + jScrollPane1.setViewportView(jListEmployees); + + jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + jPanel3.add(jPanel4, java.awt.BorderLayout.CENTER); + + jPanel8.setLayout(new java.awt.BorderLayout()); + jPanel3.add(jPanel8, java.awt.BorderLayout.SOUTH); + + getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER); + + setSize(new java.awt.Dimension(683, 495)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + selectedEmployee = (EmployeeInfo) jListEmployees.getSelectedValue(); + dispose(); + + }//GEN-LAST:event_jcmdOKActionPerformed + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_jcmdCancelActionPerformed + + private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed + + executeSearch(); + + }//GEN-LAST:event_jButton3ActionPerformed + + private void jListEmployeesValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListEmployeesValueChanged + + jcmdOK.setEnabled(jListEmployees.getSelectedValue() != null); + +}//GEN-LAST:event_jListEmployeesValueChanged + + private void jListEmployeesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListEmployeesMouseClicked + + if (evt.getClickCount() == 2) { + selectedEmployee = (EmployeeInfo) jListEmployees.getSelectedValue(); + dispose(); + } + +}//GEN-LAST:event_jListEmployeesMouseClicked + +private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + + m_jtxtName.reset(); + cleanSearch(); +}//GEN-LAST:event_jButton1ActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton3; + private javax.swing.JLabel jLabel5; + private javax.swing.JList jListEmployees; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JPanel jPanel7; + private javax.swing.JPanel jPanel8; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + private com.unicenta.editor.JEditorKeys m_jKeys; + private com.unicenta.editor.JEditorString m_jtxtName; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/epm/JPanelEmployeePresence.form b/src/main/java/com/unicenta/pos/epm/JPanelEmployeePresence.form new file mode 100644 index 0000000..56a112d --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/JPanelEmployeePresence.form @@ -0,0 +1,133 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 45]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="btnCheckIn" min="-2" pref="256" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="btnCheckOut" min="-2" pref="248" max="-2" attributes="0"/> + </Group> + <Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/> + <Component id="message" alignment="1" max="32767" attributes="0"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="message" min="-2" pref="50" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="btnCheckIn" alignment="3" min="-2" pref="49" max="-2" attributes="0"/> + <Component id="btnCheckOut" alignment="3" min="-2" pref="49" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jScrollPane1" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="80" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="btnCheckIn"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Check In"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 23]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCheckInActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="btnCheckOut"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Check Out"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCheckOutActionPerformed"/> + </Events> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Properties> + <Property name="horizontalScrollBarPolicy" type="int" value="31"/> + <Property name="verticalScrollBarPolicy" type="int" value="22"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[570, 120]"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + </Container> + <Component class="javax.swing.JLabel" name="message"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 25]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/epm/JPanelEmployeePresence.java b/src/main/java/com/unicenta/pos/epm/JPanelEmployeePresence.java new file mode 100644 index 0000000..12378ef --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/JPanelEmployeePresence.java @@ -0,0 +1,327 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + + +package com.unicenta.pos.epm; + +import com.unicenta.basic.BasicException; +import com.unicenta.beans.JFlowPanel; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.*; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.util.Date; +import javax.swing.*; + +/** + * + * @author Ali Safdar and Aneeqa Baber + */ +public class JPanelEmployeePresence extends javax.swing.JPanel implements JPanelView, BeanFactoryApp { + + private AppView app; + private DataLogicPresenceManagement dlpresencemanagement; + private JFlowPanel jBreaks; + + /** Creates new form JPanelEmployeePresence */ + public JPanelEmployeePresence() { + initComponents(); + this.setVisible(true); + } + + /** + * + * @param app + * @throws BeanFactoryException + */ + @Override + public void init(AppView app) throws BeanFactoryException { + this.app = app; + dlpresencemanagement = (DataLogicPresenceManagement) app.getBean("com.unicenta.pos.epm.DataLogicPresenceManagement"); + } + + private void listBreaks() + { + try { + jScrollPane1.getViewport().setView(null); + jBreaks = new JFlowPanel(); + jBreaks.applyComponentOrientation(getComponentOrientation()); + java.util.List breaks = dlpresencemanagement.listBreaksVisible(); + for (int i = 0; i < breaks.size(); i++) { + + Break m_break = (Break) breaks.get(i); + + JButton btn = new JButton(new BreakAction(m_break)); + btn.applyComponentOrientation(getComponentOrientation()); + btn.setFocusPainted(false); + btn.setFocusable(false); + btn.setRequestFocusEnabled(false); + btn.setHorizontalAlignment(SwingConstants.LEADING); + btn.setMaximumSize(new Dimension(190, 50)); + btn.setPreferredSize(new Dimension(190, 50)); + btn.setMinimumSize(new Dimension(190, 50)); + + jBreaks.add(btn); + } + jScrollPane1.getViewport().setView(jBreaks); + + } catch (BasicException ee) { + } + } + + private class BreakAction extends AbstractAction { + + private Break m_break; + + public BreakAction(Break aBreak) { + m_break = aBreak; + putValue(Action.NAME, m_break.getName()); + } + + public Break getBreak() { + return m_break; + } + + @Override + public void actionPerformed(ActionEvent evt) { + try { + dlpresencemanagement.StartBreak(app.getAppUserView().getUser().getId(), m_break.getId()); + message.setText(app.getAppUserView().getUser().getName()+" "+AppLocal.getIntString("message.leavefor")+" "+ m_break.getName()+" "+AppLocal.getIntString("message.at")+" "+Formats.TIMESTAMP.formatValue(new Date())); + BreakAction(); + } catch (BasicException ex) { + message.setText(AppLocal.getIntString("message.probleminbreak")); + } + } + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.CheckInCheckOut"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + boolean isOnLeave = dlpresencemanagement.IsOnLeave(app.getAppUserView().getUser().getId()); + listBreaks(); + if (isOnLeave) { + message.setText(app.getAppUserView().getUser().getName()+" "+AppLocal.getIntString("message.leavecontrol")); + LeaveAction(); + } else { + boolean isCheckedIn = dlpresencemanagement.IsCheckedIn(app.getAppUserView().getUser().getId()); + if (isCheckedIn) { + Date lastCheckIn = dlpresencemanagement.GetLastCheckIn(app.getAppUserView().getUser().getId()); + message.setText(app.getAppUserView().getUser().getName()+" "+AppLocal.getIntString("message.checkedin")+" "+Formats.TIMESTAMP.formatValue(lastCheckIn)); + CheckInAction(); + } else { + Date lastCheckOut = dlpresencemanagement.GetLastCheckOut(app.getAppUserView().getUser().getId()); + if (lastCheckOut != null) { + message.setText(app.getAppUserView().getUser().getName()+" "+AppLocal.getIntString("message.checkedout")+" "+Formats.TIMESTAMP.formatValue(lastCheckOut)); + } else { + message.setText(app.getAppUserView().getUser().getName()+" "+AppLocal.getIntString("message.noshift")); + } + CheckOutAction(); + } + boolean isOnBreak = dlpresencemanagement.IsOnBreak(app.getAppUserView().getUser().getId()); + if (isOnBreak) { + Object[] LastBreak = (Object[]) dlpresencemanagement.GetLastBreak(app.getAppUserView().getUser().getId()); + message.setText(app.getAppUserView().getUser().getName()+" "+AppLocal.getIntString("message.leavefor")+" "+(String) LastBreak[0] +" "+AppLocal.getIntString("message.at")+" "+ Formats.TIMESTAMP.formatValue((Date) LastBreak[1])); + BreakAction(); + } + } + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + return true; + } + + /** + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * + * @return + */ + @Override + public Object getBean() { + return this; + } + + private void CheckInAction() { + btnCheckIn.setEnabled(false); + btnCheckOut.setEnabled(true); + jBreaks.setEnabled(true); + } + + private void CheckOutAction() { + btnCheckIn.setEnabled(true); + btnCheckOut.setEnabled(false); + jBreaks.setEnabled(false); + } + + private void BreakAction() { + btnCheckIn.setEnabled(true); + btnCheckOut.setEnabled(true); + jBreaks.setEnabled(false); + } + + private void LeaveAction() { + btnCheckIn.setEnabled(false); + btnCheckOut.setEnabled(false); + jBreaks.setEnabled(false); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + btnCheckIn = new javax.swing.JButton(); + btnCheckOut = new javax.swing.JButton(); + jScrollPane1 = new javax.swing.JScrollPane(); + message = new javax.swing.JLabel(); + + setPreferredSize(new java.awt.Dimension(0, 45)); + + btnCheckIn.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + btnCheckIn.setText("Check In"); + btnCheckIn.setMaximumSize(new java.awt.Dimension(85, 23)); + btnCheckIn.setPreferredSize(new java.awt.Dimension(0, 45)); + btnCheckIn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCheckInActionPerformed(evt); + } + }); + + btnCheckOut.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + btnCheckOut.setText("Check Out"); + btnCheckOut.setPreferredSize(new java.awt.Dimension(0, 45)); + btnCheckOut.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCheckOutActionPerformed(evt); + } + }); + + jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + jScrollPane1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jScrollPane1.setPreferredSize(new java.awt.Dimension(570, 120)); + + message.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + message.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + message.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + message.setOpaque(true); + message.setPreferredSize(new java.awt.Dimension(160, 25)); + message.setRequestFocusEnabled(false); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(btnCheckIn, javax.swing.GroupLayout.PREFERRED_SIZE, 256, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btnCheckOut, javax.swing.GroupLayout.PREFERRED_SIZE, 248, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(message, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(message, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnCheckIn, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(btnCheckOut, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(80, Short.MAX_VALUE)) + ); + }// </editor-fold>//GEN-END:initComponents + + private void btnCheckInActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheckInActionPerformed + try { + boolean isOnBreak = dlpresencemanagement.IsOnBreak(app.getAppUserView().getUser().getId()); + if (isOnBreak) { + dlpresencemanagement.EndBreak(app.getAppUserView().getUser().getId()); + message.setText(app.getAppUserView().getUser().getName()+AppLocal.getIntString("message.breakoverandcheckedin")+" "+Formats.TIMESTAMP.formatValue(new Date())); + } else { + dlpresencemanagement.CheckIn(app.getAppUserView().getUser().getId()); + message.setText(app.getAppUserView().getUser().getName()+" "+AppLocal.getIntString("message.checkedin")+" "+Formats.TIMESTAMP.formatValue(new Date())); + } + } catch (BasicException ex) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotcheckin")); + msg.show(this); + } + CheckInAction(); +}//GEN-LAST:event_btnCheckInActionPerformed + + private void btnCheckOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheckOutActionPerformed + try { + boolean isOnBreak = dlpresencemanagement.IsOnBreak(app.getAppUserView().getUser().getId()); + if (isOnBreak) { + dlpresencemanagement.EndBreak(app.getAppUserView().getUser().getId()); + message.setText(app.getAppUserView().getUser().getName()+" "+AppLocal.getIntString("message.breakoverandcheckedout")+" "+Formats.TIMESTAMP.formatValue(new Date())); + } else { + message.setText(app.getAppUserView().getUser().getName()+" "+AppLocal.getIntString("message.checkedout")+" "+Formats.TIMESTAMP.formatValue(new Date())); + } + dlpresencemanagement.CheckOut(app.getAppUserView().getUser().getId()); + } catch (BasicException ex) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotcheckout")); + msg.show(this); + } + CheckOutAction(); +}//GEN-LAST:event_btnCheckOutActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCheckIn; + private javax.swing.JButton btnCheckOut; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JLabel message; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/epm/LeavesInfo.java b/src/main/java/com/unicenta/pos/epm/LeavesInfo.java new file mode 100644 index 0000000..ca07052 --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/LeavesInfo.java @@ -0,0 +1,164 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.epm; + +import com.unicenta.data.loader.IKeyed; + +/** + * + * @author Ali Safdar and Aneeqa Baber + */ +public class LeavesInfo implements IKeyed { + + private static final long serialVersionUID = 8936482715929L; + private String m_sID; + private String m_sName; + private String m_sEmployeeID; + private String m_sStartDate; + private String m_sEndDate; + private String m_sNotes; + + + /** Creates new LeavesInfo + * @param id + * @param name + * @param notes + * @param startdate + * @param employeeid + * @param enddate */ + public LeavesInfo(String id, String name, String employeeid, String startdate, String enddate, String notes) { + m_sID = id; + m_sName = name; + m_sEmployeeID = employeeid; + m_sStartDate = startdate; + m_sEndDate = enddate; + m_sNotes = notes; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return m_sID; + } + + /** + * + * @param sID + */ + public void setID(String sID) { + m_sID = sID; + } + + /** + * + * @return + */ + public String getID() { + return m_sID; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + + /** + * + * @param sName + */ + public void setName(String sName) { + m_sName = sName; + } + + @Override + public String toString(){ + return m_sName; + } + + /** + * + * @return + */ + public String getEmployeeID() { + return m_sEmployeeID; + } + + /** + * + * @param EmployeeID + */ + public void setEmployeeID(String EmployeeID) { + this.m_sEmployeeID = EmployeeID; + } + + /** + * + * @return + */ + public String getStartDate() { + return m_sStartDate; + } + + /** + * + * @param StartDate + */ + public void setStartDate(String StartDate) { + this.m_sStartDate = StartDate; + } + + /** + * + * @return + */ + public String getEndDate() { + return m_sEndDate; + } + + /** + * + * @param EndDate + */ + public void setEndDate(String EndDate) { + this.m_sEndDate = EndDate; + } + + /** + * + * @return + */ + public String getNotes() { + return m_sNotes; + } + + /** + * + * @param Notes + */ + public void setNotes(String Notes) { + this.m_sNotes = Notes; + } +} diff --git a/src/main/java/com/unicenta/pos/epm/LeavesPanel.java b/src/main/java/com/unicenta/pos/epm/LeavesPanel.java new file mode 100644 index 0000000..f06af70 --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/LeavesPanel.java @@ -0,0 +1,130 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.epm; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +/** + * + * @author Ali Safdar and Aneeqa Baber + */ +public class LeavesPanel extends JPanelTable { + + private TableDefinition tleaves; + private LeavesView jeditor; + + /** Creates a new instance of LeavesPanel */ + public LeavesPanel() { + } + + /** + * + */ + @Override + protected void init() { + DataLogicPresenceManagement dlPresenceManagement = (DataLogicPresenceManagement) app.getBean("com.unicenta.pos.epm.DataLogicPresenceManagement"); + tleaves = dlPresenceManagement.getTableLeaves(); + jeditor = new LeavesView(app, dirty); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + jeditor.activate(); + super.activate(); + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return new ListProviderCreator(tleaves); + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(tleaves, new int[] {0, 1, 2, 3, 4, 5}); + } + + /** + * + * @return + */ + @Override + public Vectorer getVectorer() { + return tleaves.getVectorerBasic(new int[]{2, 5}); + } + + /** + * + * @return + */ + @Override + public ComparatorCreator getComparatorCreator() { + return tleaves.getComparatorCreator(new int[] {2, 3, 4, 5}); + } + + /** + * + * @return + */ + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(tleaves.getRenderStringBasic(new int[]{2})); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Leaves"); + } +} diff --git a/src/main/java/com/unicenta/pos/epm/LeavesView.form b/src/main/java/com/unicenta/pos/epm/LeavesView.form new file mode 100644 index 0000000..49c8fe4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/LeavesView.form @@ -0,0 +1,237 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="m_Notes" alignment="1" pref="126" max="32767" attributes="1"/> + <Component id="m_EndDate" pref="126" max="32767" attributes="1"/> + <Component id="m_StartDate" alignment="0" pref="126" max="32767" attributes="1"/> + <Component id="m_Name" alignment="0" pref="126" max="32767" attributes="1"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="m_jEndDate" alignment="0" max="32767" attributes="1"/> + <Component id="m_jStartDate" max="32767" attributes="1"/> + <Component id="m_jEmployeeName" alignment="0" pref="172" max="32767" attributes="1"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="btnStartDate" alignment="0" max="32767" attributes="1"/> + <Component id="btnEmployee" alignment="0" max="32767" attributes="1"/> + <Component id="btnEndDate" alignment="0" max="32767" attributes="1"/> + </Group> + </Group> + <Component id="jScrollPane1" pref="258" max="32767" attributes="1"/> + </Group> + <EmptySpace min="-2" pref="77" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="m_Name" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jEmployeeName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="btnEmployee" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="m_StartDate" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jStartDate" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="btnStartDate" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="btnEndDate" min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_EndDate" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jEndDate" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="separate" max="32767" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_Notes" min="-2" pref="25" max="-2" attributes="0"/> + <Component id="jScrollPane1" min="-2" pref="141" max="-2" attributes="0"/> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JTextField" name="m_jEmployeeName"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="m_jLeaveNote"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Monospaced" size="14" style="0"/> + </Property> + <Property name="lineWrap" type="boolean" value="true"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="m_Name"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.epm.employee" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_StartDate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.epm.startdate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_EndDate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.epm.enddate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jStartDate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_Notes"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.epm.notes" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="btnEmployee"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/user_sml.png"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[57, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[57, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnEmployeeActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="btnEndDate"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/date.png"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnEndDateActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="btnStartDate"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/date.png"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnStartDateActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jEndDate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/epm/LeavesView.java b/src/main/java/com/unicenta/pos/epm/LeavesView.java new file mode 100644 index 0000000..94e3588 --- /dev/null +++ b/src/main/java/com/unicenta/pos/epm/LeavesView.java @@ -0,0 +1,432 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.epm; + +import com.unicenta.basic.BasicException; +import com.unicenta.beans.JCalendarDialog; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import java.awt.Component; +import java.util.Date; +import java.util.List; +import java.util.UUID; +import java.util.Calendar; + +/** + * + * @author Ali Safdar and Aneeqa Baber + */ +public final class LeavesView extends javax.swing.JPanel implements EditorRecord { + + private Object m_oId; + private Object m_employeeid; + private SentenceList m_sentcat; + + private DirtyManager m_Dirty; + private DataLogicPresenceManagement dlPresenceManagement; + + /** Creates new form LeavesView + * @param app + * @param dirty */ + public LeavesView(AppView app, DirtyManager dirty) { + + dlPresenceManagement = (DataLogicPresenceManagement) app.getBean("com.unicenta.pos.epm.DataLogicPresenceManagement"); + initComponents(); + + m_sentcat = dlPresenceManagement.getLeavesList(); + m_Dirty = dirty; + m_jEmployeeName.getDocument().addDocumentListener(dirty); + m_jStartDate.getDocument().addDocumentListener(dirty); + m_jEndDate.getDocument().addDocumentListener(dirty); + m_jLeaveNote.getDocument().addDocumentListener(dirty); + writeValueEOF(); + } + + void activate() throws BasicException { + List a = m_sentcat.list(); + a.add(0, null); + } + + /** + * + */ + @Override + public void writeValueEOF() { + m_oId = null; + m_jEmployeeName.setText(null); + m_jStartDate.setText(null); + m_jEndDate.setText(null); + m_jLeaveNote.setText(null); + m_jEmployeeName.setEditable(false); + m_jStartDate.setEnabled(false); + m_jEndDate.setEnabled(false); + m_jLeaveNote.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + m_oId = null; + m_jEmployeeName.setText(null); + m_jStartDate.setText(null); + m_jEndDate.setText(null); + m_jLeaveNote.setText(null); + m_jEmployeeName.setEditable(true); + m_jStartDate.setEnabled(true); + m_jEndDate.setEnabled(true); + m_jLeaveNote.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + Object[] leaves = (Object[]) value; + m_oId = leaves[0]; + m_employeeid = leaves[1]; + m_jEmployeeName.setText((String) leaves[2]); + m_jStartDate.setText(Formats.TIMESTAMP.formatValue((Date) leaves[3])); + m_jEndDate.setText(Formats.TIMESTAMP.formatValue((Date) leaves[4])); + m_jLeaveNote.setText((String) leaves[5]); + m_jEmployeeName.setEditable(true); + m_jStartDate.setEnabled(true); + m_jEndDate.setEnabled(true); + m_jLeaveNote.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + Object[] leaves = (Object[]) value; + m_oId = leaves[0]; + m_employeeid = leaves[1]; + m_jEmployeeName.setText((String) leaves[2]); + m_jStartDate.setText(Formats.TIMESTAMP.formatValue((Date) leaves[3])); + m_jEndDate.setText(Formats.TIMESTAMP.formatValue((Date) leaves[4])); + m_jLeaveNote.setText((String) leaves[5]); + m_jEmployeeName.setEditable(false); + m_jStartDate.setEnabled(false); + m_jEndDate.setEnabled(false); + m_jLeaveNote.setEnabled(false); + } + + /** + * + */ + @Override + public void refresh() { + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + Object[] leaves = new Object[6]; + leaves[0] = m_oId == null ? UUID.randomUUID().toString() : m_oId; + leaves[1] = m_employeeid; + leaves[2] = m_jEmployeeName.getText(); + leaves[3] = (Date) Formats.TIMESTAMP.parseValue(m_jStartDate.getText()); + leaves[4] = (Date) Formats.TIMESTAMP.parseValue(m_jEndDate.getText()); + leaves[5] = m_jLeaveNote.getText(); + boolean isCheckedIn = dlPresenceManagement.IsCheckedIn((String) m_employeeid); + Date startDate = (Date) Formats.TIMESTAMP.parseValue(m_jStartDate.getText()); + Date endDate = (Date) Formats.TIMESTAMP.parseValue(m_jEndDate.getText()); + Date systemDate = new Date(); + if (isCheckedIn && startDate.before(systemDate) && endDate.after(systemDate)) { + dlPresenceManagement.BlockEmployee((String) m_employeeid); + } + return leaves; + } +// TODO - rewrite IsValidEndDate using Apache commons or Calendar + + private boolean IsValidEndDate(Date date) { + Date systemDate = new Date(); + if (! m_jStartDate.getText().equals("")) { + Date startdate; + try { + startdate = (Date) Formats.TIMESTAMP.parseValue(m_jStartDate.getText()); + return (startdate.before(date) + || (startdate.getDate() == date.getDate() + && startdate.getMonth() == date.getMonth() + && startdate.getYear() == date.getYear())); + + } catch (BasicException ex) { + } + } + return (systemDate.before(date) + || (systemDate.getDate() == date.getDate() + && systemDate.getMonth() == date.getMonth() + && systemDate.getYear() == date.getYear())); + } + +// TODO - rewrite IsValidStartDate using Apache commons or Calendar + + private boolean IsValidStartDate(Date date) { + Date systemDate = new Date(); + boolean validEndDate = true; + if (! m_jEndDate.getText().equals("")) { + try { + Date enddate = (Date) Formats.TIMESTAMP.parseValue(m_jEndDate.getText()); + validEndDate = (enddate.after(date) + || (enddate.getDate() == date.getDate() + && enddate.getMonth() == date.getMonth() + && enddate.getYear() == date.getYear())); + } catch (BasicException ex) { + } + } + return validEndDate && (systemDate.before(date) + || (systemDate.getDate() == date.getDate() + && systemDate.getMonth() == date.getMonth() + && systemDate.getYear() == date.getYear())); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jEmployeeName = new javax.swing.JTextField(); + jScrollPane1 = new javax.swing.JScrollPane(); + m_jLeaveNote = new javax.swing.JTextArea(); + m_Name = new javax.swing.JLabel(); + m_StartDate = new javax.swing.JLabel(); + m_EndDate = new javax.swing.JLabel(); + m_jStartDate = new javax.swing.JTextField(); + m_Notes = new javax.swing.JLabel(); + btnEmployee = new javax.swing.JButton(); + btnEndDate = new javax.swing.JButton(); + btnStartDate = new javax.swing.JButton(); + m_jEndDate = new javax.swing.JTextField(); + + m_jEmployeeName.setEditable(false); + m_jEmployeeName.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jEmployeeName.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jLeaveNote.setColumns(20); + m_jLeaveNote.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N + m_jLeaveNote.setLineWrap(true); + m_jLeaveNote.setRows(5); + jScrollPane1.setViewportView(m_jLeaveNote); + + m_Name.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + m_Name.setText(bundle.getString("label.epm.employee")); // NOI18N + m_Name.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_StartDate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_StartDate.setText(AppLocal.getIntString("label.epm.startdate")); // NOI18N + m_StartDate.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_EndDate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_EndDate.setText(AppLocal.getIntString("label.epm.enddate")); // NOI18N + m_EndDate.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jStartDate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jStartDate.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_Notes.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_Notes.setText(AppLocal.getIntString("label.epm.notes")); // NOI18N + m_Notes.setPreferredSize(new java.awt.Dimension(0, 30)); + + btnEmployee.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/user_sml.png"))); // NOI18N + btnEmployee.setFocusPainted(false); + btnEmployee.setFocusable(false); + btnEmployee.setMaximumSize(new java.awt.Dimension(57, 33)); + btnEmployee.setMinimumSize(new java.awt.Dimension(57, 33)); + btnEmployee.setPreferredSize(new java.awt.Dimension(80, 45)); + btnEmployee.setRequestFocusEnabled(false); + btnEmployee.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnEmployeeActionPerformed(evt); + } + }); + + btnEndDate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/date.png"))); // NOI18N + btnEndDate.setPreferredSize(new java.awt.Dimension(80, 45)); + btnEndDate.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnEndDateActionPerformed(evt); + } + }); + + btnStartDate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/date.png"))); // NOI18N + btnStartDate.setPreferredSize(new java.awt.Dimension(80, 45)); + btnStartDate.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnStartDateActionPerformed(evt); + } + }); + + m_jEndDate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jEndDate.setPreferredSize(new java.awt.Dimension(0, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(m_Notes, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE) + .addComponent(m_EndDate, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE) + .addComponent(m_StartDate, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE) + .addComponent(m_Name, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(m_jEndDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(m_jStartDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(m_jEmployeeName, javax.swing.GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(btnStartDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btnEmployee, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btnEndDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)) + .addGap(77, 77, 77)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_Name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jEmployeeName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(btnEmployee, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_StartDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jStartDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(btnStartDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(btnEndDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_EndDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jEndDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(18, 18, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_Notes, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + }// </editor-fold>//GEN-END:initComponents + + private void btnEmployeeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEmployeeActionPerformed + + JEmployeeFinder finder = JEmployeeFinder.getEmployeeFinder(this, dlPresenceManagement); + finder.search(null); + finder.setVisible(true); + + try { + m_jEmployeeName.setText(finder.getSelectedEmployee() == null + ? null + : dlPresenceManagement.loadEmployeeExt(finder.getSelectedEmployee().getId()).toString()); + m_employeeid = finder.getSelectedEmployee() == null + ? null + :finder.getSelectedEmployee().getId(); + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindemployee"), e); + msg.show(this); + } +}//GEN-LAST:event_btnEmployeeActionPerformed + + private void btnEndDateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEndDateActionPerformed + Date date; + try { + date = (Date) Formats.TIMESTAMP.parseValue(m_jEndDate.getText()); + } catch (BasicException e) { + date = null; + } + date = JCalendarDialog.showCalendarTimeHours(this, date); + if (date != null) { + if (IsValidEndDate(date)) { + m_jEndDate.setText(Formats.TIMESTAMP.formatValue(date)); + } else { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.invalidenddate")); + msg.show(this); + } + } +}//GEN-LAST:event_btnEndDateActionPerformed + + private void btnStartDateActionPerformed(java.awt.event.ActionEvent evt) { + Date date; + try { + date = (Date) Formats.TIMESTAMP.parseValue(m_jStartDate.getText()); + } catch (BasicException e) { + date = null; + } + date = JCalendarDialog.showCalendarTimeHours(this, date); + if (date != null) { + if (IsValidStartDate(date)) { + m_jStartDate.setText(Formats.TIMESTAMP.formatValue(date)); + } else { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.invalidstartdate")); + msg.show(this); + } + } +} + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnEmployee; + private javax.swing.JButton btnEndDate; + private javax.swing.JButton btnStartDate; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JLabel m_EndDate; + private javax.swing.JLabel m_Name; + private javax.swing.JLabel m_Notes; + private javax.swing.JLabel m_StartDate; + private javax.swing.JTextField m_jEmployeeName; + private javax.swing.JTextField m_jEndDate; + private javax.swing.JTextArea m_jLeaveNote; + private javax.swing.JTextField m_jStartDate; + // End of variables declaration//GEN-END:variables +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/forms/AppConfig.java b/src/main/java/com/unicenta/pos/forms/AppConfig.java new file mode 100644 index 0000000..0e7ce61 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/AppConfig.java @@ -0,0 +1,400 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/> + +package com.unicenta.pos.forms; + +import lombok.extern.slf4j.Slf4j; + +import java.io.*; +import java.util.Locale; +import java.util.Properties; + + +/** + * Creation and Editing of stored settings + * + * @author JG uniCenta + */ +@Slf4j +public class AppConfig implements AppProperties { + + private static AppConfig m_instance = null; + private Properties properties; + private File configfile; + + /** + * Set configuration array + * + * @param args array strings + */ + public AppConfig(String[] args) { + if (args.length == 0) { + init(getDefaultConfig()); + } else { + init(new File(args[0])); + } + } + + /** + * unicenta resources file + * + * @param configfile resource file + */ + public AppConfig(File configfile) { + init(configfile); + this.configfile = configfile; + properties = new Properties(); + load(); + //log.debug("Reading configuration file: {}", configfile.getAbsolutePath()); + } + + private void init(File configfile) { + this.configfile = configfile; + properties = new Properties(); + //log.debug("Reading configuration file: {}", configfile.getAbsolutePath()); + } + + private File getDefaultConfig() { + return new File(new File(System.getProperty("user.home")) + , AppLocal.APP_ID + ".properties"); + } + + /** + * Get key pair value from properties resource + * + * @param sKey key pair value + * @return key pair from .properties filename + */ + @Override + public String getProperty(String sKey) { + return properties.getProperty(sKey); + } + + /** + * @return Machine name + */ + @Override + public String getHost() { + return getProperty("machine.hostname"); + } + + /** + * @return .properties filename + */ + @Override + public File getConfigFile() { + return configfile; + } + + + public String getTicketHeaderLine1() { + return getProperty("tkt.header1"); + } + + public String getTicketHeaderLine2() { + return getProperty("tkt.header2"); + } + + public String getTicketHeaderLine3() { + return getProperty("tkt.header3"); + } + + public String getTicketHeaderLine4() { + return getProperty("tkt.header4"); + } + + public String getTicketHeaderLine5() { + return getProperty("tkt.header5"); + } + + public String getTicketHeaderLine6() { + return getProperty("tkt.header6"); + } + + public String getTicketFooterLine1() { + return getProperty("tkt.footer1"); + } + + public String getTicketFooterLine2() { + return getProperty("tkt.footer2"); + } + + public String getTicketFooterLine3() { + return getProperty("tkt.footer3"); + } + + public String getTicketFooterLine4() { + return getProperty("tkt.footer4"); + } + + public String getTicketFooterLine5() { + return getProperty("tkt.footer5"); + } + + public String getTicketFooterLine6() { + return getProperty("tkt.footer6"); + } + + /** + * Update .properties resource key pair values + * + * @param sKey key pair left side + * @param sValue key pair right side value + */ + public void setProperty(String sKey, String sValue) { + if (sValue == null) { + properties.remove(sKey); + } else { + properties.setProperty(sKey, sValue); + } + } + + /** + * Local machine identity + * + * @return Machine name from OS + */ + private String getLocalHostName() { + try { + return java.net.InetAddress.getLocalHost().getHostName(); + } catch (java.net.UnknownHostException eUH) { + return "localhost"; + } + } + + public static AppConfig getInstance() { + + if (m_instance == null) { + m_instance = new AppConfig(new File(System.getProperty("user.home") + , AppLocal.APP_ID + ".properties")); + } + return m_instance; + } + + public Boolean getBoolean(String sKey) { + return Boolean.valueOf(properties.getProperty(sKey)); + } + + public void setBoolean(String sKey, Boolean sValue) { + if (sValue == null) { + properties.remove(sKey); + } else if (sValue) { + properties.setProperty(sKey, "true"); + } else { + properties.setProperty(sKey, "false"); + } + } + + /** + * @return Delete .properties filename + */ + public boolean delete() { + loadDefault(); + return configfile.delete(); + } + + /** + * Get instance settings + */ + public void load() { + + loadDefault(); + + try { + InputStream in = new FileInputStream(configfile); + if (in != null) { + properties.load(in); + in.close(); + } + } catch (IOException e) { + loadDefault(); + } + + } + + private void refreshProperties() { + try { + InputStream in = new FileInputStream(configfile); + if (in != null) { + properties.load(in); + in.close(); + } + } catch (IOException e) { + loadDefault(); + } + } + + /** + * @return 0 or 00 number keypad boolean true/false + */ + public Boolean isPriceWith00() { + String prop = getProperty("pricewith00"); + if (prop == null) { + return false; + } else { + return prop.equals("true"); + } + } + + public void saveWithExistingProperties() throws IOException { + + refreshProperties(); + + OutputStream out = new FileOutputStream(configfile); + if (out != null) { + properties.store(out, AppLocal.APP_NAME + ". Configuration file."); + out.close(); + } + } + + /** + * Save values to properties file + * + * @throws java.io.IOException explicit on OS + */ + public void save() throws IOException { + + OutputStream out = new FileOutputStream(configfile); + if (out != null) { + properties.store(out, AppLocal.APP_NAME + ". Configuration file."); + out.close(); + } + } + + + private void loadDefault() { + + properties = new Properties(); + String dirname = System.getProperty("dirname.path"); + dirname = dirname == null ? "./" : dirname; + + setDatabaseProperties(properties, dirname); + setPrinterProperties(properties); + setLocalProperties(properties); + setPaymentProperties(properties); + setDeviceProperties(properties); + setTableProperties(properties); + + } + + + private void setTableProperties(Properties properties){ + properties.setProperty("table.showcustomerdetails", "true"); + properties.setProperty("table.customercolour", "#58B000"); + properties.setProperty("table.showwaiterdetails", "true"); + properties.setProperty("table.waitercolour", "#258FB0"); + properties.setProperty("table.tablecolour", "#D62E52"); + properties.setProperty("till.amountattop", "true"); + properties.setProperty("till.hideinfo", "true"); + } + + private void setDeviceProperties(Properties properties) { + properties.setProperty("machine.display", "screen"); + properties.setProperty("machine.scale", "Not defined"); + properties.setProperty("machine.screenmode", "fullscreen"); + properties.setProperty("machine.ticketsbag", "standard"); + properties.setProperty("machine.scanner", "Not defined"); + properties.setProperty("machine.iButton", "false"); + properties.setProperty("machine.iButtonResponse", "5"); + properties.setProperty("machine.uniqueinstance", "true"); + + properties.setProperty("machine.hostname", getLocalHostName()); + properties.setProperty("swing.defaultlaf", System.getProperty("swing.defaultlaf","javax.swing.plaf.metal.MetalLookAndFeel")); + } + + private void setPaymentProperties(Properties properties) { + properties.setProperty("payment.gateway", "external"); + properties.setProperty("payment.magcardreader", "Not defined"); + properties.setProperty("payment.testmode", "true"); + properties.setProperty("payment.commerceid", ""); + properties.setProperty("payment.commercepassword", "password"); + } + + private void setLocalProperties(Properties properties) { + Locale l = Locale.getDefault(); + properties.setProperty("user.language", l.getLanguage()); + properties.setProperty("user.country", l.getCountry()); + properties.setProperty("user.variant", l.getVariant()); + } + + private void setPrinterProperties(Properties properties) { + // Receipt printer paper set to 72mmx200mm + properties.setProperty("paper.receipt.x", "10"); + properties.setProperty("paper.receipt.y", "10"); + properties.setProperty("paper.receipt.width", "190"); + properties.setProperty("paper.receipt.height", "546"); + properties.setProperty("paper.receipt.mediasizename", "A4"); + + // Normal printer paper for A4 + properties.setProperty("paper.standard.x", "72"); + properties.setProperty("paper.standard.y", "72"); + properties.setProperty("paper.standard.width", "451"); + properties.setProperty("paper.standard.height", "698"); + properties.setProperty("paper.standard.mediasizename", "A4"); + + properties.setProperty("tkt.header1", "uniCenta oPOS"); + properties.setProperty("tkt.header2", "Touch Friendly Point Of Sale"); + properties.setProperty("tkt.header3", "Copyright (c) 2009-2018 uniCenta"); + properties.setProperty("tkt.header4", "Change header text in Configuration"); + + properties.setProperty("tkt.footer1", "Change footer text in Configuration"); + properties.setProperty("tkt.footer2", "Thank you for your custom"); + properties.setProperty("tkt.footer3", "Please Call Again"); + + properties.setProperty("machine.printer", "screen"); + properties.setProperty("machine.printer.2", "Not defined"); + properties.setProperty("machine.printer.3", "Not defined"); + properties.setProperty("machine.printer.4", "Not defined"); + properties.setProperty("machine.printer.5", "Not defined"); + properties.setProperty("machine.printer.6", "Not defined"); + + properties.setProperty("machine.printername", "(Default)"); + properties.setProperty("screen.receipt.columns", "42"); + } + + private void setDatabaseProperties(Properties properties, String dirname) { + + properties.setProperty("db.multi", "false"); + properties.setProperty("override.check", "false"); + properties.setProperty("override.pin", ""); + + // Default database + properties.setProperty("db.driverlib", new File(new File(dirname), "derby-10.14.2.0.jar").getAbsolutePath()); + properties.setProperty("db.engine", "Derby"); + properties.setProperty("db.driver", "org.apache.derby.jdbc.EmbeddedDriver"); + + properties.setProperty("db.name", "Main DB"); + properties.setProperty("db.URL", "jdbc:derby:" + System.getProperty("user.home")+"/.unicenta/"); + properties.setProperty("db.schema", "unicentaopos-database;create=true"); + properties.setProperty("db.options", ""); + properties.setProperty("db.user", ""); + properties.setProperty("db.password", ""); + + +// secondary DB + properties.setProperty("db1.name", ""); + properties.setProperty("db1.URL", "jdbc:mysql://localhost:3306/"); + properties.setProperty("db1.schema", "unicentaopos"); + properties.setProperty("db1.options", "?zeroDateTimeBehavior=convertToNull"); + properties.setProperty("db1.user", ""); + properties.setProperty("db1.password", ""); + + } + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/forms/AppLocal.java b/src/main/java/com/unicenta/pos/forms/AppLocal.java new file mode 100644 index 0000000..5729fbf --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/AppLocal.java @@ -0,0 +1,65 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/> + +package com.unicenta.pos.forms; + +import com.unicenta.beans.LocaleResources; + +/** + * @author Jack Gerrard + * @author adrianromero + */ +public class AppLocal { + + + public static final String APP_NAME = "uniCenta oPOS"; + public static final String APP_ID = "unicentaopos"; + public static final String APP_VERSION = "5.0"; + + private static final LocaleResources m_resources; + + static { + m_resources = new LocaleResources(); + m_resources.addBundleName("pos_messages"); + m_resources.addBundleName("erp_messages"); + } + + /** Creates a new instance of AppLocal */ + private AppLocal() { + } + + /** + * + * @param sKey local values + * @return string values + */ + public static String getIntString(String sKey) { + return m_resources.getString(sKey); + } + + /** + * + * @param sKey local values + * @param sValues string values + * @return string values + */ + public static String getIntString(String sKey, Object ... sValues) { + return m_resources.getString(sKey, sValues); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/forms/AppProperties.java b/src/main/java/com/unicenta/pos/forms/AppProperties.java new file mode 100644 index 0000000..a9ddae1 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/AppProperties.java @@ -0,0 +1,48 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import java.io.File; + +/** + * + * @author adrianromero + */ +public interface AppProperties { + + /** + * Gets the configuration properties settings + * @return config file + */ + public File getConfigFile(); + + /** + * Gets the Host machine name + * @return host name + */ + public String getHost(); + + /** + * Read the property from the key pair + * @param sKey key pair value + * @return key pair property + */ + public String getProperty(String sKey); +} diff --git a/src/main/java/com/unicenta/pos/forms/AppUser.java b/src/main/java/com/unicenta/pos/forms/AppUser.java new file mode 100644 index 0000000..15f96a3 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/AppUser.java @@ -0,0 +1,304 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.data.loader.LocalRes; +import com.unicenta.pos.ticket.UserInfo; +import com.unicenta.pos.util.Hashcypher; +import lombok.extern.slf4j.Slf4j; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +import javax.swing.*; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.IOException; +import java.io.StringReader; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Set; + +/** + * @author adrianromero + */ +@Slf4j +public class AppUser { + + private static SAXParser m_sp = null; + private static HashMap<String, String> m_oldclasses; // This is for backwards compatibility purposes + + private final String m_sId; + private final String m_sName; + private final String m_sCard; + private String m_sPassword; + private final String m_sRole; + private final Icon m_Icon; + + private Set<String> m_apermissions; + + static { + initOldClasses(); + } + + /** + * Creates a new instance of AppUser + * + * @param id + * @param name + * @param card + * @param password + * @param icon + * @param role + */ + public AppUser(String id, String name, String password, String card, String role, Icon icon) { + m_sId = id; + m_sName = name; + m_sPassword = password; + m_sCard = card; + m_sRole = role; + m_Icon = icon; + m_apermissions = null; + } + + /** + * Gets the User's button icon + */ + public Icon getIcon() { + return m_Icon; + } + + /** + * Get the user's ID + */ + public String getId() { + return m_sId; + } + + /** + * Get the User's Name + */ + public String getName() { + return m_sName; + } + + /** + * Set the User's Password + */ + public void setPassword(String sValue) { + m_sPassword = sValue; + } + + /** + * Get the User's Password + */ + public String getPassword() { + return m_sPassword; + } + + /** + * Get the User's Role + */ + public String getRole() { + return m_sRole; + } + + /** + * Get the User's Card + */ + public String getCard() { + return m_sCard; + } + + /** + * Validate User's Password + * + * @return + */ + public boolean authenticate() { + return m_sPassword == null || m_sPassword.equals("") || m_sPassword.startsWith("empty:"); + } + + /** + * Eval User's Password + * + * @param sPwd + * @return + */ + public boolean authenticate(String sPwd) { + return Hashcypher.authenticate(sPwd, m_sPassword); + } + + /** + * Load User's Permissions + * + * @param dlSystem + */ + public void fillPermissions(DataLogicSystem dlSystem) { + + // JG 16 May use diamond inference + m_apermissions = new HashSet<>(); + // Y lo que todos tienen permisos + m_apermissions.add("com.unicenta.pos.forms.JPanelMenu"); + m_apermissions.add("Menu.Exit"); + + String sRolePermisions = dlSystem.findRolePermissions(m_sRole); + + if (sRolePermisions != null) { + try { + if (m_sp == null) { + SAXParserFactory spf = SAXParserFactory.newInstance(); + m_sp = spf.newSAXParser(); + } + m_sp.parse(new InputSource(new StringReader(sRolePermisions)), new ConfigurationHandler()); + + } catch (ParserConfigurationException ePC) { + log.error(LocalRes.getIntString("exception.parserconfig"), ePC); + } catch (SAXException eSAX) { + log.error(LocalRes.getIntString("exception.xmlfile"), eSAX); + } catch (IOException eIO) { + log.error(LocalRes.getIntString("exception.iofile"), eIO); + } + } + + } + + /** + * Validate User's Permissions + * + * @param classname + * @return + */ + public boolean hasPermission(String classname) { + + return (m_apermissions == null) ? false : m_apermissions.contains(classname); + } + + /** + * Get User's ID/Name + * + * @return + */ + public UserInfo getUserInfo() { + return new UserInfo(m_sId, m_sName); + } + + private static String mapNewClass(String classname) { + String newclass = m_oldclasses.get(classname); + return newclass == null + ? classname + : newclass; + } + + private static void initOldClasses() { + // JG 16 May use diamond inference + m_oldclasses = new HashMap<>(); + + // update permissions from 0.0.24 to 2.20 + m_oldclasses.put("net.adrianromero.tpv.panelsales.JPanelTicketSales", "com.unicenta.pos.sales.JPanelTicketSales"); + m_oldclasses.put("net.adrianromero.tpv.panelsales.JPanelTicketEdits", "com.unicenta.pos.sales.JPanelTicketEdits"); + m_oldclasses.put("net.adrianromero.tpv.panels.JPanelPayments", "com.unicenta.pos.panels.JPanelPayments"); + m_oldclasses.put("net.adrianromero.tpv.panels.JPanelCloseMoney", "com.unicenta.pos.panels.JPanelCloseMoney"); + m_oldclasses.put("net.adrianromero.tpv.reports.JReportClosedPos", "/com/unicenta/reports/closedpos.bs"); + + m_oldclasses.put("Menu.StockManagement", "com.unicenta.pos.forms.MenuStockManagement"); + m_oldclasses.put("net.adrianromero.tpv.inventory.ProductsPanel", "com.unicenta.pos.inventory.ProductsPanel"); + m_oldclasses.put("net.adrianromero.tpv.inventory.ProductsWarehousePanel", "com.unicenta.pos.inventory.ProductsWarehousePanel"); + m_oldclasses.put("net.adrianromero.tpv.inventory.CategoriesPanel", "com.unicenta.pos.inventory.CategoriesPanel"); + m_oldclasses.put("net.adrianromero.tpv.panels.JPanelTax", "com.unicenta.pos.inventory.TaxPanel"); + m_oldclasses.put("net.adrianromero.tpv.inventory.StockDiaryPanel", "com.unicenta.pos.inventory.StockDiaryPanel"); + m_oldclasses.put("net.adrianromero.tpv.inventory.StockManagement", "com.unicenta.pos.inventory.StockManagement"); + m_oldclasses.put("net.adrianromero.tpv.reports.JReportProducts", "/com/unicenta/reports/products.bs"); + m_oldclasses.put("net.adrianromero.tpv.reports.JReportCatalog", "/com/unicenta/reports/productscatalog.bs"); + m_oldclasses.put("net.adrianromero.tpv.reports.JReportInventory", "/com/unicenta/reports/inventory.bs"); + m_oldclasses.put("net.adrianromero.tpv.reports.JReportInventory2", "/com/unicenta/reports/inventoryb.bs"); + m_oldclasses.put("net.adrianromero.tpv.reports.JReportInventoryBroken", "/com/unicenta/reports/inventorybroken.bs"); + m_oldclasses.put("net.adrianromero.tpv.reports.JReportInventoryDiff", "/com/unicenta/reports/inventorydiff.bs"); + + m_oldclasses.put("Menu.SalesManagement", "com.unicenta.pos.forms.MenuSalesManagement"); + m_oldclasses.put("net.adrianromero.tpv.reports.JReportUserSales", "/com/unicenta/reports/usersales.bs"); + m_oldclasses.put("net.adrianromero.tpv.reports.JReportClosedProducts", "/com/unicenta/reports/closedproducts.bs"); + m_oldclasses.put("net.adrianromero.tpv.reports.JReportTaxes", "/com/unicenta/reports/taxes.bs"); + m_oldclasses.put("net.adrianromero.tpv.reports.JChartSales", "/com/unicenta/reports/chartsales.bs"); + + m_oldclasses.put("Menu.Maintenance", "com.unicenta.pos.forms.MenuMaintenance"); + m_oldclasses.put("net.adrianromero.tpv.admin.PeoplePanel", "com.unicenta.pos.admin.PeoplePanel"); + m_oldclasses.put("net.adrianromero.tpv.admin.RolesPanel", "com.unicenta.pos.admin.RolesPanel"); + m_oldclasses.put("net.adrianromero.tpv.admin.ResourcesPanel", "com.unicenta.pos.admin.ResourcesPanel"); + m_oldclasses.put("net.adrianromero.tpv.inventory.LocationsPanel", "com.unicenta.pos.inventory.LocationsPanel"); + m_oldclasses.put("net.adrianromero.tpv.mant.JPanelFloors", "com.unicenta.pos.mant.JPanelFloors"); + m_oldclasses.put("net.adrianromero.tpv.mant.JPanelPlaces", "com.unicenta.pos.mant.JPanelPlaces"); + m_oldclasses.put("com.unicenta.possync.ProductsSync", "com.unicenta.possync.ProductsSyncCreate"); + m_oldclasses.put("com.unicenta.possync.OrdersSync", "com.unicenta.possync.OrdersSyncCreate"); + + m_oldclasses.put("Menu.ChangePassword", "Menu.ChangePassword"); + m_oldclasses.put("net.adrianromero.tpv.panels.JPanelPrinter", "com.unicenta.pos.panels.JPanelPrinter"); + m_oldclasses.put("net.adrianromero.tpv.config.JPanelConfiguration", "com.unicenta.pos.config.JPanelConfiguration"); + + // update permissions from 2.00 to 2.20 + m_oldclasses.put("com.unicenta.pos.reports.JReportCustomers", "/com/unicenta/reports/customers.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportCustomersB", "/com/unicenta/reports/customersb.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportClosedPos", "/com/unicenta/reports/closedpos.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportClosedProducts", "/com/unicenta/reports/closedproducts.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JChartSales", "/com/unicenta/reports/chartsales.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportInventory", "/com/unicenta/reports/inventory.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportInventory2", "/com/unicenta/reports/inventoryb.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportInventoryBroken", "/com/unicenta/reports/inventorybroken.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportInventoryDiff", "/com/unicenta/reports/inventorydiff.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportPeople", "/com/unicenta/reports/people.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportTaxes", "/com/unicenta/reports/taxes.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportUserSales", "/com/unicenta/reports/usersales.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportProducts", "/com/unicenta/reports/products.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportCatalog", "/com/unicenta/reports/productscatalog.bs"); + + // update permissions from 2.10 to 2.20 + m_oldclasses.put("com.unicenta.pos.panels.JPanelTax", "com.unicenta.pos.inventory.TaxPanel"); + + } + + private class ConfigurationHandler extends DefaultHandler { + @Override + public void startDocument() throws SAXException { + } + + @Override + public void endDocument() throws SAXException { + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + if ("class".equals(qName)) { + m_apermissions.add(mapNewClass(attributes.getValue("name"))); + } + } + + @Override + public void endElement(String uri, String localName, String qName) throws SAXException { + } + + @Override + public void characters(char[] ch, int start, int length) throws SAXException { + } + } + + +} diff --git a/src/main/java/com/unicenta/pos/forms/AppUserView.java b/src/main/java/com/unicenta/pos/forms/AppUserView.java new file mode 100644 index 0000000..0c54161 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/AppUserView.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +/** + * + * @author adrianromero + */ +public interface AppUserView { + + /** + * + */ + public static final String ACTION_TASKNAME = "taskname"; + + // Acciones de la aplicacion + + /** + * + * @return + */ + public AppUser getUser(); // Usuario logado + + /** + * + * @param sTaskClass + */ + public void showTask(String sTaskClass); + + /** + * + * @param sTaskClass + */ + public void executeTask(String sTaskClass); +} diff --git a/src/main/java/com/unicenta/pos/forms/AppView.java b/src/main/java/com/unicenta/pos/forms/AppView.java new file mode 100644 index 0000000..9770c14 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/AppView.java @@ -0,0 +1,74 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.data.loader.Session; +import com.unicenta.pos.printer.DeviceTicket; +import com.unicenta.pos.scale.DeviceScale; +import com.unicenta.pos.scanpal2.DeviceScanner; +import java.util.Date; + +/** + * + * @author adrianromero + */ +public interface AppView { + + public DeviceScale getDeviceScale(); + public DeviceTicket getDeviceTicket(); + public DeviceScanner getDeviceScanner(); + public Session getSession(); + public AppProperties getProperties(); + + /** + * + * @param beanfactory + * @return + * @throws BeanFactoryException + */ + public Object getBean(String beanfactory) throws BeanFactoryException; + + /** + * + * @param value + * @param iSeq + * @param dStart + * @param dEnd + */ + public void setActiveCash(String value, int iSeq, Date dStart, Date dEnd); + public String getActiveCashIndex(); + public int getActiveCashSequence(); + public Date getActiveCashDateStart(); + public Date getActiveCashDateEnd(); + + public void setClosedCash(String value, int iSeq, Date dStart, Date dEnd); + public String getClosedCashIndex(); + public int getClosedCashSequence(); + public Date getClosedCashDateStart(); + public Date getClosedCashDateEnd(); + + public String getInventoryLocation(); + + public void waitCursorBegin(); + public void waitCursorEnd(); + public AppUserView getAppUserView(); + +} + diff --git a/src/main/java/com/unicenta/pos/forms/AppViewConnection.java b/src/main/java/com/unicenta/pos/forms/AppViewConnection.java new file mode 100644 index 0000000..188cb58 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/AppViewConnection.java @@ -0,0 +1,145 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Session; +import com.unicenta.pos.util.AltEncrypter; +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.sql.Driver; +import java.sql.DriverManager; +import java.sql.SQLException; +import javax.swing.ImageIcon; +import javax.swing.JOptionPane; + +/** + * + * @author adrianromero + */ +public class AppViewConnection { + + /** Creates a new instance of AppViewConnection */ + private AppViewConnection() { + } + + /** + * + * @param props + * @return + * @throws BasicException + */ + public static Session createSession(AppProperties props) throws BasicException { + try { + String dbURL=null; + String sDBUser=null; + String sDBPassword=null; + String sUserPath = System.getProperty("user.home"); + String filePath = sUserPath + "\\open.db"; + + if (isJavaWebStart()) { + Class.forName(props.getProperty("db.driver"), true, Thread.currentThread().getContextClassLoader()); + } else { + URL[] urls = {new File(props.getProperty("db.driverlib")).toURI().toURL()}; + ClassLoader cloader = new URLClassLoader(urls); + String driver = props.getProperty("db.driver"); + DriverWrapper driverWrapper = new DriverWrapper((Driver) Class.forName(driver, true, cloader).newInstance()); + DriverManager.registerDriver(driverWrapper); + } + if("true".equals(props.getProperty("db.multi"))) { + if (!Files.exists(Paths.get(filePath))) { + ImageIcon icon = new ImageIcon("/com/unicenta/images/unicentaopos.png"); + Object[] dbs = { + "0 - " + props.getProperty("db.name"), + "1 - " + props.getProperty("db1.name")}; + + Object s = (Object)JOptionPane.showInputDialog( + null, AppLocal.getIntString("message.databasechoose"), + "Selection", JOptionPane.OK_OPTION, + icon, dbs, props.getProperty("db.name")); + + if (s.toString().startsWith("1")) { + sDBUser = props.getProperty("db1.user"); + sDBPassword = props.getProperty("db1.password"); + if (sDBUser != null && sDBPassword != null && sDBPassword.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + sDBUser); + sDBPassword = cypher.decrypt(sDBPassword.substring(6)); + } + dbURL = props.getProperty("db1.URL") + + props.getProperty("db1.schema") + + props.getProperty("db1.options"); + } else { + sDBUser = props.getProperty("db.user"); + sDBPassword = props.getProperty("db.password"); + if (sDBUser != null && sDBPassword != null && sDBPassword.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + sDBUser); + sDBPassword = cypher.decrypt(sDBPassword.substring(6)); + } + dbURL = props.getProperty("db.URL") + + props.getProperty("db.schema") + + props.getProperty("db.options"); + } + } else { + sDBUser = props.getProperty("db.user"); + sDBPassword = props.getProperty("db.password"); + if (sDBUser != null && sDBPassword != null && sDBPassword.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + sDBUser); + sDBPassword = cypher.decrypt(sDBPassword.substring(6)); + } + dbURL = props.getProperty("db.URL") + + props.getProperty("db.schema") + + props.getProperty("db.options"); + } + + } else { + sDBUser = props.getProperty("db.user"); + sDBPassword = props.getProperty("db.password"); + if (sDBUser != null && sDBPassword != null && sDBPassword.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + sDBUser); + sDBPassword = cypher.decrypt(sDBPassword.substring(6)); + } + + dbURL = props.getProperty("db.URL") + + props.getProperty("db.schema") + + props.getProperty("db.options"); + } + return new Session(dbURL, sDBUser,sDBPassword); + + } catch (InstantiationException | IllegalAccessException | MalformedURLException | ClassNotFoundException e) { + throw new BasicException(AppLocal.getIntString("message.databasedrivererror"), e); + } catch (SQLException eSQL) { + throw new BasicException(AppLocal.getIntString("message.databaseconnectionerror"), eSQL); + } + } + + private static boolean isJavaWebStart() { + + try { + Class.forName("javax.jnlp.ServiceManager"); + return true; + } catch (ClassNotFoundException ue) { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/forms/BeanFactory.java b/src/main/java/com/unicenta/pos/forms/BeanFactory.java new file mode 100644 index 0000000..0d9bb0b --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/BeanFactory.java @@ -0,0 +1,33 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +/** + * + * @author adrianromero + */ +public interface BeanFactory { + + /** + * + * @return + */ + public Object getBean(); +} diff --git a/src/main/java/com/unicenta/pos/forms/BeanFactoryApp.java b/src/main/java/com/unicenta/pos/forms/BeanFactoryApp.java new file mode 100644 index 0000000..c6a5dcf --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/BeanFactoryApp.java @@ -0,0 +1,35 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +/** + * + * @author adrianromero + */ +public interface BeanFactoryApp extends BeanFactory { + + /** + * + * @param app + * @throws BeanFactoryException + */ + public void init(AppView app) throws BeanFactoryException; + +} diff --git a/src/main/java/com/unicenta/pos/forms/BeanFactoryCache.java b/src/main/java/com/unicenta/pos/forms/BeanFactoryCache.java new file mode 100644 index 0000000..8c693bd --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/BeanFactoryCache.java @@ -0,0 +1,56 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +/** + * + * @author adrianromero + */ +public abstract class BeanFactoryCache implements BeanFactoryApp { + + private Object bean = null; + + /** + * + * @param app + * @return + * @throws BeanFactoryException + */ + public abstract Object constructBean(AppView app) throws BeanFactoryException; + + /** + * + * @param app + * @throws BeanFactoryException + */ + @Override + public void init(AppView app) throws BeanFactoryException { + bean = constructBean(app); + } + + /** + * + * @return + */ + @Override + public Object getBean() { + return bean; + } +} diff --git a/src/main/java/com/unicenta/pos/forms/BeanFactoryData.java b/src/main/java/com/unicenta/pos/forms/BeanFactoryData.java new file mode 100644 index 0000000..12fa1a1 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/BeanFactoryData.java @@ -0,0 +1,64 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +/** + * + * @author adrianromero + */ +public class BeanFactoryData implements BeanFactoryApp { + + private BeanFactoryApp bf; + + /** Creates a new instance of BeanFactoryData */ + public BeanFactoryData() { + } + + /** + * + * @param app + * @throws BeanFactoryException + */ + @Override + public void init(AppView app) throws BeanFactoryException { + + try { + + String sfactoryname = this.getClass().getName(); + if (sfactoryname.endsWith("Create")) { + sfactoryname = sfactoryname.substring(0, sfactoryname.length() - 6); + } + bf = (BeanFactoryApp) Class.forName(sfactoryname + app.getSession().DB.getName()).newInstance(); + bf.init(app); +// JG 16 May use multicatch + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | BeanFactoryException ex) { + throw new BeanFactoryException(ex); + } + } + + /** + * + * @return + */ + @Override + public Object getBean() { + return bf.getBean(); + } +} diff --git a/src/main/java/com/unicenta/pos/forms/BeanFactoryDataSingle.java b/src/main/java/com/unicenta/pos/forms/BeanFactoryDataSingle.java new file mode 100644 index 0000000..02c92be --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/BeanFactoryDataSingle.java @@ -0,0 +1,58 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.data.loader.Session; + +/** + * + * @author adrianromero + */ +public abstract class BeanFactoryDataSingle implements BeanFactoryApp { + + /** Creates a new instance of BeanFactoryData */ + public BeanFactoryDataSingle() { + } + + /** + * + * @param s + */ + public abstract void init(Session s); + + /** + * + * @param app + * @throws BeanFactoryException + */ + @Override + public void init(AppView app) throws BeanFactoryException { + init(app.getSession()); + } + + /** + * + * @return + */ + @Override + public Object getBean() { + return this; + } +} diff --git a/src/main/java/com/unicenta/pos/forms/BeanFactoryException.java b/src/main/java/com/unicenta/pos/forms/BeanFactoryException.java new file mode 100644 index 0000000..c22b9f5 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/BeanFactoryException.java @@ -0,0 +1,50 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +/** + * + * @author adrianromero + */ +public class BeanFactoryException extends java.lang.RuntimeException { + + /** + * Creates a new instance of <code>BeanFactoryException</code> without detail message. + */ + public BeanFactoryException() { + } + + + /** + * Constructs an instance of <code>BeanFactoryException</code> with the specified detail message. + * @param msg the detail message. + */ + public BeanFactoryException(String msg) { + super(msg); + } + + /** + * + * @param e + */ + public BeanFactoryException(Throwable e) { + super(e); + } +} diff --git a/src/main/java/com/unicenta/pos/forms/BeanFactoryObj.java b/src/main/java/com/unicenta/pos/forms/BeanFactoryObj.java new file mode 100644 index 0000000..80a35fc --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/BeanFactoryObj.java @@ -0,0 +1,45 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +/** + * + * @author adrianromero + */ +public class BeanFactoryObj implements BeanFactory { + + private Object bean = null; + + /** Creates a new instance of BeanFactoryObj + * @param bean */ + public BeanFactoryObj(Object bean) { + this.bean = bean; + } + + /** + * + * @return + */ + @Override + public Object getBean() { + return bean; + } + +} diff --git a/src/main/java/com/unicenta/pos/forms/BeanFactoryScript.java b/src/main/java/com/unicenta/pos/forms/BeanFactoryScript.java new file mode 100644 index 0000000..0b19479 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/BeanFactoryScript.java @@ -0,0 +1,82 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.pos.scripting.ScriptEngine; +import com.unicenta.pos.scripting.ScriptException; +import com.unicenta.pos.scripting.ScriptFactory; +import com.unicenta.pos.util.StringUtils; +import java.io.IOException; + +/** + * + * @author adrianromero + */ +public class BeanFactoryScript implements BeanFactoryApp { + + private BeanFactory bean = null; + private String script; + + /** + * + * @param script + */ + public BeanFactoryScript(String script) { + this.script = script; + } + + /** + * + * @param app + * @throws BeanFactoryException + */ + @Override + public void init(AppView app) throws BeanFactoryException { + + // Resource + try { + ScriptEngine eng = ScriptFactory.getScriptEngine(ScriptFactory.BEANSHELL); + eng.put("app", app); + + bean = (BeanFactory) eng.eval(StringUtils.readResource(script)); + if (bean == null) { + // old definition + bean = (BeanFactory) eng.get("bean"); + } + + // todo // llamar al init del bean + if (bean instanceof BeanFactoryApp) { + ((BeanFactoryApp) bean).init(app); + } +// JG 16 May use multicatch + } catch (ScriptException | IOException e) { + throw new BeanFactoryException(e); + } + } + + /** + * + * @return + */ + @Override + public Object getBean() { + return bean.getBean(); + } +} diff --git a/src/main/java/com/unicenta/pos/forms/DataLogicOrders.java b/src/main/java/com/unicenta/pos/forms/DataLogicOrders.java new file mode 100644 index 0000000..b976723 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/DataLogicOrders.java @@ -0,0 +1,81 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.*; + +/** + * + * @author uniCenta + */ +public class DataLogicOrders extends BeanFactoryDataSingle { + private SentenceExec m_addOrder; + private SentenceExec m_resetPickup; + + /** Creates a new instance of DataLogicOrders */ + public DataLogicOrders() { + } + + /** + * + * @param s + */ + @Override + public void init(Session s){ + + m_addOrder = new StaticSentence(s + , "INSERT INTO orders (orderid, qty, details, attributes, " + + "notes, ticketid, ordertime, displayid, auxiliary, " + + "completetime) " + + "VALUES (?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ? ) " + , new SerializerWriteBasic(new Datas[] { + Datas.STRING, // OrderId + Datas.INT, // Qty + Datas.STRING, // Details + Datas.STRING, // Attributes + Datas.STRING, // Notes + Datas.STRING, // TicketId + Datas.STRING, // OrderTime + Datas.INT, // DisplayId + Datas.INT, // Auxiliary + Datas.STRING // CompleteTime + })); + + m_resetPickup = new PreparedSentence(s + , "UPDATE pickup_number SET id=1" + , SerializerWriteParams.INSTANCE); + } + + + public final void addOrder(String orderId, Integer qty, + String details, String attributes, String notes, String ticketId, + String ordertime, Integer displayId, String auxiliary, String completetime + ) throws BasicException { + + m_addOrder.exec(orderId, qty, details, attributes, notes, ticketId, + ordertime, displayId, auxiliary, completetime); + } + + public final void resetPickup() throws BasicException { + m_resetPickup.exec(); + } +} diff --git a/src/main/java/com/unicenta/pos/forms/DataLogicSales.java b/src/main/java/com/unicenta/pos/forms/DataLogicSales.java new file mode 100644 index 0000000..0712453 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/DataLogicSales.java @@ -0,0 +1,2828 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.*; +import com.unicenta.data.model.Field; +import com.unicenta.data.model.Row; +import com.unicenta.format.Formats; +import com.unicenta.pos.catalog.CategoryStock; +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.customers.CustomerTransaction; +import com.unicenta.pos.inventory.*; +import com.unicenta.pos.mant.FloorsInfo; +import com.unicenta.pos.payment.PaymentInfo; +import com.unicenta.pos.payment.PaymentInfoMagcard; +import com.unicenta.pos.payment.PaymentInfoTicket; +import com.unicenta.pos.sales.ReprintTicketInfo; +import com.unicenta.pos.suppliers.SupplierInfo; +import com.unicenta.pos.suppliers.SupplierInfoExt; +import com.unicenta.pos.ticket.*; +import com.unicenta.pos.voucher.VoucherInfo; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.Date; +import java.util.List; +import java.util.UUID; +import java.util.logging.Logger; +import java.io.File; + +/** + * + * @author adrianromero + * @author jackgerrard + */ +public class DataLogicSales extends BeanFactoryDataSingle { + + protected Session s; + + protected Datas[] auxiliarDatas; + protected Datas[] stockdiaryDatas; + protected Datas[] paymenttabledatas; + protected Datas[] stockdatas; + protected Datas[] stockAdjustDatas; + + protected Row productsRow; + protected Row customersRow; + + private String pName; + private Double getTotal; + private Double getTendered; + private String getRetMsg; + private String getVoucher; + + public static final String DEBT = "debt"; + public static final String DEBT_PAID = "debtpaid"; + protected static final String PREPAY = "prepay"; + private static final Logger logger = Logger.getLogger("com.unicenta.pos.forms.DataLogicSales"); + + private String getCardName; + protected SentenceExec m_createCat; + protected SentenceExec m_createSupp; + + protected AppView m_App; + + private AppConfig m_config; + + public DataLogicSales() { + AppView app = null; + m_config = new AppConfig(new File((System.getProperty("user.home")), AppLocal.APP_ID + ".properties")); + m_config.load(); + m_App = app; + + stockdiaryDatas = new Datas[] { + Datas.STRING, Datas.TIMESTAMP, Datas.INT, Datas.STRING, + Datas.STRING, Datas.STRING, Datas.DOUBLE, Datas.DOUBLE, + Datas.STRING, Datas.STRING, Datas.STRING}; + + paymenttabledatas = new Datas[] { + Datas.STRING, Datas.STRING, Datas.TIMESTAMP, + Datas.STRING, Datas.STRING, Datas.DOUBLE, + Datas.STRING}; + + stockdatas = new Datas[] { + Datas.STRING, Datas.STRING, Datas.STRING, + Datas.DOUBLE, Datas.DOUBLE, Datas.DOUBLE}; + + stockAdjustDatas = new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.DOUBLE}; + + auxiliarDatas = new Datas[] { + Datas.STRING, Datas.STRING, Datas.STRING, + Datas.STRING, Datas.STRING, Datas.STRING}; + + productsRow = new Row( + new Field("ID", Datas.STRING, Formats.STRING), + new Field(AppLocal.getIntString("label.prodref"), Datas.STRING, Formats.STRING, true, true, true), + new Field(AppLocal.getIntString("label.prodbarcode"), Datas.STRING, Formats.STRING, false, true, true), + new Field(AppLocal.getIntString("label.prodbarcodetype"), Datas.STRING, Formats.STRING, false, true, true), + new Field(AppLocal.getIntString("label.prodname"), Datas.STRING, Formats.STRING, true, true, true), + new Field(AppLocal.getIntString("label.prodpricebuy"), Datas.DOUBLE, Formats.CURRENCY, false, true, true), + new Field(AppLocal.getIntString("label.prodpricesell"), Datas.DOUBLE, Formats.CURRENCY, false, true, true), + new Field(AppLocal.getIntString("label.prodcategory"), Datas.STRING, Formats.STRING, false, false, true), + new Field(AppLocal.getIntString("label.taxcategory"), Datas.STRING, Formats.STRING, false, false, true), + new Field(AppLocal.getIntString("label.attributeset"), Datas.STRING, Formats.STRING, false, false, true), + new Field("STOCKCOST", Datas.DOUBLE, Formats.CURRENCY), + new Field("STOCKVOLUME", Datas.DOUBLE, Formats.DOUBLE), + new Field("IMAGE", Datas.IMAGE, Formats.NULL), + new Field("ISCOM", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("ISSCALE", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("ISCONSTANT", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("PRINTKB", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("SENDSTATUS", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("ISSERVICE", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("PROPERTIES", Datas.BYTES, Formats.NULL), + new Field(AppLocal.getIntString("label.display"), Datas.STRING, Formats.STRING, false, true, true), + new Field("ISVPRICE", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("ISVERPATRIB", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("TEXTTIP", Datas.STRING, Formats.STRING), + new Field("WARRANTY", Datas.BOOLEAN, Formats.BOOLEAN), + new Field(AppLocal.getIntString("label.stockunits"), Datas.DOUBLE, Formats.DOUBLE), + new Field("PRINTTO", Datas.STRING, Formats.STRING), + new Field(AppLocal.getIntString("label.prodsupplier"), Datas.STRING, Formats.STRING, false, false, true), + new Field(AppLocal.getIntString("label.UOM"), Datas.STRING, Formats.STRING), + new Field("MEMODATE", Datas.TIMESTAMP, Formats.DATE), + + new Field("ISCATALOG", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("CATORDER", Datas.INT, Formats.INT) + ); + +// creating customers object here for now for future global reuse +// LOYALTY, MEMBERSHIP & etc as will be more system centric than customer + + customersRow = new Row( + new Field("ID", Datas.STRING, Formats.STRING), + new Field("SEARCHKEY", Datas.STRING, Formats.STRING), + new Field("TAXID", Datas.STRING, Formats.STRING), + new Field("NAME", Datas.STRING, Formats.STRING), + new Field("TAXCATEGORY", Datas.STRING, Formats.STRING), + new Field("CARD", Datas.STRING, Formats.STRING), + new Field("MAXDEBT", Datas.DOUBLE, Formats.CURRENCY), + new Field("ADDRESS", Datas.STRING, Formats.STRING), + new Field("ADDRESS2", Datas.STRING, Formats.STRING), + new Field("POSTAL", Datas.STRING, Formats.STRING), + new Field("CITY", Datas.STRING, Formats.STRING), + new Field("REGION", Datas.STRING, Formats.STRING), + new Field("COUNTRY", Datas.STRING, Formats.STRING), + new Field("FIRSTNAME", Datas.STRING, Formats.STRING), + new Field("LASTNAME", Datas.STRING, Formats.STRING), + new Field("EMAIL", Datas.STRING, Formats.STRING), + new Field("PHONE", Datas.STRING, Formats.STRING), + new Field("PHONE2", Datas.STRING, Formats.STRING), + new Field("FAX", Datas.STRING, Formats.STRING), + new Field("NOTES", Datas.STRING, Formats.STRING), + new Field("VISIBLE", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("CURDATE", Datas.STRING, Formats.TIMESTAMP), + new Field("CURDEBT", Datas.DOUBLE, Formats.CURRENCY), + new Field("IMAGE", Datas.BYTES, Formats.NULL), + new Field("ISVIP", Datas.BOOLEAN, Formats.BOOLEAN), + new Field("DISCOUNT", Datas.DOUBLE, Formats.CURRENCY), + new Field("MEMODATE", Datas.STRING, Formats.TIMESTAMP) + ); + + } + + /** + * + * @param s + */ + @Override + public void init(Session s){ + this.s = s; + + m_createCat = new StaticSentence(s, + "INSERT INTO categories ( ID, NAME, CATSHOWNAME ) " + + "VALUES (?, ?, ?)" + , new SerializerWriteBasic(new Datas[]{ + Datas.STRING, + Datas.STRING, + Datas.BOOLEAN}) + ); + + m_createSupp = new StaticSentence(s, + "INSERT INTO suppliers ( ID, NAME, SEARCHKEY, VISIBLE ) " + + "VALUES (?, ?, ?, ?)" + , new SerializerWriteBasic(new Datas[]{ + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.BOOLEAN}) + ); + } + + // Import Creates + public final void createCategory(Object[] category) throws BasicException { + m_createCat.exec(category); + } + + public final void createSupplier(Object[] supplier) throws BasicException { + m_createSupp.exec(supplier); + } +// End Import Creates + + public final Row getProductsRow() { + return productsRow; + } + + public final Row getCustomersRow() { + return customersRow; + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public final ProductInfoExt getProductInfo(String id) throws BasicException { + return (ProductInfoExt) new PreparedSentence(s + , "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products WHERE ID = ?" + , SerializerWriteString.INSTANCE + , ProductInfoExt.getSerializerRead()).find(id); + } + + public final ProductInfoExt getProductInfoByCode(String sCode) throws BasicException { +// if (sCode.length() == 13 && (sCode.startsWith("2") || sCode.startsWith("02"))) +// return getProductInfoByShortCode(sCode); +// else { + return (ProductInfoExt) new PreparedSentence(s + , "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products WHERE CODE = ?" + , SerializerWriteString.INSTANCE + , ProductInfoExt.getSerializerRead()).find(sCode); +// } + } + + public final ProductInfoExt getProductInfoByShortCode(String sCode) throws BasicException { + + return (ProductInfoExt) new PreparedSentence(s + , "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products " + + "WHERE SUBSTRING( CODE, 3, 6 ) = ?" + , SerializerWriteString.INSTANCE + , ProductInfoExt.getSerializerRead()).find(sCode.substring(2, 8)); + } + + /* + * Important Note: + * Deliberately extracted from other code to force strict UPC-A (full 12 digits) + * Why? Because other manf' or in-store codes may exist and we just need a single + * record returned. Also, handling things this way will allow use (future) of a + * COUPON code (5 or 9 normally used) in-store + * + */ + public final ProductInfoExt getProductInfoByUShortCode(String sCode) throws BasicException { + + return (ProductInfoExt) new PreparedSentence(s + , "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products " + + "WHERE LEFT( CODE, 7 ) = ? AND CODETYPE = 'UPC-A' " +// selection of 7 digits ie: 2123456 specific to allow for other 12 digit +// codes that may be in use at positions 234567 +// last digit (position 7) can be used to identify COUPON (5 or 9) - FUTURE + , SerializerWriteString.INSTANCE + , ProductInfoExt.getSerializerRead()) + .find(sCode.substring(0, 7)); + } + + /** + * + * @param sReference + * @return + * @throws BasicException + */ + public final ProductInfoExt getProductInfoByReference(String sReference) throws BasicException { + return (ProductInfoExt) new PreparedSentence(s + , "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products WHERE REFERENCE = ?" + , SerializerWriteString.INSTANCE + , ProductInfoExt.getSerializerRead()).find(sReference); + } + + /** + * + * @return + * @throws BasicException + */ + public final List<CategoryInfo> getRootCategories() throws BasicException { + return new PreparedSentence(s + , "SELECT " + + "ID, " + + "NAME, " + + "IMAGE, " + + "TEXTTIP, " + + "CATSHOWNAME, " + + "CATORDER " + + "FROM categories " + + "WHERE PARENTID IS NULL AND CATSHOWNAME = " + s.DB.TRUE() + " " + + "ORDER BY CATORDER, NAME" + , null + , CategoryInfo.getSerializerRead()).list(); + } + + /** + * + * @param category + * @return + * @throws BasicException + */ + public final List<CategoryInfo> getSubcategories(String category) throws BasicException { + return new PreparedSentence(s + , "SELECT " + + "ID, " + + "NAME, " + + "IMAGE, " + + "TEXTTIP, " + + "CATSHOWNAME, " + + "CATORDER " + + "FROM categories WHERE PARENTID = ? " + + "ORDER BY CATORDER, NAME" + , SerializerWriteString.INSTANCE + , CategoryInfo.getSerializerRead()).list(category); + } + + /** + * + * @param category + * @return + * @throws BasicException + */ + public List<ProductInfoExt> getProductCatalog(String category) throws BasicException { + return new PreparedSentence(s + , "SELECT " + + "P.ID, " + + "P.REFERENCE, " + + "P.CODE, " + + "P.CODETYPE, " + + "P.NAME, " + + "P.PRICEBUY, " + + "P.PRICESELL, " + + "P.CATEGORY, " + + "P.TAXCAT, " + + "P.ATTRIBUTESET_ID, " + + "P.STOCKCOST, " + + "P.STOCKVOLUME, " + + "P.IMAGE, " + + "P.ISCOM, " + + "P.ISSCALE, " + + "P.ISCONSTANT, " + + "P.PRINTKB, " + + "P.SENDSTATUS, " + + "P.ISSERVICE, " + + "P.ATTRIBUTES, " + + "P.DISPLAY, " + + "P.ISVPRICE, " + + "P.ISVERPATRIB, " + + "P.TEXTTIP, " + + "P.WARRANTY, " + + "P.STOCKUNITS, " + + "P.PRINTTO, " + + "P.SUPPLIER, " + + "P.UOM, " + + "P.MEMODATE " + + "FROM products P, products_cat O " + + "WHERE P.ID = O.PRODUCT AND P.CATEGORY = ? " + + "ORDER BY O.CATORDER, P.NAME " + , SerializerWriteString.INSTANCE + , ProductInfoExt.getSerializerRead()).list(category); + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public List<ProductInfoExt> getProductComments(String id) throws BasicException { + return new PreparedSentence(s + , "SELECT " + + "P.ID, " + + "P.REFERENCE, " + + "P.CODE, " + + "P.CODETYPE, " + + "P.NAME, " + + "P.PRICEBUY, " + + "P.PRICESELL, " + + "P.CATEGORY, " + + "P.TAXCAT, " + + "P.ATTRIBUTESET_ID, " + + "P.STOCKCOST, " + + "P.STOCKVOLUME, " + + "P.IMAGE, " + + "P.ISCOM, " + + "P.ISSCALE, " + + "P.ISCONSTANT, " + + "P.PRINTKB, " + + "P.SENDSTATUS, " + + "P.ISSERVICE, " + + "P.ATTRIBUTES, " + + "P.DISPLAY, " + + "P.ISVPRICE, " + + "P.ISVERPATRIB, " + + "P.TEXTTIP, " + + "P.WARRANTY, " + + "P.STOCKUNITS, " + + "P.PRINTTO, " + + "P.SUPPLIER, " + + "P.UOM, " + + "P.MEMODATE " + + "FROM products P, " + + "products_cat O, products_com M " + + "WHERE P.ID = O.PRODUCT AND P.ID = M.PRODUCT2 AND M.PRODUCT = ? " + + "AND P.ISCOM = " + s.DB.TRUE() + " " + + "ORDER BY O.CATORDER, P.NAME" + , SerializerWriteString.INSTANCE + , ProductInfoExt.getSerializerRead()).list(id); + } + + // JG uniCenta June 2014 includes StockUnits + /** + * + * @return + * @throws BasicException + */ + public List<ProductInfoExt> getProductConstant() throws BasicException { + return new PreparedSentence(s + , "SELECT " + + "products.ID, " + + "products.REFERENCE, " + + "products.CODE, " + + "products.CODETYPE, " + + "products.NAME, " + + "products.PRICEBUY, " + + "products.PRICESELL, " + + "products.CATEGORY, " + + "products.TAXCAT, " + + "products.ATTRIBUTESET_ID, " + + "products.STOCKCOST, " + + "products.STOCKVOLUME, " + + "products.IMAGE, " + + "products.ISCOM, " + + "products.ISSCALE, " + + "products.ISCONSTANT, " + + "products.PRINTKB, " + + "products.SENDSTATUS, " + + "products.ISSERVICE, " + + "products.ATTRIBUTES, " + + "products.DISPLAY, " + + "products.ISVPRICE, " + + "products.ISVERPATRIB, " + + "products.TEXTTIP, " + + "products.WARRANTY, " + + "products.STOCKUNITS, " + + "products.PRINTTO, " + + "products.SUPPLIER, " + + "products.UOM, " + + "products.MEMODATE " + + "FROM categories INNER JOIN products ON (products.CATEGORY = categories.ID) " + + "WHERE products.ISCONSTANT = " +s.DB.TRUE()+ " " + + "ORDER BY categories.NAME, products.NAME", + null, + ProductInfoExt.getSerializerRead()).list(); + + + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public final CategoryInfo getCategoryInfo(String id) throws BasicException { + return (CategoryInfo) new PreparedSentence(s + , "SELECT " + + "ID, " + + "NAME, " + + "IMAGE, " + + "TEXTTIP, " + + "CATSHOWNAME, " + + "CATORDER " + + "FROM categories " + + "WHERE ID = ? " + + "ORDER BY CATORDER, NAME" + , SerializerWriteString.INSTANCE + , CategoryInfo.getSerializerRead()).find(id); + } + + /** + * JG Dec 2017 + * @param pId + * @return + * @throws BasicException + */ + @SuppressWarnings("unchecked") + public final List<CategoryStock> getCategorysProductList(String pId) throws BasicException { + return new PreparedSentence(s, + "SELECT products.ID, " + + "products.NAME AS Name, " + + "products.CODE AS Barcode, " + + "categories.ID AS Category " + + "FROM products products " + + "INNER JOIN categories categories ON (products.CATEGORY = categories.ID) " + + "WHERE products.category = ? " + + "ORDER BY products.NAME ASC", + SerializerWriteString.INSTANCE, + CategoryStock.getSerializerRead()).list(pId); + } + + /** + * + * @return + */ + + public final SentenceList getProductList() { + return new StaticSentence(s + , new QBFBuilder( + "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products " + + "WHERE ?(QBF_FILTER) " + + "ORDER BY REFERENCE", + new String[] {"NAME", "PRICEBUY", "PRICESELL", "CATEGORY", "CODE"}) + , new SerializerWriteBasic(new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING}) + , ProductInfoExt.getSerializerRead()); + } + + /** + * + * @return + */ + public SentenceList getProductListNormal() { + return new StaticSentence(s + , new QBFBuilder( + "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products " + + "WHERE ISCOM = " + s.DB.FALSE() + " AND ?(QBF_FILTER) ORDER BY REFERENCE", + new String[] {"NAME", "PRICEBUY", "PRICESELL", "CATEGORY", "CODE"}) + , new SerializerWriteBasic(new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING}) + , ProductInfoExt.getSerializerRead()); + } + + /** + * + * @return + */ + public SentenceList getProductsList() { + return new StaticSentence(s + , "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products " + + "ORDER BY NAME" + , null + , ProductInfo.getSerializerRead()); + } + + public SentenceList getProductList2() { + return new StaticSentence(s + , new QBFBuilder( + "SELECT " + + "products.id, " + + "products.name, " + + "stockcurrent.units, " + + "locations.name, " + + "products.pricesell, " + + "taxes.rate, " + + "products.pricesell + (products.pricesell * taxes.rate) AS SellIncTax " + + " FROM (((stockcurrent stockcurrent " + + "INNER JOIN locations locations " + + "ON (stockcurrent.location = locations.id)) " + + "INNER JOIN products products " + + "ON (stockcurrent.product = products.id)) " + + "INNER JOIN taxcategories taxcategories " + + "ON (products.taxcat = taxcategories.id)) " + + "INNER JOIN taxes taxes " + + "ON (taxes.category = taxcategories.id) " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY products.name ", + new String[] {"NAME", "UNITS", "SellIncTax", "LOCATION",}) + , new SerializerWriteBasic(new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.STRING}) + , ProductInfoExt.getSerializerRead()); + } + + /** + * + * @return + */ + public SentenceList getProductListAuxiliar() { + return new StaticSentence(s + , new QBFBuilder( + "SELECT " + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE " + + "FROM products " + + "WHERE ISCOM = " + s.DB.TRUE() + " AND ?(QBF_FILTER) " + + "ORDER BY REFERENCE", new String[] {"NAME", "PRICEBUY", "PRICESELL", "CATEGORY", "CODE"}) + , new SerializerWriteBasic(new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING}) + , ProductInfoExt.getSerializerRead()); + } + + /** + * + * @param productId The product id to look for bundle + * @return List of products part of the searched product + * @throws BasicException + */ + public final List<ProductsBundleInfo> getProductsBundle(String productId) throws BasicException { + return new PreparedSentence(s + , "SELECT " + + "ID, " + + "PRODUCT, " + + "PRODUCT_BUNDLE, " + + "QUANTITY " + + "FROM products_bundle WHERE PRODUCT = ?" + , SerializerWriteString.INSTANCE + , ProductsBundleInfo.getSerializerRead()).list(productId); + } + + /** + * JG Oct 2016 + * Called from JPanelTicket + * @param pId + * @param location + * @return + * @throws BasicException + */ + public final ProductStock getProductStockState(String pId, String location) throws BasicException { + + PreparedSentence preparedSentence = new PreparedSentence(s, + "SELECT " + + "MIN(products.id), " + + "locations.id as Location, " + + "MIN(stockcurrent.units), " + + "MIN(stocklevel.stocksecurity) AS Minimum, " + + "MIN(stocklevel.stockmaximum) AS Maximum, " + + "MIN(products.pricebuy), " + + "MIN(products.pricesell), " + + "MIN(products.memodate) " + + "FROM locations " + + "INNER JOIN ((products " + + "INNER JOIN stockcurrent " + + "ON products.id = stockcurrent.product) " + + "LEFT JOIN stocklevel ON products.id = stocklevel.product) " + + "ON locations.id = stockcurrent.location " + + "WHERE products.id = ? " + + "AND locations.id = ?" + , SerializerWriteString.INSTANCE + , ProductStock.getSerializerRead()); + + ProductStock productStock = (ProductStock) preparedSentence.find(pId, location); + + return productStock; + } + + /** + * JG May 2016 + * Called from StockManagement + * @param pId + * @return + * @throws BasicException + */ + @SuppressWarnings("unchecked") + public final List<ProductStock> getProductStockList(String pId) throws BasicException { + return new PreparedSentence(s, + "SELECT MIN(products.id), " + + "MIN(locations.name) AS Location, " + + "MIN(stockcurrent.units) AS stockcurrent, " + + "MIN(stocklevel.stocksecurity) AS Minimum, " + + "MIN(stocklevel.stockmaximum) AS Maximum, " + + "MIN(products.pricebuy) AS PriceBuy, " + + "(MIN(products.pricesell) * MIN(taxes.rate)) + MIN(products.pricesell) AS PriceSell, " + + "MIN(products.memodate) " + + "FROM ((((taxcategories TC " + + "INNER JOIN taxes taxes " + + "ON (TC.id = taxes.category)) " + + "RIGHT OUTER JOIN products products " + + "ON (products.TAXCAT = TC.id)) " + + "LEFT OUTER JOIN stocklevel stocklevel " + + "ON (stocklevel.product = products.ID)) " + + "LEFT OUTER JOIN stockcurrent stockcurrent " + + "ON (products.ID = stockcurrent.product)) " + + "INNER JOIN locations locations " + + "ON (stockcurrent.location = locations.id) " + + "WHERE products.id= ? " + + "GROUP BY locations.name", + SerializerWriteString.INSTANCE, + ProductStock.getSerializerRead()).list(pId); + } + + /** + * JG Sept 2017 + * @return + * @throws BasicException + */ + @SuppressWarnings("unchecked") + public final List<ReprintTicketInfo> getReprintTicketList() throws BasicException { + + //payment queries + List<ReprintTicketInfo> ticketInfoList = (List<ReprintTicketInfo>) new StaticSentence(s + , "SELECT " + + "T.TICKETID, " + + "T.TICKETTYPE, " + + "R.DATENEW, " + + "P.NAME, " + + "C.NAME, " + + "SUM(PM.TOTAL), " + + "T.STATUS " + + "FROM receipts " + + "R JOIN tickets T ON R.ID = T.ID LEFT OUTER JOIN payments PM " + + "ON R.ID = PM.RECEIPT LEFT OUTER JOIN customers C " + + "ON C.ID = T.CUSTOMER LEFT OUTER JOIN people P ON T.PERSON = P.ID " + + "GROUP BY " + + "T.ID, " + + "T.TICKETID, " + + "T.TICKETTYPE, " + + "R.DATENEW, " + + "P.NAME, " + + "C.NAME " + + "ORDER BY R.DATENEW DESC, T.TICKETID " + + "LIMIT 10 " + , null + , new SerializerReadClass(ReprintTicketInfo.class)).list(); + + return ticketInfoList; + } + + /** + * + * @param Id + * @return + * @throws BasicException + */ + public final TicketInfo getReprintTicket(String Id) throws BasicException { + + //payment queries + + if (Id == null) { + return null; + } else { + Object[]record = (Object[]) new StaticSentence(s + , "SELECT " + + "T.TICKETID, " + + "SUM(PM.TOTAL), " + + "R.DATENEW, " + + "P.NAME, " + + "T.TICKETTYPE, " + + "C.NAME, " + + "T.STATUS " + + "FROM receipts R " + + "JOIN tickets T ON R.ID = T.ID LEFT OUTER JOIN payments PM " + + "ON R.ID = PM.RECEIPT LEFT OUTER JOIN customers C " + + "ON C.ID = T.CUSTOMER LEFT OUTER JOIN people P ON T.PERSON = P.ID " + + "WHERE T.TICKETID = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[] {Datas.SERIALIZABLE})).find(Id); + return record == null ? null : (TicketInfo) record[0]; + } + } + + //Tickets and Receipt list + + // Payment queries + public SentenceList getTicketsList() { + + + StaticSentence staticSentence = new StaticSentence(s + , new QBFBuilder( + "SELECT " + + "T.TICKETID, " + + "T.TICKETTYPE, " + + "R.DATENEW, " + + "P.NAME, " + + "C.NAME, " + + "SUM(PM.TOTAL), " + + "SUM(T.STATUS), " + + "PM.notes " + + "FROM receipts R " + + "JOIN tickets T ON R.ID = T.ID LEFT OUTER JOIN payments PM " + + "ON R.ID = PM.RECEIPT LEFT OUTER JOIN customers C " + + "ON C.ID = T.CUSTOMER LEFT OUTER JOIN people P ON T.PERSON = P.ID " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY T.ID, T.TICKETID, T.TICKETTYPE, R.DATENEW, P.NAME, C.NAME, PM.notes " + + "ORDER BY R.DATENEW DESC, T.TICKETID", + new String[]{ + "T.TICKETID", "T.TICKETTYPE", "PM.TOTAL", "R.DATENEW", "R.DATENEW", "P.NAME", "C.NAME", "PM.NOTES"}) + , new SerializerWriteBasic(new Datas[]{ + Datas.OBJECT, Datas.INT, + Datas.OBJECT, Datas.INT, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.TIMESTAMP, + Datas.OBJECT, Datas.TIMESTAMP, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING}) + , new SerializerReadClass(FindTicketsInfo.class)); + + return staticSentence; + } + + //User list + + /** + * + * @return + */ + public final SentenceList getUserList() { + return new StaticSentence(s + , "SELECT " + + "ID, " + + "NAME " + + "FROM people " + + "ORDER BY NAME" + , null + , (DataRead dr) -> new TaxCategoryInfo( + dr.getString(1), + dr.getString(2))); + } + + /** + * + * @return + */ + public final SentenceList getTaxList() { + return new StaticSentence(s + , "SELECT " + + "ID, " + + "NAME, " + + "CATEGORY, " + + "CUSTCATEGORY, " + + "PARENTID, " + + "RATE, " + + "RATECASCADE, " + + "RATEORDER " + + "FROM taxes " + + "ORDER BY NAME" + , null + , (DataRead dr) -> new TaxInfo( + dr.getString(1), + dr.getString(2), + dr.getString(3), + dr.getString(4), + dr.getString(5), + dr.getDouble(6), + dr.getBoolean(7), + dr.getInt(8))); + } + + /** + * + * @return + */ + public final SentenceList getCategoriesList() { + return new StaticSentence(s + , "SELECT " + + "ID, " + + "NAME, " + + "IMAGE, " + + "TEXTTIP, " + + "CATSHOWNAME, " + + "CATORDER " + + "FROM categories " + + "ORDER BY NAME" + , null + , CategoryInfo.getSerializerRead()); + } + /** + * JG Feb 2017 + * Returns all PARENT categories + * @return + */ + public final SentenceList getCategoriesList_1() { + return new StaticSentence(s + , "SELECT " + + "ID, " + + "NAME, " + + "IMAGE, " + + "TEXTTIP, " + + "CATSHOWNAME, " + + "CATORDER " + + "FROM categories " + + "WHERE PARENTID IS NULL " + + "ORDER BY NAME" + , null + , CategoryInfo.getSerializerRead()); + } + /** + * + * @return + */ + public final SentenceList getSuppList() { + return new StaticSentence(s + , "SELECT " + + "ID, " + + "SEARCHKEY, " + + "NAME " + + "FROM suppliers " + + "ORDER BY NAME" + , null + , (DataRead dr) -> new SupplierInfo( + dr.getString(1), + dr.getString(2), + dr.getString(3))); + } + + /** + * + * @return + */ + public final SentenceList getTaxCustCategoriesList() { + return new StaticSentence(s + , "SELECT " + + "ID, " + + "NAME " + + "FROM taxcustcategories " + + "ORDER BY NAME" + , null + , (DataRead dr) -> new TaxCustCategoryInfo( + dr.getString(1), + dr.getString(2))); + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public final CustomerInfoExt getCustomerInfo(String id) throws BasicException { + return (CustomerInfoExt) new PreparedSentence(s + , "SELECT " + + "ID, " + + "SEARCHKEY, " + + "TAXID, " + + "NAME, " + + "TAXCATEGORY, " + + "CARD, " + + "MAXDEBT, " + + "ADDRESS, " + + "ADDRESS2, " + + "POSTAL, " + + "CITY, " + + "REGION, " + + "COUNTRY, " + + "FIRSTNAME, " + + "LASTNAME, " + + "EMAIL, " + + "PHONE, " + + "PHONE2, " + + "FAX, " + + "NOTES, " + + "VISIBLE, " + + "CURDATE, " + + "CURDEBT, " + + "IMAGE, " + + "ISVIP, " + + "DISCOUNT, " + + "MEMODATE " + + "FROM customers WHERE ID = ?" + , SerializerWriteString.INSTANCE + , new CustomerExtRead()).find(id); + } + + /** + * JG Apr 2017 - Revised to return Customer Id - cId param + * @param cId + * @return + * @throws BasicException + */ + @SuppressWarnings("unchecked") + public final List<CustomerTransaction> getCustomersTransactionList(String cId) throws BasicException { + + return new PreparedSentence(s, + "SELECT tickets.TICKETID, " + + "products.NAME AS PNAME, " + + "SUM(ticketlines.UNITS) AS UNITS, " + + "SUM(ticketlines.UNITS * ticketlines.PRICE) AS AMOUNT, " + + "SUM(ticketlines.UNITS * ticketlines.PRICE * (1.0 + taxes.RATE)) AS TOTAL, " + + "receipts.DATENEW, " + + "customers.ID AS CID " + + "FROM ((((ticketlines ticketlines " + + "CROSS JOIN taxes taxes ON (ticketlines.TAXID = taxes.ID)) " + + "INNER JOIN tickets tickets ON (tickets.ID = ticketlines.TICKET)) " + + "INNER JOIN customers customers ON (customers.ID = tickets.CUSTOMER)) " + + "INNER JOIN receipts receipts ON (tickets.ID = receipts.ID)) " + + "LEFT OUTER JOIN products products ON (ticketlines.PRODUCT = products.ID) " + + "WHERE tickets.CUSTOMER = ? " + + "GROUP BY customers.ID, receipts.DATENEW, tickets.TICKETID, " + + "products.NAME, tickets.TICKETTYPE " + + "ORDER BY receipts.DATENEW DESC", + SerializerWriteString.INSTANCE, + CustomerTransaction.getSerializerRead()).list(cId); + } + + /** + * + * @return + */ + public final SentenceList getTaxCategoriesList() { + return new StaticSentence(s + , "SELECT " + + "ID, " + + "NAME " + + "FROM taxcategories " + + "ORDER BY NAME" + , null + , (DataRead dr) -> new TaxCategoryInfo(dr.getString(1), dr.getString(2))); + } + + /** + * + * @return + */ + public final SentenceList getAttributeSetList() { + return new StaticSentence(s + , "SELECT " + + "ID, " + + "NAME " + + "FROM attributeset " + + "ORDER BY NAME" + , null + , (DataRead dr) -> new AttributeSetInfo(dr.getString(1), dr.getString(2))); + } + + /** + * + * @return + */ + public final SentenceList getLocationsList() { + return new StaticSentence(s + , "SELECT " + + "ID, " + + "NAME, " + + "ADDRESS FROM locations " + + "ORDER BY NAME" + , null + , new SerializerReadClass(LocationInfo.class)); + } + + /** + * + * @return + */ + public final SentenceList getFloorsList() { + return new StaticSentence(s + , "SELECT ID, NAME FROM floors ORDER BY NAME" + , null + , new SerializerReadClass(FloorsInfo.class)); + } + /** + * + * @return + */ + public final SentenceList getFloorTablesList() { + return new StaticSentence(s + , "SELECT ID, NAME, SEATS, width, height FROM places ORDER BY NAME" + , null + , new SerializerReadClass(FloorsInfo.class)); + } + + + /** + * + * @param card + * @return + * @throws BasicException + */ + public CustomerInfoExt findCustomerExt(String card) throws BasicException { + return (CustomerInfoExt) new PreparedSentence(s + , "SELECT " + + "ID, " + + "TAXID, " + + "SEARCHKEY, " + + "NAME, " + + "TAXCATEGORY, " + + "CARD, " + + "MAXDEBT, " + + "ADDRESS, " + + "ADDRESS2, " + + "POSTAL, " + + "CITY, " + + "REGION, " + + "COUNTRY, " + + "FIRSTNAME, " + + "LASTNAME, " + + "EMAIL, " + + "PHONE, " + + "PHONE2, " + + "FAX, " + + "NOTES, " + + "VISIBLE, " + + "CURDATE, " + + "CURDEBT, " + + "IMAGE, " + + "ISVIP, " + + "DISCOUNT, " + + "MEMODATE " + + "FROM customers " + + "WHERE CARD = ? AND VISIBLE = " + s.DB.TRUE() + " " + + "ORDER BY NAME" + , SerializerWriteString.INSTANCE + , new CustomerExtRead()).find(card); + } + /** + * + * @param name + * @return + * @throws BasicException + */ + public CustomerInfoExt findCustomerName(String name) throws BasicException { + return (CustomerInfoExt) new PreparedSentence(s + , "SELECT " + + "ID, " + + "SEARCHKEY, " + + "TAXID, " + + "NAME, " + + "TAXCATEGORY, " + + "CARD, " + + "MAXDEBT, " + + "ADDRESS, " + + "ADDRESS2, " + + "POSTAL, " + + "CITY, " + + "REGION, " + + "COUNTRY, " + + "FIRSTNAME, " + + "LASTNAME, " + + "EMAIL, " + + "PHONE, " + + "PHONE2, " + + "FAX, " + + "NOTES, " + + "VISIBLE, " + + "CURDATE, " + + "CURDEBT, " + + "IMAGE, " + + "ISVIP, " + + "DISCOUNT, " + + "MEMODATE " + + "FROM customers " + + "WHERE NAME = ? AND VISIBLE = " + s.DB.TRUE() + " " + + "ORDER BY NAME" + , SerializerWriteString.INSTANCE + , new CustomerExtRead()).find(name); + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public CustomerInfoExt loadCustomerExt(String id) throws BasicException { + return (CustomerInfoExt) new PreparedSentence(s + , "SELECT " + + "ID, " + + "SEARCHKEY, " + + "TAXID, " + + "NAME, " + + "TAXCATEGORY, " + + "CARD, " + + "MAXDEBT, " + + "ADDRESS, " + + "ADDRESS2, " + + "POSTAL, " + + "CITY, " + + "REGION, " + + "COUNTRY, " + + "FIRSTNAME, " + + "LASTNAME, " + + "EMAIL, " + + "PHONE, " + + "PHONE2, " + + "FAX, " + + "NOTES, " + + "VISIBLE, " + + "CURDATE, " + + "CURDEBT, " + + "IMAGE, " + + "ISVIP, " + + "DISCOUNT, " + + "MEMODATE " + + "FROM customers WHERE ID = ?" + , SerializerWriteString.INSTANCE + , new CustomerExtRead()).find(id); + } + + /** + * Quick Customer create + * @param id + * @return + * @throws BasicException + */ + public CustomerInfoExt qCustomerExt(String id) throws BasicException { + return (CustomerInfoExt) new PreparedSentence(s + , "SELECT " + + "ID, " + + "SEARCHKEY, " + + "TAXID, " + + "NAME, " + + "TAXCATEGORY, " + + "MAXDEBT, " + + "FIRSTNAME, " + + "LASTNAME, " + + "EMAIL, " + + "PHONE, " + + "PHONE2, " + + "ISVIP, " + + "DISCOUNT " + + "FROM customers WHERE ID = ?" + , SerializerWriteString.INSTANCE + , new CustomerExtRead()).find(id); + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public final boolean isCashActive(String id) throws BasicException { + + return new PreparedSentence(s, + "SELECT MONEY FROM closedcash WHERE DATEEND IS NULL AND MONEY = ?", + SerializerWriteString.INSTANCE, + SerializerReadString.INSTANCE).find(id) + != null; + } + + /** + * + * @param tickettype + * @param ticketid + * @return + * @throws BasicException + */ + public final TicketInfo loadTicket(final int tickettype, final int ticketid) throws BasicException { + TicketInfo ticket = (TicketInfo) new PreparedSentence(s + , "SELECT " + + "T.ID, " + + "T.TICKETTYPE, " + + "T.TICKETID, " + + "R.DATENEW, " + + "R.MONEY, " + + "R.ATTRIBUTES, " + + "P.ID, " + + "P.NAME, " + + "T.CUSTOMER, " + + "T.STATUS " + + "FROM receipts R " + + "JOIN tickets T ON R.ID = T.ID " + + "LEFT OUTER JOIN people P ON T.PERSON = P.ID " + + "WHERE T.TICKETTYPE = ? AND T.TICKETID = ? " + + "ORDER BY R.DATENEW DESC" + , SerializerWriteParams.INSTANCE + , new SerializerReadClass(TicketInfo.class)) + .find(new DataParams() { + @Override + public void writeValues() throws BasicException { + setInt(1, tickettype); + setInt(2, ticketid); + }}); + + if (ticket != null) { + + String customerid = ticket.getCustomerId(); + ticket.setCustomer(customerid == null + ? null + : loadCustomerExt(customerid)); + + ticket.setLines(new PreparedSentence(s + , "SELECT L.TICKET, L.LINE, L.PRODUCT, L.ATTRIBUTESETINSTANCE_ID, " + + "L.UNITS, L.PRICE, T.ID, T.NAME, T.CATEGORY, T.CUSTCATEGORY, " + + "T.PARENTID, T.RATE, T.RATECASCADE, T.RATEORDER, L.ATTRIBUTES " + + "FROM ticketlines L, taxes T " + + "WHERE L.TAXID = T.ID AND L.TICKET = ? ORDER BY L.LINE" + , SerializerWriteString.INSTANCE + , new SerializerReadClass(TicketLineInfo.class)).list(ticket.getId())); + + ticket.setPayments(new PreparedSentence(s + , "SELECT PAYMENT, TOTAL, TRANSID, TENDERED, CARDNAME FROM payments WHERE RECEIPT = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadClass(PaymentInfoTicket.class)).list(ticket.getId())); + } + return ticket; + } + + /** + * + * @param ticket + * @param location + * @throws BasicException + */ + public final void saveTicket(final TicketInfo ticket, final String location) throws BasicException { + + Transaction t; + t = new Transaction(s) { + @Override + public Object transact() throws BasicException { + + // Set Receipt Id + if (ticket.getTicketId() == 0) { + switch (ticket.getTicketType()) { + case TicketInfo.RECEIPT_NORMAL: + ticket.setTicketId(getNextTicketIndex()); + break; + case TicketInfo.RECEIPT_REFUND: + ticket.setTicketId(getNextTicketRefundIndex()); + break; + case TicketInfo.RECEIPT_PAYMENT: + ticket.setTicketId(getNextTicketPaymentIndex()); + break; + case TicketInfo.RECEIPT_NOSALE: + ticket.setTicketId(getNextTicketPaymentIndex()); + break; + default: + throw new BasicException(); + } + } + + new PreparedSentence(s + , "INSERT INTO receipts (ID, MONEY, DATENEW, ATTRIBUTES, PERSON) VALUES (?, ?, ?, ?, ?)" + , SerializerWriteParams.INSTANCE ) + .exec(new DataParams() { + + @Override + public void writeValues() throws BasicException { + setString(1, ticket.getId()); + setString(2, ticket.getActiveCash()); + setTimestamp(3, ticket.getDate()); + + try { + ByteArrayOutputStream o = new ByteArrayOutputStream(); + ticket.getProperties().storeToXML(o, AppLocal.APP_NAME, "UTF-8"); + setBytes(4, o.toByteArray()); + } catch (IOException e) { + setBytes(4, null); + } + setString(5, ticket.getProperty("person")); + } + }); + + // new ticket + new PreparedSentence(s + , "INSERT INTO tickets (ID, TICKETTYPE, TICKETID, PERSON, CUSTOMER, STATUS) " + + "VALUES (?, ?, ?, ?, ?, ?)" + , SerializerWriteParams.INSTANCE ) + .exec(new DataParams() { + + @Override + public void writeValues() throws BasicException { + setString(1, ticket.getId()); + setInt(2, ticket.getTicketType()); + setInt(3, ticket.getTicketId()); + setString(4, ticket.getUser().getId()); + setString(5, ticket.getCustomerId()); + setInt(6, ticket.getTicketStatus()); + } + }); + + // update status of existing ticket + new PreparedSentence(s + , "UPDATE tickets SET STATUS = ? " + + "WHERE TICKETTYPE = 0 AND TICKETID = ?" + , SerializerWriteParams.INSTANCE ) + .exec(new DataParams() { + + @Override + public void writeValues() throws BasicException { + setInt(1, ticket.getTicketId()); + setInt(2, ticket.getTicketStatus()); + } + }); + + SentenceExec ticketlineinsert = new PreparedSentence(s + , "INSERT INTO ticketlines (TICKET, LINE, " + + "PRODUCT, ATTRIBUTESETINSTANCE_ID, " + + "UNITS, PRICE, TAXID, ATTRIBUTES) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?)" + , SerializerWriteBuilder.INSTANCE); + + for (TicketLineInfo l : ticket.getLines()) { + ticketlineinsert.exec(l); + + if (l.getProductID() != null && l.isProductService() != true) { + getStockDiaryInsert().exec(new Object[] { + UUID.randomUUID().toString(), + ticket.getDate(), + l.getMultiply() < 0.0 + ? MovementReason.IN_REFUND.getKey() + : MovementReason.OUT_SALE.getKey(), + location, + l.getProductID(), + l.getProductAttSetInstId(), -l.getMultiply(), l.getPrice(), + ticket.getUser().getName() + }); + } + } + + final Payments payments = new Payments(); + SentenceExec paymentinsert = new PreparedSentence(s + , "INSERT INTO payments (ID, RECEIPT, PAYMENT, TOTAL, TRANSID, RETURNMSG, " + + "TENDERED, CARDNAME, VOUCHER, NOTES) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" + , SerializerWriteParams.INSTANCE); + + ticket.getPayments().forEach((p) -> { + if (p instanceof PaymentInfoMagcard) { + payments.addPayment(p.getName(),p.getTotal(), p.getPaid(),ticket.getReturnMessage(), p.getVoucher(), ((PaymentInfoMagcard) p).getLastFourDigits()); + }else { + payments.addPayment(p.getName(),p.getTotal(), p.getPaid(),ticket.getReturnMessage(), p.getVoucher(), null); + } + + }); + while (payments.getSize()>=1){ + paymentinsert.exec(new DataParams() { + @Override + public void writeValues() throws BasicException { + pName = payments.getFirstElement(); + getTotal = payments.getPaidAmount(pName); + getTendered = payments.getTendered(pName); + getRetMsg = payments.getRtnMessage(pName); + + if (pName.contains("voucher")) { + getVoucher = payments.getVoucher(pName); + } + payments.removeFirst(pName); + + setString(1, UUID.randomUUID().toString()); + setString(2, ticket.getId()); + setString(3, pName); + setDouble(4, getTotal); + setString(5, ticket.getTransactionID()); + setBytes(6, (byte[]) Formats.BYTEA.parseValue(getRetMsg)); + setDouble(7, getTendered); + setString(8, getCardName); + setString(9, getVoucher); + setString(10, payments.getNote(pName)); + payments.removeFirst(pName); + } + }); + + if (pName.contains("voucher")) { + getVoucherNonActive().exec(payments.getVoucher(pName)); + } + + if ("debt".equals(pName) || "debtpaid".equals(pName)) { + ticket.getCustomer().updateCurDebt(getTotal, ticket.getDate()); + getDebtUpdate().exec(new DataParams() { + + @Override + public void writeValues() throws BasicException { + setDouble(1, ticket.getCustomer().getAccdebt()); + setTimestamp(2, ticket.getCustomer().getCurdate()); + setString(3, ticket.getCustomer().getId()); + } + }); + } + } + + SentenceExec taxlinesinsert = new PreparedSentence(s + , "INSERT INTO taxlines (ID, RECEIPT, TAXID, BASE, AMOUNT) " + + "VALUES (?, ?, ?, ?, ?)" + , SerializerWriteParams.INSTANCE); + + if (ticket.getTaxes() != null) { + for (final TicketTaxInfo tickettax: ticket.getTaxes()) { + taxlinesinsert.exec(new DataParams() { + @Override + public void writeValues() throws BasicException { + setString(1, UUID.randomUUID().toString()); + setString(2, ticket.getId()); + setString(3, tickettax.getTaxInfo().getId()); + setDouble(4, tickettax.getSubTotal()); + setDouble(5, tickettax.getTax()); + } + }); + } + } + return null; + } + }; + + t.execute(); + } + + /** + * + * @param ticket + * @param location + * @throws BasicException + */ + public final void deleteTicket(final TicketInfo ticket, final String location) throws BasicException { + + Transaction t; + t = new Transaction(s) { + @Override + public Object transact() throws BasicException { + + // update the inventory + Date d = new Date(); + for (int i = 0; i < ticket.getLinesCount(); i++) { + if (ticket.getLine(i).getProductID() != null) { + // Hay que actualizar el stock si el hay producto + getStockDiaryInsert().exec( new Object[] { + UUID.randomUUID().toString(), + d, + ticket.getLine(i).getMultiply() >= 0.0 + ? MovementReason.IN_REFUND.getKey() + : MovementReason.OUT_SALE.getKey(), + location, + ticket.getLine(i).getProductID(), + ticket.getLine(i).getProductAttSetInstId(), ticket.getLine(i).getMultiply(), ticket.getLine(i).getPrice(), + ticket.getUser().getName() + }); + } +// For productBundle + List<ProductsBundleInfo> bundle = getProductsBundle((String)ticket.getLine(i).getProductID()); + + if (bundle.size() > 0) { + for (ProductsBundleInfo bundleComponent : bundle) { + ProductInfoExt bundleProduct = getProductInfo(bundleComponent.getProductBundleId()); + + getStockDiaryInsert().exec(new Object[]{ + UUID.randomUUID().toString(), + d, + ticket.getLine(i).getMultiply() * bundleComponent.getQuantity() >= 0.0 + ? MovementReason.IN_REFUND.getKey() + : MovementReason.OUT_SALE.getKey(), + location, + bundleComponent.getProductBundleId(), + null, ticket.getLine(i).getMultiply() * bundleComponent.getQuantity() + , bundleProduct.getPriceSell(), + ticket.getUser().getName()}); + } + } + } + + // update customer debts + for (PaymentInfo p : ticket.getPayments()) { + if ("debt".equals(p.getName()) || "debtpaid".equals(p.getName())) { + + // udate customer fields... + ticket.getCustomer().updateCurDebt(-p.getTotal(), ticket.getDate()); + + // save customer fields... + getDebtUpdate().exec(new DataParams() { + @Override + public void writeValues() throws BasicException { + setDouble(1, ticket.getCustomer().getAccdebt()); + setTimestamp(2, ticket.getCustomer().getCurdate()); + setString(3, ticket.getCustomer().getId()); + }}); + } + } + + // and delete the receipt + new StaticSentence(s + , "DELETE FROM taxlines WHERE RECEIPT = ?" + , SerializerWriteString.INSTANCE).exec(ticket.getId()); + new StaticSentence(s + , "DELETE FROM payments WHERE RECEIPT = ?" + , SerializerWriteString.INSTANCE).exec(ticket.getId()); + new StaticSentence(s + , "DELETE FROM ticketlines WHERE TICKET = ?" + , SerializerWriteString.INSTANCE).exec(ticket.getId()); + new StaticSentence(s + , "DELETE FROM tickets WHERE ID = ?" + , SerializerWriteString.INSTANCE).exec(ticket.getId()); + new StaticSentence(s + , "DELETE FROM receipts WHERE ID = ?" + , SerializerWriteString.INSTANCE).exec(ticket.getId()); + return null; + } + }; + t.execute(); + } + + /** + * + * @return + * @throws BasicException + */ + public final Integer getNextPickupIndex() throws BasicException { + return (Integer) s.DB.getSequenceSentence(s, "pickup_number").find(); + } + + /** + * + * @return + * @throws BasicException + */ + public final Integer getNextTicketIndex() throws BasicException { + return (Integer) s.DB.getSequenceSentence(s, "ticketsnum").find(); + } + + /** + * + * @return + * @throws BasicException + */ + public final Integer getNextTicketRefundIndex() throws BasicException { + return (Integer) s.DB.getSequenceSentence(s, "ticketsnum_refund").find(); + } + + /** + * + * @return + * @throws BasicException + */ + public final Integer getNextTicketPaymentIndex() throws BasicException { + return (Integer) s.DB.getSequenceSentence(s, "ticketsnum_payment").find(); + } + + // JG 3 Feb 16 - Product load speedup + public final SentenceFind getProductImage() { + return new PreparedSentence(s, + "SELECT IMAGE FROM products WHERE ID = ?", + SerializerWriteString.INSTANCE + , (DataRead dr) -> ImageUtils.readImage(dr.getBytes(1))); + } + + /** + * Loads on ProductsEditor + * @return + */ + public final SentenceList getProductCatQBF() { + return new StaticSentence(s + , new QBFBuilder( + "SELECT " + + "P.ID, " + + "P.REFERENCE, " + + "P.CODE, " + + "P.CODETYPE, " + + "P.NAME, " + + "P.PRICEBUY, " + + "P.PRICESELL, " + + "P.CATEGORY, " + + "P.TAXCAT, " + + "P.ATTRIBUTESET_ID, " + + "P.STOCKCOST, " + + "P.STOCKVOLUME, " +// JG 3 feb 16 speedup + "P.IMAGE, " + + s.DB.CHAR_NULL() + "," + + "P.ISCOM, " + + "P.ISSCALE, " + + "P.ISCONSTANT, " + + "P.PRINTKB, " + + "P.SENDSTATUS, " + + "P.ISSERVICE, " + + "P.ATTRIBUTES, " + + "P.DISPLAY, " + + "P.ISVPRICE, " + + "P.ISVERPATRIB, " + + "P.TEXTTIP, " + + "P.WARRANTY, " + + "P.STOCKUNITS, " + + "P.PRINTTO, " + + "P.SUPPLIER, " + + "P.UOM, " + + "P.MEMODATE, " + + "CASE WHEN " + + "C.PRODUCT IS NULL " + + "THEN " + s.DB.FALSE() + + " ELSE " + s.DB.TRUE() + + " END, " + + "C.CATORDER " + + "FROM products P LEFT OUTER JOIN products_cat C " + + "ON P.ID = C.PRODUCT " + + "WHERE ?(QBF_FILTER) " + + "ORDER BY P.REFERENCE", + new String[] { + "P.NAME", "P.PRICEBUY", "P.PRICESELL", "P.CATEGORY", "P.CODE"}) + , new SerializerWriteBasic(new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING}) + , productsRow.getSerializerRead()); + } + + /** + * + * @return + */ + + public final SentenceExec getProductCatInsert() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + Object[] values = (Object[]) params; + int i = new PreparedSentence(s + , "INSERT INTO products (" + + "ID, " + + "REFERENCE, " + + "CODE, " + + "CODETYPE, " + + "NAME, " + + "PRICEBUY, " + + "PRICESELL, " + + "CATEGORY, " + + "TAXCAT, " + + "ATTRIBUTESET_ID, " + + "STOCKCOST, " + + "STOCKVOLUME, " + + "IMAGE, " + + "ISCOM, " + + "ISSCALE, " + + "ISCONSTANT, " + + "PRINTKB, " + + "SENDSTATUS, " + + "ISSERVICE, " + + "ATTRIBUTES, " + + "DISPLAY, " + + "ISVPRICE, " + + "ISVERPATRIB, " + + "TEXTTIP, " + + "WARRANTY, " + + "STOCKUNITS, " + + "PRINTTO, " + + "SUPPLIER, " + + "UOM, " + + "MEMODATE ) " + + "VALUES (" + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?)" + , new SerializerWriteBasicExt(productsRow.getDatas(), + new int[]{0, + 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29})) + + .exec(params); + + if (i > 0 && ((Boolean)values[30])) { + return new PreparedSentence(s + , "INSERT INTO products_cat (PRODUCT, CATORDER) VALUES (?, ?)" + , new SerializerWriteBasicExt(productsRow.getDatas(), new int[] {0, 31})) + + .exec(params); + } else { + return i; + } + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getProductCatUpdate() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + Object[] values = (Object[]) params; + int i = new PreparedSentence(s + , "UPDATE products SET " + + "ID = ?, " + + "REFERENCE = ?, " + + "CODE = ?, " + + "CODETYPE = ?, " + + "NAME = ?, " + + "PRICEBUY = ?, " + + "PRICESELL = ?, " + + "CATEGORY = ?, " + + "TAXCAT = ?, " + + "ATTRIBUTESET_ID = ?, " + + "STOCKCOST = ?, " + + "STOCKVOLUME = ?, " + + "IMAGE = ?, " + + "ISCOM = ?, " + + "ISSCALE = ?, " + + "ISCONSTANT = ?, " + + "PRINTKB = ?, " + + "SENDSTATUS = ?, " + + "ISSERVICE = ?, " + + "ATTRIBUTES = ?," + + "DISPLAY = ?, " + + "ISVPRICE = ?, " + + "ISVERPATRIB = ?, " + + "TEXTTIP = ?, " + + "WARRANTY = ?, " + + "STOCKUNITS = ?, " + + "PRINTTO = ?, " + + "SUPPLIER = ?, " + + "UOM = ?, " + + "MEMODATE = ? " + + "WHERE ID = ?" + , new SerializerWriteBasicExt(productsRow.getDatas(), + new int[]{0, + 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, + 26, 27, 28, 29, 0})) + .exec(params); + if (i > 0) { + if (((Boolean)values[30])) { + if (new PreparedSentence(s + , "UPDATE products_cat SET CATORDER = ? WHERE PRODUCT = ?" + , new SerializerWriteBasicExt(productsRow.getDatas() + , new int[] {31, 0})).exec(params) == 0) { + new PreparedSentence(s + , "INSERT INTO products_cat (PRODUCT, CATORDER) VALUES (?, ?)" + , new SerializerWriteBasicExt(productsRow.getDatas(), new int[] {0, 31})).exec(params); + } + } else { + new PreparedSentence(s + , "DELETE FROM products_cat WHERE PRODUCT = ?" + , new SerializerWriteBasicExt(productsRow.getDatas(), new int[] {0})).exec(params); + } + } + return i; + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getProductCatDelete() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + new PreparedSentence(s + , "DELETE FROM products_cat WHERE PRODUCT = ?" + , new SerializerWriteBasicExt(productsRow.getDatas(), new int[] {0})).exec(params); + return new PreparedSentence(s + , "DELETE FROM products WHERE ID = ?" + , new SerializerWriteBasicExt(productsRow.getDatas(), new int[] {0})).exec(params); + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getDebtUpdate() { + + return new PreparedSentence(s + , "UPDATE customers SET CURDEBT = ?, CURDATE = ? WHERE ID = ?" + , SerializerWriteParams.INSTANCE); + } + + /** + * ProductBundle version + * @return + */ + public final SentenceExec getStockDiaryInsert() { + return new SentenceExecTransaction(s) { + @Override + /** + * @param params[0] String STOCKDIARY.ID + * @param params[1] Date Timestamp + * @param params[2] Integer Reason + * @param params[3] String Location + * @param params[4] String Product ID + * @param params[5] String Attribute instance ID + * @param params[6] Double Units + * @param params[7] Double Price + * @param params[8] String Application User + */ + public int execInTransaction(Object params) throws BasicException { + + Object[] adjustParams = new Object[4]; + Object[] paramsArray = (Object[]) params; + adjustParams[0] = paramsArray[4]; //product ->Location + adjustParams[1] = paramsArray[3]; //location -> Product + adjustParams[2] = paramsArray[5]; //attributesetinstance + adjustParams[3] = paramsArray[6]; //units + adjustStock(adjustParams); + + return new PreparedSentence(s + , "INSERT INTO stockdiary (ID, DATENEW, REASON, LOCATION, " + + "PRODUCT, ATTRIBUTESETINSTANCE_ID, " + + "UNITS, PRICE, AppUser) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)" + , new SerializerWriteBasicExt(stockdiaryDatas + , new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8})) + .exec(params); + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getStockDiaryInsert1() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + + int updateresult = ((Object[]) params)[5] == null + ? new PreparedSentence(s + , "UPDATE stockcurrent SET UNITS = (UNITS + ?) " + + "WHERE LOCATION = ? AND PRODUCT = ? " + + "AND ATTRIBUTESETINSTANCE_ID IS NULL" + , new SerializerWriteBasicExt(stockdiaryDatas, new int[] {6, 3, 4})).exec(params) + : new PreparedSentence(s + , "UPDATE stockcurrent SET UNITS = (UNITS + ?) " + + "WHERE LOCATION = ? AND PRODUCT = ? " + + "AND ATTRIBUTESETINSTANCE_ID = ?" + , new SerializerWriteBasicExt(stockdiaryDatas, new int[] {6, 3, 4, 5})).exec(params); + + if (updateresult == 0) { + new PreparedSentence(s + , "INSERT INTO stockcurrent (LOCATION, PRODUCT, " + + "ATTRIBUTESETINSTANCE_ID, UNITS) " + + "VALUES (?, ?, ?, ?)" + , new SerializerWriteBasicExt(stockdiaryDatas, new int[] {3, 4, 5, 6})).exec(params); + } + return new PreparedSentence(s + , "INSERT INTO stockdiary (ID, DATENEW, REASON, LOCATION, PRODUCT, " + + "ATTRIBUTESETINSTANCE_ID, UNITS, PRICE, AppUser, " + + "SUPPLIER, SUPPLIERDOC) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" + , new SerializerWriteBasicExt(stockdiaryDatas, + new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10})).exec(params); + + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getStockDiaryDelete() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + int updateresult = ((Object[]) params)[5] == null // if ATTRIBUTESETINSTANCE_ID is null + ? new PreparedSentence(s + , "UPDATE stockcurrent SET UNITS = (UNITS - ?) " + + "WHERE LOCATION = ? AND PRODUCT = ? " + + "AND ATTRIBUTESETINSTANCE_ID IS NULL" + , new SerializerWriteBasicExt(stockdiaryDatas, new int[] {6, 3, 4})).exec(params) + : new PreparedSentence(s + , "UPDATE stockcurrent SET UNITS = (UNITS - ?) " + + "WHERE LOCATION = ? AND PRODUCT = ? " + + "AND ATTRIBUTESETINSTANCE_ID = ?" + , new SerializerWriteBasicExt(stockdiaryDatas, new int[] {6, 3, 4, 5})).exec(params); + + if (updateresult == 0) { + new PreparedSentence(s + , "INSERT INTO stockcurrent (LOCATION, PRODUCT, " + + "ATTRIBUTESETINSTANCE_ID, UNITS) " + + "VALUES (?, ?, ?, -(?))" + , new SerializerWriteBasicExt(stockdiaryDatas, new int[] {3, 4, 5, 6})).exec(params); + } + return new PreparedSentence(s + , "DELETE FROM stockdiary WHERE ID = ?" + , new SerializerWriteBasicExt(stockdiaryDatas, new int[] {0})).exec(params); + } + }; + } + + + private void adjustStock(Object params) throws BasicException { + + List<ProductsBundleInfo> bundle = getProductsBundle((String) ((Object[])params)[0]); + + if (bundle.size() > 0) { + + for (ProductsBundleInfo component : bundle) { + Object[] adjustParams = new Object[4]; + adjustParams[0] = component.getProductBundleId(); + adjustParams[1] = ((Object[])params)[1]; + adjustParams[2] = ((Object[])params)[2]; + adjustParams[3] = ((Double)((Object[])params)[3]) * component.getQuantity(); + adjustStock(adjustParams); + } + } else { + + int updateresult = ((Object[]) params)[2] == null + ? new PreparedSentence(s + , "UPDATE stockcurrent SET UNITS = (UNITS + ?) " + + "WHERE LOCATION = ? AND PRODUCT = ? " + + "AND ATTRIBUTESETINSTANCE_ID IS NULL" + , new SerializerWriteBasicExt(stockAdjustDatas + , new int[] {3, 1, 0})) + .exec(params) + : new PreparedSentence(s + , "UPDATE stockcurrent SET UNITS = (UNITS + ?) " + + "WHERE LOCATION = ? AND PRODUCT = ? " + + "AND ATTRIBUTESETINSTANCE_ID = ?" + , new SerializerWriteBasicExt(stockAdjustDatas + , new int[] {3, 1, 0, 2})) + .exec(params); + + if (updateresult == 0) { + + new PreparedSentence(s + , "INSERT INTO stockcurrent (LOCATION, PRODUCT, " + + "ATTRIBUTESETINSTANCE_ID, UNITS) " + + "VALUES (?, ?, ?, ?)" + , new SerializerWriteBasicExt(stockAdjustDatas + , new int[] {1, 0, 2, 3})) + .exec(params); + } + } + } + + /** + * + * @return + */ + public final SentenceExec getPaymentMovementInsert() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + new PreparedSentence(s + , "INSERT INTO receipts (ID, MONEY, DATENEW) " + + "VALUES (?, ?, ?)" + , new SerializerWriteBasicExt(paymenttabledatas, + new int[] {0, 1, 2})).exec(params); + return new PreparedSentence(s + , "INSERT INTO payments (ID, RECEIPT, PAYMENT, TOTAL, NOTES) " + + "VALUES (?, ?, ?, ?, ?)" + , new SerializerWriteBasicExt(paymenttabledatas, + new int[] {3, 0, 4, 5, 6})).exec(params); + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getPaymentMovementDelete() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + new PreparedSentence(s + , "DELETE FROM payments WHERE ID = ?" + , new SerializerWriteBasicExt(paymenttabledatas, new int[] {3})).exec(params); + return new PreparedSentence(s + , "DELETE FROM receipts WHERE ID = ?" + , new SerializerWriteBasicExt(paymenttabledatas, new int[] {0})).exec(params); + } + }; + } + + /** + * + * @param warehouse + * @param id + * @param attsetinstid + * @return + * @throws BasicException + */ + public final double findProductStock(String warehouse, String id, String attsetinstid) throws BasicException { + + PreparedSentence p = attsetinstid == null + ? new PreparedSentence(s, "SELECT UNITS FROM stockcurrent " + + "WHERE LOCATION = ? AND PRODUCT = ? AND ATTRIBUTESETINSTANCE_ID IS NULL" + , new SerializerWriteBasic(Datas.STRING, Datas.STRING) + , SerializerReadDouble.INSTANCE) + : new PreparedSentence(s, "SELECT UNITS FROM stockcurrent " + + "WHERE LOCATION = ? AND PRODUCT = ? AND ATTRIBUTESETINSTANCE_ID = ?" + , new SerializerWriteBasic(Datas.STRING, Datas.STRING, Datas.STRING) + , SerializerReadDouble.INSTANCE); + + Double d = (Double) p.find(warehouse, id, attsetinstid); + return d == null ? 0.0 : d; + } + + /** + * + * @return + */ + public final SentenceExec getCatalogCategoryAdd() { + return new StaticSentence(s + , "INSERT INTO products_cat(PRODUCT, CATORDER) SELECT ID, " + s.DB.INTEGER_NULL() + " FROM products WHERE CATEGORY = ?" + , SerializerWriteString.INSTANCE); + } + + /** + * + * @return + */ + public final SentenceExec getCatalogCategoryDel() { + return new StaticSentence(s + , "DELETE FROM products_cat WHERE PRODUCT = ANY (SELECT ID " + + "FROM products WHERE CATEGORY = ?)" + , SerializerWriteString.INSTANCE); + } + + /** + * + * @return + */ + public final TableDefinition getTableCategories() { + return new TableDefinition(s, + "categories" + , new String[] {"ID", "NAME", "PARENTID", "IMAGE", "TEXTTIP", "CATSHOWNAME", "CATORDER"} + , new String[] {"ID", AppLocal.getIntString("label.name"), "", AppLocal.getIntString("label.image")} + , new Datas[] {Datas.STRING, Datas.STRING, Datas.STRING, + Datas.IMAGE, Datas.STRING, Datas.BOOLEAN, Datas.STRING} + , new Formats[] {Formats.STRING, Formats.STRING, Formats.STRING, + Formats.NULL, Formats.STRING, Formats.BOOLEAN, Formats.STRING} + , new int[] {0} + ); + } + + /** + * + * @return + */ + public final TableDefinition getTableTaxes() { + return new TableDefinition(s, + "taxes" + , new String[] {"ID", "NAME", "CATEGORY", "CUSTCATEGORY", "PARENTID", "RATE", "RATECASCADE", "RATEORDER"} + , new String[] {"ID", AppLocal.getIntString("label.name"), AppLocal.getIntString("label.taxcategory"), AppLocal.getIntString("label.custtaxcategory"), AppLocal.getIntString("label.taxparent"), AppLocal.getIntString("label.dutyrate"), AppLocal.getIntString("label.cascade"), AppLocal.getIntString("label.order")} + , new Datas[] {Datas.STRING, Datas.STRING, Datas.STRING, Datas.STRING, Datas.STRING, Datas.DOUBLE, Datas.BOOLEAN, Datas.INT} + , new Formats[] {Formats.STRING, Formats.STRING, Formats.STRING, Formats.STRING, Formats.STRING, Formats.PERCENT, Formats.BOOLEAN, Formats.INT} + , new int[] {0} + ); + } + + /** + * + * @return + */ + public final TableDefinition getTableTaxCustCategories() { + return new TableDefinition(s, + "taxcustcategories" + , new String[] {"ID", "NAME"} + , new String[] {"ID", AppLocal.getIntString("label.name")} + , new Datas[] {Datas.STRING, Datas.STRING} + , new Formats[] {Formats.STRING, Formats.STRING} + , new int[] {0} + ); + } + + /** + * + * @return + */ + public final TableDefinition getTableTaxCategories() { + return new TableDefinition(s, + "taxcategories" + , new String[] {"ID", "NAME"} + , new String[] {"ID", AppLocal.getIntString("label.name")} + , new Datas[] {Datas.STRING, Datas.STRING} + , new Formats[] {Formats.STRING, Formats.STRING} + , new int[] {0} + ); + } + + /** + * + * @return + */ + public final TableDefinition getTableLocations() { + return new TableDefinition(s, + "locations" + , new String[] {"ID", "NAME", "ADDRESS"} + , new String[] {"ID", AppLocal.getIntString("label.locationname"), + AppLocal.getIntString("label.locationaddress")} + , new Datas[] {Datas.STRING, Datas.STRING, Datas.STRING} + , new Formats[] {Formats.STRING, Formats.STRING, Formats.STRING} + , new int[] {0} + ); + } + + + /** + * + */ + protected static class CustomerExtRead implements SerializerRead { + + /** + * + * @param dr + * @return + * @throws BasicException + */ + @Override + public Object readValues(DataRead dr) throws BasicException { + CustomerInfoExt c = new CustomerInfoExt(dr.getString(1)); + c.setSearchkey(dr.getString(2)); + c.setTaxid(dr.getString(3)); + c.setTaxCustomerID(dr.getString(3)); + c.setName(dr.getString(4)); + c.setTaxCustCategoryID(dr.getString(5)); + c.setCard(dr.getString(6)); + c.setMaxdebt(dr.getDouble(7)); + c.setAddress(dr.getString(8)); + c.setAddress2(dr.getString(9)); + c.setPcode(dr.getString(10)); + c.setCity(dr.getString(11)); + c.setRegion(dr.getString(12)); + c.setCountry(dr.getString(13)); + c.setFirstname(dr.getString(14)); + c.setLastname(dr.getString(15)); + c.setCemail(dr.getString(16)); + c.setPhone1(dr.getString(17)); + c.setPhone2(dr.getString(18)); + c.setFax(dr.getString(19)); + c.setNotes(dr.getString(20)); + c.setVisible(dr.getBoolean(21)); + c.setCurdate(dr.getTimestamp(22)); + c.setAccdebt(dr.getDouble(23)); + c.setImage(ImageUtils.readImage(dr.getString(24))); + c.setisVIP(dr.getBoolean(25)); + c.setDiscount(dr.getDouble(26)); + c.setMemoDate(dr.getString(27)); + + return c; + } + } + + public final UomInfo getUomInfoById(String id) throws BasicException { + return (UomInfo) new PreparedSentence(s, + "SELECT " + + "id, name " + + "FROM uom " + + "WHERE id = ?" + , SerializerWriteString.INSTANCE, UomInfo.getSerializerRead()).find(id); + } + + public final TableDefinition getTableUom() { + return new TableDefinition(s, + "uom", + new String[]{"id", "name"}, + new String[]{"id", + AppLocal.getIntString("Label.Name")}, + new Datas[]{ + Datas.STRING, Datas.STRING}, + new Formats[]{ + Formats.STRING, Formats.STRING}, + new int[]{0} + ); + } + + public final SentenceList getUomList() { + return new StaticSentence(s, "SELECT ID, NAME FROM uom ORDER BY NAME", null, UomInfo.getSerializerRead()); + } + +/* public final SentenceList getVoucherList() { + return new StaticSentence(s, + "SELECT " + + "vouchers.ID,vouchers.VOUCHER_NUMBER,vouchers.CUSTOMER, " + + "customers.NAME,AMOUNT, STATUS " + + "FROM vouchers " + + "JOIN customers ON customers.id = vouchers.CUSTOMER " + + "WHERE STATUS='A' " + + "ORDER BY vouchers.VOUCHER_NUMBER ASC" + , null, VoucherInfo.getSerializerRead()); + } +*/ + + public final SentenceList getVoucherList() { + return new StaticSentence(s, + "SELECT " + + "vouchers.ID,vouchers.VOUCHER_NUMBER,vouchers.CUSTOMER, " + + "vouchers.AMOUNT, vouchers.STATUS " + + "FROM vouchers " + + "WHERE STATUS='A' " + + "ORDER BY vouchers.VOUCHER_NUMBER ASC" + , null, VoucherInfo.getSerializerRead()); + } + + public final SentenceExec getVoucherNonActive() { + return new PreparedSentence(s, + "UPDATE vouchers SET STATUS = 'D' " + + "WHERE VOUCHER_NUMBER = ?" + , SerializerWriteString.INSTANCE); + } + public final SentenceExec setVoucherPending() { + return new PreparedSentence(s, + "UPDATE vouchers SET STATUS = 'P' " + + "WHERE VOUCHER_NUMBER = ?" + , SerializerWriteString.INSTANCE); + } + + public final SentenceExec resetPickupId() { + + return new PreparedSentence(s, + "UPDATE pickup_number SET ID=1 " + , SerializerWriteString.INSTANCE); + + } + + /** + * + * @param id + * @return + * @throws BasicException + */ + public SupplierInfoExt loadSupplierExt(String id) throws BasicException { + return (SupplierInfoExt) new PreparedSentence(s + , "SELECT " + + "ID, " + + "SEARCHKEY, " + + "TAXID, " + + "NAME, " + + "MAXDEBT, " + + "ADDRESS, " + + "ADDRESS2, " + + "POSTAL, " + + "CITY, " + + "REGION, " + + "COUNTRY, " + + "FIRSTNAME, " + + "LASTNAME, " + + "EMAIL, " + + "PHONE, " + + "PHONE2, " + + "FAX, " + + "NOTES, " + + "VISIBLE, " + + "CURDATE, " + + "CURDEBT, " + + "VATID " + + "FROM suppliers WHERE ID = ?" + , SerializerWriteString.INSTANCE + , new SupplierExtRead()).find(id); + } + + /** + * + */ + protected static class SupplierExtRead implements SerializerRead { + + /** + * + * @param dr + * @return + * @throws BasicException + */ + @Override + public Object readValues(DataRead dr) throws BasicException { + SupplierInfoExt s = new SupplierInfoExt(dr.getString(1)); + s.setSearchkey(dr.getString(2)); + s.setTaxid(dr.getString(3)); + s.setName(dr.getString(4)); + s.setMaxdebt(dr.getDouble(5)); + s.setAddress(dr.getString(6)); + s.setAddress2(dr.getString(7)); + s.setPostal(dr.getString(8)); + s.setCity(dr.getString(9)); + s.setRegion(dr.getString(10)); + s.setCountry(dr.getString(11)); + s.setFirstname(dr.getString(12)); + s.setLastname(dr.getString(13)); + s.setEmail(dr.getString(14)); + s.setPhone(dr.getString(15)); + s.setPhone2(dr.getString(16)); + s.setFax(dr.getString(17)); + s.setNotes(dr.getString(18)); + s.setVisible(dr.getBoolean(19)); + s.setCurdate(dr.getTimestamp(20)); + s.setCurdebt(dr.getDouble(21)); + s.setSupplierVATID(dr.getString(22)); + + return s; + } + } + + /** + * + * @return + */ + + public final SentenceExec getCustomerInsert() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + Object[] values = (Object[]) params; + int i = new PreparedSentence(s + , "INSERT INTO customers (" + + "ID, " + + "SEARCHKEY, " + + "TAXID, " + + "NAME, " + + "TAXCATEGORY, " + + "CARD, " + + "MAXDEBT, " + + "ADDRESS, " + + "ADDRESS2, " + + "POSTAL, " + + "CITY, " + + "REGION, " + + "COUNTRY, " + + "FIRSTNAME, " + + "LASTNAME, " + + "EMAIL, " + + "PHONE, " + + "PHONE2, " + + "FAX, " + + "NOTES, " + + "VISIBLE, " + + "CURDATE, " + + "CURDEBT, " + + "IMAGE, " + + "ISVIP, " + + "DISCOUNT, " + + "MEMODATE ) " + + "VALUES (" + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, ?, " + + "?, ?, ?)" + , new SerializerWriteBasicExt(customersRow.getDatas(), + new int[]{0, + 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, + 25, 26})) + + .exec(params); + return i; + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getCustomerUpdate() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + Object[] values = (Object[]) params; + int i = new PreparedSentence(s + , "UPDATE customers SET " + + "ID = ?, " + + "SEARCHKEY = ?, " + + "TAXID = ?, " + + "NAME = ?, " + + "TAXCATEGORY = ?, " + + "CARD = ?, " + + "MAXDEBT = ?, " + + "ADDRESS = ?, " + + "ADDRESS2 = ?, " + + "POSTAL = ?, " + + "CITY = ?, " + + "REGION = ?, " + + "COUNTRY = ?, " + + "FIRSTNAME = ?, " + + "LASTNAME = ?, " + + "EMAIL = ?, " + + "PHONE = ?, " + + "PHONE2 = ?, " + + "FAX = ?, " + + "NOTES = ?," + + "VISIBLE = ?, " + + "CURDATE = ?, " + + "CURDEBT = ?, " + + "IMAGE = ?, " + + "ISVIP = ?, " + + "DISCOUNT = ?, " + + "MEMODATE = ? " + + "WHERE ID = ?" + , new SerializerWriteBasicExt(customersRow.getDatas(), + new int[]{0, + 1, 2, 3, 4, 5, + 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, + 26, 0})) + .exec(params); + +/* + * Use this block workflow as template to pump LOYALTY, MEMBERSHIP & etc + * updates to internal or external DB table + if (i > 0) { + if (((Boolean)values[n0])) { + if (new PreparedSentence(s + , "UPDATE tablename SET FIELD = ? WHERE CUSTOMER = ?" + , new SerializerWriteBasicExt(customersRow.getDatas() + , new int[] {n1, 0})).exec(params) == 0) { + new PreparedSentence(s + , "INSERT INTO other_tablename (CUSTOMER, FIELD) VALUES (?, ?)" + , new SerializerWriteBasicExt(productsRow.getDatas(), new int[] {0, n1})).exec(params); + } + } else { + new PreparedSentence(s + , "DELETE FROM FIELD WHERE CUSTOMER = ?" + , new SerializerWriteBasicExt(customersRow.getDatas(), new int[] {0})).exec(params); + } + } +*/ + return i; + } + }; + } + + /** + * + * @return + */ + public final SentenceExec getCustomerDelete() { + return new SentenceExecTransaction(s) { + @Override + public int execInTransaction(Object params) throws BasicException { + return new PreparedSentence(s + , "DELETE FROM customers WHERE ID = ?" + , new SerializerWriteBasicExt(customersRow.getDatas(), + new int[] {0} + )).exec(params); + } + }; + } + + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/forms/DataLogicSystem.java b/src/main/java/com/unicenta/pos/forms/DataLogicSystem.java new file mode 100644 index 0000000..b4357b8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/DataLogicSystem.java @@ -0,0 +1,891 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.*; +import com.unicenta.format.Formats; +import com.unicenta.pos.util.ThumbNailBuilder; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.*; +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; + +/** + * + * @author JG uniCenta + */ +public class DataLogicSystem extends BeanFactoryDataSingle { + + protected String m_sInitScript; + private SentenceFind m_version; + private SentenceExec m_dummy; + private String m_dbVersion; + protected SentenceList m_peoplevisible; + protected SentenceFind m_peoplebycard; + protected SerializerRead peopleread; + protected SentenceList m_permissionlist; + protected SerializerRead productIdRead; + protected SerializerRead customerIdRead; + + private SentenceFind m_rolepermissions; + private SentenceExec m_changepassword; + private SentenceFind m_locationfind; + private SentenceExec m_insertCSVEntry; + private SentenceExec m_insertStockUpdateEntry; + + private SentenceFind m_getProductAllFields; + private SentenceFind m_getProductRefAndCode; + private SentenceFind m_getProductRefAndName; + private SentenceFind m_getProductCodeAndName; + private SentenceFind m_getProductByReference; + private SentenceFind m_getProductByCode; + private SentenceFind m_getProductByName; + + private SentenceExec m_insertCustomerCSVEntry; + private SentenceFind m_getCustomerAllFields; + private SentenceFind m_getCustomerSearchKeyAndName; + private SentenceFind m_getCustomerBySearchKey; + private SentenceFind m_getCustomerByName; + + private SentenceFind m_resourcebytes; + private SentenceExec m_resourcebytesinsert; + private SentenceExec m_resourcebytesupdate; + + protected SentenceFind m_sequencecash; + protected SentenceFind m_activecash; + protected SentenceFind m_closedcash; + protected SentenceExec m_insertcash; + protected SentenceExec m_draweropened; + protected SentenceExec m_updatepermissions; + protected SentenceExec m_lineremoved; + protected SentenceExec m_ticketremoved; + + private String SQL; + private Map<String, byte[]> resourcescache; + + private SentenceList m_voucherlist; + + protected SentenceExec m_addOrder; + protected SentenceExec m_updateOrder; + protected SentenceExec m_deleteOrder; + + private SentenceExec m_resetPickup; + + private SentenceExec m_updatePlaces; + + /** Creates a new instance of DataLogicSystem */ + public DataLogicSystem() { + } + + /** + * + * @param s + */ + @Override + public void init(Session s){ + + m_sInitScript = "/com/unicenta/pos/scripts/" + s.DB.getName(); + m_dbVersion = s.DB.getName(); + + m_version = new PreparedSentence(s, "SELECT VERSION FROM applications WHERE ID = ?" + , SerializerWriteString.INSTANCE, SerializerReadString.INSTANCE); + + m_dummy = new StaticSentence(s, "SELECT * FROM people WHERE 1 = 0"); + + final ThumbNailBuilder tnb = new ThumbNailBuilder(32, 32, "com/unicenta/images/user.png"); + + peopleread = (DataRead dr) -> new AppUser( + dr.getString(1), + dr.getString(2), + dr.getString(3), + dr.getString(4), + dr.getString(5), + new ImageIcon(tnb.getThumbNail(ImageUtils.readImage(dr.getBytes(6))))); + +// START OF PRODUCT ************************************************************ + productIdRead =(DataRead dr) -> ( + dr.getString(1) + ); + + m_getProductAllFields = new PreparedSentence(s + , "SELECT ID FROM products WHERE REFERENCE=? AND CODE=? AND NAME=? " + , new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING, Datas.STRING}) + , productIdRead + ); + + m_getProductRefAndCode = new PreparedSentence(s + , "SELECT ID FROM products WHERE REFERENCE=? AND CODE=?" + , new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING}) + , productIdRead + ); + + m_getProductRefAndName = new PreparedSentence(s + , "SELECT ID FROM products WHERE REFERENCE=? AND NAME=? " + , new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING}) + , productIdRead + ); + + m_getProductCodeAndName = new PreparedSentence(s + , "SELECT ID FROM products WHERE CODE=? AND NAME=? " + , new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING}) + , productIdRead + ); + + m_getProductByReference = new PreparedSentence(s + , "SELECT ID FROM products WHERE REFERENCE=? " + , SerializerWriteString.INSTANCE //(Datas.STRING) + , productIdRead + ); + + m_getProductByCode = new PreparedSentence(s + , "SELECT ID FROM products WHERE CODE=? " + , SerializerWriteString.INSTANCE //(Datas.STRING) + //, new SerializerWriteBasic(Datas.STRING) + , productIdRead + ); + + m_getProductByName = new PreparedSentence(s + , "SELECT ID FROM products WHERE NAME=? " + , SerializerWriteString.INSTANCE //(Datas.STRING) + //, new SerializerWriteBasic(Datas.STRING) + , productIdRead + ); + + // END OF PRODUCT ************************************************************* + +// START OF CUSTOMER *********************************************************** + customerIdRead =(DataRead dr) -> ( + dr.getString(1) + ); +// duplicate this for now as will extend in future release + m_getCustomerAllFields = new PreparedSentence(s + , "SELECT ID FROM customers WHERE SEARCHKEY=? AND NAME=? " + , new SerializerWriteBasic(new Datas[] { + Datas.STRING, Datas.STRING}) + , customerIdRead + ); + + m_getCustomerSearchKeyAndName = new PreparedSentence(s + , "SELECT ID FROM customers WHERE SEARCHKEY=? AND NAME=? " + , new SerializerWriteBasic(new Datas[] { + Datas.STRING, Datas.STRING}) + , customerIdRead + ); + + m_getCustomerBySearchKey = new PreparedSentence(s + , "SELECT ID FROM customers WHERE SEARCHKEY=? " + , SerializerWriteString.INSTANCE + , customerIdRead + ); + + m_getCustomerByName = new PreparedSentence(s + , "SELECT ID FROM customers WHERE NAME=? " + , SerializerWriteString.INSTANCE + , customerIdRead + ); + + // END OF CUSTOMER ****************************************************************** + + m_peoplevisible = new StaticSentence(s + , "SELECT ID, NAME, APPPASSWORD, CARD, ROLE, IMAGE FROM people WHERE VISIBLE = " + s.DB.TRUE() + " ORDER BY NAME" + , null + , peopleread); + + m_peoplebycard = new PreparedSentence(s + , "SELECT ID, NAME, APPPASSWORD, CARD, ROLE, IMAGE FROM people WHERE CARD = ? AND VISIBLE = " + s.DB.TRUE() + , SerializerWriteString.INSTANCE + , peopleread); + + m_resourcebytes = new PreparedSentence(s + , "SELECT CONTENT FROM resources WHERE NAME = ?" + , SerializerWriteString.INSTANCE + , SerializerReadBytes.INSTANCE); + + Datas[] resourcedata = new Datas[] { + Datas.STRING, Datas.STRING, + Datas.INT, Datas.BYTES}; + + m_resourcebytesinsert = new PreparedSentence(s + , "INSERT INTO resources(ID, NAME, RESTYPE, CONTENT) VALUES (?, ?, ?, ?)" + , new SerializerWriteBasic(resourcedata)); + + m_resourcebytesupdate = new PreparedSentence(s + , "UPDATE resources SET NAME = ?, RESTYPE = ?, CONTENT = ? WHERE NAME = ?" + , new SerializerWriteBasicExt(resourcedata, new int[] {1, 2, 3, 1})); + + m_rolepermissions = new PreparedSentence(s + , "SELECT PERMISSIONS FROM roles WHERE ID = ?" + , SerializerWriteString.INSTANCE + , SerializerReadBytes.INSTANCE); + + m_changepassword = new StaticSentence(s + , "UPDATE people SET APPPASSWORD = ? WHERE ID = ?" + ,new SerializerWriteBasic(new Datas[] {Datas.STRING, Datas.STRING})); + + m_sequencecash = new StaticSentence(s, + "SELECT MAX(HOSTSEQUENCE) FROM closedcash WHERE HOST = ?", + SerializerWriteString.INSTANCE, + SerializerReadInteger.INSTANCE); + + m_activecash = new StaticSentence(s + , "SELECT HOST, HOSTSEQUENCE, DATESTART, DATEEND, NOSALES FROM closedcash WHERE MONEY = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[] { + Datas.STRING, + Datas.INT, + Datas.TIMESTAMP, + Datas.TIMESTAMP, + Datas.INT})); + + m_closedcash = new StaticSentence(s + , "SELECT HOST, HOSTSEQUENCE, DATESTART, DATEEND, NOSALES " + + "FROM closedcash WHERE HOSTSEQUENCE = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[] { + Datas.STRING, + Datas.INT, + Datas.TIMESTAMP, + Datas.TIMESTAMP, + Datas.INT})); + + m_insertcash = new StaticSentence(s + , "INSERT INTO closedcash(MONEY, HOST, HOSTSEQUENCE, DATESTART, DATEEND) " + + "VALUES (?, ?, ?, ?, ?)" + , new SerializerWriteBasic(new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.INT, + Datas.TIMESTAMP, + Datas.TIMESTAMP})); + + m_draweropened = new StaticSentence(s + , "INSERT INTO draweropened ( NAME, TICKETID) " + + "VALUES (?, ?)" + , new SerializerWriteBasic(new Datas[] { + Datas.STRING, + Datas.STRING})); + + m_lineremoved = new StaticSentence(s, + "INSERT INTO lineremoved (NAME, TICKETID, PRODUCTID, PRODUCTNAME, UNITS) " + + "VALUES (?, ?, ?, ?, ?)", + new SerializerWriteBasic(new Datas[] { + Datas.STRING, Datas.STRING, + Datas.STRING, Datas.STRING, + Datas.DOUBLE + })); + + m_ticketremoved = new StaticSentence(s, + "INSERT INTO lineremoved (NAME, TICKETID, PRODUCTNAME, UNITS) " + + "VALUES (?, ?, ?, ?)", + new SerializerWriteBasic(new Datas[] { + Datas.STRING, Datas.STRING, + Datas.STRING, Datas.DOUBLE + })); + + m_locationfind = new StaticSentence(s + , "SELECT NAME FROM locations WHERE ID = ?" + , SerializerWriteString.INSTANCE + , SerializerReadString.INSTANCE); + + m_permissionlist = new StaticSentence(s + , "SELECT PERMISSIONS FROM permissions WHERE ID = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[] { + Datas.STRING + })); + + m_updatepermissions = new StaticSentence(s + , "INSERT INTO permissions (ID, PERMISSIONS) " + + "VALUES (?, ?)" + , new SerializerWriteBasic(new Datas[] { + Datas.STRING, + Datas.STRING})); + + +// Push Products into CSVImport table + m_insertCSVEntry = new StaticSentence(s + , "INSERT INTO csvimport ( " + + "ID, ROWNUMBER, CSVERROR, REFERENCE, " + + "CODE, NAME, PRICEBUY, PRICESELL, " + + "PREVIOUSBUY, PREVIOUSSELL, CATEGORY, TAX) " + + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" + , new SerializerWriteBasic(new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.DOUBLE, + Datas.DOUBLE, + Datas.DOUBLE, + Datas.DOUBLE, + Datas.STRING, + Datas.STRING + })); + +// Push Product Quantity Update into CSVImport table + m_insertStockUpdateEntry = new StaticSentence(s + , "INSERT INTO csvimport ( " + + "ID, ROWNUMBER, CSVERROR, REFERENCE, " + + "CODE, PRICEBUY ) " + + "VALUES (?, ?, ?, ?, ?, ?)" + , new SerializerWriteBasic(new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.DOUBLE + })); + +// Push Customers into CSVImport table + m_insertCustomerCSVEntry = new StaticSentence(s + , "INSERT INTO csvimport ( " + + "ID, ROWNUMBER, CSVERROR, SEARCHKEY, NAME) " + + "VALUES (?, ?, ?, ?, ?)" + , new SerializerWriteBasic(new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.STRING + })); + + m_addOrder = new StaticSentence(s + , "INSERT INTO orders (ORDERID, QTY, DETAILS, ATTRIBUTES, " + + "NOTES, TICKETID, ORDERTIME, DISPLAYID, AUXILIARY, " + + "COMPLETETIME) " + + "VALUES (?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ? ) " + , new SerializerWriteBasic(new Datas[] { + Datas.STRING, // OrderId + Datas.INT, // Qty + Datas.STRING, // Details + Datas.STRING, // Attributes + Datas.STRING, // Notes + Datas.STRING, // TicketId + Datas.STRING, // OrderTime + Datas.INT, // DisplayId + Datas.INT, // Auxiliary + Datas.STRING // CompleteTime + })); + + m_updateOrder = new StaticSentence(s + , "UPDATE orders SET " + + "ORDERID = ?, " + + "QTY = ?, " + + "DETAILS = ?, " + + "ATTRIBUTES = ?, " + + "NOTES = ?, " + + "TICKETID = ?, " + + "ORDERTIME = ?, " + + "DISPLAYID = ?, " + + "AUXILIARY = ?, " + + "COMPLETETIME = ? " + + "WHERE ORDERID = ? " + , new SerializerWriteBasic(new Datas[] { + Datas.STRING, // OrderId + Datas.INT, // Qty + Datas.STRING, // Details + Datas.STRING, // Attributes + Datas.STRING, // Notes + Datas.STRING, // TicketId + Datas.STRING, // OrderTime + Datas.INT, // DisplayId + Datas.INT, // Auxiliary + Datas.STRING // CompleteTime + })); + + m_deleteOrder = new StaticSentence(s + , "DELETE FROM orders WHERE ORDERID = ?" + , SerializerWriteString.INSTANCE); + + m_updatePlaces = new StaticSentence(s + , "UPDATE places SET X = ?, Y = ? " + + "WHERE ID = ? " + , new SerializerWriteBasic(new Datas[]{ + Datas.INT, + Datas.INT, + Datas.STRING + })); + + m_resetPickup = new StaticSentence(s + , "UPDATE pickup_number SET id=1" + , SerializerWriteInteger.INSTANCE); + + resetResourcesCache(); + } + + /** + * + * @return + */ + public String getInitScript() { + return m_sInitScript; + } + + /** + * + * @return + */ + public String getDBVersion(){ + return m_dbVersion; + } + + /** + * + * @return + * @throws BasicException + */ + public final String findVersion() throws BasicException { + return (String) m_version.find(AppLocal.APP_ID); + } + + /** + * + * @return + * @throws BasicException + */ + public final String getUser() throws BasicException { + return (""); + + } + + /** + * + * @throws BasicException + */ + public final void execDummy() throws BasicException { + m_dummy.exec(); + } + + /** + * + * @return + * @throws BasicException + */ + public final List listPeopleVisible() throws BasicException { + return m_peoplevisible.list(); + } + + /** + * + * @param role + * @return + * @throws BasicException + */ + public final List<String> getPermissions(String role)throws BasicException { + return m_permissionlist.list(role); + } + + /** + * + * @param card + * @return + * @throws BasicException + */ + public final AppUser findPeopleByCard(String card) throws BasicException { + return (AppUser) m_peoplebycard.find(card); + } + + /** + * + * @param sRole + * @return + */ + public final String findRolePermissions(String sRole) { + + try { + return Formats.BYTEA.formatValue(m_rolepermissions.find(sRole)); + } catch (BasicException e) { + return null; + } + } + + /** + * + * @param userdata + * @throws BasicException + */ + public final void execChangePassword(Object[] userdata) throws BasicException { + m_changepassword.exec(userdata); + } + + /** + * + */ + public final void resetResourcesCache() { + resourcescache = new HashMap<>(); + } + + private byte[] getResource(String name) { + + byte[] resource; + + resource = resourcescache.get(name); + + if (resource == null) { + try { + resource = (byte[]) m_resourcebytes.find(name); + resourcescache.put(name, resource); + } catch (BasicException e) { + resource = null; + } + } + + return resource; + } + + /** + * + * @param name + * @param type + * @param data + */ + public final void setResource(String name, int type, byte[] data) { + + Object[] value = new Object[] { + UUID.randomUUID().toString(), + name, + type, + data + }; + try { + if (m_resourcebytesupdate.exec(value) == 0) { + m_resourcebytesinsert.exec(value); + } + resourcescache.put(name, data); + } catch (BasicException e) { + } + } + + /** + * + * @param sName + * @param data + */ + public final void setResourceAsBinary(String sName, byte[] data) { + setResource(sName, 2, data); + } + + /** + * + * @param sName + * @return + */ + public final byte[] getResourceAsBinary(String sName) { + return getResource(sName); + } + + /** + * + * @param sName + * @return + */ + public final String getResourceAsText(String sName) { + return Formats.BYTEA.formatValue(getResource(sName)); + } + + /** + * + * @param sName + * @return + */ + public final String getResourceAsXML(String sName) { + return Formats.BYTEA.formatValue(getResource(sName)); + } + + /** + * + * @param sName + * @return + */ + public final BufferedImage getResourceAsImage(String sName) { + try { + byte[] img = getResource(sName); // , ".png" + return img == null ? null : ImageIO.read(new ByteArrayInputStream(img)); + } catch (IOException e) { + return null; + } + } + + /** + * + * @param sName + * @param p + */ + public final void setResourceAsProperties(String sName, Properties p) { + if (p == null) { + setResource(sName, 0, null); // texto + } else { + try { + ByteArrayOutputStream o = new ByteArrayOutputStream(); + p.storeToXML(o, AppLocal.APP_NAME, "UTF8"); + setResource(sName, 0, o.toByteArray()); // El texto de las propiedades + } catch (IOException e) { // no deberia pasar nunca + } + } + } + + /** + * + * @param sName + * @return + */ + public final Properties getResourceAsProperties(String sName) { + + Properties p = new Properties(); + try { + byte[] img = getResourceAsBinary(sName); + if (img != null) { + p.loadFromXML(new ByteArrayInputStream(img)); + } + } catch (IOException e) { + } + return p; + } + + /** + * + * @param host + * @return + * @throws BasicException + */ + public final int getSequenceCash(String host) throws BasicException { + Integer i = (Integer) m_sequencecash.find(host); + return (i == null) ? 1 : i; + } + + /** + * + * @param sActiveCashIndex + * @return + * @throws BasicException + */ + public final Object[] findActiveCash(String sActiveCashIndex) throws BasicException { + return (Object[]) m_activecash.find(sActiveCashIndex); + } + /** + * + * @param sClosedCashIndex + * @return + * @throws BasicException + */ + public final Object[] findClosedCash(String sClosedCashIndex) throws BasicException { + return (Object[]) m_activecash.find(sClosedCashIndex); + } + + + /** + * + * @param cash + * @throws BasicException + */ + public final void execInsertCash(Object[] cash) throws BasicException { + m_insertcash.exec(cash); + } + + /** + * + * @param drawer + * @throws BasicException + */ + public final void execDrawerOpened(Object[] drawer) throws BasicException { + m_draweropened.exec(drawer); + } + + /** + * + * @param permissions + * @throws BasicException + */ + public final void execUpdatePermissions(Object[] permissions) throws BasicException { + m_updatepermissions.exec(permissions); + } + + /** + * + * @param line + */ + public final void execLineRemoved(Object[] line) { + try { + m_lineremoved.exec(line); + } catch (BasicException e) { + } + } + + /** + * + * @param ticket + */ + public final void execTicketRemoved(Object[] ticket) { + try { + m_ticketremoved.exec(ticket); + } catch (BasicException e) { + } + } + + /** + * + * @param iLocation + * @return + * @throws BasicException + */ + public final String findLocationName(String iLocation) throws BasicException { + return (String) m_locationfind.find(iLocation); + } + + /** + * + * @param csv + * @throws BasicException + */ + public final void execCSVStockUpdate(Object[] csv) throws BasicException { + m_insertStockUpdateEntry.exec(csv); + + } + /** + * + * @param csv + * @throws BasicException + */ + public final void execAddCSVEntry(Object[] csv) throws BasicException { + m_insertCSVEntry.exec(csv); + + } + + /** + * + * @param csv + * @throws BasicException + */ + public final void execCustomerAddCSVEntry(Object[] csv) throws BasicException { + m_insertCustomerCSVEntry.exec(csv); + + } + + +// This is used by CSVimport to detect what type of product insert we are looking at, or what error occured + + /** + * + * @param myProduct + * @return + * @throws BasicException + */ + public final String getProductRecordType(Object[] myProduct) throws BasicException { + // check if the product exist with all the details, if so return product ID + if (m_getProductAllFields.find(myProduct) != null){ + return m_getProductAllFields.find(myProduct).toString(); + } + // check if the product exists with matching reference and code, but a different name + if (m_getProductRefAndCode.find(myProduct[0],myProduct[1]) != null){ + return "Name change"; + } + + if (m_getProductRefAndName.find(myProduct[0],myProduct[2]) != null){ + return "Barcode change"; + } + + if (m_getProductCodeAndName.find(myProduct[1],myProduct[2]) != null){ + return "Reference change"; + } + + if (m_getProductByReference.find(myProduct[0]) != null){ + return "Duplicate Reference found."; + } + + if (m_getProductByCode.find(myProduct[1]) != null){ + return "Duplicate Barcode found."; + } + + if (m_getProductByName.find(myProduct[2]) != null){ + return "Duplicate Description found."; + } + + return "new"; + } + + /** + * + * @param myCustomer + * @return + * @throws BasicException + */ + public final String getCustomerRecordType(Object[] myCustomer) throws BasicException { + + if (m_getCustomerAllFields.find(myCustomer) != null){ + return m_getCustomerAllFields.find(myCustomer).toString(); + } + + if (m_getCustomerSearchKeyAndName.find(myCustomer[0],myCustomer[1]) != null){ + return "reference error"; + } + + if (m_getCustomerBySearchKey.find(myCustomer[0]) != null){ + return "Duplicate Search Key found."; + } + + if (m_getCustomerByName.find(myCustomer[1]) != null){ + return "Duplicate Name found."; + } + + return "new"; + } + + public final void updatePlaces(int x, int y, String id) throws BasicException { + m_updatePlaces.exec(x, y, id); + } + + public final void resetPickup(int x) throws BasicException { + m_resetPickup.exec(x); + } + + public final SentenceList getVouchersActiveList() { + return m_voucherlist; + } + + public final void addOrder(String orderId, Integer qty, + String details, String attributes, String notes, String ticketId, + String ordertime, Integer displayId, String auxiliary, String completetime + ) throws BasicException { + + m_addOrder.exec(orderId, qty, details, attributes, notes, ticketId, + ordertime, displayId, auxiliary, completetime); + } + + public final void updateOrder(String orderId, Integer qty, + String details, String attributes, String notes, String ticketId, + String ordertime, Integer displayId, String auxiliary, String completetime + ) throws BasicException { + + m_updateOrder.exec(orderId, qty, details, attributes, notes, ticketId, + ordertime, displayId, auxiliary, completetime); + } + + public void deleteOrder(String orderId) throws BasicException { + m_deleteOrder.exec(orderId); + } +} diff --git a/src/main/java/com/unicenta/pos/forms/DriverWrapper.java b/src/main/java/com/unicenta/pos/forms/DriverWrapper.java new file mode 100644 index 0000000..b55f491 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/DriverWrapper.java @@ -0,0 +1,73 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import lombok.extern.slf4j.Slf4j; + +import java.sql.*; +import java.util.Properties; +import java.util.logging.Logger; + +/** + * + * @author adrianromero + */ +@Slf4j +public class DriverWrapper implements Driver { + + private Driver driver; + + /** + * + * @param d + */ + public DriverWrapper(Driver d) { + driver = d; + } + @Override + public boolean acceptsURL(String u) throws SQLException { + return driver.acceptsURL(u); + } + @Override + public Connection connect(String u, Properties p) throws SQLException { + return driver.connect(u, p); + } + @Override + public int getMajorVersion() { + return driver.getMajorVersion(); + } + @Override + public int getMinorVersion() { + return driver.getMinorVersion(); + } + @Override + public DriverPropertyInfo[] getPropertyInfo(String u, Properties p) throws SQLException { + return driver.getPropertyInfo(u, p); + } + @Override + public boolean jdbcCompliant() { + return driver.jdbcCompliant(); + } + + @Override + public Logger getParentLogger() throws SQLFeatureNotSupportedException { + throw new UnsupportedOperationException("Not supported yet."); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/forms/JDlgChangePassword.form b/src/main/java/com/unicenta/pos/forms/JDlgChangePassword.form new file mode 100644 index 0000000..4f14d87 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JDlgChangePassword.form @@ -0,0 +1,219 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="title.changepassword" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-22,0,0,1,-96"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_formBundle" type="java.lang.String" value="pos_messages"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="2"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="jcmdCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jcmdOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="11" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jtxtPasswordOld" min="-2" pref="180" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jtxtPasswordNew" min="-2" pref="180" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jtxtPasswordRepeat" min="-2" pref="180" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace min="-2" pref="88" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jtxtPasswordOld" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jtxtPasswordNew" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jtxtPasswordRepeat" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.passwordold" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JPasswordField" name="jtxtPasswordOld"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.passwordnew" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JPasswordField" name="jtxtPasswordNew"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JPasswordField" name="jtxtPasswordRepeat"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.passwordrepeat" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/forms/JDlgChangePassword.java b/src/main/java/com/unicenta/pos/forms/JDlgChangePassword.java new file mode 100644 index 0000000..4d8d4a3 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JDlgChangePassword.java @@ -0,0 +1,242 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.data.gui.JMessageDialog; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.pos.util.Hashcypher; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Window; +import javax.swing.JFrame; + +/** + * + * @author adrianromero + */ +public class JDlgChangePassword extends javax.swing.JDialog { + + private String m_sOldPassword; + private String m_sNewPassword; + + /** Creates new form ChangePassword */ + private JDlgChangePassword(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + /** Creates new form ChangePassword */ + private JDlgChangePassword(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + private String init(String sOldPassword) { + + initComponents(); + + getRootPane().setDefaultButton(jcmdOK); + + m_sOldPassword = sOldPassword; + m_sNewPassword = null; + + //show(); + setVisible(true); + + return m_sNewPassword; + } + + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window)parent; + } else { + return getWindow(parent.getParent()); + } + } + + /** + * + * @param parent + * @param sOldPassword + * @return + */ + public static String showMessage(Component parent, String sOldPassword) { + + Window window = getWindow(parent); + + JDlgChangePassword myMsg; + if (window instanceof Frame) { + myMsg = new JDlgChangePassword((Frame) window, true); + } else { + myMsg = new JDlgChangePassword((Dialog) window, true); + } + return myMsg.init(sOldPassword); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel2 = new javax.swing.JPanel(); + jcmdCancel = new javax.swing.JButton(); + jcmdOK = new javax.swing.JButton(); + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jtxtPasswordOld = new javax.swing.JPasswordField(); + jLabel2 = new javax.swing.JLabel(); + jtxtPasswordNew = new javax.swing.JPasswordField(); + jtxtPasswordRepeat = new javax.swing.JPasswordField(); + jLabel3 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("title.changepassword")); // NOI18N + setResizable(false); + + jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N + jcmdCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel2.add(jcmdCancel); + + jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + jcmdOK.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel2.add(jcmdOK); + + getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); + + jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel1.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.passwordold")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(150, 30)); + + jtxtPasswordOld.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtPasswordOld.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.passwordnew")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(150, 30)); + + jtxtPasswordNew.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jtxtPasswordNew.setPreferredSize(new java.awt.Dimension(0, 30)); + + jtxtPasswordRepeat.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtPasswordRepeat.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.passwordrepeat")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(150, 30)); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jtxtPasswordOld, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jtxtPasswordNew, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jtxtPasswordRepeat, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(88, 88, 88)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtPasswordOld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jtxtPasswordNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jtxtPasswordRepeat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + ); + + getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); + + setSize(new java.awt.Dimension(416, 234)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + dispose(); + }//GEN-LAST:event_jcmdCancelActionPerformed + + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + if (new String(jtxtPasswordNew.getPassword()).equals(new String(jtxtPasswordRepeat.getPassword()))) { + if (Hashcypher.authenticate(new String(jtxtPasswordOld.getPassword()), m_sOldPassword)) { + m_sNewPassword = Hashcypher.hashString(new String(jtxtPasswordNew.getPassword())); + dispose(); + } else { + JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.BadPassword"))); + } + } else { + JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.changepassworddistinct"))); + } + }//GEN-LAST:event_jcmdOKActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + private javax.swing.JPasswordField jtxtPasswordNew; + private javax.swing.JPasswordField jtxtPasswordOld; + private javax.swing.JPasswordField jtxtPasswordRepeat; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/forms/JPanelMenu.form b/src/main/java/com/unicenta/pos/forms/JPanelMenu.form new file mode 100644 index 0000000..b035b3a --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JPanelMenu.form @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="20" left="20" right="20" top="20"/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_formBundle" type="java.lang.String" value="pos_messages"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,18,0,0,2,35"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="menucontainer"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/forms/JPanelMenu.java b/src/main/java/com/unicenta/pos/forms/JPanelMenu.java new file mode 100644 index 0000000..5d49cc5 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JPanelMenu.java @@ -0,0 +1,153 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.basic.BasicException; +import java.awt.Component; +import javax.swing.JComponent; +import javax.swing.JPanel; + +/** + * + * @author adrianromero + */ +public class JPanelMenu extends JPanel implements JPanelView { + + private final MenuDefinition m_menu; + private boolean created = false; + + /** Creates new form JPanelMenu + * @param menu */ + public JPanelMenu(MenuDefinition menu) { + + m_menu = menu; + created = false; + + initComponents(); + + } + + /** + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return m_menu.getTitle(); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + if (created == false) { + + for(int i = 0; i < m_menu.countMenuElements(); i++) { + MenuElement menuitem = m_menu.getMenuElement(i); + menuitem.addComponent(this); + } + created = true; + } + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + return true; + } + + /** + * + * @param title + */ + public void addTitle(Component title) { + + currententrypanel = null; + + JPanel titlepanel = new JPanel(); + titlepanel.setLayout(new java.awt.BorderLayout()); + titlepanel.add(title, java.awt.BorderLayout.CENTER); + titlepanel.applyComponentOrientation(getComponentOrientation()); + + menucontainer.add(titlepanel); + + } + + /** + * + * @param entry + */ + public void addEntry(Component entry) { + + if (currententrypanel == null) { + currententrypanel = new JPanel(); + currententrypanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 0, 20, 0)); + currententrypanel.setLayout(new java.awt.GridLayout(0, 6, 5, 5)); + menucontainer.add(currententrypanel); + + } + + currententrypanel.add(entry); + currententrypanel.applyComponentOrientation(getComponentOrientation()); + + } + + private JPanel currententrypanel = null; + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + menucontainer = new javax.swing.JPanel(); + + setBorder(javax.swing.BorderFactory.createEmptyBorder(20, 20, 20, 20)); + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setLayout(new java.awt.BorderLayout()); + + menucontainer.setBackground(new java.awt.Color(102, 102, 102)); + menucontainer.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + menucontainer.setLayout(new javax.swing.BoxLayout(menucontainer, javax.swing.BoxLayout.Y_AXIS)); + add(menucontainer, java.awt.BorderLayout.NORTH); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel menucontainer; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/forms/JPanelNull.form b/src/main/java/com/unicenta/pos/forms/JPanelNull.form new file mode 100644 index 0000000..7a5b850 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JPanelNull.form @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,2,117"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="m_jLabelError"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.LoadError" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="30" width="490" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="jscrException"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="70" width="550" height="180"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="jtxtException"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="lineWrap" type="boolean" value="true"/> + <Property name="wrapStyleWord" type="boolean" value="true"/> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/forms/JPanelNull.java b/src/main/java/com/unicenta/pos/forms/JPanelNull.java new file mode 100644 index 0000000..fefb7f4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JPanelNull.java @@ -0,0 +1,115 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.basic.BasicException; +import javax.swing.JComponent; +import javax.swing.JPanel; + +/** + * + * @author adrianromero + */ +public class JPanelNull extends JPanel implements JPanelView { + + /** Creates new form JPanelNull + * @param oApp + * @param o */ + public JPanelNull(AppView oApp, Object o) { + + initComponents (); + if (o instanceof Exception) { + } + jtxtException.setText(o.toString()); + } + + /** + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return null; + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + return true; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the FormEditor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jLabelError = new javax.swing.JLabel(); + jscrException = new javax.swing.JScrollPane(); + jtxtException = new javax.swing.JTextArea(); + + setLayout(null); + + m_jLabelError.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jLabelError.setText(AppLocal.getIntString("label.LoadError")); // NOI18N + m_jLabelError.setPreferredSize(new java.awt.Dimension(110, 30)); + add(m_jLabelError); + m_jLabelError.setBounds(30, 30, 490, 30); + + jtxtException.setEditable(false); + jtxtException.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtException.setLineWrap(true); + jtxtException.setWrapStyleWord(true); + jscrException.setViewportView(jtxtException); + + add(jscrException); + jscrException.setBounds(30, 70, 550, 180); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JScrollPane jscrException; + private javax.swing.JTextArea jtxtException; + private javax.swing.JLabel m_jLabelError; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/forms/JPanelView.java b/src/main/java/com/unicenta/pos/forms/JPanelView.java new file mode 100644 index 0000000..c4c34b6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JPanelView.java @@ -0,0 +1,54 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.basic.BasicException; +import javax.swing.JComponent; + +/** + * + * @author adrianromero + */ +public interface JPanelView { + + /** + * + * @return + */ + public abstract String getTitle(); + + /** + * + * @throws BasicException + */ + public abstract void activate() throws BasicException; + + /** + * + * @return + */ + public abstract boolean deactivate(); + + /** + * + * @return + */ + public abstract JComponent getComponent(); +} diff --git a/src/main/java/com/unicenta/pos/forms/JPrincipalApp.form b/src/main/java/com/unicenta/pos/forms/JPrincipalApp.form new file mode 100644 index 0000000..6170ec8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JPrincipalApp.form @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,53,0,0,1,-65"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Before"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="m_jPanelLeft"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 2]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Before"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[45, 45]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace min="0" pref="0" max="-2" attributes="0"/> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace pref="88" max="32767" attributes="0"/> + <Component id="jButton1" pref="33" max="32767" attributes="0"/> + <EmptySpace pref="188" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.menu" replaceFormat="AppLocal.getIntString("tooltip.menu")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="iconTextGap" type="int" value="0"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[10, 2, 10, 2]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[45, 32224661]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 32]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[36, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="m_jPanelRight"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 40]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jPanelTitle"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="javax.swing.JLabel" name="m_jTitle"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="1"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="df" green="a8" red="0" type="rgb"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.MatteColorBorderInfo"> + <MatteColorBorder bottom="1" left="0" right="0" top="0"> + <Color PropertyName="color" blue="40" green="40" id="darkGray" palette="1" red="40" type="palette"/> + </MatteColorBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="10" left="10" right="10" top="10"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 35]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[30, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 35]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="m_jPanelContainer"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/forms/JPrincipalApp.java b/src/main/java/com/unicenta/pos/forms/JPrincipalApp.java new file mode 100644 index 0000000..37495ef --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JPrincipalApp.java @@ -0,0 +1,650 @@ +// uniCenta oPOS Touch Friendly Point of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com/product +// +// This file is part of uniCenta oPOS. +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 Openbravo POS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.JMessageDialog; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.pos.customers.CustomerInfo; +import com.unicenta.pos.scripting.ScriptEngine; +import com.unicenta.pos.scripting.ScriptException; +import com.unicenta.pos.scripting.ScriptFactory; +import com.unicenta.pos.util.Hashcypher; +import com.unicenta.pos.util.StringUtils; +import lombok.extern.slf4j.Slf4j; +import org.jdesktop.swingx.JXTaskPane; +import org.jdesktop.swingx.JXTaskPaneContainer; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +// import java.awt.Color; +// import org.jdesktop.swingx.painter.MattePainter; + +/** + * @author adrianromero + */ +@Slf4j +public class JPrincipalApp extends javax.swing.JPanel implements AppUserView { + + private final JRootApp m_appview; + private final AppUser m_appuser; + + private DataLogicSystem m_dlSystem; + + private JLabel m_principalnotificator; + + private JPanelView m_jLastView; + private Action m_actionfirst; + + private Map<String, JPanelView> m_aPreparedViews; // Prepared views + private Map<String, JPanelView> m_aCreatedViews; + + private Icon menu_open; + private Icon menu_close; + + //HS Updates + private CustomerInfo customerInfo; + + /** + * Creates new form JPrincipalApp + * + * @param appview + * @param appuser + */ + public JPrincipalApp(JRootApp appview, AppUser appuser) { + + m_appview = appview; + m_appuser = appuser; + + m_dlSystem = (DataLogicSystem) m_appview.getBean("com.unicenta.pos.forms.DataLogicSystem"); + + m_appuser.fillPermissions(m_dlSystem); + + m_actionfirst = null; + m_jLastView = null; + + m_aPreparedViews = new HashMap<>(); + m_aCreatedViews = new HashMap<>(); + + initComponents(); + + jPanel2.add(Box.createVerticalStrut(50), 0); + m_jPanelLeft.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); + + applyComponentOrientation(appview.getComponentOrientation()); + + m_principalnotificator = new JLabel(); + m_principalnotificator.applyComponentOrientation(getComponentOrientation()); + m_principalnotificator.setText(m_appuser.getName()); + m_principalnotificator.setIcon(m_appuser.getIcon()); + + if (jButton1.getComponentOrientation().isLeftToRight()) { + menu_open = new javax.swing.ImageIcon(getClass().getResource( + "/com/unicenta/images/menu-right.png")); + menu_close = new javax.swing.ImageIcon(getClass().getResource( + "/com/unicenta/images/menu-left.png")); + } else { + menu_open = new javax.swing.ImageIcon(getClass().getResource( + "/com/unicenta/images/menu-left.png")); + menu_close = new javax.swing.ImageIcon(getClass().getResource( + "/com/unicenta/images/menu-right.png")); + } + assignMenuButtonIcon(); + + m_jPanelTitle.setVisible(false); + m_jPanelContainer.add(new JPanel(), "<NULL>"); + + showView("<NULL>"); + + try { + + Component scriptMenu = getScriptMenu(m_dlSystem.getResourceAsText("Menu.Root")); + m_jPanelLeft.setViewportView(scriptMenu); + + } catch (ScriptException e) { + log.error("Cannot read Menu.Root resource. Trying default menu.", e.getMessage()); + try { + m_jPanelLeft.setViewportView(getScriptMenu( + StringUtils.readResource("/com/unicenta/pos/templates/Menu.Root.txt"))); + } catch (IOException | ScriptException ex) { + log.error("Cannot read default menu", ex.getMessage()); + } + } + } + + private Component getScriptMenu(String menutext) throws ScriptException { + + ScriptMenu menu = new ScriptMenu(); + + ScriptEngine eng = ScriptFactory.getScriptEngine(ScriptFactory.BEANSHELL); + eng.put("menu", menu); + eng.eval(menutext); + return menu.getTaskPane(); + } + + private void assignMenuButtonIcon() { + jButton1.setIcon(m_jPanelLeft.isVisible() + ? menu_close + : menu_open); + } + + /** + * + */ + public class ScriptMenu { + private final JXTaskPaneContainer taskPane; + + private ScriptMenu() { + taskPane = new JXTaskPaneContainer(); + taskPane.applyComponentOrientation(getComponentOrientation()); + } + + /** + * @param key + * @return + */ + public ScriptGroup addGroup(String key) { + ScriptGroup group = new ScriptGroup(key); + taskPane.add(group.getTaskGroup()); + return group; + } + + /** + * @return + */ + public JXTaskPaneContainer getTaskPane() { + return taskPane; + } + } + + /** + * + */ + public class ScriptGroup { + + private final JXTaskPane taskGroup; + + private ScriptGroup(String key) { + taskGroup = new JXTaskPane(); + taskGroup.applyComponentOrientation(getComponentOrientation()); + taskGroup.setFocusable(false); + taskGroup.setRequestFocusEnabled(false); + taskGroup.setTitle(AppLocal.getIntString(key)); + taskGroup.setVisible(false); + taskGroup.setFont(new java.awt.Font("Arial", 0, 16)); + + } + + /** + * @param icon + * @param key + * @param classname + */ + public void addPanel(String icon, String key, String classname) { + addAction(new MenuPanelAction(m_appview, icon, key, classname)); + } + + /** + * @param icon + * @param key + * @param classname + */ + public void addExecution(String icon, String key, String classname) { + addAction(new MenuExecAction(m_appview, icon, key, classname)); + } + + /** + * @param icon + * @param key + * @param classname + * @return + */ + public ScriptSubmenu addSubmenu(String icon, String key, String classname) { + ScriptSubmenu submenu = new ScriptSubmenu(key); + m_aPreparedViews.put(classname, new JPanelMenu(submenu.getMenuDefinition())); + MenuPanelAction menuPanelAction = new MenuPanelAction(m_appview, icon, key, classname); + addAction(menuPanelAction); + return submenu; + } + + /** + * + */ + public void addChangePasswordAction() { + addAction(new ChangePasswordAction("/com/unicenta/images/password.png", "Menu.ChangePassword")); + } + + /** + * + */ + public void addExitAction() { + addAction(new ExitAction("/com/unicenta/images/logout.png", "Menu.Exit")); + } + + private void addAction(Action act) { + String permissions = (String) act.getValue(AppUserView.ACTION_TASKNAME); + boolean hasPermission = m_appuser.hasPermission(permissions); + if (hasPermission) { + Component c = taskGroup.add(act); + c.applyComponentOrientation(getComponentOrientation()); + c.setFocusable(false); + + taskGroup.setVisible(true); + + if (m_actionfirst == null) { + m_actionfirst = act; + } + } + } + + + /** + * @return + */ + public JXTaskPane getTaskGroup() { + return taskGroup; + } + } + + /** + * + */ + public class ScriptSubmenu { + private final MenuDefinition menudef; + + private ScriptSubmenu(String key) { + menudef = new MenuDefinition(key); + } + + /** + * @param key + */ + public void addTitle(String key) { + menudef.addMenuTitle(key); + } + + /** + * @param icon + * @param key + * @param classname + */ + public void addPanel(String icon, String key, String classname) { + menudef.addMenuItem(new MenuPanelAction(m_appview, icon, key, classname)); + } + + /** + * @param icon + * @param key + * @param classname + */ + public void addExecution(String icon, String key, String classname) { + menudef.addMenuItem(new MenuExecAction(m_appview, icon, key, classname)); + } + + /** + * @param icon + * @param key + * @param classname + * @return + */ + public ScriptSubmenu addSubmenu(String icon, String key, String classname) { + ScriptSubmenu submenu = new ScriptSubmenu(key); + m_aPreparedViews.put(classname, new JPanelMenu(submenu.getMenuDefinition())); + menudef.addMenuItem(new MenuPanelAction(m_appview, icon, key, classname)); + return submenu; + } + + /** + * + */ + public void addChangePasswordAction() { + menudef.addMenuItem(new ChangePasswordAction("/com/unicenta/images/password.png", "Menu.ChangePassword")); + } + + /** + * + */ + public void addExitAction() { + menudef.addMenuItem(new ExitAction("/com/unicenta/images/logout.png", "Menu.Exit")); + } + + /** + * @return + */ + public MenuDefinition getMenuDefinition() { + return menudef; + } + } + + private void setMenuVisible(boolean value) { + + m_jPanelLeft.setVisible(value); + assignMenuButtonIcon(); + revalidate(); + } + + /** + * @return + */ + public JComponent getNotificator() { + return m_principalnotificator; + } + + /** + * + */ + public void activate() { + + setMenuVisible(getBounds().width > 800); + + if (m_actionfirst != null) { + m_actionfirst.actionPerformed(null); + m_actionfirst = null; + } + } + + /** + * @return + */ + public boolean deactivate() { + if (m_jLastView == null) { + return true; + } else if (m_jLastView.deactivate()) { + m_jLastView = null; + showView("<NULL>"); + return true; + } else { + return false; + } + + } + + private class ExitAction extends AbstractAction { + + public ExitAction(String icon, String keytext) { + putValue(Action.SMALL_ICON, new ImageIcon(JPrincipalApp.class.getResource(icon))); + putValue(Action.NAME, AppLocal.getIntString(keytext)); + putValue(AppUserView.ACTION_TASKNAME, keytext); + } + + @Override + public void actionPerformed(ActionEvent evt) { + m_appview.closeAppView(); + } + } + + /** + * + */ + public void exitToLogin() { + m_appview.closeAppView(); + } + + + private class ChangePasswordAction extends AbstractAction { + public ChangePasswordAction(String icon, String keytext) { + putValue(Action.SMALL_ICON, new ImageIcon(JPrincipalApp.class.getResource(icon))); + putValue(Action.NAME, AppLocal.getIntString(keytext)); + putValue(AppUserView.ACTION_TASKNAME, keytext); + + } + + @Override + public void actionPerformed(ActionEvent evt) { + + String sNewPassword = Hashcypher.changePassword(JPrincipalApp.this, m_appuser.getPassword()); + if (sNewPassword != null) { + try { + + m_dlSystem.execChangePassword(new Object[]{sNewPassword, m_appuser.getId()}); + m_appuser.setPassword(sNewPassword); + } catch (BasicException e) { + JMessageDialog.showMessage(JPrincipalApp.this + , new MessageInf(MessageInf.SGN_WARNING + , AppLocal.getIntString("message.cannotchangepassword"))); + } + } + } + } + + + private void showView(String sView) { + CardLayout cl = (CardLayout) (m_jPanelContainer.getLayout()); + cl.show(m_jPanelContainer, sView); + } + + /** + * @return + */ + @Override + public AppUser getUser() { + return m_appuser; + } + + /** + * @param sTaskClass + */ + @Override + public void showTask(String sTaskClass) { + + customerInfo = new CustomerInfo(""); + customerInfo.setName(""); + + m_appview.waitCursorBegin(); + + if (m_appuser.hasPermission(sTaskClass)) { + + JPanelView m_jMyView = (JPanelView) m_aCreatedViews.get(sTaskClass); + + if (m_jLastView == null|| (m_jMyView != m_jLastView && m_jLastView.deactivate())) { + + if (m_jMyView == null) { + + m_jMyView = m_aPreparedViews.get(sTaskClass); + + if (m_jMyView == null) { + + try { + m_jMyView = (JPanelView) m_appview.getBean(sTaskClass); + } catch (BeanFactoryException e) { + m_jMyView = new JPanelNull(m_appview, e); + } + } + + m_jMyView.getComponent().applyComponentOrientation(getComponentOrientation()); + m_jPanelContainer.add(m_jMyView.getComponent(), sTaskClass); + m_aCreatedViews.put(sTaskClass, m_jMyView); + } + + try { + m_jMyView.activate(); + } catch (BasicException e) { + JMessageDialog.showMessage(this + , new MessageInf(MessageInf.SGN_WARNING + , AppLocal.getIntString("message.notactive"), e)); + } + + m_jLastView = m_jMyView; + + setMenuVisible(getBounds().width > 800); + setMenuVisible(false); + + showView(sTaskClass); + String sTitle = m_jMyView.getTitle(); + m_jPanelTitle.setVisible(sTitle != null); + m_jTitle.setText(sTitle); + } + } else { + + JMessageDialog.showMessage(this + , new MessageInf(MessageInf.SGN_WARNING + , AppLocal.getIntString("message.notpermissions"))); + } + m_appview.waitCursorEnd(); + } + + /** + * @param sTaskClass + */ + @Override + public void executeTask(String sTaskClass) { + + m_appview.waitCursorBegin(); + + if (m_appuser.hasPermission(sTaskClass)) { + try { + ProcessAction myProcess = (ProcessAction) m_appview.getBean(sTaskClass); + + try { + MessageInf m = myProcess.execute(); + if (m != null) { + JMessageDialog.showMessage(JPrincipalApp.this, m); + } + } catch (BasicException eb) { + JMessageDialog.showMessage(JPrincipalApp.this, new MessageInf(eb)); + } + } catch (BeanFactoryException e) { + JMessageDialog.showMessage(JPrincipalApp.this + , new MessageInf(MessageInf.SGN_WARNING + , AppLocal.getIntString("label.LoadError"), e)); + } + } else { + JMessageDialog.showMessage(JPrincipalApp.this + , new MessageInf(MessageInf.SGN_WARNING + , AppLocal.getIntString("message.notpermissions"))); + } + m_appview.waitCursorEnd(); + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + m_jPanelLeft = new javax.swing.JScrollPane(); + jPanel2 = new javax.swing.JPanel(); + jButton1 = new javax.swing.JButton(); + m_jPanelRight = new javax.swing.JPanel(); + m_jPanelTitle = new javax.swing.JPanel(); + m_jTitle = new javax.swing.JLabel(); + m_jPanelContainer = new javax.swing.JPanel(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setLayout(new java.awt.BorderLayout()); + + jPanel1.setLayout(new java.awt.BorderLayout()); + + m_jPanelLeft.setBackground(new java.awt.Color(102, 102, 102)); + m_jPanelLeft.setBorder(null); + m_jPanelLeft.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPanelLeft.setPreferredSize(new java.awt.Dimension(250, 2)); + jPanel1.add(m_jPanelLeft, java.awt.BorderLayout.LINE_START); + + jPanel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel2.setPreferredSize(new java.awt.Dimension(45, 45)); + + jButton1.setToolTipText(AppLocal.getIntString("tooltip.menu")); // NOI18N + jButton1.setFocusPainted(false); + jButton1.setFocusable(false); + jButton1.setIconTextGap(0); + jButton1.setMargin(new java.awt.Insets(10, 2, 10, 2)); + jButton1.setMaximumSize(new java.awt.Dimension(45, 32224661)); + jButton1.setMinimumSize(new java.awt.Dimension(32, 32)); + jButton1.setPreferredSize(new java.awt.Dimension(36, 45)); + jButton1.setRequestFocusEnabled(false); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addGap(0, 0, 0) + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap(88, Short.MAX_VALUE) + .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 33, Short.MAX_VALUE) + .addContainerGap(188, Short.MAX_VALUE)) + ); + + jPanel1.add(jPanel2, java.awt.BorderLayout.LINE_END); + + add(jPanel1, java.awt.BorderLayout.LINE_START); + + m_jPanelRight.setPreferredSize(new java.awt.Dimension(200, 40)); + m_jPanelRight.setLayout(new java.awt.BorderLayout()); + + m_jPanelTitle.setLayout(new java.awt.BorderLayout()); + + m_jTitle.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + m_jTitle.setForeground(new java.awt.Color(0, 168, 223)); + m_jTitle.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, java.awt.Color.darkGray), javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10))); + m_jTitle.setMaximumSize(new java.awt.Dimension(100, 35)); + m_jTitle.setMinimumSize(new java.awt.Dimension(30, 25)); + m_jTitle.setPreferredSize(new java.awt.Dimension(100, 35)); + m_jPanelTitle.add(m_jTitle, java.awt.BorderLayout.NORTH); + + m_jPanelRight.add(m_jPanelTitle, java.awt.BorderLayout.NORTH); + + m_jPanelContainer.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPanelContainer.setLayout(new java.awt.CardLayout()); + m_jPanelRight.add(m_jPanelContainer, java.awt.BorderLayout.CENTER); + + add(m_jPanelRight, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + + setMenuVisible(!m_jPanelLeft.isVisible()); + + }//GEN-LAST:event_jButton1ActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel m_jPanelContainer; + private javax.swing.JScrollPane m_jPanelLeft; + private javax.swing.JPanel m_jPanelRight; + private javax.swing.JPanel m_jPanelTitle; + private javax.swing.JLabel m_jTitle; + // End of variables declaration//GEN-END:variables + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/forms/JRootApp.form b/src/main/java/com/unicenta/pos/forms/JRootApp.form new file mode 100644 index 0000000..4a55394 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JRootApp.form @@ -0,0 +1,443 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1024, 768]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,3,86,0,0,4,0"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jPanelTitle"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.MatteColorBorderInfo"> + <MatteColorBorder bottom="1" left="0" right="0" top="0"> + <Color PropertyName="color" blue="99" green="8a" id="Button.darkShadow" palette="3" red="7a" type="palette"/> + </MatteColorBorder> + </Border> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[449, 40]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="javax.swing.JLabel" name="m_jLblTitle"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="16" style="1"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" value="Window.Title"/> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JRootApp_m_jLblTitle"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="poweredby"> + <Properties> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/poweredby_uni.png"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="5" right="5" top="0"/> + </Border> + </Property> + <Property name="horizontalTextPosition" type="int" value="4"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 34]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 34]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="16" style="1"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 34]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Before"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="m_jPanelContainer"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jPanelLogin"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription"> + <CardConstraints cardName="login"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/unicenta.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code=""<html><center>uniCenta oPOS - Touch Friendly Point of Sale<br>" + "Copyright \u00A9 2009-2017 uniCenta <br>" + "https://unicenta.com<br>" + "<br>" + "uniCenta oPOS 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.<br>" + "<br>" + "uniCenta oPOS 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.<br>" + "<br>" + "You should have received a copy of the GNU General Public License along with uniCenta oPOS. If not, see http://www.gnu.org/licenses/<br>" + "</center>"" type="code"/> + </Property> + <Property name="alignmentX" type="float" value="0.5"/> + <Property name="horizontalTextPosition" type="int" value="0"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[800, 1024]"/> + </Property> + <Property name="verticalTextPosition" type="int" value="3"/> + </Properties> + </Component> + <Component class="javax.swing.Box$Filler" name="filler2"> + <Properties> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32767, 0]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 10]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalGlue"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 400]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="jPanel1" max="32767" attributes="1"/> + <Component id="jScrollPane1" max="32767" attributes="1"/> + </Group> + <EmptySpace min="-2" pref="104" max="-2" attributes="0"/> + <Component id="m_jLogonName" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="15" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="m_jLogonName" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="434" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jScrollPane1" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jPanel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jLogonName"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="5" right="5" top="0"/> + </Border> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 100]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel8"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout"> + <Property name="columns" type="int" value="1"/> + <Property name="horizontalGap" type="int" value="5"/> + <Property name="rows" type="int" value="0"/> + <Property name="verticalGap" type="int" value="5"/> + </Layout> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="horizontalScrollBarPolicy" type="int" value="31"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JRootApp_jScrollPane1"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="m_txtKeys" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jClose" pref="267" max="32767" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="m_txtKeys" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jClose" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JTextField" name="m_txtKeys"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 0]"/> + </Property> + </Properties> + <Events> + <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="m_txtKeysKeyTyped"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jClose"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/exit.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.close" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 50]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jCloseActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="m_jPanelDown"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.MatteColorBorderInfo"> + <MatteColorBorder bottom="0" left="0" right="0" top="1"> + <Color PropertyName="color" blue="99" green="8a" id="Button.darkShadow" palette="3" red="7a" type="palette"/> + </MatteColorBorder> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="panelTask"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Before"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JLabel" name="m_jHost"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="11" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/display.png"/> + </Property> + <Property name="text" type="java.lang.String" value="*Hostname"/> + </Properties> + </Component> + <Component class="com.alee.extended.statusbar.WebMemoryBar" name="webMemoryBar1"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="99" green="99" red="99" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" value=""/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="11" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="usedBorderColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="cc" green="cc" red="0" type="rgb"/> + </Property> + <Property name="usedFillColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="cc" red="0" type="rgb"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.progressbar.WebProgressBar" name="serverMonitor"> + <Properties> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 18]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="progressBottomColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ed" green="c5" red="4c" type="rgb"/> + </Property> + <Property name="round" type="int" value="2"/> + <Property name="string" type="java.lang.String" value="Keep Alive"/> + <Property name="stringPainted" type="boolean" value="true"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/forms/JRootApp.java b/src/main/java/com/unicenta/pos/forms/JRootApp.java new file mode 100644 index 0000000..71b653e --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JRootApp.java @@ -0,0 +1,1217 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/> + +package com.unicenta.pos.forms; + +import com.dalsemi.onewire.OneWireAccessProvider; +import com.dalsemi.onewire.OneWireException; +import com.dalsemi.onewire.adapter.DSPortAdapter; +import com.dalsemi.onewire.application.monitor.DeviceMonitor; +import com.dalsemi.onewire.application.monitor.DeviceMonitorEvent; +import com.dalsemi.onewire.application.monitor.DeviceMonitorEventListener; +import com.dalsemi.onewire.application.monitor.DeviceMonitorException; +import com.dalsemi.onewire.container.OneWireContainer; +import com.dalsemi.onewire.utils.Address; +import com.unicenta.basic.BasicException; +import com.unicenta.beans.JFlowPanel; +import com.unicenta.beans.JPasswordDialog; +import com.unicenta.data.gui.JMessageDialog; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.BatchSentence; +import com.unicenta.data.loader.BatchSentenceResource; +import com.unicenta.data.loader.Session; +import com.unicenta.format.Formats; +import com.unicenta.pos.printer.DeviceTicket; +import com.unicenta.pos.printer.TicketParser; +import com.unicenta.pos.printer.TicketPrinterException; +import com.unicenta.pos.scale.DeviceScale; +import com.unicenta.pos.scanpal2.DeviceScanner; +import com.unicenta.pos.scanpal2.DeviceScannerFactory; +import com.unicenta.pos.util.uOWWatch; +import lombok.extern.slf4j.Slf4j; +import org.joda.time.DateTime; +import org.joda.time.Instant; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.net.*; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.sql.*; +import java.text.DateFormat; +import java.util.Date; +import java.util.*; +import java.util.regex.Matcher; + + +/** + * @author adrianromero + */ +// public class JRootApp extends JPanel implements AppView { +@Slf4j +public class JRootApp extends JPanel implements AppView, DeviceMonitorEventListener { + + private AppProperties m_props; + private Session session; + private DataLogicSystem m_dlSystem; + + private Properties m_propsdb = null; + private String m_sActiveCashIndex; + private int m_iActiveCashSequence; + private Date m_dActiveCashDateStart; + private Date m_dActiveCashDateEnd; + + private Double m_dActiveCashNotes; + private Double m_dActiveCashCoins; + private Double m_dActiveCashCards; + + private String m_sClosedCashIndex; + private int m_iClosedCashSequence; + private Date m_dClosedCashDateStart; + private Date m_dClosedCashDateEnd; + +// private Double m_dClosedCashNotes; +// private Double m_dClosedCashCoins; +// private Double m_dClosedCashCards; + + private String m_sInventoryLocation; + + private StringBuilder inputtext; + + private DeviceScale m_Scale; + private DeviceScanner m_Scanner; + private DeviceTicket m_TP; + private TicketParser m_TTP; + + private final Map<String, BeanFactory> m_aBeanFactories; + + private JPrincipalApp m_principalapp = null; + + private static HashMap<String, String> m_oldclasses; + + private String m_clock; + private String m_date; + private Connection con; + private ResultSet rs; + private Statement stmt; + private String SQL; + private String sJLVersion; + private DatabaseMetaData md; + + private final int m_rate = 0; + + static { + initOldClasses(); + } + + private String sLaunch; + private String sMachine; + + private class PrintTimeAction implements ActionListener { + + @Override + public void actionPerformed(ActionEvent evt) { + m_clock = getLineTimer(); + m_date = getLineDate(); + + DateTime m_datetime = getDateTime(); + + m_jLblTitle.setText(m_dlSystem.getResourceAsText("Window.Title")); + m_jLblTitle.repaint(); + jLabel2.setText(" " + m_date + " " + m_clock); +/* +* JG Note: Arbritary 8 hour cycle for MySQL server ping on chosen port:nnnn +* MySQL default setting is 28800 seconds (8hrs) +* Better than a host ping as need to know if MySQL is alive & kicking +* Be careful though as MySQL could run out of Connections if it's left on default + + + webProgressBar.setValue(0); + + if (getDateTime().getHourOfDay() == 7 + || getDateTime().getHourOfDay() == 15 + || getDateTime().getHourOfDay() == 23) { + + if (getDateTime().getMinuteOfHour() == 59 && + (getDateTime().getSecondOfMinute() == 59)) { + try { + if (pingServer()) { + webProgressBar.setValue(0); + } else { + webProgressBar.setString("Server is down!"); + webProgressBar.setValue(100); + } + } catch (UnknownHostException ex) { + log.error(ex.getMessage()); } + } + } +*/ + } + } + + private DateTime getDateTime() { + DateTime dt = DateTime.now(); + return dt; + } + + private String getLineTimer() { + return Formats.HOURMIN.formatValue(new Date()); + } + + private String getLineDate() { + DateFormat df = DateFormat.getDateInstance(DateFormat.DEFAULT, getDefaultLocale()); + return df.format(new Date()); + } + + + public JRootApp() { + + m_aBeanFactories = new HashMap<>(); + + initComponents(); + jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(30, 30)); + serverMonitor.setVisible(false); + webMemoryBar1.setShowMaximumMemory(true); + } + + private DSPortAdapter m_oneWireAdapter; + private DeviceMonitor m_oneWireMonitor; + + private void initIButtonMonitor() { + + assert m_oneWireMonitor == null; + try { + m_oneWireAdapter = OneWireAccessProvider.getDefaultAdapter(); + m_oneWireAdapter.setSearchAllDevices(); + m_oneWireAdapter.targetFamily(0x01); + m_oneWireAdapter.setSpeed(DSPortAdapter.SPEED_REGULAR); + m_oneWireMonitor = new DeviceMonitor(m_oneWireAdapter); +// Normal state + m_oneWireMonitor.setMaxStateCount(5); +// Use for testing +// m_oneWireMonitor.setMaxStateCount(100); + m_oneWireMonitor.addDeviceMonitorEventListener(this); + new Thread(m_oneWireMonitor).start(); + } catch (OneWireException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.ibuttonnotfound"), e)); + } + } + + private void shutdownIButtonMonitor() { + if (m_oneWireMonitor != null) { + m_oneWireMonitor.killMonitor(); + try { + m_oneWireAdapter.freePort(); + } catch (OneWireException e) { +// System.out.println(e); + } + } + } + + public void releaseResources() { + shutdownIButtonMonitor(); + } + + final static int UNIQUE_KEY_FAMILY = 0x01; + + private boolean isDeviceRelevant(OneWireContainer container) { + String iButtonId = container.getAddressAsString(); + try { + if (container.getAdapter().getAdapterAddress().equals(iButtonId)) + return false; + } catch (OneWireException e) { + } + + int familyNumber = Address.toByteArray(iButtonId)[0]; + return (familyNumber == UNIQUE_KEY_FAMILY); + } + + /** + * Called when an iButton is inserted. + * + * @param devt + */ + @Override + public void deviceArrival(DeviceMonitorEvent devt) { + assert m_dlSystem != null; + + for (int i = 0; i < devt.getDeviceCount(); i++) { + OneWireContainer container = devt.getContainerAt(i); + if (!isDeviceRelevant(container)) + continue; + + String iButtonId = devt.getAddressAsStringAt(i); + + AppUser user = null; + try { + user = m_dlSystem.findPeopleByCard(iButtonId); + } catch (BasicException e) { + if (user == null) { + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.ibuttonnotassign"), + AppLocal.getIntString("title.editor"), + JOptionPane.INFORMATION_MESSAGE); + } + } + + if (user == null) { + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.ibuttonnotassign"), + AppLocal.getIntString("title.editor"), + JOptionPane.INFORMATION_MESSAGE); + + } else { + setVisible(false); + openAppView(user); + setVisible(true); + } + } + } + + /** + * Called when an iButton is removed. + * + * @param devt + */ + @Override + public void deviceDeparture(DeviceMonitorEvent devt) { + + for (int i = 0; i < devt.getDeviceCount(); i++) { + OneWireContainer container = devt.getContainerAt(i); + if (!isDeviceRelevant(container)) + continue; + + String iButtonId = devt.getAddressAsStringAt(i); + + if (m_principalapp != null) { + AppUser currentUser = m_principalapp.getUser(); + if (currentUser != null && currentUser.getCard().equals(iButtonId)) + closeAppView(); + } + } + } + + @Override + public void networkException(DeviceMonitorException dexc) { +// System.out.println("ERROR: " + dexc.toString()); + } + + /** + * @param props + * @return + */ + public boolean initApp(AppProperties props) { + + m_props = props; + m_jPanelDown.setVisible(!(Boolean.valueOf(m_props.getProperty("till.hideinfo")))); + + applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault())); + + try { + session = AppViewConnection.createSession(m_props); + + } catch (BasicException e) { + JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_DANGER, e.getMessage(), e)); + return false; + } + + m_dlSystem = (DataLogicSystem) getBean("com.unicenta.pos.forms.DataLogicSystem"); +/** + * CONDITIONS; + * if dbversion is null then new createDatabase + * if dbversion is not null then check the version + * if appversion equals dbversion then check for updates + * IF APP_VERSION = existing db version + * + */ + String sDBVersion = readDataBaseVersion(); + if (!AppLocal.APP_VERSION.equals(sDBVersion)) { + String sScript = sDBVersion == null + ? m_dlSystem.getInitScript() + "-create.sql" + : m_dlSystem.getInitScript() + "-upgrade_master.sql"; + + if (JRootApp.class.getResource(sScript) == null) { + JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_DANGER, sDBVersion == null + ? AppLocal.getIntString("message.databasenotsupported", session.DB.getName() + " " + sDBVersion) + : AppLocal.getIntString("message.noupdatescript"))); + session.close(); + return false; + } else { + + String migrationMessage = sDBVersion == null ? "message.createdatabase" : "message.eolupdate"; + if (JOptionPane.showConfirmDialog(this + , AppLocal.getIntString(migrationMessage, session.DB.getName() + " " + sDBVersion) + , AppLocal.getIntString("message.title") + , JOptionPane.OK_OPTION + , JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { + + try { + BatchSentence bsentence = new BatchSentenceResource(session, sScript); + bsentence.putParameter("APP_ID", Matcher.quoteReplacement(AppLocal.APP_ID)); + bsentence.putParameter("APP_NAME", Matcher.quoteReplacement(AppLocal.APP_NAME)); + bsentence.putParameter("APP_VERSION", Matcher.quoteReplacement(AppLocal.APP_VERSION)); + + java.util.List l = bsentence.list(); + + if (l.size() > 0) { + JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING + , AppLocal.getIntString("database.scriptwarning") + , l.toArray(new Throwable[l.size()]))); + } + } catch (BasicException e) { + JMessageDialog.showMessage(this + , new MessageInf(MessageInf.SGN_DANGER + , AppLocal.getIntString("database.scripterror"), e)); + session.close(); + return false; + } + } else { + session.close(); + return false; + } + } + } + + /* + * JG 10 Dec 2018 + * Test rig in prep' to track user install/launch success/fails + * We only need core info' to identify for POC + * For testing; code and declares are deliberately verbose + * + * FUTURE : + * App' error logging + * Also auto-Notify users of available app' updates. + * To be replaced with our REST API + */ + + try { + sMachine = InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException ex) { + log.error(ex.getMessage()); + } +// create the filename + String sUserPath = System.getProperty("user.home"); + String filePath = sUserPath + "/" + sMachine + ".lau"; + + Instant machineTimestamp = Instant.now(); + String sContent = sUserPath + "," + + machineTimestamp + "," + + AppLocal.APP_ID + "," + + AppLocal.APP_NAME + "," + + AppLocal.APP_VERSION + "\n"; + + try { + Files.write(Paths.get(filePath), sContent.getBytes(), + StandardOpenOption.APPEND, StandardOpenOption.CREATE); + } catch (IOException ex) { + log.error(ex.getMessage()); + } + + try { + filePath = sUserPath + "/open.db"; + Files.write(Paths.get(filePath), sContent.getBytes(), + StandardOpenOption.CREATE); + } catch (IOException ex) { + log.error(ex.getMessage()); + } + + m_propsdb = m_dlSystem.getResourceAsProperties(m_props.getHost() + "/properties"); + + try { + String sActiveCashIndex = m_propsdb.getProperty("activecash"); + + Object[] valcash = sActiveCashIndex == null + ? null + : m_dlSystem.findActiveCash(sActiveCashIndex); + + + if (valcash == null || !m_props.getHost().equals(valcash[0])) { + + setActiveCash(UUID.randomUUID().toString(),m_dlSystem.getSequenceCash(m_props.getHost()) + 1, new Date(), null); + + Object[] cash = new Object[]{ + getActiveCashIndex(), + m_props.getHost(), + getActiveCashSequence(), + getActiveCashDateStart(), + getActiveCashDateEnd() + }; + + m_dlSystem.execInsertCash(cash); + + } else { + setActiveCash(sActiveCashIndex + , (Integer) valcash[1] + , (Date) valcash[2] + , (Date) valcash[3]); + } + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE + , AppLocal.getIntString("message.cannotclosecash"), e); + msg.show(this); + session.close(); + return false; + } + + m_sInventoryLocation = m_propsdb.getProperty("location"); + if (m_sInventoryLocation == null) { + m_sInventoryLocation = "0"; + m_propsdb.setProperty("location", m_sInventoryLocation); + m_dlSystem.setResourceAsProperties(m_props.getHost() + "/properties" + , m_propsdb); + } + + m_TP = new DeviceTicket(this, m_props); + + m_TTP = new TicketParser(getDeviceTicket(), m_dlSystem); + printerStart(); + + m_Scale = new DeviceScale(this, m_props); + + m_Scanner = DeviceScannerFactory.createInstance(m_props); + + new javax.swing.Timer(250, new PrintTimeAction()).start(); + + String sWareHouse; + + try { + sWareHouse = m_dlSystem.findLocationName(m_sInventoryLocation); + } catch (BasicException e) { + sWareHouse = null; + } + + String url; + try { + url = session.getURL(); + } catch (SQLException e) { + url = ""; + } + m_jHost.setText("<html>" + m_props.getHost() + " - " + sWareHouse + "<br>" + url); + + + String newLogo = m_props.getProperty("start.logo"); + if (newLogo != null) { + if ("".equals(newLogo)) { + jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/logo.png"))); + } else { + jLabel1.setIcon(new javax.swing.ImageIcon(newLogo)); + } + } + + String newText = m_props.getProperty("start.text"); + if (newText != null) { + if (newText.equals("")) { + jLabel1.setText("<html><center>uniCenta oPOS - Touch Friendly Point of Sale<br>" + + "Copyright \u00A9 uniCenta <br>" + + "https://unicenta.com/<br>" + + "<br>" + + "uniCenta oPOS 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.<br>" + + "<br>" + + "uniCenta oPOS 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.<br>" + + "<br>" + + "You should have received a copy of the GNU General Public License along with uniCenta oPOS. If not, see http://www.gnu.org/licenses/<br>" + + "</center>"); + + } else { + try { + String newTextCode = new Scanner(new File(newText) + , "UTF-8").useDelimiter("\\A").next(); + jLabel1.setText(newTextCode); + } catch (FileNotFoundException e) { + } + + jLabel1.setAlignmentX(0.5F); + jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jLabel1.setMaximumSize(new java.awt.Dimension(800, 1024)); + jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + } + } + + showLogin(); + + String ibutton = m_props.getProperty("machine.iButton"); + if (ibutton.equals("true")) { + initIButtonMonitor(); + uOWWatch.iButtonOn(); + } + return true; + } + + private String readDataBaseVersion() { + try { + return m_dlSystem.findVersion(); + } catch (BasicException ed) { + return null; + } + } + + public void tryToClose() { + + if (closeAppView()) { + m_TP.getDeviceDisplay().clearVisor(); + shutdownIButtonMonitor(); + +// delete the open.db tracking file + String sUserPath = System.getProperty("user.home"); +// String filePath = sUserPath + "\\open.db"; + String filePath = sUserPath + "/open.db"; + try { + Files.deleteIfExists(Paths.get(filePath)); + } catch (IOException ex) { + log.error(ex.getMessage()); + } + + session.close(); + SwingUtilities.getWindowAncestor(this).dispose(); + } + } + + @Override + public DeviceTicket getDeviceTicket() { + return m_TP; + } + + @Override + public DeviceScale getDeviceScale() { + return m_Scale; + } + + @Override + public DeviceScanner getDeviceScanner() { + return m_Scanner; + } + + @Override + public Session getSession() { + return session; + } + + @Override + public String getInventoryLocation() { + return m_sInventoryLocation; + } + + @Override + public String getActiveCashIndex() { + return m_sActiveCashIndex; + } + + @Override + public int getActiveCashSequence() { + return m_iActiveCashSequence; + } + + @Override + public Date getActiveCashDateStart() { + return m_dActiveCashDateStart; + } + + @Override + public Date getActiveCashDateEnd() { + return m_dActiveCashDateEnd; + } + + @Override + public void setActiveCash(String sIndex, int iSeq, Date dStart, Date dEnd) { + m_sActiveCashIndex = sIndex; + m_iActiveCashSequence = iSeq; + m_dActiveCashDateStart = dStart; + m_dActiveCashDateEnd = dEnd; + + m_propsdb.setProperty("activecash", m_sActiveCashIndex); + m_dlSystem.setResourceAsProperties(m_props.getHost() + "/properties", m_propsdb); + } + + @Override + public String getClosedCashIndex() { + return m_sClosedCashIndex; + } + + @Override + public int getClosedCashSequence() { + return m_iClosedCashSequence; + } + + @Override + public Date getClosedCashDateStart() { + return m_dClosedCashDateStart; + } + + @Override + public Date getClosedCashDateEnd() { + return m_dClosedCashDateEnd; + } + + @Override + public void setClosedCash(String sIndex, int iSeq, Date dStart, Date dEnd) { + m_sClosedCashIndex = sIndex; + m_iClosedCashSequence = iSeq; + m_dClosedCashDateStart = dStart; + m_dClosedCashDateEnd = dEnd; + + m_dlSystem.setResourceAsProperties(m_props.getHost() + "/properties", m_propsdb); + } + + @Override + public AppProperties getProperties() { + return m_props; + } + + @Override + public Object getBean(String beanfactory) throws BeanFactoryException { + + beanfactory = mapNewClass(beanfactory); + BeanFactory bf = m_aBeanFactories.get(beanfactory); + + if (bf == null) { + + if (beanfactory.startsWith("/")) { + bf = new BeanFactoryScript(beanfactory); + } else { + try { + Class bfclass = Class.forName(beanfactory); + + if (BeanFactory.class.isAssignableFrom(bfclass)) { + bf = (BeanFactory) bfclass.newInstance(); + } else { + Constructor constMyView = bfclass.getConstructor(new Class[]{AppView.class}); + Object bean = constMyView.newInstance(new Object[]{this}); + bf = new BeanFactoryObj(bean); + } + + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException | NoSuchMethodException + | SecurityException | IllegalArgumentException | InvocationTargetException e) { + throw new BeanFactoryException(e); + } + } + + m_aBeanFactories.put(beanfactory, bf); + + if (bf instanceof BeanFactoryApp) { + ((BeanFactoryApp) bf).init(this); + } + } + return bf.getBean(); + } + + private static String mapNewClass(String classname) { + String newclass = m_oldclasses.get(classname); + return newclass == null + ? classname + : newclass; + } + + private static void initOldClasses() { + m_oldclasses = new HashMap<>(); + + m_oldclasses.put("com.unicenta.pos.reports.JReportCustomers", "/com/unicenta/reports/customers.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportCustomersB", "/com/unicenta/reports/customersb.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportClosedPos", "/com/unicenta/reports/closedpos.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportClosedProducts", "/com/unicenta/reports/closedproducts.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JChartSales", "/com/unicenta/reports/chartsales.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportInventory", "/com/unicenta/reports/inventory.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportInventory2", "/com/unicenta/reports/inventoryb.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportInventoryBroken", "/com/unicenta/reports/inventorybroken.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportInventoryDiff", "/com/unicenta/reports/inventorydiff.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportPeople", "/com/unicenta/reports/people.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportTaxes", "/com/unicenta/reports/taxes.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportUserSales", "/com/unicenta/reports/usersales.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportProducts", "/com/unicenta/reports/products.bs"); + m_oldclasses.put("com.unicenta.pos.reports.JReportCatalog", "/com/unicenta/reports/productscatalog.bs"); + + m_oldclasses.put("com.unicenta.pos.panels.JPanelTax", "com.unicenta.pos.inventory.TaxPanel"); + + } + + @Override + public void waitCursorBegin() { + setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + } + + @Override + public void waitCursorEnd() { + setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + + @Override + public AppUserView getAppUserView() { + return m_principalapp; + } + + private void printerStart() { + + String sresource = m_dlSystem.getResourceAsXML("Printer.Start"); + if (sresource == null) { + m_TP.getDeviceDisplay().writeVisor(AppLocal.APP_NAME, AppLocal.APP_VERSION); + } else { + try { + m_TTP.printTicket(sresource); + } catch (TicketPrinterException eTP) { + m_TP.getDeviceDisplay().writeVisor(AppLocal.APP_NAME, AppLocal.APP_VERSION); + } + } + } + + private void listPeople() { + + try { + + jScrollPane1.getViewport().setView(null); + + JFlowPanel jPeople = new JFlowPanel(); + jPeople.applyComponentOrientation(getComponentOrientation()); + + java.util.List people = m_dlSystem.listPeopleVisible(); + + for (Object people1 : people) { + AppUser user = (AppUser) people1; + JButton btn = new JButton(new AppUserAction(user)); + btn.applyComponentOrientation(getComponentOrientation()); + btn.setFocusPainted(false); + btn.setFocusable(false); + btn.setRequestFocusEnabled(false); + btn.setMaximumSize(new Dimension(110, 60)); + btn.setPreferredSize(new Dimension(110, 60)); + btn.setMinimumSize(new Dimension(110, 60)); + btn.setHorizontalAlignment(SwingConstants.CENTER); + btn.setHorizontalTextPosition(AbstractButton.CENTER); + btn.setVerticalTextPosition(AbstractButton.BOTTOM); + jPeople.add(btn); + } + + jScrollPane1.getViewport().setView(jPeople); + + } catch (BasicException ee) { + } + } + + class AppUserAction extends AbstractAction { + + private final AppUser m_actionuser; + + public AppUserAction(AppUser user) { + m_actionuser = user; + putValue(Action.SMALL_ICON, m_actionuser.getIcon()); + putValue(Action.NAME, m_actionuser.getName()); + } + + public AppUser getUser() { + return m_actionuser; + } + + @Override + public void actionPerformed(ActionEvent evt) { + + if (m_actionuser.authenticate()) { + openAppView(m_actionuser); + } else { + String sPassword = JPasswordDialog.showEditPassword(JRootApp.this, + AppLocal.getIntString("label.Password"), + m_actionuser.getName(), + m_actionuser.getIcon()); + if (sPassword != null) { + + if (m_actionuser.authenticate(sPassword)) { + openAppView(m_actionuser); + } else { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.BadPassword")); + msg.show(JRootApp.this); + } + } + } + } + } + + private void showView(String view) { + CardLayout cl = (CardLayout) (m_jPanelContainer.getLayout()); + cl.show(m_jPanelContainer, view); + } + + private void openAppView(AppUser user) { + + if (closeAppView()) { + + m_principalapp = new JPrincipalApp(this, user); + + jPanel3.add(m_principalapp.getNotificator()); + jPanel3.revalidate(); + + m_jPanelContainer.add(m_principalapp + , "_" + m_principalapp.getUser().getId()); + showView("_" + m_principalapp.getUser().getId()); + + m_principalapp.activate(); + } + } + + public void exitToLogin() { + closeAppView(); + showLogin(); + } + + public boolean closeAppView() { + + if (m_principalapp == null) { + return true; + } else if (!m_principalapp.deactivate()) { + return false; + } else { + jPanel3.remove(m_principalapp.getNotificator()); + jPanel3.revalidate(); + jPanel3.repaint(); + + m_jPanelContainer.remove(m_principalapp); + m_principalapp = null; + + showLogin(); + + return true; + } + } + + private void showLogin() { + + listPeople(); + showView("login"); + + printerStart(); + + inputtext = new StringBuilder(); + m_txtKeys.setText(null); + java.awt.EventQueue.invokeLater(() -> { + m_txtKeys.requestFocus(); + }); + } + + private void processKey(char c) { + + if ((c == '\n') || (c == '?')) { + AppUser user = null; + try { + user = m_dlSystem.findPeopleByCard(inputtext.toString()); + } catch (BasicException e) { + } + + if (user == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.nocard")); + msg.show(this); + } else { + openAppView(user); + } + + inputtext = new StringBuilder(); + } else { + inputtext.append(c); + } + } + + private int getProgressBar() { + int rate = serverMonitor.getValue(); + return rate; + } + + private boolean pingServer() throws UnknownHostException { + /* + * This method is for the future. Connects and will include both servers + backup server + * Tested locally on JG machine and unicenta-server + */ + serverMonitor.setString("Checking..."); + + InetAddress addr = InetAddress.getByName(AppLocal.getIntString("db.ip")); + int port = 3306; + + SocketAddress sockaddr = new InetSocketAddress(addr, port); + Socket sock = new Socket(); + try { + sock.connect(sockaddr, 2000); + serverMonitor.setString("Server is alive!"); + serverMonitor.setValue(0); + return true; + } catch (IOException ex) { + log.error(ex.getMessage()); + return false; + } + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the FormEditor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jPanelTitle = new javax.swing.JPanel(); + m_jLblTitle = new javax.swing.JLabel(); + poweredby = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + m_jPanelContainer = new javax.swing.JPanel(); + m_jPanelLogin = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 10), new java.awt.Dimension(32767, 0)); + jPanel5 = new javax.swing.JPanel(); + m_jLogonName = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + jPanel8 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jPanel1 = new javax.swing.JPanel(); + m_txtKeys = new javax.swing.JTextField(); + m_jClose = new javax.swing.JButton(); + m_jPanelDown = new javax.swing.JPanel(); + panelTask = new javax.swing.JPanel(); + m_jHost = new javax.swing.JLabel(); + webMemoryBar1 = new com.alee.extended.statusbar.WebMemoryBar(); + serverMonitor = new com.alee.laf.progressbar.WebProgressBar(); + jPanel3 = new javax.swing.JPanel(); + + setEnabled(false); + setPreferredSize(new java.awt.Dimension(1024, 768)); + setLayout(new java.awt.BorderLayout()); + + m_jPanelTitle.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, javax.swing.UIManager.getDefaults().getColor("Button.darkShadow"))); + m_jPanelTitle.setPreferredSize(new java.awt.Dimension(449, 40)); + m_jPanelTitle.setLayout(new java.awt.BorderLayout()); + + m_jLblTitle.setFont(new java.awt.Font("Arial", 1, 16)); // NOI18N + m_jLblTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jLblTitle.setText("Window.Title"); + m_jPanelTitle.add(m_jLblTitle, java.awt.BorderLayout.CENTER); + + poweredby.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + poweredby.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/poweredby_uni.png"))); // NOI18N + poweredby.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5)); + poweredby.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + poweredby.setMaximumSize(new java.awt.Dimension(180, 34)); + poweredby.setPreferredSize(new java.awt.Dimension(180, 34)); + m_jPanelTitle.add(poweredby, java.awt.BorderLayout.LINE_END); + + jLabel2.setFont(new java.awt.Font("Arial", 1, 16)); // NOI18N + jLabel2.setForeground(new java.awt.Color(102, 102, 102)); + jLabel2.setPreferredSize(new java.awt.Dimension(180, 34)); + m_jPanelTitle.add(jLabel2, java.awt.BorderLayout.LINE_START); + + add(m_jPanelTitle, java.awt.BorderLayout.NORTH); + + m_jPanelContainer.setLayout(new java.awt.CardLayout()); + + m_jPanelLogin.setLayout(new java.awt.BorderLayout()); + + jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/unicenta.png"))); // NOI18N + jLabel1.setText("<html><center>uniCenta oPOS - Touch Friendly Point of Sale<br>" + + "Copyright \u00A9 2009-2017 uniCenta <br>" + + "https://unicenta.com<br>" + + "<br>" + + "uniCenta oPOS 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.<br>" + + "<br>" + + "uniCenta oPOS 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.<br>" + + "<br>" + + "You should have received a copy of the GNU General Public License along with uniCenta oPOS. If not, see http://www.gnu.org/licenses/<br>" + + "</center>"); + jLabel1.setAlignmentX(0.5F); + jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jLabel1.setMaximumSize(new java.awt.Dimension(800, 1024)); + jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + jPanel4.add(jLabel1); + jPanel4.add(filler2); + + m_jPanelLogin.add(jPanel4, java.awt.BorderLayout.CENTER); + + jPanel5.setPreferredSize(new java.awt.Dimension(300, 400)); + + m_jLogonName.setLayout(new java.awt.BorderLayout()); + + jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5)); + jPanel2.setPreferredSize(new java.awt.Dimension(100, 100)); + jPanel2.setLayout(new java.awt.BorderLayout()); + + jPanel8.setLayout(new java.awt.GridLayout(0, 1, 5, 5)); + jPanel2.add(jPanel8, java.awt.BorderLayout.NORTH); + + m_jLogonName.add(jPanel2, java.awt.BorderLayout.LINE_END); + + jScrollPane1.setBorder(null); + jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + jScrollPane1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + m_txtKeys.setPreferredSize(new java.awt.Dimension(0, 0)); + m_txtKeys.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { + m_txtKeysKeyTyped(evt); + } + }); + + m_jClose.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jClose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/exit.png"))); // NOI18N + m_jClose.setText(AppLocal.getIntString("button.close")); // NOI18N + m_jClose.setFocusPainted(false); + m_jClose.setFocusable(false); + m_jClose.setPreferredSize(new java.awt.Dimension(100, 50)); + m_jClose.setRequestFocusEnabled(false); + m_jClose.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jCloseActionPerformed(evt); + } + }); + + org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .add(m_txtKeys, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(0, 0, Short.MAX_VALUE)) + .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup() + .addContainerGap() + .add(m_jClose, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE))) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .add(m_txtKeys, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(m_jClose, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + ); + + org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5); + jPanel5.setLayout(jPanel5Layout); + jPanel5Layout.setHorizontalGroup( + jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel5Layout.createSequentialGroup() + .addContainerGap() + .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) + .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(jScrollPane1)) + .add(104, 104, 104) + .add(m_jLogonName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(0, 0, Short.MAX_VALUE)) + ); + jPanel5Layout.setVerticalGroup( + jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel5Layout.createSequentialGroup() + .add(15, 15, 15) + .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel5Layout.createSequentialGroup() + .add(m_jLogonName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(434, 434, 434)) + .add(jPanel5Layout.createSequentialGroup() + .add(jScrollPane1) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap()))) + ); + + m_jPanelLogin.add(jPanel5, java.awt.BorderLayout.EAST); + + m_jPanelContainer.add(m_jPanelLogin, "login"); + + add(m_jPanelContainer, java.awt.BorderLayout.CENTER); + + m_jPanelDown.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 0, 0, 0, javax.swing.UIManager.getDefaults().getColor("Button.darkShadow"))); + m_jPanelDown.setLayout(new java.awt.BorderLayout()); + + m_jHost.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + m_jHost.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/display.png"))); // NOI18N + m_jHost.setText("*Hostname"); + panelTask.add(m_jHost); + + webMemoryBar1.setBackground(new java.awt.Color(153, 153, 153)); + webMemoryBar1.setText(""); + webMemoryBar1.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + webMemoryBar1.setPreferredSize(new java.awt.Dimension(150, 30)); + webMemoryBar1.setUsedBorderColor(new java.awt.Color(0, 204, 204)); + webMemoryBar1.setUsedFillColor(new java.awt.Color(0, 204, 255)); + panelTask.add(webMemoryBar1); + + serverMonitor.setToolTipText(""); + serverMonitor.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + serverMonitor.setMaximumSize(new java.awt.Dimension(50, 18)); + serverMonitor.setPreferredSize(new java.awt.Dimension(150, 30)); + serverMonitor.setProgressBottomColor(new java.awt.Color(76, 197, 237)); + serverMonitor.setRound(2); + serverMonitor.setString("Keep Alive"); + serverMonitor.setStringPainted(true); + panelTask.add(serverMonitor); + + m_jPanelDown.add(panelTask, java.awt.BorderLayout.LINE_START); + m_jPanelDown.add(jPanel3, java.awt.BorderLayout.LINE_END); + + add(m_jPanelDown, java.awt.BorderLayout.SOUTH); + }// </editor-fold>//GEN-END:initComponents + + + private void m_txtKeysKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_m_txtKeysKeyTyped + + m_txtKeys.setText("0"); + processKey(evt.getKeyChar()); + + }//GEN-LAST:event_m_txtKeysKeyTyped + + private void m_jCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jCloseActionPerformed + tryToClose(); + }//GEN-LAST:event_m_jCloseActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.Box.Filler filler2; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel8; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton m_jClose; + private javax.swing.JLabel m_jHost; + private javax.swing.JLabel m_jLblTitle; + private javax.swing.JPanel m_jLogonName; + private javax.swing.JPanel m_jPanelContainer; + private javax.swing.JPanel m_jPanelDown; + private javax.swing.JPanel m_jPanelLogin; + private javax.swing.JPanel m_jPanelTitle; + private javax.swing.JTextField m_txtKeys; + private javax.swing.JPanel panelTask; + private javax.swing.JLabel poweredby; + private com.alee.laf.progressbar.WebProgressBar serverMonitor; + private com.alee.extended.statusbar.WebMemoryBar webMemoryBar1; + // End of variables declaration//GEN-END:variables +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/forms/JRootFrame.form b/src/main/java/com/unicenta/pos/forms/JRootFrame.form new file mode 100644 index 0000000..768996a --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JRootFrame.form @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="0"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="2"/> + </SyntheticProperties> + <Events> + <EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosed"/> + <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosing"/> + </Events> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> +</Form> diff --git a/src/main/java/com/unicenta/pos/forms/JRootFrame.java b/src/main/java/com/unicenta/pos/forms/JRootFrame.java new file mode 100644 index 0000000..c8fcf10 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JRootFrame.java @@ -0,0 +1,161 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.plugins.Application; +import com.unicenta.plugins.metrics.Metrics; +import com.unicenta.pos.config.JFrmConfig; +import com.unicenta.pos.instance.AppMessage; +import com.unicenta.pos.instance.InstanceManager; + +import java.awt.BorderLayout; +import java.io.IOException; +import java.rmi.AlreadyBoundException; +import java.rmi.RemoteException; +import javax.imageio.ImageIO; +import javax.swing.JFrame; + +import com.unicenta.pos.scripting.ScriptEngine; +import com.unicenta.pos.scripting.ScriptException; +import com.unicenta.pos.scripting.ScriptFactory; +import com.unicenta.pos.util.AltEncrypter; +import com.unicenta.pos.util.OSValidator; +import com.unicenta.pos.util.SessionKeepAlive; +import lombok.extern.slf4j.Slf4j; + +/** + * @author adrianromero + */ +@Slf4j +public class JRootFrame extends javax.swing.JFrame implements AppMessage { + + private InstanceManager m_instmanager = null; + + private JRootApp m_rootapp; + private AppProperties m_props; + + private OSValidator m_OS; + + /** + * Creates new form JRootFrame + */ + public JRootFrame() { + + initComponents(); + } + + /** + * @param props + */ + public void initFrame(AppProperties props) { + + m_OS = new OSValidator(); + m_props = props; + + m_rootapp = new JRootApp(); + + if (m_rootapp.initApp(m_props)) { + + if ("true".equals(props.getProperty("machine.uniqueinstance"))) { + // Register the running application + try { + m_instmanager = new InstanceManager(this); + } catch (RemoteException | AlreadyBoundException e) { + } + } + + // Show the application + add(m_rootapp, BorderLayout.CENTER); + + try { + this.setIconImage(ImageIO.read(JRootFrame.class.getResourceAsStream("/com/unicenta/images/favicon.png"))); + } catch (IOException e) { + } + + setTitle(AppLocal.APP_NAME + " - " + AppLocal.APP_VERSION); + pack(); + setLocationRelativeTo(null); + + setVisible(true); + } else { + new JFrmConfig(props).setVisible(true); // Show the configuration window. + } + + } + + /** + * @throws RemoteException + */ + @Override + public void restoreWindow() throws RemoteException { + java.awt.EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + if (getExtendedState() == JFrame.ICONIFIED) { + setExtendedState(JFrame.NORMAL); + } + requestFocus(); + } + }); + } + + private void startSessionKeepAlive(DataLogicSystem dataLogicSystem) { + SessionKeepAlive sessionKeepAlive = new SessionKeepAlive(dataLogicSystem); + sessionKeepAlive.start(); + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosed(java.awt.event.WindowEvent evt) { + formWindowClosed(evt); + } + + public void windowClosing(java.awt.event.WindowEvent evt) { + formWindowClosing(evt); + } + }); + }// </editor-fold>//GEN-END:initComponents + + private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing + + m_rootapp.tryToClose(); + + }//GEN-LAST:event_formWindowClosing + + private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed + + m_rootapp.releaseResources(); + System.exit(0); + + }//GEN-LAST:event_formWindowClosed + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/forms/JRootKiosk.form b/src/main/java/com/unicenta/pos/forms/JRootKiosk.form new file mode 100644 index 0000000..9c38533 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JRootKiosk.form @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="0"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="2"/> + </SyntheticProperties> + <Events> + <EventHandler event="windowClosed" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosed"/> + <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosing"/> + </Events> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,113,0,0,2,23"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> +</Form> diff --git a/src/main/java/com/unicenta/pos/forms/JRootKiosk.java b/src/main/java/com/unicenta/pos/forms/JRootKiosk.java new file mode 100644 index 0000000..433e262 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/JRootKiosk.java @@ -0,0 +1,175 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.pos.config.JFrmConfig; +import com.unicenta.pos.instance.AppMessage; +import com.unicenta.pos.instance.InstanceManager; +import com.unicenta.pos.util.OSValidator; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.io.IOException; +import java.rmi.AlreadyBoundException; +import java.rmi.RemoteException; +import javax.swing.JFrame; + +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import javax.swing.JOptionPane; + +/** + * + * @author adrianromero + */ +public class JRootKiosk extends javax.swing.JFrame implements AppMessage { + + private InstanceManager m_instmanager = null; + + private JRootApp m_rootapp; + private AppProperties m_props; + private OSValidator m_OS; + + /** Creates new form JRootKiosk */ + public JRootKiosk() { + + setUndecorated(true); + setResizable(false); + + initComponents(); + } + + /** + * + * @param props + * @throws java.io.IOException + */ + public void initFrame(AppProperties props) throws IOException { + + m_OS = new OSValidator(); + m_props = props; + + m_rootapp = new JRootApp(); + + if (m_rootapp.initApp(m_props)) { + + if ("true".equals(props.getProperty("machine.uniqueinstance"))) { + try { + m_instmanager = new InstanceManager(this); + } catch (RemoteException | AlreadyBoundException e) { + } + } + + add(m_rootapp, BorderLayout.CENTER); + + setTitle(AppLocal.APP_NAME + " - " + AppLocal.APP_VERSION); + + Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); + setBounds(0, 0, d.width, d.height); + +/* + * 4 Sep 17 JG + * 2 Dec 17 - Mod' Thanks Hayk Sokolov! + * Change here for Linux/Ubuntu full screen + * Thanks to Hans Lengerke for solution +*/ + String osName = System.getProperty("os.name").toLowerCase(); + boolean isWindows = osName.startsWith("windows"); + + GraphicsDevice device = GraphicsEnvironment + .getLocalGraphicsEnvironment().getDefaultScreenDevice(); + + if (device.isFullScreenSupported() && !isWindows) { + setResizable(true); + + addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent arg0) { + setAlwaysOnTop(true); + } + @Override + public void focusLost(FocusEvent arg0) { + setAlwaysOnTop(false); + } + }); + device.setFullScreenWindow(this); + } else { + setVisible(true); + } + } else { + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.databasechange"), + "Connection", JOptionPane.INFORMATION_MESSAGE); + + new JFrmConfig(props).setVisible(true); // Show the configuration window. + } + } + + @Override + public void restoreWindow() throws RemoteException { + java.awt.EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + if (getExtendedState() == JFrame.ICONIFIED) { + setExtendedState(JFrame.NORMAL); + } + requestFocus(); + } + }); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosed(java.awt.event.WindowEvent evt) { + formWindowClosed(evt); + } + public void windowClosing(java.awt.event.WindowEvent evt) { + formWindowClosing(evt); + } + }); + }// </editor-fold>//GEN-END:initComponents + + private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing + + m_rootapp.tryToClose(); + + }//GEN-LAST:event_formWindowClosing + + private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed + + m_rootapp.releaseResources(); + System.exit(0); + + }//GEN-LAST:event_formWindowClosed + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/forms/MenuDefinition.java b/src/main/java/com/unicenta/pos/forms/MenuDefinition.java new file mode 100644 index 0000000..ad0964e --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/MenuDefinition.java @@ -0,0 +1,94 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import java.util.ArrayList; +import javax.swing.Action; + +/** + * + * @author adrianromero + */ +public class MenuDefinition { + + private final String m_sKey; + + private final ArrayList m_aMenuElements; + + /** Creates a new instance of MenuDefinition + * @param skey */ + public MenuDefinition(String skey) { + m_sKey = skey; + m_aMenuElements = new ArrayList(); + } + + /** + * + * @return + */ + public String getKey() { + return m_sKey; + } + + /** + * + * @return + */ + public String getTitle() { + return AppLocal.getIntString(m_sKey); + } + + /** + * + * @param act + */ + public void addMenuItem(Action act) { + MenuItemDefinition menuitem = new MenuItemDefinition(act); + m_aMenuElements.add(menuitem); + } + + /** + * + * @param keytext + */ + public void addMenuTitle(String keytext) { + MenuTitleDefinition menutitle = new MenuTitleDefinition(); + menutitle.KeyText = keytext; + m_aMenuElements.add(menutitle); + } + + /** + * + * @param i + * @return + */ + public MenuElement getMenuElement(int i) { + return (MenuElement) m_aMenuElements.get(i); + } + + /** + * + * @return + */ + public int countMenuElements() { + return m_aMenuElements.size(); + } + +} diff --git a/src/main/java/com/unicenta/pos/forms/MenuElement.java b/src/main/java/com/unicenta/pos/forms/MenuElement.java new file mode 100644 index 0000000..09cc8b0 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/MenuElement.java @@ -0,0 +1,33 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +/** + * + * @author adrianromero + */ +public interface MenuElement { + + /** + * + * @param menu + */ + public void addComponent(JPanelMenu menu); +} diff --git a/src/main/java/com/unicenta/pos/forms/MenuExecAction.java b/src/main/java/com/unicenta/pos/forms/MenuExecAction.java new file mode 100644 index 0000000..8ef31b4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/MenuExecAction.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import java.awt.event.ActionEvent; +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.ImageIcon; + +/** + * + * @author adrianromero + */ +public class MenuExecAction extends AbstractAction { + + private final AppView m_App; + private final String m_sMyView; + + /** Creates a new instance of MenuExecAction + * @param app + * @param icon + * @param keytext + * @param sMyView */ + public MenuExecAction(AppView app, String icon, String keytext, String sMyView) { + putValue(Action.SMALL_ICON, new ImageIcon(JPrincipalApp.class.getResource(icon))); + putValue(Action.NAME, AppLocal.getIntString(keytext)); + putValue(AppUserView.ACTION_TASKNAME, sMyView); + m_App = app; + m_sMyView = sMyView; + } + @Override + public void actionPerformed(ActionEvent evt) { + m_App.getAppUserView().executeTask(m_sMyView); + } +} diff --git a/src/main/java/com/unicenta/pos/forms/MenuItemDefinition.java b/src/main/java/com/unicenta/pos/forms/MenuItemDefinition.java new file mode 100644 index 0000000..f516bb9 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/MenuItemDefinition.java @@ -0,0 +1,60 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import java.awt.Dimension; +import javax.swing.Action; +import javax.swing.JButton; +import javax.swing.SwingConstants; + +/** + * + * @author adrianromero + */ +public class MenuItemDefinition implements MenuElement { + + private Action act; + + /** + * + * @param act + */ + public MenuItemDefinition(Action act) { + this.act = act; + } + + /** + * + * @param menu + */ + @Override + public void addComponent(JPanelMenu menu) { + + JButton btn = new JButton(act); + + btn.setFocusPainted(false); + btn.setFocusable(false); + btn.setRequestFocusEnabled(false); + btn.setHorizontalAlignment(SwingConstants.LEADING); + btn.setPreferredSize(new Dimension(100, 100)); + + menu.addEntry(btn); + } +} diff --git a/src/main/java/com/unicenta/pos/forms/MenuPanelAction.java b/src/main/java/com/unicenta/pos/forms/MenuPanelAction.java new file mode 100644 index 0000000..2be0eec --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/MenuPanelAction.java @@ -0,0 +1,73 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.plugins.Application; +import lombok.extern.slf4j.Slf4j; + +import java.awt.*; +import java.awt.event.ActionEvent; +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.ImageIcon; + +/** + * + * @author adrianromero + */ +@Slf4j +public class MenuPanelAction extends AbstractAction { + + private final AppView m_App; + private final String m_sMyView; + + /** Creates a new instance of MenuPanelAction + * @param app + * @param icon + * @param keytext + * @param sMyView */ + public MenuPanelAction(AppView app, String icon, String keytext, String sMyView) { + putValue(Action.SMALL_ICON, new ImageIcon(JPrincipalApp.class.getResource(icon))); + putValue(Action.NAME, AppLocal.getIntString(keytext)); + putValue(AppUserView.ACTION_TASKNAME, sMyView); + m_App = app; + m_sMyView = sMyView; + } + @Override + public void actionPerformed(ActionEvent evt) { + + if (m_sMyView.equals("plugins.configure") ) { + log.debug("Configure plugins"); + new Application().initScreen("Dashboard", getActiveWindow()); + } + else { + m_App.getAppUserView().showTask(m_sMyView); + } + } + + private Window getActiveWindow() { + for (Window window: Window.getWindows()) { + if (window instanceof JRootFrame) { + return window; + } + } + return null; + } +} diff --git a/src/main/java/com/unicenta/pos/forms/MenuTitleDefinition.java b/src/main/java/com/unicenta/pos/forms/MenuTitleDefinition.java new file mode 100644 index 0000000..784f8d1 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/MenuTitleDefinition.java @@ -0,0 +1,51 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import java.awt.Color; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.border.MatteBorder; + +/** + * + * @author adrianromero + */ +public class MenuTitleDefinition implements MenuElement { + + /** + * + */ + public String KeyText; + + /** + * + * @param menu + */ + @Override + public void addComponent(JPanelMenu menu) { + + JLabel lbl = new JLabel(AppLocal.getIntString(KeyText)); + lbl.applyComponentOrientation(menu.getComponentOrientation()); + lbl.setBorder(new MatteBorder(new Insets(0, 0, 1, 0), new Color(0, 0, 0))); + + menu.addTitle(lbl); + } +} diff --git a/src/main/java/com/unicenta/pos/forms/Payments.java b/src/main/java/com/unicenta/pos/forms/Payments.java new file mode 100644 index 0000000..f2f2528 --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/Payments.java @@ -0,0 +1,163 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import java.util.HashMap; + +/** + * + * @author Jack Gerrard + */ +public class Payments { + private Double amount; + private Double tendered; + private final HashMap paymentPaid; + private final HashMap paymentTendered; + private final HashMap rtnMessage; + private String name; + private final HashMap paymentVoucher; + private final HashMap paymentNote; + + /** + * + */ + public Payments() { + paymentPaid = new HashMap(); + paymentTendered = new HashMap(); + rtnMessage = new HashMap(); + paymentVoucher = new HashMap(); + paymentNote = new HashMap(); + } + + /** + * + * @param pName + * @param pAmountPaid + * @param pTendered + * @param rtnMsg + */ + + public void addPayment (String pName, Double pAmountPaid, Double pTendered, String rtnMsg){ + if (paymentPaid.containsKey(pName)){ + paymentPaid.put(pName,Double.parseDouble(paymentPaid.get(pName).toString()) + pAmountPaid); + paymentTendered.put(pName,Double.parseDouble(paymentTendered.get(pName).toString()) + pTendered); + rtnMessage.put(pName, rtnMsg); + }else { + paymentPaid.put(pName, pAmountPaid); + paymentTendered.put(pName,pTendered); + rtnMessage.put(pName, rtnMsg); + } + } + + /** + * + * @param pName + * @param pAmountPaid + * @param pTendered + * @param rtnMsg + * @param pVoucher + */ + public void addPayment (String pName, Double pAmountPaid, Double pTendered, String rtnMsg, String pVoucher, String pNote){ + if (paymentPaid.containsKey(pName)){ + paymentPaid.put(pName,Double.parseDouble(paymentPaid.get(pName).toString()) + pAmountPaid); + paymentTendered.put(pName,Double.parseDouble(paymentTendered.get(pName).toString()) + pTendered); + rtnMessage.put(pName, rtnMsg); + paymentVoucher.put(pName, pVoucher); + paymentNote.put(pName, pNote); + + }else { + paymentPaid.put(pName, pAmountPaid); + paymentTendered.put(pName,pTendered); + rtnMessage.put(pName, rtnMsg); + paymentNote.put(pName, pNote); + if (pVoucher !=null) { + paymentVoucher.put(pName, pVoucher); + } else { + pVoucher = "0"; + paymentVoucher.put(pName, pVoucher); + } + } + } + + + /** + * + * @param pName + * @return + */ + public Double getTendered (String pName){ + return(Double.parseDouble(paymentTendered.get(pName).toString())); + } + + /** + * + * @param pName + * @return + */ + public Double getPaidAmount (String pName){ + return(Double.parseDouble(paymentPaid.get(pName).toString())); + } + + /** + * + * @return + */ + public Integer getSize(){ + return (paymentPaid.size()); + } + + /** + * + * @param pName + * @return + */ + public String getRtnMessage(String pName){ + return (rtnMessage.get(pName).toString()); + } + + public String getVoucher(String pName){ + return (paymentVoucher.get(pName).toString()); + } + + public String getNote(String pName) { + String note = null; + if (paymentNote.get(pName) != null) { + note = paymentNote.get(pName).toString(); + + } + return note ; + } + + public String getFirstElement(){ + String rtnKey= paymentPaid.keySet().iterator().next().toString(); + return(rtnKey); + } + + /** + * + * @param pName + */ + public void removeFirst (String pName){ + paymentPaid.remove(pName); + paymentTendered.remove(pName); + rtnMessage.remove(pName); + } + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/forms/ProcessAction.java b/src/main/java/com/unicenta/pos/forms/ProcessAction.java new file mode 100644 index 0000000..3060daf --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/ProcessAction.java @@ -0,0 +1,37 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.forms; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; + +/** + * + * @author adrianromero + */ +public interface ProcessAction { + + /** + * + * @return + * @throws BasicException + */ + public MessageInf execute() throws BasicException; +} diff --git a/src/main/java/com/unicenta/pos/forms/StartPOS.java b/src/main/java/com/unicenta/pos/forms/StartPOS.java new file mode 100644 index 0000000..9696e3e --- /dev/null +++ b/src/main/java/com/unicenta/pos/forms/StartPOS.java @@ -0,0 +1,138 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/> + +package com.unicenta.pos.forms; + +import com.formdev.flatlaf.FlatDarkLaf; +import com.formdev.flatlaf.FlatLaf; +import com.formdev.flatlaf.FlatLightLaf; +import com.formdev.flatlaf.intellijthemes.FlatCarbonIJTheme; +import com.formdev.flatlaf.intellijthemes.FlatDraculaIJTheme; +import com.formdev.flatlaf.intellijthemes.FlatMaterialDesignDarkIJTheme; +import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatArcDarkIJTheme; +import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightIJTheme; +import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubIJTheme; +import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialLighterIJTheme; +import com.unicenta.format.Formats; +import com.unicenta.plugins.Application; +import com.unicenta.plugins.metrics.Metrics; +import com.unicenta.pos.instance.InstanceQuery; +import com.unicenta.pos.ticket.TicketInfo; +import lombok.extern.slf4j.Slf4j; +import org.pushingpixels.substance.api.SubstanceLookAndFeel; +import org.pushingpixels.substance.api.SubstanceSkin; + +import javax.swing.*; +import javax.swing.plaf.metal.MetalLookAndFeel; +import java.io.IOException; +import java.rmi.NotBoundException; +import java.rmi.RemoteException; +import java.util.Locale; + +@Slf4j +public class StartPOS { + + private StartPOS() { + } + + public static boolean registerApp() { + + InstanceQuery i = null; + try { + i = new InstanceQuery(); + i.getAppMessage().restoreWindow(); + return false; + } catch (RemoteException | NotBoundException e) { + return true; + } + } + + public static void main(final String args[]) { + + SwingUtilities.invokeLater(() -> { + if (!registerApp()) { + System.exit(1); + } + + AppConfig config = new AppConfig(args); + + config.load(); + + String slang = config.getProperty("user.language"); + String scountry = config.getProperty("user.country"); + String svariant = config.getProperty("user.variant"); + if (slang != null + && !slang.equals("") + && scountry != null + && svariant != null) { + Locale.setDefault(new Locale(slang, scountry, svariant)); + } + + Formats.setIntegerPattern(config.getProperty("format.integer")); + Formats.setDoublePattern(config.getProperty("format.double")); + Formats.setCurrencyPattern(config.getProperty("format.currency")); + Formats.setPercentPattern(config.getProperty("format.percent")); + Formats.setDatePattern(config.getProperty("format.date")); + Formats.setTimePattern(config.getProperty("format.time")); + Formats.setDateTimePattern(config.getProperty("format.datetime")); + + // Set the look and feel + try { + Object laf = Class.forName(config.getProperty("swing.defaultlaf")).newInstance(); + if (!(laf instanceof MetalLookAndFeel) && laf instanceof LookAndFeel) { + UIManager.setLookAndFeel((LookAndFeel) laf); + } else { + UIManager.setLookAndFeel("com.formdev.flatlaf.intellijthemes.FlatGrayIJTheme"); + } + } catch (Exception e) { + log.error("Cannot set Look and Feel ${0}", e.getMessage()); + } + + String hostname = config.getProperty("machine.hostname"); + TicketInfo.setHostname(hostname); + applicationStarted(hostname); + + String screenmode = config.getProperty("machine.screenmode"); + + if ("fullscreen".equals(screenmode)) { + JRootKiosk rootkiosk = new JRootKiosk(); + try { + rootkiosk.initFrame(config); + } catch (IOException ex) { + log.error(ex.getMessage()); + } + } else { + JRootFrame rootframe = new JRootFrame(); + try { + rootframe.initFrame(config); + } catch (Exception ex) { + log.error(ex.getMessage()); + } + } + }); + } + private static void applicationStarted(String host) { + new Thread(() -> { + Metrics metrics = new Metrics(); + metrics.setDevice(host); + metrics.setUniCentaVersion(AppLocal.APP_VERSION); + new Application().postMetrics(metrics); + }).start(); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/imports/CustomerCSVImport.form b/src/main/java/com/unicenta/pos/imports/CustomerCSVImport.form new file mode 100644 index 0000000..2e1c98a --- /dev/null +++ b/src/main/java/com/unicenta/pos/imports/CustomerCSVImport.form @@ -0,0 +1,1302 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="opaque" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[750, 500]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jFileChooserPanel" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel18" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboSeparator" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jCBiso" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="7" max="-2" attributes="0"/> + <Component id="jbtnRead" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jScrollPane1" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="jPanel2" max="32767" attributes="0"/> + <Component id="webPBar" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jFileChooserPanel" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboSeparator" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel18" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jbtnRead" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jCBiso" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="webPBar" min="-2" pref="32" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jPanel2" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="99" max="32767" attributes="0"/> + </Group> + <Component id="jScrollPane1" pref="588" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jFileChooserPanel"> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel1" max="32767" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jFileName" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jbtnFileChoose" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="120" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jFileName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + <Component id="jbtnFileChoose" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvfile" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jFileName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jFileNameActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jbtnFileChoose"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/fileopen.png"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 32]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 32]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnFileChooseActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel18"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvdelimit" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jbtnRead"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvread" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnReadActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JPanelCSVSelect_jHeaderRead"/> + </AuxValues> + </Component> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> + <TitledBorder title="Status"> + <Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder roundedCorners="true"> + <Color PropertyName="color" blue="99" green="99" red="99" type="rgb"/> + </LineBorder> + </Border> + <ResourceString PropertyName="titleX" bundle="pos_messages.properties" key="title.CSVImport" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + <Font PropertyName="font" name="Arial" size="14" style="1"/> + <Color PropertyName="color" blue="66" green="66" red="66" type="rgb"/> + </TitledBorder> + </Border> + </Property> + </Properties> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jlblRecords" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jtxtRecords" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="1" max="-2" attributes="0"> + <Component id="jlblNotChanged" alignment="0" max="-2" attributes="0"/> + <Component id="jlblInvalid" alignment="0" max="-2" attributes="0"/> + <Component id="jlblUpdates" alignment="0" max="-2" attributes="0"/> + <Component id="jlblMissing" alignment="0" max="-2" attributes="0"/> + <Component id="jlblBad" alignment="0" max="-2" attributes="0"/> + <Component id="jlblNew" alignment="1" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jtxtNew" min="-2" max="-2" attributes="0"/> + <Component id="jtxtInvalid" min="-2" max="-2" attributes="0"/> + <Component id="jtxtUpdate" min="-2" max="-2" attributes="0"/> + <Component id="jtxtMissing" min="-2" max="-2" attributes="0"/> + <Component id="jtxtBad" min="-2" max="-2" attributes="0"/> + <Component id="jtxtNoChange" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="0" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jlblRecords" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jtxtRecords" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jlblNew" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jtxtNew" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jlblInvalid" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jtxtInvalid" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jlblUpdates" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jtxtUpdate" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jlblMissing" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jtxtMissing" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jlblBad" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jtxtBad" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jlblNotChanged" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jtxtNoChange" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jlblRecords"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvrecordsfound" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jlblNew"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvnewcustomers" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[77, 14]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[77, 14]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jlblInvalid"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.invalidcustomers" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jlblUpdates"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.customerupdated" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jlblMissing"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvmissing" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jlblBad"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvbad" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jlblNotChanged"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvnotchanged" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jtxtRecords"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jtxtNew"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jtxtInvalid"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jtxtUpdate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jtxtMissing"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jtxtBad"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="cc" green="0" red="ff" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jtxtNoChange"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JComboBox" name="jComboSeparator"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.progressbar.WebProgressBar" name="webPBar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="13" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[240, 30]"/> + </Property> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Properties> + <Property name="verticalScrollBarPolicy" type="int" value="22"/> + <Property name="autoscrolls" type="boolean" value="true"/> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[430, 650]"/> + </Property> + </Properties> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel8" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jCheckVisible" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="1" attributes="0"> + <Component id="jbtnReset" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="12" max="-2" attributes="0"/> + <Component id="jbtnImport" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="93" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel7" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="jComboCity" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboSearchKey" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboAccountID" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboName" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel10" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboAddress1" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel20" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboAddress2" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel23" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboPhone2" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel22" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboPhone" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel21" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboEmail" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel12" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboLastName" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel9" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboFirstName" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel11" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboRegion" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboPostal" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jComboSearchKey" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboAccountID" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboAddress1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboAddress2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel20" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboCity" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboRegion" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboPostal" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboFirstName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboLastName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboEmail" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel21" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboPhone" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel22" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboPhone2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel23" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jLabel8" min="-2" max="-2" attributes="0"/> + <Component id="jCheckVisible" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jbtnImport" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jbtnReset" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace pref="74" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JComboBox" name="jComboSearchKey"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboSearchKeyItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboSearchKeyFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboNameItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboNameFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboAccountID"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboAccountIDItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboAccountIDFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboAddress1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="1"> + <StringItem index="0" value=""/> + </StringArray> + </Property> + <Property name="selectedIndex" type="int" value="-1"/> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboAddress1ItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboAddress1FocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboAddress2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboAddress2ItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboAddress2FocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboCity"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboCityItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboCityFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboRegion"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="name" type="java.lang.String" value="" noResource="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboRegionItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboRegionFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboPostal"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="name" type="java.lang.String" value="" noResource="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboPostalItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboPostalFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboFirstName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboFirstNameItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboFirstNameFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboLastName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboLastNameItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboLastNameFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboEmail"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="name" type="java.lang.String" value="" noResource="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboEmailItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboEmailFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboPhone"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboPhoneItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboPhoneFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboPhone2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboPhone2ItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboPhone2FocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JCheckBox" name="jCheckVisible"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="selected" type="boolean" value="true"/> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[30, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jbtnReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.reset" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnResetActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jbtnImport"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvimpostbtn" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnImportActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.taxid" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.searchkeym" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.namem" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel10"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.address" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel11"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.region" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.city" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.visible" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel20"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.address2" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.postal" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel21"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.email" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel22"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.phone" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel23"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.phone2" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel9"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.firstname" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel12"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.lastname" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Component class="javax.swing.JComboBox" name="jCBiso"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="13"> + <StringItem index="0" value="ISO-8859-1"/> + <StringItem index="1" value="ISO-8859-2"/> + <StringItem index="2" value="ISO-8859-3"/> + <StringItem index="3" value="ISO-8859-4"/> + <StringItem index="4" value="ISO-8859-5"/> + <StringItem index="5" value="ISO-8859-6"/> + <StringItem index="6" value="ISO-8859-7"/> + <StringItem index="7" value="ISO-8859-8"/> + <StringItem index="8" value="ISO-8859-9"/> + <StringItem index="9" value="ISO-8859-10"/> + <StringItem index="10" value="UTF-8"/> + <StringItem index="11" value="UTF-16"/> + <StringItem index="12" value=" "/> + </StringArray> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.import.cbiso" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/imports/CustomerCSVImport.java b/src/main/java/com/unicenta/pos/imports/CustomerCSVImport.java new file mode 100644 index 0000000..8fe269b --- /dev/null +++ b/src/main/java/com/unicenta/pos/imports/CustomerCSVImport.java @@ -0,0 +1,2005 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + + +package com.unicenta.pos.imports; + +import com.csvreader.CsvReader; +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Session; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.customers.DataLogicCustomers; +import com.unicenta.pos.forms.*; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.filechooser.FileNameExtensionFilter; +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + + +/** + * Graphical User Interface and code for importing data from a CSV file allowing + * adding or updating many customers quickly and easily. + */ +@Slf4j +public class CustomerCSVImport extends JPanel implements JPanelView { + + private ArrayList<String> Headers = new ArrayList<>(); + private Session s; + private Connection con; + private String csvFileName; + + private String csvMessage = ""; + private CsvReader customers; + private int currentRecord; + private int rowCount = 0; + private String last_folder; + private File config_file; + + private DataLogicSales m_dlSales; + private DataLogicSystem m_dlSystem; + private DataLogicCustomers m_dlCustomer; + + protected SaveProvider spr; + + private String customerSearchKey; + private String customerAccount; + private String customerName; + private String customerAddress1; + private String customerAddress2; + private String customerPostal; + private String customerCity; + private String customerRegion; + private String customerFirstName; + private String customerLastName; + private String customerEmail; + private String customerPhone; + private String customerPhone2; + + private DocumentListener documentListener; + private CustomerInfoExt custInfo; + private String recordType = null; + + private int newRecords = 0; + private int invalid = 0; + private int updated = 0; + private int missing = 0; + private int noChange = 0; + private int bad = 0; + + private Integer progress = 0; + + private String iso = "ISO-8859-1"; + + /** + * Constructs a new CustomerCSVImport object + * + * @param oApp AppView + */ + public CustomerCSVImport(AppView oApp) { + this(oApp.getProperties()); + } + + /** + * Constructs a new JPanelCSVImport object + * + * @param props AppProperties + */ + @SuppressWarnings("empty-statement") + public CustomerCSVImport(AppProperties props) { + initComponents(); + + try { + s = AppViewConnection.createSession(props); + con = s.getConnection(); + } catch (BasicException | SQLException e) { + ; + } + + m_dlSales = new DataLogicSales(); + m_dlSales.init(s); + + m_dlSystem = new DataLogicSystem(); + m_dlSystem.init(s); + + + spr = new SaveProvider( + m_dlSales.getCustomerUpdate(), + m_dlSales.getCustomerInsert(), + m_dlSales.getCustomerDelete()); + + last_folder = props.getProperty("CSV.last_folder"); + config_file = props.getConfigFile(); + + jFileName.getDocument().addDocumentListener(documentListener); + + documentListener = new DocumentListener() { + @Override + public void changedUpdate(DocumentEvent documentEvent) { + jbtnRead.setEnabled(true); + } + + @Override + public void insertUpdate(DocumentEvent documentEvent) { + if (!"".equals(jFileName.getText().trim())) { + jbtnRead.setEnabled(true); + } + } + + @Override + public void removeUpdate(DocumentEvent documentEvent) { + if (jFileName.getText().trim().equals("")) { + jbtnRead.setEnabled(false); + } + } + }; + jFileName.getDocument().addDocumentListener(documentListener); + + } + + /** + * Reads the headers from the CSV file and initializes subsequent form + * fields. This function first reads the headers from the CSVFileName file, + * then puts them into the header combo boxes and enables the other form + * inputs. + * + * @param CSVFileName Name of the file (including the path) to open and read + * CSV data from + * @throws IOException If there is an issue reading the CSV file + */ + private void GetheadersFromFile(String CSVFileName) throws IOException { + + File f = new File(CSVFileName); + if (f.exists()) { +// customers = new CsvReader(CSVFileName, ',' ,Charset.forName("UTF-8")); + customers = new CsvReader(CSVFileName, ',', Charset.forName(jCBiso.getSelectedItem().toString())); + customers.setDelimiter(((String) jComboSeparator.getSelectedItem()).charAt(0)); + customers.readHeaders(); + + if (customers.getHeaderCount() < 5) { + JOptionPane.showMessageDialog(null, + "Incorrect header in your source file", + "Header Error", + JOptionPane.WARNING_MESSAGE); + customers.close(); + return; + } + rowCount = 0; + int i = 0; + Headers.clear(); + Headers.add(""); + jComboName.addItem(""); + jComboAccountID.addItem(""); + jComboSearchKey.addItem(""); + jComboAddress1.addItem(""); + jComboAddress2.addItem(""); + jComboPostal.addItem(""); + jComboCity.addItem(""); + jComboRegion.addItem(""); + jComboFirstName.addItem(""); + jComboLastName.addItem(""); + jComboEmail.addItem(""); + jComboPhone.addItem(""); + jComboPhone2.addItem(""); + + while (i < customers.getHeaderCount()) { + jComboName.addItem(customers.getHeader(i)); + jComboAccountID.addItem(customers.getHeader(i)); + jComboSearchKey.addItem(customers.getHeader(i)); + jComboAddress1.addItem(customers.getHeader(i)); + jComboAddress2.addItem(customers.getHeader(i)); + jComboPostal.addItem(customers.getHeader(i)); + jComboCity.addItem(customers.getHeader(i)); + jComboRegion.addItem(customers.getHeader(i)); + jComboFirstName.addItem(customers.getHeader(i)); + jComboLastName.addItem(customers.getHeader(i)); + jComboEmail.addItem(customers.getHeader(i)); + jComboPhone.addItem(customers.getHeader(i)); + jComboPhone2.addItem(customers.getHeader(i)); + + Headers.add(customers.getHeader(i)); + ++i; + } + + enableCheckBoxes(); + + while (customers.readRecord()) { + ++rowCount; + } + + jtxtRecords.setText(Long.toString(rowCount)); + + customers.close(); + + } else { + JOptionPane.showMessageDialog(null, "Unable to locate " + + CSVFileName, + "File not found", + JOptionPane.WARNING_MESSAGE); + } + } + + /** + * Enables all the selection options on the for to allow the user to + * interact with the routine. + */ + private void enableCheckBoxes() { + jbtnRead.setEnabled(false); + jbtnImport.setEnabled(false); + jbtnReset.setEnabled(true); + jComboAccountID.setEnabled(true); + jComboName.setEnabled(true); + jComboSearchKey.setEnabled(true); + jComboAddress1.setEnabled(true); + jComboAddress2.setEnabled(true); + jComboPostal.setEnabled(true); + jComboCity.setEnabled(true); + jComboRegion.setEnabled(true); + jComboFirstName.setEnabled(true); + jComboLastName.setEnabled(true); + jComboEmail.setEnabled(true); + jComboPhone.setEnabled(true); + jComboPhone2.setEnabled(true); + + jCheckVisible.setEnabled(true); + + } + + /** + * Pushes the Import process into a new thread so it doesn't interfere with + * the UI responsiveness. + */ + private void setWorker() { + progress = 0; + webPBar.setStringPainted(true); + + final SwingWorker<Integer, Integer> pbWorker; + pbWorker = new SwingWorker<Integer, Integer>() { + + @Override + protected final Integer doInBackground() throws Exception { + while ((progress >= 0) && (progress < 100)) { + Thread.sleep(50); + this.publish(progress); + } + this.publish(100); + this.done(); + return 100; + } + + @Override + protected final void process(final List<Integer> chunks) { + webPBar.setValue(chunks.get(0)); + if (progress > 100) { + progress = 100; + webPBar.setString("Imported 100%"); + } else { + webPBar.setString("Imported " + progress + "%"); + } + } + }; + pbWorker.execute(); + } + + /** + * Runs the setWorker. + */ + private class workProcess implements Runnable { + + @Override + public void run() { + try { + ImportCsvFile(jFileName.getText()); + } catch (IOException | BasicException ex) { + log.error(ex.getMessage()); + } + } + } + + /** + * Imports the CSV File using specifications from the form. + * + * @param CSVFileName Name of the file (including path) to import. + * @throws IOException If there are file reading issues. + */ + private void ImportCsvFile(String CSVFileName) throws IOException, BasicException { + + File f = new File(CSVFileName); + if (f.exists()) { + webPBar.setString("Starting..."); + webPBar.setVisible(true); + jbtnImport.setEnabled(false); + +// Read file +// customers = new CsvReader(CSVFileName, ',' ,Charset.forName("UTF-8")); + customers = new CsvReader(CSVFileName, ',', Charset.forName(jCBiso.getSelectedItem().toString())); + customers.setDelimiter(((String) jComboSeparator.getSelectedItem()).charAt(0)); + customers.readHeaders(); + + currentRecord = 0; + + while (customers.readRecord()) { + customerSearchKey = customers.get((String) jComboSearchKey.getSelectedItem()); + customerAccount = customers.get((String) jComboAccountID.getSelectedItem()); + customerName = customers.get((String) jComboName.getSelectedItem()); + customerAddress1 = customers.get((String) jComboAddress1.getSelectedItem()); + customerAddress2 = customers.get((String) jComboAddress2.getSelectedItem()); + customerPostal = customers.get((String) jComboPostal.getSelectedItem()); + customerCity = customers.get((String) jComboCity.getSelectedItem()); + customerRegion = customers.get((String) jComboRegion.getSelectedItem()); + customerFirstName = customers.get((String) jComboFirstName.getSelectedItem()); + customerLastName = customers.get((String) jComboLastName.getSelectedItem()); + customerEmail = customers.get((String) jComboEmail.getSelectedItem()); + customerPhone = customers.get((String) jComboPhone.getSelectedItem()); + customerPhone2 = customers.get((String) jComboPhone2.getSelectedItem()); + + currentRecord++; + progress = currentRecord; + + if ("".equals(customerSearchKey) + | "".equals(customerName)) { + + createCustomerCSVEntry(csvMessage, null, null); + } else { + + recordType = getRecord(); + switch (recordType) { + case "new": + createCustomer("new"); + newRecords++; + createCustomerCSVEntry("New Customer", null, null); + break; + case "name error": + case "searchkey error": + case "Duplicate searchkey found.": + case "Duplicate name found.": + case "Exception": + invalid++; + createCustomerCSVEntry(recordType, null, null); + break; + default: + updateRecord(recordType); + break; + } + } + } + + } else { + JOptionPane.showMessageDialog(null, + "Unable to locate " + + CSVFileName, "File not found", + JOptionPane.WARNING_MESSAGE); + } + + jtxtNew.setText(Integer.toString(newRecords)); + jtxtUpdate.setText(Integer.toString(updated)); + jtxtInvalid.setText(Integer.toString(invalid)); + jtxtMissing.setText(Integer.toString(missing)); + jtxtNoChange.setText(Integer.toString(noChange)); + jtxtBad.setText(Integer.toString(bad)); + + JOptionPane.showMessageDialog(null, + "Import Complete", + "Imported", + JOptionPane.WARNING_MESSAGE); + +// webPBar.setString("Imported " + progress); + progress = 100; + webPBar.setValue(progress); + webPBar.setString("Imported" + progress); +// } + } + + + /** + * testString for validity as a number + * + * @param testString the string to be checked + * @return True if a real number False if not + */ + private Boolean validateNumber(String testString) { + try { + Double res = Double.parseDouble(testString); + return (true); + } catch (NumberFormatException e) { + return (false); + } + } + + /** + * Updated the record in the database with the new prices and category if + * needed. + * + * @param cID Unique Customer id of the record to be updated It then creates + * an updated record for the Customer, subject to the ???? be different + */ + private void updateRecord(String cID) throws BasicException { +// custInfo = new CustomerInfoExt(); + custInfo = m_dlSales.getCustomerInfo(cID); + createCustomer("update"); + noChange++; + } + + /** + * Gets the title of the current panel + * + * @return The name of the panel + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.CustomerCSVImport"); + } + + /** + * Returns this object + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * Set CSV field and line separator + * + * @throws com.unicenta.basic.BasicException + */ + @Override + public void activate() throws BasicException { + + jComboSeparator.removeAllItems(); + jComboSeparator.addItem(","); + jComboSeparator.addItem(";"); + jComboSeparator.addItem("~"); + jComboSeparator.addItem("^"); + + } + + /** + * Resets all the form fields + */ + public void resetFields() { + + jComboAccountID.removeAllItems(); + jComboAccountID.setEnabled(false); + + jComboName.removeAllItems(); + jComboName.setEnabled(false); + + jComboSearchKey.removeAllItems(); + jComboSearchKey.setEnabled(false); + + jComboAddress1.removeAllItems(); + jComboAddress1.setEnabled(false); + + jComboAddress2.removeAllItems(); + jComboAddress2.setEnabled(false); + + jComboCity.removeAllItems(); + jComboCity.setEnabled(false); + + jComboRegion.removeAllItems(); + jComboRegion.setEnabled(false); + + jComboPostal.removeAllItems(); + jComboPostal.setEnabled(false); + + jComboFirstName.removeAllItems(); + jComboFirstName.setEnabled(false); + + jComboLastName.removeAllItems(); + jComboLastName.setEnabled(false); + + jComboEmail.removeAllItems(); + jComboEmail.setEnabled(false); + + jComboPhone.removeAllItems(); + jComboPhone.setEnabled(false); + + jComboPhone2.removeAllItems(); + jComboPhone2.setEnabled(false); + + jCheckVisible.setSelected(false); + jCheckVisible.setEnabled(true); + + jbtnImport.setEnabled(false); + jbtnReset.setEnabled(true); + jbtnRead.setEnabled(false); + + jFileName.setText(null); + csvFileName = ""; + +// clear Status area fields + jtxtNew.setText(""); + jtxtUpdate.setText(""); + jtxtInvalid.setText(""); + jtxtMissing.setText(""); + jtxtNoChange.setText(""); + jtxtRecords.setText(""); + jtxtBad.setText(""); + + progress = 0; + + Headers.clear(); + } + + /** + * Checks the field mappings to ensure all compulsory fields have been + * completed to allow import to proceed + */ + public void checkFieldMapping() { + if (jComboSearchKey.getSelectedItem() != "" + & jComboName.getSelectedItem() != "") { + jbtnImport.setEnabled(true); + jbtnReset.setEnabled(true); + } else { + jbtnImport.setEnabled(false); + jbtnReset.setEnabled(false); + } + } + + /** + * Deactivates and resets all form fields. + * + * @return + */ + @Override + public boolean deactivate() { + resetFields(); + return (true); + } + + /** + * @param cType + */ + public void createCustomer(String cType) { + + Object[] mycust = new Object[27]; + if ("new".equals(cType)) { + mycust[0] = UUID.randomUUID().toString(); + } else { + mycust[0] = custInfo.getId(); + } // id string + mycust[1] = customerSearchKey; // searchkey String + mycust[2] = customerAccount; // taxid string + mycust[3] = customerName; // name string + mycust[4] = null; // taxCategory string + mycust[5] = null; // card string + mycust[6] = 0.0; // maxdebt Double + mycust[7] = customerAddress1; // address1 string + mycust[8] = customerAddress2; // address2 string + mycust[9] = customerPostal; // postal string + mycust[10] = customerCity; // city string + mycust[11] = customerRegion; // region string + mycust[12] = null; // country string + mycust[13] = customerFirstName; // firstname string + mycust[14] = customerLastName; // lastname string + mycust[15] = customerEmail; // email string + mycust[16] = customerPhone; // phone string + mycust[17] = customerPhone2; // phone2 string + mycust[18] = null; // fax string + mycust[19] = null; // notes string + mycust[20] = jCheckVisible.isSelected(); // visible flag + mycust[21] = null; // curdate string + mycust[22] = 0.0; // curdate double + mycust[23] = null; // image + mycust[24] = false; // isvip + mycust[25] = 0.0; // discount + mycust[26] = null; // memodate date + + try { + if ("new".equals(cType)) { + spr.insertData(mycust); + webPBar.setString("Adding record " + progress); + } else { + spr.updateData(mycust); + webPBar.setString("Updating record " + progress); + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + /** + * Insert file row read and adds to import table log + * + * @param csvError + * @param searchKey + * @param Name + */ + public void createCustomerCSVEntry(String csvError, String searchKey, String Name) { + + Object[] mycust = new Object[5]; + mycust[0] = UUID.randomUUID().toString(); // ID string + mycust[1] = Integer.toString(currentRecord); // Record number + mycust[2] = csvError; // Error description + mycust[3] = customerSearchKey; // SearchKey String + mycust[4] = customerName; // Name string + + try { + m_dlSystem.execCustomerAddCSVEntry(mycust); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + /** + * @return + */ + public String getRecord() { + // Get record type using using DataLogicSystem + Object[] mycust = new Object[2]; + mycust[0] = customerSearchKey; + mycust[1] = customerName; + + try { + return (m_dlSystem.getCustomerRecordType(mycust)); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + return "Exception"; + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jFileChooserPanel = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jFileName = new javax.swing.JTextField(); + jbtnFileChoose = new javax.swing.JButton(); + jLabel18 = new javax.swing.JLabel(); + jbtnRead = new javax.swing.JButton(); + jPanel2 = new javax.swing.JPanel(); + jlblRecords = new javax.swing.JLabel(); + jlblNew = new javax.swing.JLabel(); + jlblInvalid = new javax.swing.JLabel(); + jlblUpdates = new javax.swing.JLabel(); + jlblMissing = new javax.swing.JLabel(); + jlblBad = new javax.swing.JLabel(); + jlblNotChanged = new javax.swing.JLabel(); + jtxtRecords = new javax.swing.JTextField(); + jtxtNew = new javax.swing.JTextField(); + jtxtInvalid = new javax.swing.JTextField(); + jtxtUpdate = new javax.swing.JTextField(); + jtxtMissing = new javax.swing.JTextField(); + jtxtBad = new javax.swing.JTextField(); + jtxtNoChange = new javax.swing.JTextField(); + jComboSeparator = new javax.swing.JComboBox(); + webPBar = new com.alee.laf.progressbar.WebProgressBar(); + jScrollPane1 = new javax.swing.JScrollPane(); + jPanel1 = new javax.swing.JPanel(); + jComboSearchKey = new javax.swing.JComboBox(); + jComboName = new javax.swing.JComboBox(); + jComboAccountID = new javax.swing.JComboBox(); + jComboAddress1 = new javax.swing.JComboBox(); + jComboAddress2 = new javax.swing.JComboBox(); + jComboCity = new javax.swing.JComboBox(); + jComboRegion = new javax.swing.JComboBox(); + jComboPostal = new javax.swing.JComboBox(); + jComboFirstName = new javax.swing.JComboBox(); + jComboLastName = new javax.swing.JComboBox(); + jComboEmail = new javax.swing.JComboBox(); + jComboPhone = new javax.swing.JComboBox(); + jComboPhone2 = new javax.swing.JComboBox(); + jCheckVisible = new javax.swing.JCheckBox(); + jbtnReset = new javax.swing.JButton(); + jbtnImport = new javax.swing.JButton(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jLabel10 = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + jLabel7 = new javax.swing.JLabel(); + jLabel8 = new javax.swing.JLabel(); + jLabel20 = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + jLabel21 = new javax.swing.JLabel(); + jLabel22 = new javax.swing.JLabel(); + jLabel23 = new javax.swing.JLabel(); + jLabel9 = new javax.swing.JLabel(); + jLabel12 = new javax.swing.JLabel(); + jCBiso = new javax.swing.JComboBox<>(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setOpaque(false); + setPreferredSize(new java.awt.Dimension(750, 500)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLabel1.setText(bundle.getString("label.csvfile")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(100, 30)); + + jFileName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jFileName.setPreferredSize(new java.awt.Dimension(400, 30)); + jFileName.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jFileNameActionPerformed(evt); + } + }); + + jbtnFileChoose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/fileopen.png"))); // NOI18N + jbtnFileChoose.setMaximumSize(new java.awt.Dimension(64, 32)); + jbtnFileChoose.setMinimumSize(new java.awt.Dimension(64, 32)); + jbtnFileChoose.setPreferredSize(new java.awt.Dimension(80, 45)); + jbtnFileChoose.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnFileChooseActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jFileChooserPanelLayout = new javax.swing.GroupLayout(jFileChooserPanel); + jFileChooserPanel.setLayout(jFileChooserPanelLayout); + jFileChooserPanelLayout.setHorizontalGroup( + jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jFileChooserPanelLayout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jFileName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jbtnFileChoose, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(120, 120, 120)) + ); + jFileChooserPanelLayout.setVerticalGroup( + jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jFileChooserPanelLayout.createSequentialGroup() + .addGroup(jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jFileName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + .addComponent(jbtnFileChoose, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + + jLabel18.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel18.setText(bundle.getString("label.csvdelimit")); // NOI18N + jLabel18.setPreferredSize(new java.awt.Dimension(100, 30)); + + jbtnRead.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnRead.setText(bundle.getString("label.csvread")); // NOI18N + jbtnRead.setEnabled(false); + jbtnRead.setPreferredSize(new java.awt.Dimension(110, 45)); + jbtnRead.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnReadActionPerformed(evt); + } + }); + + jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true), bundle.getString("title.CSVImport"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14), new java.awt.Color(102, 102, 102))); // NOI18N + + jlblRecords.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jlblRecords.setText(bundle.getString("label.csvrecordsfound")); // NOI18N + jlblRecords.setPreferredSize(new java.awt.Dimension(150, 30)); + + jlblNew.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jlblNew.setText(bundle.getString("label.csvnewcustomers")); // NOI18N + jlblNew.setMaximumSize(new java.awt.Dimension(77, 14)); + jlblNew.setMinimumSize(new java.awt.Dimension(77, 14)); + jlblNew.setPreferredSize(new java.awt.Dimension(150, 30)); + + jlblInvalid.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jlblInvalid.setText(bundle.getString("label.invalidcustomers")); // NOI18N + jlblInvalid.setPreferredSize(new java.awt.Dimension(150, 30)); + + jlblUpdates.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jlblUpdates.setText(bundle.getString("label.customerupdated")); // NOI18N + jlblUpdates.setPreferredSize(new java.awt.Dimension(150, 30)); + + jlblMissing.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jlblMissing.setText(bundle.getString("label.csvmissing")); // NOI18N + jlblMissing.setPreferredSize(new java.awt.Dimension(150, 30)); + + jlblBad.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jlblBad.setText(bundle.getString("label.csvbad")); // NOI18N + jlblBad.setPreferredSize(new java.awt.Dimension(150, 30)); + + jlblNotChanged.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jlblNotChanged.setText(bundle.getString("label.csvnotchanged")); // NOI18N + jlblNotChanged.setPreferredSize(new java.awt.Dimension(150, 30)); + + jtxtRecords.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtRecords.setForeground(new java.awt.Color(102, 102, 102)); + jtxtRecords.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jtxtRecords.setBorder(null); + jtxtRecords.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jtxtRecords.setEnabled(false); + jtxtRecords.setPreferredSize(new java.awt.Dimension(100, 30)); + + jtxtNew.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtNew.setForeground(new java.awt.Color(102, 102, 102)); + jtxtNew.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jtxtNew.setBorder(null); + jtxtNew.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jtxtNew.setEnabled(false); + jtxtNew.setPreferredSize(new java.awt.Dimension(100, 30)); + + jtxtInvalid.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtInvalid.setForeground(new java.awt.Color(102, 102, 102)); + jtxtInvalid.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jtxtInvalid.setBorder(null); + jtxtInvalid.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jtxtInvalid.setEnabled(false); + jtxtInvalid.setPreferredSize(new java.awt.Dimension(100, 30)); + + jtxtUpdate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtUpdate.setForeground(new java.awt.Color(102, 102, 102)); + jtxtUpdate.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jtxtUpdate.setBorder(null); + jtxtUpdate.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jtxtUpdate.setEnabled(false); + jtxtUpdate.setPreferredSize(new java.awt.Dimension(100, 30)); + + jtxtMissing.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtMissing.setForeground(new java.awt.Color(102, 102, 102)); + jtxtMissing.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jtxtMissing.setBorder(null); + jtxtMissing.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jtxtMissing.setEnabled(false); + jtxtMissing.setPreferredSize(new java.awt.Dimension(100, 30)); + + jtxtBad.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtBad.setForeground(new java.awt.Color(255, 0, 204)); + jtxtBad.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jtxtBad.setBorder(null); + jtxtBad.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jtxtBad.setEnabled(false); + jtxtBad.setPreferredSize(new java.awt.Dimension(100, 30)); + + jtxtNoChange.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtNoChange.setForeground(new java.awt.Color(102, 102, 102)); + jtxtNoChange.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jtxtNoChange.setBorder(null); + jtxtNoChange.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jtxtNoChange.setEnabled(false); + jtxtNoChange.setPreferredSize(new java.awt.Dimension(100, 30)); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jlblRecords, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jtxtRecords, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jlblNotChanged, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblInvalid, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblUpdates, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblMissing, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblBad, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblNew, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtxtNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtInvalid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtMissing, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtBad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtNoChange, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap()) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(0, 0, 0) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jlblRecords, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtRecords, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jlblNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jlblInvalid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtInvalid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jlblUpdates, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jlblMissing, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtMissing, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jlblBad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtBad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jlblNotChanged, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtNoChange, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + jComboSeparator.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboSeparator.setPreferredSize(new java.awt.Dimension(50, 30)); + + webPBar.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N + webPBar.setPreferredSize(new java.awt.Dimension(240, 30)); + + jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + jScrollPane1.setAutoscrolls(true); + + jPanel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel1.setPreferredSize(new java.awt.Dimension(430, 650)); + + jComboSearchKey.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboSearchKey.setEnabled(false); + jComboSearchKey.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboSearchKey.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboSearchKey.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboSearchKeyItemStateChanged(evt); + } + }); + jComboSearchKey.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboSearchKeyFocusGained(evt); + } + }); + + jComboName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboName.setEnabled(false); + jComboName.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboName.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboName.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboNameItemStateChanged(evt); + } + }); + jComboName.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboNameFocusGained(evt); + } + }); + + jComboAccountID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboAccountID.setEnabled(false); + jComboAccountID.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboAccountID.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboAccountID.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboAccountIDItemStateChanged(evt); + } + }); + jComboAccountID.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboAccountIDFocusGained(evt); + } + }); + + jComboAddress1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboAddress1.setModel(new javax.swing.DefaultComboBoxModel(new String[]{""})); + jComboAddress1.setSelectedIndex(-1); + jComboAddress1.setEnabled(false); + jComboAddress1.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboAddress1.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboAddress1.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboAddress1ItemStateChanged(evt); + } + }); + jComboAddress1.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboAddress1FocusGained(evt); + } + }); + + jComboAddress2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboAddress2.setEnabled(false); + jComboAddress2.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboAddress2.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboAddress2.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboAddress2ItemStateChanged(evt); + } + }); + jComboAddress2.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboAddress2FocusGained(evt); + } + }); + + jComboCity.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboCity.setEnabled(false); + jComboCity.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboCity.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboCityItemStateChanged(evt); + } + }); + jComboCity.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboCityFocusGained(evt); + } + }); + + jComboRegion.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboRegion.setEnabled(false); + jComboRegion.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboRegion.setName(""); // NOI18N + jComboRegion.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboRegion.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboRegionItemStateChanged(evt); + } + }); + jComboRegion.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboRegionFocusGained(evt); + } + }); + + jComboPostal.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboPostal.setEnabled(false); + jComboPostal.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboPostal.setName(""); // NOI18N + jComboPostal.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboPostal.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboPostalItemStateChanged(evt); + } + }); + jComboPostal.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboPostalFocusGained(evt); + } + }); + + jComboFirstName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboFirstName.setEnabled(false); + jComboFirstName.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboFirstName.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboFirstName.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboFirstNameItemStateChanged(evt); + } + }); + jComboFirstName.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboFirstNameFocusGained(evt); + } + }); + + jComboLastName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboLastName.setEnabled(false); + jComboLastName.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboLastName.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboLastName.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboLastNameItemStateChanged(evt); + } + }); + jComboLastName.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboLastNameFocusGained(evt); + } + }); + + jComboEmail.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboEmail.setEnabled(false); + jComboEmail.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboEmail.setName(""); // NOI18N + jComboEmail.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboEmail.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboEmailItemStateChanged(evt); + } + }); + jComboEmail.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboEmailFocusGained(evt); + } + }); + + jComboPhone.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboPhone.setEnabled(false); + jComboPhone.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboPhone.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboPhone.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboPhoneItemStateChanged(evt); + } + }); + jComboPhone.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboPhoneFocusGained(evt); + } + }); + + jComboPhone2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboPhone2.setEnabled(false); + jComboPhone2.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboPhone2.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboPhone2.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboPhone2ItemStateChanged(evt); + } + }); + jComboPhone2.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboPhone2FocusGained(evt); + } + }); + + jCheckVisible.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jCheckVisible.setSelected(true); + jCheckVisible.setEnabled(false); + jCheckVisible.setPreferredSize(new java.awt.Dimension(30, 30)); + + jbtnReset.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jbtnReset.setText(bundle.getString("button.reset")); // NOI18N + jbtnReset.setPreferredSize(new java.awt.Dimension(110, 45)); + jbtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnResetActionPerformed(evt); + } + }); + + jbtnImport.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jbtnImport.setText(bundle.getString("label.csvimpostbtn")); // NOI18N + jbtnImport.setEnabled(false); + jbtnImport.setPreferredSize(new java.awt.Dimension(110, 45)); + jbtnImport.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnImportActionPerformed(evt); + } + }); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(bundle.getString("label.taxid")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(bundle.getString("label.searchkeym")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(bundle.getString("label.namem")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel10.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel10.setText(bundle.getString("label.address")); // NOI18N + jLabel10.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel11.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel11.setText(bundle.getString("label.region")); // NOI18N + jLabel11.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(bundle.getString("label.city")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLabel8.setText(bundle.getString("label.visible")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel20.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel20.setText(bundle.getString("label.address2")); // NOI18N + jLabel20.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(bundle.getString("label.postal")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel21.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel21.setText(bundle.getString("label.email")); // NOI18N + jLabel21.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel22.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel22.setText(bundle.getString("label.phone")); // NOI18N + jLabel22.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel23.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel23.setText(bundle.getString("label.phone2")); // NOI18N + jLabel23.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel9.setText(bundle.getString("label.firstname")); // NOI18N + jLabel9.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel12.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel12.setText(bundle.getString("label.lastname")); // NOI18N + jLabel12.setPreferredSize(new java.awt.Dimension(100, 30)); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jCheckVisible, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addComponent(jbtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(12, 12, 12) + .addComponent(jbtnImport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(93, 93, 93)))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jComboCity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboSearchKey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboAccountID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboAddress1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboAddress2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboPhone2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboRegion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jComboSearchKey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboAccountID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboAddress1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboAddress2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboCity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboRegion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboPhone2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jCheckVisible, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jbtnImport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(74, Short.MAX_VALUE)) + ); + + jScrollPane1.setViewportView(jPanel1); + + jCBiso.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jCBiso.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"ISO-8859-1", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-10", "UTF-8", "UTF-16", " "})); + jCBiso.setToolTipText(bundle.getString("tooltip.import.cbiso")); // NOI18N + jCBiso.setPreferredSize(new java.awt.Dimension(125, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jFileChooserPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jCBiso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(7, 7, 7) + .addComponent(jbtnRead, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(webPBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jFileChooserPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnRead, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jCBiso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(webPBar, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(99, Short.MAX_VALUE)) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 588, Short.MAX_VALUE))) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jbtnReadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnReadActionPerformed + try { + GetheadersFromFile(jFileName.getText()); + webPBar.setString("Source file Header OK"); + } catch (IOException ex) { + log.error(ex.getMessage()); + webPBar.setString("Source file Header error!"); + } + }//GEN-LAST:event_jbtnReadActionPerformed + + private void jFileNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileNameActionPerformed + jbtnImport.setEnabled(false); + jbtnRead.setEnabled(true); + }//GEN-LAST:event_jFileNameActionPerformed + + private void jbtnFileChooseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnFileChooseActionPerformed + resetFields(); + setWorker(); + + JFileChooser chooser = new JFileChooser(last_folder == null ? "C:\\" : last_folder); + FileNameExtensionFilter filter = new FileNameExtensionFilter("csv files", "csv"); + chooser.setFileFilter(filter); + chooser.showOpenDialog(null); + File csvFile = chooser.getSelectedFile(); + + if (csvFile == null) { + return; + } + + File current_folder = chooser.getCurrentDirectory(); + + if (last_folder == null + || !last_folder.equals(current_folder.getAbsolutePath())) { + AppConfig CSVConfig = new AppConfig(config_file); + CSVConfig.load(); + CSVConfig.setProperty("CSV.last_folder" + , current_folder.getAbsolutePath()); + last_folder = current_folder.getAbsolutePath(); + try { + CSVConfig.save(); + } catch (IOException ex) { + log.error(ex.getMessage()); + } + } + + String csv = csvFile.getName(); + if (!(csv.trim().equals(""))) { + csvFileName = csvFile.getAbsolutePath(); + jFileName.setText(csvFileName); + } + }//GEN-LAST:event_jbtnFileChooseActionPerformed + + private void jComboPostalFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboPostalFocusGained + jComboPostal.removeAllItems(); + int i = 1; + jComboPostal.addItem(""); + + while (i < Headers.size()) { + if ((Headers.get(i) + != jComboSearchKey.getSelectedItem()) + & (Headers.get(i) != jComboAccountID.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboAddress1.getSelectedItem()) + & (Headers.get(i) != jComboAddress2.getSelectedItem()) +// & (Headers.get(i) != jComboPostal.getSelectedItem()) + & (Headers.get(i) != jComboCity.getSelectedItem()) + & (Headers.get(i) != jComboRegion.getSelectedItem()) + & (Headers.get(i) != jComboFirstName.getSelectedItem()) + & (Headers.get(i) != jComboLastName.getSelectedItem()) + & (Headers.get(i) != jComboEmail.getSelectedItem()) + & (Headers.get(i) != jComboPhone.getSelectedItem()) + & (Headers.get(i) != jComboPhone2.getSelectedItem()) + ) { + + jComboPostal.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboPostalFocusGained + + private void jComboPostalItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboPostalItemStateChanged + + checkFieldMapping(); + + }//GEN-LAST:event_jComboPostalItemStateChanged + + private void jComboLastNameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboLastNameItemStateChanged + + checkFieldMapping(); + + }//GEN-LAST:event_jComboLastNameItemStateChanged + + private void jComboFirstNameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboFirstNameItemStateChanged + + checkFieldMapping(); + + }//GEN-LAST:event_jComboFirstNameItemStateChanged + + private void jComboPhone2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboPhone2ItemStateChanged + + checkFieldMapping(); + + }//GEN-LAST:event_jComboPhone2ItemStateChanged + + private void jComboPhoneItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboPhoneItemStateChanged + + checkFieldMapping(); + + }//GEN-LAST:event_jComboPhoneItemStateChanged + + private void jComboEmailFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboEmailFocusGained + jComboEmail.removeAllItems(); + int i = 1; + jComboEmail.addItem(""); + + while (i < Headers.size()) { + if ((Headers.get(i) + != jComboSearchKey.getSelectedItem()) + & (Headers.get(i) != jComboAccountID.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboAddress1.getSelectedItem()) + & (Headers.get(i) != jComboAddress2.getSelectedItem()) + & (Headers.get(i) != jComboPostal.getSelectedItem()) + & (Headers.get(i) != jComboCity.getSelectedItem()) + & (Headers.get(i) != jComboRegion.getSelectedItem()) + & (Headers.get(i) != jComboFirstName.getSelectedItem()) + & (Headers.get(i) != jComboLastName.getSelectedItem()) +// & (Headers.get(i) != jComboEmail.getSelectedItem()) + & (Headers.get(i) != jComboPhone.getSelectedItem()) + & (Headers.get(i) != jComboPhone2.getSelectedItem()) + ) { + + jComboEmail.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboEmailFocusGained + + private void jComboEmailItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboEmailItemStateChanged + + checkFieldMapping(); + + }//GEN-LAST:event_jComboEmailItemStateChanged + + private void jbtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnResetActionPerformed + resetFields(); + progress = -1; + webPBar.setString("Waiting..."); + }//GEN-LAST:event_jbtnResetActionPerformed + + private void jbtnImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnImportActionPerformed + + jbtnImport.setEnabled(false); + + workProcess work = new workProcess(); + Thread thread2 = new Thread(work); + thread2.start(); + }//GEN-LAST:event_jbtnImportActionPerformed + + private void jComboRegionFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboRegionFocusGained + jComboRegion.removeAllItems(); + int i = 1; + jComboRegion.addItem(""); + + while (i < Headers.size()) { + if ((Headers.get(i) + != jComboSearchKey.getSelectedItem()) + & (Headers.get(i) != jComboAccountID.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboAddress1.getSelectedItem()) + & (Headers.get(i) != jComboAddress2.getSelectedItem()) + & (Headers.get(i) != jComboPostal.getSelectedItem()) + & (Headers.get(i) != jComboCity.getSelectedItem()) +// & (Headers.get(i) != jComboRegion.getSelectedItem()) + & (Headers.get(i) != jComboFirstName.getSelectedItem()) + & (Headers.get(i) != jComboLastName.getSelectedItem()) + & (Headers.get(i) != jComboEmail.getSelectedItem()) + & (Headers.get(i) != jComboPhone.getSelectedItem()) + & (Headers.get(i) != jComboPhone2.getSelectedItem()) + ) { + + jComboRegion.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboRegionFocusGained + + private void jComboRegionItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboRegionItemStateChanged + + checkFieldMapping(); + + }//GEN-LAST:event_jComboRegionItemStateChanged + + private void jComboCityFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboCityFocusGained + jComboCity.removeAllItems(); + int i = 1; + jComboCity.addItem(""); + + while (i < Headers.size()) { + if ((Headers.get(i) + != jComboSearchKey.getSelectedItem()) + & (Headers.get(i) != jComboAccountID.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboAddress1.getSelectedItem()) + & (Headers.get(i) != jComboAddress2.getSelectedItem()) + & (Headers.get(i) != jComboPostal.getSelectedItem()) +// & (Headers.get(i) != jComboCity.getSelectedItem()) + & (Headers.get(i) != jComboRegion.getSelectedItem()) + & (Headers.get(i) != jComboFirstName.getSelectedItem()) + & (Headers.get(i) != jComboLastName.getSelectedItem()) + & (Headers.get(i) != jComboEmail.getSelectedItem()) + & (Headers.get(i) != jComboPhone.getSelectedItem()) + & (Headers.get(i) != jComboPhone2.getSelectedItem()) + ) { + + jComboCity.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboCityFocusGained + + private void jComboCityItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboCityItemStateChanged + + checkFieldMapping(); + + }//GEN-LAST:event_jComboCityItemStateChanged + + private void jComboAddress2FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboAddress2FocusGained + jComboAddress2.removeAllItems(); + int i = 1; + jComboAddress2.addItem(""); + + while (i < Headers.size()) { + if ((Headers.get(i) + != jComboSearchKey.getSelectedItem()) + & (Headers.get(i) != jComboAccountID.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboAddress1.getSelectedItem()) +// & (Headers.get(i) != jComboAddress2.getSelectedItem()) + & (Headers.get(i) != jComboPostal.getSelectedItem()) + & (Headers.get(i) != jComboCity.getSelectedItem()) + & (Headers.get(i) != jComboRegion.getSelectedItem()) + & (Headers.get(i) != jComboFirstName.getSelectedItem()) + & (Headers.get(i) != jComboLastName.getSelectedItem()) + & (Headers.get(i) != jComboEmail.getSelectedItem()) + & (Headers.get(i) != jComboPhone.getSelectedItem()) + & (Headers.get(i) != jComboPhone2.getSelectedItem()) + ) { + + jComboAddress2.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboAddress2FocusGained + + private void jComboAddress2ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboAddress2ItemStateChanged + + checkFieldMapping(); + + }//GEN-LAST:event_jComboAddress2ItemStateChanged + + private void jComboAddress1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboAddress1FocusGained + jComboAddress1.removeAllItems(); + int i = 1; + jComboAddress1.addItem(""); + + while (i < Headers.size()) { + if ((Headers.get(i) + != jComboSearchKey.getSelectedItem()) + & (Headers.get(i) != jComboAccountID.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) +// & (Headers.get(i) != jComboAddress1.getSelectedItem()) + & (Headers.get(i) != jComboAddress2.getSelectedItem()) + & (Headers.get(i) != jComboPostal.getSelectedItem()) + & (Headers.get(i) != jComboCity.getSelectedItem()) + & (Headers.get(i) != jComboRegion.getSelectedItem()) + & (Headers.get(i) != jComboFirstName.getSelectedItem()) + & (Headers.get(i) != jComboLastName.getSelectedItem()) + & (Headers.get(i) != jComboEmail.getSelectedItem()) + & (Headers.get(i) != jComboPhone.getSelectedItem()) + & (Headers.get(i) != jComboPhone2.getSelectedItem()) + ) { + + jComboAddress1.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboAddress1FocusGained + + private void jComboAddress1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboAddress1ItemStateChanged + + checkFieldMapping(); + + }//GEN-LAST:event_jComboAddress1ItemStateChanged + + private void jComboNameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboNameFocusGained + jComboName.removeAllItems(); + int i = 1; + jComboName.addItem(""); + + while (i < Headers.size()) { + if ((Headers.get(i) + != jComboSearchKey.getSelectedItem()) + & (Headers.get(i) != jComboAccountID.getSelectedItem()) +// & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboAddress1.getSelectedItem()) + & (Headers.get(i) != jComboAddress2.getSelectedItem()) + & (Headers.get(i) != jComboPostal.getSelectedItem()) + & (Headers.get(i) != jComboCity.getSelectedItem()) + & (Headers.get(i) != jComboRegion.getSelectedItem()) + & (Headers.get(i) != jComboFirstName.getSelectedItem()) + & (Headers.get(i) != jComboLastName.getSelectedItem()) + & (Headers.get(i) != jComboEmail.getSelectedItem()) + & (Headers.get(i) != jComboPhone.getSelectedItem()) + & (Headers.get(i) != jComboPhone2.getSelectedItem()) + ) { + + jComboName.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboNameFocusGained + + private void jComboNameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboNameItemStateChanged + + checkFieldMapping(); + + }//GEN-LAST:event_jComboNameItemStateChanged + + private void jComboSearchKeyFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboSearchKeyFocusGained + jComboName.removeAllItems(); + int i = 1; + jComboName.addItem(""); + + while (i < Headers.size()) { + if ((Headers.get(i) +// != jComboSearchKey.getSelectedItem()) + != jComboAccountID.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboAddress1.getSelectedItem()) + & (Headers.get(i) != jComboAddress2.getSelectedItem()) + & (Headers.get(i) != jComboPostal.getSelectedItem()) + & (Headers.get(i) != jComboCity.getSelectedItem()) + & (Headers.get(i) != jComboRegion.getSelectedItem()) + & (Headers.get(i) != jComboFirstName.getSelectedItem()) + & (Headers.get(i) != jComboLastName.getSelectedItem()) + & (Headers.get(i) != jComboEmail.getSelectedItem()) + & (Headers.get(i) != jComboPhone.getSelectedItem()) + & (Headers.get(i) != jComboPhone2.getSelectedItem()) + ) { + + jComboSearchKey.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboSearchKeyFocusGained + + private void jComboSearchKeyItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboSearchKeyItemStateChanged + + checkFieldMapping(); + + }//GEN-LAST:event_jComboSearchKeyItemStateChanged + + private void jComboAccountIDFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboAccountIDFocusGained + jComboAccountID.removeAllItems(); + int i = 1; + jComboAccountID.addItem(""); + + while (i < Headers.size()) { + if ((Headers.get(i) + != jComboSearchKey.getSelectedItem()) +// & (Headers.get(i) != jComboAccountID.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboAddress1.getSelectedItem()) + & (Headers.get(i) != jComboAddress2.getSelectedItem()) + & (Headers.get(i) != jComboPostal.getSelectedItem()) + & (Headers.get(i) != jComboCity.getSelectedItem()) + & (Headers.get(i) != jComboRegion.getSelectedItem()) + & (Headers.get(i) != jComboFirstName.getSelectedItem()) + & (Headers.get(i) != jComboLastName.getSelectedItem()) + & (Headers.get(i) != jComboEmail.getSelectedItem()) + & (Headers.get(i) != jComboPhone.getSelectedItem()) + & (Headers.get(i) != jComboPhone2.getSelectedItem()) + ) { + + jComboAccountID.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboAccountIDFocusGained + + private void jComboAccountIDItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboAccountIDItemStateChanged + + checkFieldMapping(); + + }//GEN-LAST:event_jComboAccountIDItemStateChanged + + private void jComboFirstNameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboFirstNameFocusGained + jComboFirstName.removeAllItems(); + int i = 1; + jComboFirstName.addItem(""); + + while (i < Headers.size()) { + if ((Headers.get(i) + != jComboSearchKey.getSelectedItem()) + & (Headers.get(i) != jComboAccountID.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboAddress1.getSelectedItem()) + & (Headers.get(i) != jComboAddress2.getSelectedItem()) + & (Headers.get(i) != jComboPostal.getSelectedItem()) + & (Headers.get(i) != jComboCity.getSelectedItem()) + & (Headers.get(i) != jComboRegion.getSelectedItem()) +// & (Headers.get(i) != jComboFirstName.getSelectedItem()) + & (Headers.get(i) != jComboLastName.getSelectedItem()) + & (Headers.get(i) != jComboEmail.getSelectedItem()) + & (Headers.get(i) != jComboPhone.getSelectedItem()) + & (Headers.get(i) != jComboPhone2.getSelectedItem()) + ) { + + jComboFirstName.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboFirstNameFocusGained + + private void jComboLastNameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboLastNameFocusGained + jComboLastName.removeAllItems(); + int i = 1; + jComboLastName.addItem(""); + + while (i < Headers.size()) { + if ((Headers.get(i) + != jComboSearchKey.getSelectedItem()) + & (Headers.get(i) != jComboAccountID.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboAddress1.getSelectedItem()) + & (Headers.get(i) != jComboAddress2.getSelectedItem()) + & (Headers.get(i) != jComboPostal.getSelectedItem()) + & (Headers.get(i) != jComboCity.getSelectedItem()) + & (Headers.get(i) != jComboRegion.getSelectedItem()) + & (Headers.get(i) != jComboFirstName.getSelectedItem()) +// & (Headers.get(i) != jComboLastName.getSelectedItem()) + & (Headers.get(i) != jComboEmail.getSelectedItem()) + & (Headers.get(i) != jComboPhone.getSelectedItem()) + & (Headers.get(i) != jComboPhone2.getSelectedItem()) + ) { + + jComboLastName.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboLastNameFocusGained + + private void jComboPhoneFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboPhoneFocusGained + jComboPhone.removeAllItems(); + int i = 1; + jComboPhone.addItem(""); + + while (i < Headers.size()) { + if ((Headers.get(i) + != jComboSearchKey.getSelectedItem()) + & (Headers.get(i) != jComboAccountID.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboAddress1.getSelectedItem()) + & (Headers.get(i) != jComboAddress2.getSelectedItem()) + & (Headers.get(i) != jComboPostal.getSelectedItem()) + & (Headers.get(i) != jComboCity.getSelectedItem()) + & (Headers.get(i) != jComboRegion.getSelectedItem()) + & (Headers.get(i) != jComboFirstName.getSelectedItem()) + & (Headers.get(i) != jComboLastName.getSelectedItem()) + & (Headers.get(i) != jComboEmail.getSelectedItem()) +// & (Headers.get(i) != jComboPhone.getSelectedItem()) + & (Headers.get(i) != jComboPhone2.getSelectedItem()) + ) { + + jComboPhone.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboPhoneFocusGained + + private void jComboPhone2FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboPhone2FocusGained + jComboPhone2.removeAllItems(); + int i = 1; + jComboPhone2.addItem(""); + + while (i < Headers.size()) { + if ((Headers.get(i) + != jComboSearchKey.getSelectedItem()) + & (Headers.get(i) != jComboAccountID.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboAddress1.getSelectedItem()) + & (Headers.get(i) != jComboAddress2.getSelectedItem()) + & (Headers.get(i) != jComboPostal.getSelectedItem()) + & (Headers.get(i) != jComboCity.getSelectedItem()) + & (Headers.get(i) != jComboRegion.getSelectedItem()) + & (Headers.get(i) != jComboFirstName.getSelectedItem()) + & (Headers.get(i) != jComboLastName.getSelectedItem()) + & (Headers.get(i) != jComboEmail.getSelectedItem()) + & (Headers.get(i) != jComboPhone.getSelectedItem()) +// & (Headers.get(i) != jComboPhone2.getSelectedItem()) + ) { + + jComboPhone2.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboPhone2FocusGained + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox<String> jCBiso; + private javax.swing.JCheckBox jCheckVisible; + private javax.swing.JComboBox jComboAccountID; + private javax.swing.JComboBox jComboAddress1; + private javax.swing.JComboBox jComboAddress2; + private javax.swing.JComboBox jComboCity; + private javax.swing.JComboBox jComboEmail; + private javax.swing.JComboBox jComboFirstName; + private javax.swing.JComboBox jComboLastName; + private javax.swing.JComboBox jComboName; + private javax.swing.JComboBox jComboPhone; + private javax.swing.JComboBox jComboPhone2; + private javax.swing.JComboBox jComboPostal; + private javax.swing.JComboBox jComboRegion; + private javax.swing.JComboBox jComboSearchKey; + private javax.swing.JComboBox jComboSeparator; + private javax.swing.JPanel jFileChooserPanel; + private javax.swing.JTextField jFileName; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel20; + private javax.swing.JLabel jLabel21; + private javax.swing.JLabel jLabel22; + private javax.swing.JLabel jLabel23; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton jbtnFileChoose; + private javax.swing.JButton jbtnImport; + private javax.swing.JButton jbtnRead; + private javax.swing.JButton jbtnReset; + private javax.swing.JLabel jlblBad; + private javax.swing.JLabel jlblInvalid; + private javax.swing.JLabel jlblMissing; + private javax.swing.JLabel jlblNew; + private javax.swing.JLabel jlblNotChanged; + private javax.swing.JLabel jlblRecords; + private javax.swing.JLabel jlblUpdates; + private javax.swing.JTextField jtxtBad; + private javax.swing.JTextField jtxtInvalid; + private javax.swing.JTextField jtxtMissing; + private javax.swing.JTextField jtxtNew; + private javax.swing.JTextField jtxtNoChange; + private javax.swing.JTextField jtxtRecords; + private javax.swing.JTextField jtxtUpdate; + private com.alee.laf.progressbar.WebProgressBar webPBar; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/imports/JPanelCSV.form b/src/main/java/com/unicenta/pos/imports/JPanelCSV.form new file mode 100644 index 0000000..1a0bd58 --- /dev/null +++ b/src/main/java/com/unicenta/pos/imports/JPanelCSV.form @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="750" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="500" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> +</Form> diff --git a/src/main/java/com/unicenta/pos/imports/JPanelCSV.java b/src/main/java/com/unicenta/pos/imports/JPanelCSV.java new file mode 100644 index 0000000..5d1f09d --- /dev/null +++ b/src/main/java/com/unicenta/pos/imports/JPanelCSV.java @@ -0,0 +1,53 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// CSV Import Panel added by JDL - February 2013 +// Additonal library required - javacsv + +package com.unicenta.pos.imports; + +public class JPanelCSV extends javax.swing.JPanel { + + + public JPanelCSV() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 750, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 500, Short.MAX_VALUE) + ); + }// </editor-fold>//GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/imports/JPanelCSVCleardb.form b/src/main/java/com/unicenta/pos/imports/JPanelCSVCleardb.form new file mode 100644 index 0000000..caf82ea --- /dev/null +++ b/src/main/java/com/unicenta/pos/imports/JPanelCSVCleardb.form @@ -0,0 +1,133 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 240]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="16" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" max="-2" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jEnableButton" pref="0" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jBtnCleardb" min="-2" pref="218" max="-2" attributes="0"/> + </Group> + <Component id="jScrollPane1" min="-2" pref="400" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jScrollPane1" min="-2" pref="127" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jBtnCleardb" min="-2" max="-2" attributes="0"/> + <Component id="jEnableButton" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvresetimport" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextPane" name="jMessageBox"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JCheckBox" name="jEnableButton"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvenableclear" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="jEnableButtonStateChanged"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jEnableButtonActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jBtnCleardb"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/sale_delete.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.clearimport" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvclearlog" replaceFormat="AppLocal.getIntString("button.exit")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnCleardbActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/imports/JPanelCSVCleardb.java b/src/main/java/com/unicenta/pos/imports/JPanelCSVCleardb.java new file mode 100644 index 0000000..7f5a673 --- /dev/null +++ b/src/main/java/com/unicenta/pos/imports/JPanelCSVCleardb.java @@ -0,0 +1,238 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// CSV Import Panel added by JDL - February 2013 +// Additonal library required - javacsv + + +package com.unicenta.pos.imports; + +import com.unicenta.basic.BasicException; +import com.unicenta.pos.forms.*; +import com.unicenta.pos.util.AltEncrypter; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.Statement; +import javax.swing.*; + +public class JPanelCSVCleardb extends JPanel implements JPanelView { + + private Connection con; + private Statement stmt; + private String SQL; + private AppConfig config; + + /** + * + * @param oApp + */ + public JPanelCSVCleardb(AppView oApp) { + this(oApp.getProperties()); + + } + + /** + * + * @param props + */ + public JPanelCSVCleardb(AppProperties props) { + + initComponents(); + + config = new AppConfig(props.getConfigFile()); + config.load(); + + jMessageBox.setText("Performing this action, will clear all " + + "data in the CSVImport table. \n\n" + + "It is recommended that this is performed before " + + "running a new import. \n"); + + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.CSVReset"); + } + + /** + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + String db_user =(config.getProperty("db.user")); + String db_url = (config.getProperty("db.URL")); + String db_password = (config.getProperty("db.password")); + + if (db_user != null && db_password != null && db_password.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + db_user); + db_password = cypher.decrypt(db_password.substring(6)); + } + try{ + con = DriverManager.getConnection(db_url,db_user,db_password); + stmt = (Statement) con.createStatement(); + + } catch (Exception e) { + } + + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + try{ + stmt.close(); + con.close(); + }catch (Exception e){} + + return (true); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jMessageBox = new javax.swing.JTextPane(); + jEnableButton = new javax.swing.JCheckBox(); + jBtnCleardb = new javax.swing.JButton(); + + setPreferredSize(new java.awt.Dimension(450, 240)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLabel1.setText(bundle.getString("label.csvresetimport")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(250, 30)); + + jMessageBox.setEditable(false); + jMessageBox.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jScrollPane1.setViewportView(jMessageBox); + + jEnableButton.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jEnableButton.setText(bundle.getString("label.csvenableclear")); // NOI18N + jEnableButton.setPreferredSize(new java.awt.Dimension(250, 30)); + jEnableButton.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + jEnableButtonStateChanged(evt); + } + }); + jEnableButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jEnableButtonActionPerformed(evt); + } + }); + + jBtnCleardb.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jBtnCleardb.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_delete.png"))); // NOI18N + jBtnCleardb.setText(bundle.getString("label.clearimport")); // NOI18N + jBtnCleardb.setActionCommand(AppLocal.getIntString("button.exit")); // NOI18N + jBtnCleardb.setEnabled(false); + jBtnCleardb.setPreferredSize(new java.awt.Dimension(160, 45)); + jBtnCleardb.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnCleardbActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addGap(16, 16, 16) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(jEnableButton, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jBtnCleardb, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jBtnCleardb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jEnableButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jEnableButtonStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jEnableButtonStateChanged + if (jEnableButton.isSelected()){ + jBtnCleardb.setEnabled(true); + }else { + jBtnCleardb.setEnabled(false); + } + }//GEN-LAST:event_jEnableButtonStateChanged + + private void jBtnCleardbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnCleardbActionPerformed + SQL="DELETE FROM csvimport"; + try{ + stmt.executeUpdate(SQL); + }catch (Exception e){ + } + }//GEN-LAST:event_jBtnCleardbActionPerformed + + private void jEnableButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jEnableButtonActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jEnableButtonActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jBtnCleardb; + private javax.swing.JCheckBox jEnableButton; + private javax.swing.JLabel jLabel1; + private javax.swing.JTextPane jMessageBox; + private javax.swing.JScrollPane jScrollPane1; + // End of variables declaration//GEN-END:variables + + + +} diff --git a/src/main/java/com/unicenta/pos/imports/JPanelCSVImport.form b/src/main/java/com/unicenta/pos/imports/JPanelCSVImport.form new file mode 100644 index 0000000..c8f1d54 --- /dev/null +++ b/src/main/java/com/unicenta/pos/imports/JPanelCSVImport.form @@ -0,0 +1,1268 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="opaque" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[750, 500]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jLabel17" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jFileChooserPanel" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel1" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel18" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboSeparator" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jCBiso" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jHeaderRead" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="jPanel2" max="32767" attributes="0"/> + <Component id="webPBar" max="32767" attributes="0"/> + <Component id="jLblImportNotice" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel17" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jFileChooserPanel" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboSeparator" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel18" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jHeaderRead" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jCBiso" alignment="1" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="webPBar" min="-2" pref="32" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jPanel2" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jLblImportNotice" min="-2" pref="70" max="-2" attributes="0"/> + </Group> + <Component id="jPanel1" min="-2" pref="469" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jFileChooserPanel"> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel1" max="32767" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jFileName" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jbtnFileChoose" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="120" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jFileName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + <Component id="jbtnFileChoose" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvfile" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jFileName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jFileNameActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jbtnFileChoose"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/fileopen.png"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 32]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 32]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnFileChooseActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[430, 400]"/> + </Property> + </Properties> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel8" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jCheckInCatalogue" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="59" max="-2" attributes="0"/> + <Component id="jCheckSellIncTax" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel12" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Component id="jbtnReset" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="jImport" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="93" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <Group type="103" alignment="0" groupAlignment="1" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel7" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboTax" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboBarcode" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboReference" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboName" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel10" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboBuy" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel20" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboSell" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboDefaultCategory" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel11" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboCategory" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel21" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboSupplier" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel22" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboDefaultSupplier" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="2" pref="2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboReference" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jComboBarcode" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboBuy" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboSell" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel20" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboTax" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel11" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="jComboCategory" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboDefaultCategory" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel21" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="jComboSupplier" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboDefaultSupplier" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel22" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel12" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jCheckSellIncTax" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="103" alignment="0" groupAlignment="1" attributes="0"> + <Component id="jLabel8" min="-2" max="-2" attributes="0"/> + <Component id="jCheckInCatalogue" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jImport" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jbtnReset" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace pref="16" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JComboBox" name="jComboReference"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboReferenceItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboReferenceFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboBarcode"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboBarcodeItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboBarcodeFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboNameItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboNameFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboBuy"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="1"> + <StringItem index="0" value=""/> + </StringArray> + </Property> + <Property name="selectedIndex" type="int" value="-1"/> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboBuyItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboBuyFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboSell"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboSellItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboSellFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboDefaultCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboDefaultCategoryItemStateChanged"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jComboDefaultCategoryActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboTax"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboTaxItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboTaxFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodref" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbarcode" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodname" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel10"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricebuy" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel11"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodcategory" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodtaxcode" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="jCheckInCatalogue"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[30, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodincatalog" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="jCheckSellIncTax"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[30, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel12"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvsellingintax" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jComboCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="name" type="java.lang.String" value="" noResource="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboCategoryItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboCategoryFocusGained"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel20"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricesell" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jImport"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvimpostbtn" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jImportActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.proddefaultcategory" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jbtnReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.reset" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnResetActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboSupplier"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="name" type="java.lang.String" value="" noResource="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboSupplierItemStateChanged"/> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jComboSupplierFocusGained"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jComboSupplierActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel21"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.suppliername" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel22"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.proddefaultsupplier" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jComboDefaultSupplier"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboDefaultSupplierItemStateChanged"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jComboDefaultSupplierActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel17"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="10" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Import version 4.5"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel18"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvdelimit" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jHeaderRead"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvread" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jHeaderReadActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JPanelCSVSelect_jHeaderRead"/> + </AuxValues> + </Component> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> + <TitledBorder title="Status"> + <Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder roundedCorners="true"> + <Color PropertyName="color" blue="99" green="99" red="99" type="rgb"/> + </LineBorder> + </Border> + <ResourceString PropertyName="titleX" bundle="pos_messages.properties" key="title.CSVImport" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + <Font PropertyName="font" name="Arial" size="14" style="1"/> + <Color PropertyName="color" blue="66" green="66" red="66" type="rgb"/> + </TitledBorder> + </Border> + </Property> + </Properties> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel9" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jTextRecords" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="1" max="-2" attributes="0"> + <Component id="jLabel19" max="-2" attributes="0"/> + <Component id="jLabel13" alignment="0" max="-2" attributes="0"/> + <Component id="jLabel16" alignment="0" max="-2" attributes="0"/> + <Component id="jTextUpdates" alignment="0" max="-2" attributes="0"/> + <Component id="jLabel2" alignment="0" max="-2" attributes="0"/> + <Component id="jLabel15" alignment="0" max="-2" attributes="0"/> + <Component id="jLabel14" alignment="1" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jTextBadCats" min="-2" max="-2" attributes="0"/> + <Component id="jTextNew" min="-2" max="-2" attributes="0"/> + <Component id="jTextInvalid" min="-2" max="-2" attributes="0"/> + <Component id="jTextUpdate" min="-2" max="-2" attributes="0"/> + <Component id="jTextMissing" min="-2" max="-2" attributes="0"/> + <Component id="jTextBadPrice" min="-2" max="-2" attributes="0"/> + <Component id="jTextNoChange" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="0" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jTextRecords" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel14" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jTextNew" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel16" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jTextInvalid" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jTextUpdates" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jTextUpdate" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jTextMissing" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel15" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jTextBadPrice" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jTextNoChange" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel19" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jTextBadCats" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel9"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvrecordsfound" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel14"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvnewproducts" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[77, 14]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[77, 14]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel16"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvchanged" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jTextUpdates"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvpriceupdated" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvmissing" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel15"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvbad" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel13"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvnotchanged" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTextRecords"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTextNew"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTextInvalid"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTextUpdate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTextMissing"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTextBadPrice"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="cc" green="0" red="ff" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTextNoChange"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel19"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvbadcats" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTextBadCats"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="cc" green="0" red="ff" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JComboBox" name="jComboSeparator"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.progressbar.WebProgressBar" name="webPBar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="13" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[240, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblImportNotice"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/refundit.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.importnotice" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 37]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jCBiso"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="13"> + <StringItem index="0" value="ISO-8859-1"/> + <StringItem index="1" value="ISO-8859-2"/> + <StringItem index="2" value="ISO-8859-3"/> + <StringItem index="3" value="ISO-8859-4"/> + <StringItem index="4" value="ISO-8859-5"/> + <StringItem index="5" value="ISO-8859-6"/> + <StringItem index="6" value="ISO-8859-7"/> + <StringItem index="7" value="ISO-8859-8"/> + <StringItem index="8" value="ISO-8859-9"/> + <StringItem index="9" value="ISO-8859-10"/> + <StringItem index="10" value="UTF-8"/> + <StringItem index="11" value="UTF-16"/> + <StringItem index="12" value=" "/> + </StringArray> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.import.cbiso" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/imports/JPanelCSVImport.java b/src/main/java/com/unicenta/pos/imports/JPanelCSVImport.java new file mode 100644 index 0000000..348cc65 --- /dev/null +++ b/src/main/java/com/unicenta/pos/imports/JPanelCSVImport.java @@ -0,0 +1,2076 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + + +package com.unicenta.pos.imports; + +import com.csvreader.CsvReader; +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.*; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.*; +import com.unicenta.pos.sales.TaxesLogic; +import com.unicenta.pos.ticket.ProductInfoExt; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; + +import javax.swing.*; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.filechooser.FileNameExtensionFilter; +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + + +/** + * Graphical User Interface and code for importing data from a CSV file allowing + * adding or updating many products quickly and easily. + * + */ +@Slf4j +public class JPanelCSVImport extends JPanel implements JPanelView { + + private ArrayList<String> Headers = new ArrayList<>(); + private Session s; + private Connection con; + private String csvFileName; + private Double dOriginalRate = 0.0; + private String dCategory; + private String dSupplier; + private String csvMessage = ""; + private CsvReader products; + private double oldSellPrice = 0; + private double oldBuyPrice = 0; + private int currentRecord; + private int rowCount = 0; + private String last_folder; + private File config_file; + + private static String category_default = "[ USE DEFAULT CATEGORY ]"; + private static String reject_bad_category = "[ REJECT ITEMS WITH BAD CATEGORIES ]"; + private static String supplier_default = "[ USE DEFAULT SUPPLIER ]"; + private static String reject_bad_supplier = "[ REJECT ITEMS WITH BAD SUPPLIER ]"; + + private DataLogicSales m_dlSales; + private DataLogicSystem m_dlSystem; + + protected SaveProvider spr; + + private String Category; + private String categoryName; + private String categoryParentid; + private Integer categoryCatorder; + private SentenceList m_sentcat; + private ComboBoxValModel m_CategoryModel; + private HashMap cat_list = new HashMap(); + private ArrayList badCategories = new ArrayList(); + + private String productReference; + private String productBarcode; + private String productBarcodetype; + private String productName; + private Double productBuyPrice; + private Double productSellPrice; + private String productTax; + + private String Supplier; + private String supplierName; + private SentenceList m_sentsupp; + private ComboBoxValModel m_SupplierModel; + private HashMap supp_list = new HashMap(); + private ArrayList badSuppliers = new ArrayList(); + + private SentenceList taxcatsent; + private ComboBoxValModel taxcatmodel; + private SentenceList taxsent; + private TaxesLogic taxeslogic; + + private DocumentListener documentListener; + private ProductInfoExt prodInfo; + private String recordType = null; + + private int newRecords = 0; + private int invalidRecords = 0; + private int priceUpdates = 0; + private int missingData = 0; + private int noChanges = 0; + private int badPrice = 0; + + private double dTaxRate; + + private Integer progress = 0; + + private String iso="ISO-8859-1"; + + /** + * Constructs a new JPanelCSVImport object + * + * @param oApp AppView + */ + public JPanelCSVImport(AppView oApp) { + this(oApp.getProperties()); + } + + /** + * Constructs a new JPanelCSVImport object + * + * @param props AppProperties + */ + @SuppressWarnings("empty-statement") + public JPanelCSVImport(AppProperties props) { + initComponents(); + + try { + s = AppViewConnection.createSession(props); + con = s.getConnection(); + } catch (BasicException | SQLException e) {; + } + + m_dlSales = new DataLogicSales(); + m_dlSales.init(s); + + m_dlSystem = new DataLogicSystem(); + m_dlSystem.init(s); + + spr = new SaveProvider( + m_dlSales.getProductCatUpdate(), + m_dlSales.getProductCatInsert(), + m_dlSales.getProductCatDelete()); + + last_folder = props.getProperty("CSV.last_folder"); + config_file = props.getConfigFile(); + + jFileName.getDocument().addDocumentListener(documentListener); + + documentListener = new DocumentListener() { + @Override + public void changedUpdate(DocumentEvent documentEvent) { + jHeaderRead.setEnabled(true); + } + + @Override + public void insertUpdate(DocumentEvent documentEvent) { + if (!"".equals(jFileName.getText().trim())) { + jHeaderRead.setEnabled(true); + } + } + + @Override + public void removeUpdate(DocumentEvent documentEvent) { + if (jFileName.getText().trim().equals("")) { + jHeaderRead.setEnabled(false); + } + } + }; + jFileName.getDocument().addDocumentListener(documentListener); + + } + + /** + * Reads the headers from the CSV file and initializes subsequent form + * fields. This function first reads the headers from the CSVFileName file, + * then puts them into the header combo boxes and enables the other form + * inputs. + * + * @param CSVFileName Name of the file (including the path) to open and read + * CSV data from + * @throws IOException If there is an issue reading the CSV file + */ + private void GetheadersFromFile(String CSVFileName) throws IOException { + + File f = new File(CSVFileName); + if (f.exists()) { +// products = new CsvReader(CSVFileName, ',' ,Charset.forName("UTF-8")); + products = new CsvReader(CSVFileName, ',' ,Charset.forName(jCBiso.getSelectedItem().toString())); + products.setDelimiter(((String) jComboSeparator.getSelectedItem()).charAt(0)); + products.readHeaders(); + + if (products.getHeaderCount() < 5) { + JOptionPane.showMessageDialog(null, + "Incorrect header in your source file", + "Header Error", + JOptionPane.WARNING_MESSAGE); + products.close(); + return; + } + rowCount = 0; + int i = 0; + Headers.clear(); + Headers.add(""); + jComboName.addItem(""); + jComboReference.addItem(""); + jComboBarcode.addItem(""); + jComboBuy.addItem(""); + jComboSell.addItem(""); + jComboTax.addItem(""); + jComboCategory.addItem(""); + jComboSupplier.addItem(""); + + while (i < products.getHeaderCount()) { + jComboName.addItem(products.getHeader(i)); + jComboReference.addItem(products.getHeader(i)); + jComboBarcode.addItem(products.getHeader(i)); + jComboBuy.addItem(products.getHeader(i)); + jComboSell.addItem(products.getHeader(i)); + jComboTax.addItem(products.getHeader(i)); + jComboCategory.addItem(products.getHeader(i)); + jComboSupplier.addItem(products.getHeader(i)); + + Headers.add(products.getHeader(i)); + ++i; + } + + enableCheckBoxes(); + + while (products.readRecord()) { + System.out.println(products.getRawRecord()); + ++rowCount; + } + + jTextRecords.setText(Long.toString(rowCount)); + + products.close(); + + } else { + JOptionPane.showMessageDialog(null, "Unable to locate " + + CSVFileName, + "File not found", + JOptionPane.WARNING_MESSAGE); + } + } + + /** + * Enables all the selection options on the for to allow the user to + * interact with the routine. + * + */ + private void enableCheckBoxes() { + jHeaderRead.setEnabled(false); + jImport.setEnabled(false); + jbtnReset.setEnabled(true); + jComboReference.setEnabled(true); + jComboName.setEnabled(true); + jComboBarcode.setEnabled(true); + jComboBuy.setEnabled(true); + jComboSell.setEnabled(true); + jComboTax.setEnabled(true); + jComboCategory.setEnabled(true); + jComboDefaultCategory.setEnabled(true); + jComboSupplier.setEnabled(true); + jComboDefaultSupplier.setEnabled(true); + + jCheckInCatalogue.setEnabled(true); + jCheckSellIncTax.setEnabled(true); + } + + /** + * Pushes the Import process into a new thread so it doesn't interfere with + * the UI responsiveness. + */ + private void setWorker() { + progress = 0; + webPBar.setStringPainted(true); + + final SwingWorker<Integer, Integer> pbWorker; + pbWorker = new SwingWorker<Integer, Integer>() { + + @Override + protected final Integer doInBackground() throws Exception { + while ((progress >= 0) && (progress < 100)) { + Thread.sleep(50); + this.publish(progress); + } + this.publish(100); + this.done(); + return 100; + } + + @Override + protected final void process(final List<Integer> chunks) { + webPBar.setValue(chunks.get(0)); + if (progress > 100) { + progress = 100; + webPBar.setString("Imported 100%"); + } else { + webPBar.setString("Imported " + progress + "%"); + } + } + }; + pbWorker.execute(); + } + + /** + * Runs the setWorker. + * + */ + private class workProcess implements Runnable { + + @Override + public void run() { + try { + ImportCsvFile(jFileName.getText()); + } catch (IOException ex) { + log.error(ex.getMessage()); + } + } + } + + /** + * Imports the CSV File using specifications from the form. + * + * @param CSVFileName Name of the file (including path) to import. + * @throws IOException If there are file reading issues. + */ + private void ImportCsvFile(String CSVFileName) throws IOException { + + File f = new File(CSVFileName); + if (f.exists()) { + webPBar.setString ( "Starting..." ); + webPBar.setVisible(true); + jImport.setEnabled(false); + +// Read file +// products = new CsvReader(CSVFileName, ',' ,Charset.forName("UTF-8")); + products = new CsvReader(CSVFileName, ',' ,Charset.forName(jCBiso.getSelectedItem().toString())); + + products.setDelimiter(((String) jComboSeparator.getSelectedItem()).charAt(0)); + products.readHeaders(); + + currentRecord = 0; + + while (products.readRecord()) { + productReference = products.get((String) jComboReference.getSelectedItem()); + productName = products.get((String) jComboName.getSelectedItem()); + productBarcode = products.get((String) jComboBarcode.getSelectedItem()); + String BuyPrice = products.get((String) jComboBuy.getSelectedItem()); + String SellPrice = products.get((String) jComboSell.getSelectedItem()); + productTax = products.get((String) jComboTax.getSelectedItem()); + + Category = products.get((String) jComboCategory.getSelectedItem()); + Supplier = products.get((String) jComboSupplier.getSelectedItem()); + + currentRecord++; + progress = currentRecord; + +// Strip Currencies Dollar GBP, euro + BuyPrice = StringUtils.replaceChars(BuyPrice, "$", ""); + SellPrice = StringUtils.replaceChars(SellPrice, "$", ""); + + BuyPrice = StringUtils.replaceChars(BuyPrice, "£", ""); + SellPrice = StringUtils.replaceChars(SellPrice, "£", ""); + + BuyPrice = StringUtils.replaceChars(BuyPrice, "€", ""); + SellPrice = StringUtils.replaceChars(SellPrice, "€", ""); + + dCategory = getCategory(); + if ("Bad Category".equals(dCategory)) { + csvMessage = "Bad category details"; + } else { + csvMessage = "Missing data or Invalid number"; + } + + dSupplier = getSupplier(); + if ("Bad Supplier".equals(dSupplier)) { + csvMessage = "Bad Supplier details"; + } else { + csvMessage = "Missing data or Invalid number"; + } + + if (validateNumber(BuyPrice)) { + productBuyPrice = Double.parseDouble(BuyPrice); + } else { + productBuyPrice = null; + } + + if (validateNumber(SellPrice)) { + productSellPrice = getSellPrice(SellPrice); + } else { + productSellPrice = null; + } + + if ("".equals(productReference) +// | "".equals(productName) + | "".equals(productBarcode) + | "".equals(BuyPrice) + | "".equals(SellPrice) + | "".equals(productTax) + | productBuyPrice == null + | productSellPrice == null + | "Bad Category".equals(dCategory)) { + + if (productBuyPrice == null + | productSellPrice == null) { + badPrice++; + } else { + missingData++; + } + createCSVEntry(csvMessage, null, null); + } else { + + recordType = getRecord(); + switch (recordType) { + case "new": + createProduct("new"); + newRecords++; + createCSVEntry("New product", null, null); + break; + case "Name change": + case "Barcode change": + case "Reference change": + case "Duplicate Reference found.": + case "Duplicate Barcode found.": + case "Duplicate Description found.": + createProduct("new"); + newRecords++; + createCSVEntry("New product", null, null); + break; + case "Tax change": + case "Exception": + invalidRecords++; + createCSVEntry(recordType, null, null); + break; + default: + updateRecord(recordType); + break; + } + } + } + products.close(); + } else { + JOptionPane.showMessageDialog(null, + "Unable to locate " + + CSVFileName, + "File not found", + JOptionPane.WARNING_MESSAGE); + } + + jTextNew.setText(Integer.toString(newRecords)); + jTextUpdate.setText(Integer.toString(priceUpdates)); + jTextInvalid.setText(Integer.toString(invalidRecords)); + jTextMissing.setText(Integer.toString(missingData)); + jTextNoChange.setText(Integer.toString(noChanges)); + jTextBadPrice.setText(Integer.toString(badPrice)); + if (badCategories.size() == 1 && badCategories.get(0) == "") { + jTextBadCats.setText("0"); + } else { + jTextBadCats.setText(Integer.toString(badCategories.size())); + } + + JOptionPane.showMessageDialog(null, + "Import Complete", + "Imported", + JOptionPane.WARNING_MESSAGE); + + progress = 100; + webPBar.setValue(progress); + webPBar.setString("Imported : " + progress + " records"); +// } + } + + /** + * Tests + * <code>testString</code> for validity as a number + * + * @param testString the string to be checked + * @return True if a real number False if not + */ + private Boolean validateNumber(String testString) { + try { + Double res = Double.parseDouble(testString); + return (true); + } catch (NumberFormatException e) { + return (false); + } + } + + /** + * Lookup for an existing Product's Category + * CategoryID as string. + */ + private String getCategory() { + + if (jComboCategory.getSelectedItem() != category_default) { + String cat = (String) cat_list.get(Category); + + if (cat != null) { + return (cat); + } + } + + if (!Category.equals("")) { + Object[] newcat = new Object[3]; + newcat[0] = UUID.randomUUID().toString(); + newcat[1] = Category; + newcat[2] = true; + + try { + m_dlSales.createCategory(newcat); + + cat_list = new HashMap<>(); + for (Object category : m_sentcat.list()) { + m_CategoryModel.setSelectedItem(category); + cat_list.put(category.toString(), m_CategoryModel.getSelectedKey().toString()); + } + String cat = (String) cat_list.get(Category); + return (cat); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + if (!badCategories.contains(Category)) { + badCategories.add(Category.trim()); // Save a list of the bad categories + } + return ((jComboDefaultCategory.getSelectedItem() + == reject_bad_category) + ? "Bad Category" + : (String) cat_list.get(m_CategoryModel.getSelectedText())); + } + + /** + * Grab Supplier from Import file. + * + */ + private String getSupplier() { + + if (jComboSupplier.getSelectedItem() != supplier_default) { + String supp = (String) supp_list.get(Supplier); + + if (supp != null) { + return (supp); + } + } + + if (!Supplier.equals("")) { + Object[] newsupp = new Object[4]; + newsupp[0] = UUID.randomUUID().toString(); + newsupp[1] = Supplier; + newsupp[2] = Supplier; + newsupp[3] = true; + + try { + m_dlSales.createSupplier(newsupp); + + supp_list = new HashMap<>(); + for (Object supplier : m_sentsupp.list()) { + m_SupplierModel.setSelectedItem(supplier); + supp_list.put(supplier.toString(), m_SupplierModel.getSelectedKey().toString()); + } + String supp = (String) supp_list.get(Supplier); + return (supp); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + if (!badSuppliers.contains(Supplier)) { + badSuppliers.add(Supplier.trim()); + } + return ((jComboDefaultSupplier.getSelectedItem() + == reject_bad_supplier) + ? "Bad Supplier" + : (String) supp_list.get(m_SupplierModel.getSelectedText())); + } + + /** + * Adjusts the sell price for included taxes + * + * @param pSellPrice sell price to be converted + * @return sell price after adjustment for included taxes and converted to double + */ + private Double getSellPrice(String pSellPrice) { + + // Get the Tax Rate from the Import file + dTaxRate = taxeslogic.getTaxRate(productTax); + + if (jCheckSellIncTax.isSelected()) { + productSellPrice = ((Double.parseDouble(pSellPrice)) / (1 + dTaxRate)); + return productSellPrice; + } else { + return (Double.parseDouble(pSellPrice)); + } + } + + /** + * Updated the record in the database with the new prices and category if + * needed. + * + * @param pID Unique product id of the record to be updated It then creates + * an updated record for the product, subject to the prices being different + * + */ + private void updateRecord(String pID) { + prodInfo = new ProductInfoExt(); + try { + prodInfo = m_dlSales.getProductInfo(pID); + dOriginalRate = taxeslogic.getTaxRate(prodInfo.getTaxCategoryID()); + dCategory = ((String) cat_list.get(prodInfo.getCategoryID()) + == null) ? prodInfo.getCategoryID() + : (String) cat_list.get(prodInfo.getCategoryID()); + oldBuyPrice = prodInfo.getPriceBuy(); + oldSellPrice = prodInfo.getPriceSell(); +// productSellPrice *= (1 + dOriginalRate); + + dSupplier = ((String) supp_list.get(prodInfo.getSupplierID()) + == null) ? prodInfo.getSupplierID() + : (String) supp_list.get(prodInfo.getSupplierID()); + + if ((oldBuyPrice != productBuyPrice) + || (oldSellPrice != productSellPrice)) { + createCSVEntry("Updated Price Details", oldBuyPrice, + (jCheckSellIncTax.isSelected()) + ? oldSellPrice * (1 + dOriginalRate) + : oldSellPrice); + createProduct("update"); + priceUpdates++; + } else { + noChanges++; + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + /** + * Gets the title of the current panel + * + * @return The name of the panel + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.CSVImport"); + } + + /** + * Returns this object + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * Loads Tax and Category data into their combo boxes. + * @throws com.unicenta.basic.BasicException + */ + @Override + public void activate() throws BasicException { + // Get tax details and logic + taxsent = m_dlSales.getTaxList(); + taxeslogic = new TaxesLogic(taxsent.list()); + taxcatsent = m_dlSales.getTaxCategoriesList(); + taxcatmodel = new ComboBoxValModel(taxcatsent.list()); + + // Get categories list + m_sentcat = m_dlSales.getCategoriesList(); + m_CategoryModel = new ComboBoxValModel(m_sentcat.list()); + m_CategoryModel.add(reject_bad_category); + jComboDefaultCategory.setModel(m_CategoryModel); + + // Build the cat_list for later use + cat_list = new HashMap<>(); + for (Object category : m_sentcat.list()) { + m_CategoryModel.setSelectedItem(category); + cat_list.put(category.toString(), m_CategoryModel.getSelectedKey().toString()); + } + + // Get suppliers list + m_sentsupp = m_dlSales.getSuppList(); + m_SupplierModel = new ComboBoxValModel(m_sentsupp.list()); + m_SupplierModel.add(reject_bad_supplier); + jComboDefaultSupplier.setModel(m_SupplierModel); + + // Build the supp_list for later + supp_list = new HashMap<>(); + for (Object supplier : m_sentsupp.list()) { + m_SupplierModel.setSelectedItem(supplier); + supp_list.put(supplier.toString(), m_SupplierModel.getSelectedKey().toString()); + } + + // reset the selected to the first in the list + m_CategoryModel.setSelectedItem(null); + m_SupplierModel.setSelectedItem(null); + + // Set the column delimiter + jComboSeparator.removeAllItems(); + jComboSeparator.addItem(","); + jComboSeparator.addItem(";"); + jComboSeparator.addItem("~"); + jComboSeparator.addItem("^"); + + } + + /** + * Resets all the form fields + */ + public void resetFields() { + // Clear the form + jComboReference.removeAllItems(); + jComboReference.setEnabled(false); + + jComboName.removeAllItems(); + jComboName.setEnabled(false); + + jComboBarcode.removeAllItems(); + jComboBarcode.setEnabled(false); + + jComboBuy.removeAllItems(); + jComboBuy.setEnabled(false); + + jComboSell.removeAllItems(); + jComboSell.setEnabled(false); + + jComboTax.removeAllItems(); + jComboTax.setEnabled(false); + + jComboCategory.removeAllItems(); + jComboCategory.setEnabled(false); + jComboDefaultCategory.setEnabled(false); + + jComboSupplier.removeAllItems(); + jComboSupplier.setEnabled(false); + jComboDefaultSupplier.setEnabled(false); + + jImport.setEnabled(false); + jbtnReset.setEnabled(true); + jHeaderRead.setEnabled(false); + jCheckInCatalogue.setSelected(true); + jCheckInCatalogue.setEnabled(true); + jCheckSellIncTax.setSelected(true); + jCheckSellIncTax.setEnabled(true); + jFileName.setText(null); + csvFileName = ""; + jTextNew.setText(""); + jTextUpdate.setText(""); + jTextInvalid.setText(""); + jTextMissing.setText(""); + jTextNoChange.setText(""); + jTextRecords.setText(""); + jTextBadPrice.setText(""); + jTextBadCats.setText(""); + + progress = 0; + + Headers.clear(); + newRecords = 0; + invalidRecords = 0; + priceUpdates = 0; + missingData = 0; + noChanges = 0; + badPrice = 0; +// badCategories = 0; + + } + + /** + * Checks the field mappings to ensure all compulsory fields have been + * completed to allow import to proceed + */ + public void checkFieldMapping() { + if (jComboReference.getSelectedItem() != "" + & jComboName.getSelectedItem() != "" + & jComboBarcode.getSelectedItem() != "" + & jComboBuy.getSelectedItem() != "" + & jComboSell.getSelectedItem() != "" + & jComboTax.getSelectedItem() != "" + & jComboCategory.getSelectedItem() != "" + & m_CategoryModel.getSelectedText() != null) { + jImport.setEnabled(true); + jbtnReset.setEnabled(true); + } else { + jImport.setEnabled(false); + jbtnReset.setEnabled(false); + } + } + + /** + * Deactivates and resets all form fields. + * + * @return + */ + @Override + public boolean deactivate() { + resetFields(); + return (true); + } + + /** + * Creates a new Category if it doesn't exist + * @param cType + */ + public void createCategory(String cType) { + + Object[] mycat = new Object[7]; + mycat[0] = UUID.randomUUID().toString(); // ID string + mycat[1] = categoryName; // Name string + mycat[2] = categoryParentid; // Parent String + mycat[3] = null; // Image + mycat[4] = "<html><center><h4>" + categoryName; // Text tip string + mycat[5] = true; // Show + mycat[6] = categoryCatorder; // Order + + try { + if ("new".equals(cType)) { + spr.insertData(mycat); + } else { + spr.updateData(mycat); + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + /** + * + * @param sType + */ + public void createSupplier(String sType) { + + Object[] mysupp = new Object[4]; + mysupp[0] = UUID.randomUUID().toString(); // ID string + mysupp[1] = supplierName; // SearchKey + mysupp[2] = supplierName; // Name string + mysupp[3] = true; // Visible + + try { + if ("new".equals(sType)) { + spr.insertData(mysupp); + } else { + spr.updateData(mysupp); + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + + /** + * + * @param pType + */ + public void createProduct(String pType) { + + Object[] myprod = new Object[32]; + if("new".equals(pType)) { + myprod[0] = UUID.randomUUID().toString(); + } else { + myprod[0] = prodInfo.getID(); + } // ID string + myprod[1] = productReference; // Reference string + myprod[2] = productBarcode; // Barcode String + myprod[3] = null; // Barcode Type + myprod[4] = productName; // Name string + myprod[5] = productBuyPrice; // Buy price double + myprod[6] = productSellPrice; // Sell price double + myprod[7] = dCategory; // Category string + myprod[8] = productTax; // User Tax string + myprod[9] = null; // Attributeset string + myprod[10] = 0.0; // Stock cost double + myprod[11] = 0.0; // Stock volume double + myprod[12] = null; // Image + myprod[13] = false; // IScomment flag (Attribute modifier) + myprod[14] = false; // ISscale flag + myprod[15] = false; // IsConstant flag + myprod[16] = false; // PrintKB flag + myprod[17] = false; // SendStatus flag + myprod[18] = false; // isService flag + myprod[19] = null; // Attributes + myprod[20] = "<html><center>" + productName; // Setup Display button + myprod[21] = false; // isVariable price flag + myprod[22] = false; // Compulsory Att flag + myprod[23] = "<html><center><h4>" + productName; // Text tip string + myprod[24] = false; // Warranty flag + myprod[25] = 0.0; // Stock Units + myprod[26] = "1"; // Printer + myprod[27] = dSupplier; // Supplier + myprod[28] = "0"; // UOM + myprod[29]= null; // memodate + myprod[30] = jCheckInCatalogue.isSelected(); // In catalog flag + myprod[31] = null; // catalog order + + try { + if ("new".equals(pType)) { + spr.insertData(myprod); + addStockCurrent("0", myprod[0].toString(), 0.0); + webPBar.setString("Adding record " + progress); + } else { + spr.updateData(myprod); + webPBar.setString("Updating record " + progress); + } + + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + public void addStockCurrent(String LocationID, String ProductID, Double Units) throws BasicException { + + Object[] values = new Object[3]; + values[0] = "0"; + values[1] = ProductID; + values[2] = (double) Units; + + PreparedSentence sentence = new PreparedSentence(s, + "INSERT INTO stockcurrent ( " + + "LOCATION, PRODUCT, UNITS) VALUES (?, ?, ?)" + , new SerializerWriteBasicExt((new Datas[]{ + Datas.STRING, Datas.STRING, Datas.DOUBLE}), + new int[]{0, 1, 2})); + + sentence.exec(values); + } + + /** + * + * @param csvError + * @param previousBuy + * @param previousSell + */ + public void createCSVEntry(String csvError, Double previousBuy, Double previousSell) { + + Object[] myprod = new Object[13]; + myprod[0] = UUID.randomUUID().toString(); // ID string + myprod[1] = Integer.toString(currentRecord); // Record number + myprod[2] = csvError; // Error description + myprod[3] = productReference; // Reference string + myprod[4] = productBarcode; // Barcode String + myprod[5] = productName; // Name string + myprod[6] = productBuyPrice; // Buy price + myprod[7] = productSellPrice; // Sell price + myprod[8] = previousBuy; // Previous Buy price double + myprod[9] = previousSell; // Previous Sell price double + myprod[10] = Category; // Category + myprod[11] = productTax; // Tax + myprod[12] = Supplier; // Supplier + try { + m_dlSystem.execAddCSVEntry(myprod); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + /** + * + * @return + */ + public String getRecord() { + // Get record type using using DataLogicSystem + Object[] myprod = new Object[3]; + myprod[0] = productReference; + myprod[1] = productBarcode; + myprod[2] = productName; + try { + return (m_dlSystem.getProductRecordType(myprod)); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + return "Exception"; + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jFileChooserPanel = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jFileName = new javax.swing.JTextField(); + jbtnFileChoose = new javax.swing.JButton(); + jPanel1 = new javax.swing.JPanel(); + jComboReference = new javax.swing.JComboBox(); + jComboBarcode = new javax.swing.JComboBox(); + jComboName = new javax.swing.JComboBox(); + jComboBuy = new javax.swing.JComboBox(); + jComboSell = new javax.swing.JComboBox(); + jComboDefaultCategory = new javax.swing.JComboBox(); + jComboTax = new javax.swing.JComboBox(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jLabel10 = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + jLabel7 = new javax.swing.JLabel(); + jCheckInCatalogue = new javax.swing.JCheckBox(); + jLabel8 = new javax.swing.JLabel(); + jCheckSellIncTax = new javax.swing.JCheckBox(); + jLabel12 = new javax.swing.JLabel(); + jComboCategory = new javax.swing.JComboBox(); + jLabel20 = new javax.swing.JLabel(); + jImport = new javax.swing.JButton(); + jLabel6 = new javax.swing.JLabel(); + jbtnReset = new javax.swing.JButton(); + jComboSupplier = new javax.swing.JComboBox(); + jLabel21 = new javax.swing.JLabel(); + jLabel22 = new javax.swing.JLabel(); + jComboDefaultSupplier = new javax.swing.JComboBox(); + jLabel17 = new javax.swing.JLabel(); + jLabel18 = new javax.swing.JLabel(); + jHeaderRead = new javax.swing.JButton(); + jPanel2 = new javax.swing.JPanel(); + jLabel9 = new javax.swing.JLabel(); + jLabel14 = new javax.swing.JLabel(); + jLabel16 = new javax.swing.JLabel(); + jTextUpdates = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel15 = new javax.swing.JLabel(); + jLabel13 = new javax.swing.JLabel(); + jTextRecords = new javax.swing.JTextField(); + jTextNew = new javax.swing.JTextField(); + jTextInvalid = new javax.swing.JTextField(); + jTextUpdate = new javax.swing.JTextField(); + jTextMissing = new javax.swing.JTextField(); + jTextBadPrice = new javax.swing.JTextField(); + jTextNoChange = new javax.swing.JTextField(); + jLabel19 = new javax.swing.JLabel(); + jTextBadCats = new javax.swing.JTextField(); + jComboSeparator = new javax.swing.JComboBox(); + webPBar = new com.alee.laf.progressbar.WebProgressBar(); + jLblImportNotice = new javax.swing.JLabel(); + jCBiso = new javax.swing.JComboBox<>(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setOpaque(false); + setPreferredSize(new java.awt.Dimension(750, 500)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLabel1.setText(bundle.getString("label.csvfile")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(100, 30)); + + jFileName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jFileName.setPreferredSize(new java.awt.Dimension(400, 30)); + jFileName.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jFileNameActionPerformed(evt); + } + }); + + jbtnFileChoose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/fileopen.png"))); // NOI18N + jbtnFileChoose.setMaximumSize(new java.awt.Dimension(64, 32)); + jbtnFileChoose.setMinimumSize(new java.awt.Dimension(64, 32)); + jbtnFileChoose.setPreferredSize(new java.awt.Dimension(80, 45)); + jbtnFileChoose.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnFileChooseActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jFileChooserPanelLayout = new javax.swing.GroupLayout(jFileChooserPanel); + jFileChooserPanel.setLayout(jFileChooserPanelLayout); + jFileChooserPanelLayout.setHorizontalGroup( + jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jFileChooserPanelLayout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jFileName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jbtnFileChoose, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(120, 120, 120)) + ); + jFileChooserPanelLayout.setVerticalGroup( + jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jFileChooserPanelLayout.createSequentialGroup() + .addGroup(jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jFileName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + .addComponent(jbtnFileChoose, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + + jPanel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel1.setPreferredSize(new java.awt.Dimension(430, 400)); + + jComboReference.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboReference.setEnabled(false); + jComboReference.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboReference.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboReference.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboReferenceItemStateChanged(evt); + } + }); + jComboReference.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboReferenceFocusGained(evt); + } + }); + + jComboBarcode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboBarcode.setEnabled(false); + jComboBarcode.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboBarcode.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboBarcode.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboBarcodeItemStateChanged(evt); + } + }); + jComboBarcode.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboBarcodeFocusGained(evt); + } + }); + + jComboName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboName.setEnabled(false); + jComboName.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboName.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboName.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboNameItemStateChanged(evt); + } + }); + jComboName.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboNameFocusGained(evt); + } + }); + + jComboBuy.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboBuy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "" })); + jComboBuy.setSelectedIndex(-1); + jComboBuy.setEnabled(false); + jComboBuy.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboBuy.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboBuy.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboBuyItemStateChanged(evt); + } + }); + jComboBuy.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboBuyFocusGained(evt); + } + }); + + jComboSell.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboSell.setEnabled(false); + jComboSell.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboSell.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboSell.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboSellItemStateChanged(evt); + } + }); + jComboSell.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboSellFocusGained(evt); + } + }); + + jComboDefaultCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboDefaultCategory.setEnabled(false); + jComboDefaultCategory.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboDefaultCategory.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboDefaultCategory.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboDefaultCategoryItemStateChanged(evt); + } + }); + jComboDefaultCategory.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jComboDefaultCategoryActionPerformed(evt); + } + }); + + jComboTax.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboTax.setEnabled(false); + jComboTax.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboTax.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboTaxItemStateChanged(evt); + } + }); + jComboTax.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboTaxFocusGained(evt); + } + }); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(bundle.getString("label.prodref")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(bundle.getString("label.prodbarcode")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(bundle.getString("label.prodname")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel10.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel10.setText(bundle.getString("label.prodpricebuy")); // NOI18N + jLabel10.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel11.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel11.setText(bundle.getString("label.prodcategory")); // NOI18N + jLabel11.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(bundle.getString("label.prodtaxcode")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(100, 30)); + + jCheckInCatalogue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jCheckInCatalogue.setEnabled(false); + jCheckInCatalogue.setPreferredSize(new java.awt.Dimension(30, 30)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLabel8.setText(bundle.getString("label.prodincatalog")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(100, 30)); + + jCheckSellIncTax.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jCheckSellIncTax.setEnabled(false); + jCheckSellIncTax.setPreferredSize(new java.awt.Dimension(30, 30)); + + jLabel12.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLabel12.setText(bundle.getString("label.csvsellingintax")); // NOI18N + jLabel12.setPreferredSize(new java.awt.Dimension(200, 30)); + + jComboCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboCategory.setEnabled(false); + jComboCategory.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboCategory.setName(""); // NOI18N + jComboCategory.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboCategory.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboCategoryItemStateChanged(evt); + } + }); + jComboCategory.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboCategoryFocusGained(evt); + } + }); + + jLabel20.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel20.setText(bundle.getString("label.prodpricesell")); // NOI18N + jLabel20.setPreferredSize(new java.awt.Dimension(100, 30)); + + jImport.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jImport.setText(bundle.getString("label.csvimpostbtn")); // NOI18N + jImport.setEnabled(false); + jImport.setPreferredSize(new java.awt.Dimension(110, 45)); + jImport.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jImportActionPerformed(evt); + } + }); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(bundle.getString("label.proddefaultcategory")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(100, 30)); + + jbtnReset.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jbtnReset.setText(bundle.getString("button.reset")); // NOI18N + jbtnReset.setPreferredSize(new java.awt.Dimension(110, 45)); + jbtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnResetActionPerformed(evt); + } + }); + + jComboSupplier.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboSupplier.setEnabled(false); + jComboSupplier.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboSupplier.setName(""); // NOI18N + jComboSupplier.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboSupplier.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboSupplierItemStateChanged(evt); + } + }); + jComboSupplier.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jComboSupplierFocusGained(evt); + } + }); + jComboSupplier.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jComboSupplierActionPerformed(evt); + } + }); + + jLabel21.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel21.setText(bundle.getString("label.suppliername")); // NOI18N + jLabel21.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel22.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel22.setText(bundle.getString("label.proddefaultsupplier")); // NOI18N + jLabel22.setPreferredSize(new java.awt.Dimension(100, 30)); + + jComboDefaultSupplier.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboDefaultSupplier.setEnabled(false); + jComboDefaultSupplier.setMinimumSize(new java.awt.Dimension(32, 25)); + jComboDefaultSupplier.setPreferredSize(new java.awt.Dimension(300, 30)); + jComboDefaultSupplier.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + jComboDefaultSupplierItemStateChanged(evt); + } + }); + jComboDefaultSupplier.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jComboDefaultSupplierActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jCheckInCatalogue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(59, 59, 59) + .addComponent(jCheckSellIncTax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addComponent(jbtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jImport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(93, 93, 93)))) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboTax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboReference, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboDefaultCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboSupplier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboDefaultSupplier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(2, 2, 2) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboReference, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jComboBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboTax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jComboCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboDefaultCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel21, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jComboSupplier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboDefaultSupplier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jCheckSellIncTax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jCheckInCatalogue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jImport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(16, Short.MAX_VALUE)) + ); + + jLabel17.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N + jLabel17.setText("Import version 4.5"); + + jLabel18.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel18.setText(bundle.getString("label.csvdelimit")); // NOI18N + jLabel18.setPreferredSize(new java.awt.Dimension(100, 30)); + + jHeaderRead.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jHeaderRead.setText(bundle.getString("label.csvread")); // NOI18N + jHeaderRead.setEnabled(false); + jHeaderRead.setPreferredSize(new java.awt.Dimension(110, 45)); + jHeaderRead.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jHeaderReadActionPerformed(evt); + } + }); + + jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true), bundle.getString("title.CSVImport"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14), new java.awt.Color(102, 102, 102))); // NOI18N + + jLabel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel9.setText(bundle.getString("label.csvrecordsfound")); // NOI18N + jLabel9.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel14.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel14.setText(bundle.getString("label.csvnewproducts")); // NOI18N + jLabel14.setMaximumSize(new java.awt.Dimension(77, 14)); + jLabel14.setMinimumSize(new java.awt.Dimension(77, 14)); + jLabel14.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel16.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel16.setText(bundle.getString("label.csvchanged")); // NOI18N + jLabel16.setPreferredSize(new java.awt.Dimension(150, 30)); + + jTextUpdates.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextUpdates.setText(bundle.getString("label.csvpriceupdated")); // NOI18N + jTextUpdates.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(bundle.getString("label.csvmissing")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel15.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel15.setText(bundle.getString("label.csvbad")); // NOI18N + jLabel15.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel13.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel13.setText(bundle.getString("label.csvnotchanged")); // NOI18N + jLabel13.setPreferredSize(new java.awt.Dimension(150, 30)); + + jTextRecords.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextRecords.setForeground(new java.awt.Color(102, 102, 102)); + jTextRecords.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jTextRecords.setBorder(null); + jTextRecords.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jTextRecords.setEnabled(false); + jTextRecords.setPreferredSize(new java.awt.Dimension(100, 30)); + + jTextNew.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextNew.setForeground(new java.awt.Color(102, 102, 102)); + jTextNew.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jTextNew.setBorder(null); + jTextNew.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jTextNew.setEnabled(false); + jTextNew.setPreferredSize(new java.awt.Dimension(100, 30)); + + jTextInvalid.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextInvalid.setForeground(new java.awt.Color(102, 102, 102)); + jTextInvalid.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jTextInvalid.setBorder(null); + jTextInvalid.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jTextInvalid.setEnabled(false); + jTextInvalid.setPreferredSize(new java.awt.Dimension(100, 30)); + + jTextUpdate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextUpdate.setForeground(new java.awt.Color(102, 102, 102)); + jTextUpdate.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jTextUpdate.setBorder(null); + jTextUpdate.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jTextUpdate.setEnabled(false); + jTextUpdate.setPreferredSize(new java.awt.Dimension(100, 30)); + + jTextMissing.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextMissing.setForeground(new java.awt.Color(102, 102, 102)); + jTextMissing.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jTextMissing.setBorder(null); + jTextMissing.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jTextMissing.setEnabled(false); + jTextMissing.setPreferredSize(new java.awt.Dimension(100, 30)); + + jTextBadPrice.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextBadPrice.setForeground(new java.awt.Color(255, 0, 204)); + jTextBadPrice.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jTextBadPrice.setBorder(null); + jTextBadPrice.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jTextBadPrice.setEnabled(false); + jTextBadPrice.setPreferredSize(new java.awt.Dimension(100, 30)); + + jTextNoChange.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextNoChange.setForeground(new java.awt.Color(102, 102, 102)); + jTextNoChange.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jTextNoChange.setBorder(null); + jTextNoChange.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jTextNoChange.setEnabled(false); + jTextNoChange.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel19.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel19.setText(bundle.getString("label.csvbadcats")); // NOI18N + jLabel19.setPreferredSize(new java.awt.Dimension(150, 30)); + + jTextBadCats.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextBadCats.setForeground(new java.awt.Color(255, 0, 204)); + jTextBadCats.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jTextBadCats.setBorder(null); + jTextBadCats.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jTextBadCats.setEnabled(false); + jTextBadCats.setPreferredSize(new java.awt.Dimension(100, 30)); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTextRecords, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jLabel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel16, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextUpdates, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel15, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jTextBadCats, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextInvalid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextMissing, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextBadPrice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextNoChange, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap()) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(0, 0, 0) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextRecords, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextInvalid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jTextUpdates, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextMissing, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextBadPrice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextNoChange, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextBadCats, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + jComboSeparator.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboSeparator.setPreferredSize(new java.awt.Dimension(50, 30)); + + webPBar.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N + webPBar.setPreferredSize(new java.awt.Dimension(240, 30)); + + jLblImportNotice.setBackground(new java.awt.Color(255, 255, 255)); + jLblImportNotice.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblImportNotice.setForeground(new java.awt.Color(102, 102, 102)); + jLblImportNotice.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLblImportNotice.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/refundit.png"))); // NOI18N + jLblImportNotice.setText(bundle.getString("label.importnotice")); // NOI18N + jLblImportNotice.setOpaque(true); + jLblImportNotice.setPreferredSize(new java.awt.Dimension(150, 37)); + + jCBiso.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jCBiso.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-10", "UTF-8", "UTF-16", " " })); + jCBiso.setToolTipText(bundle.getString("tooltip.import.cbiso")); // NOI18N + jCBiso.setPreferredSize(new java.awt.Dimension(125, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jLabel17)) + .addComponent(jFileChooserPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jCBiso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jHeaderRead, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(webPBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLblImportNotice, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel17) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jFileChooserPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jHeaderRead, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jCBiso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(webPBar, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLblImportNotice, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 469, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jHeaderReadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jHeaderReadActionPerformed + try { + GetheadersFromFile(jFileName.getText()); + webPBar.setString("Source file Header OK"); + } catch (IOException ex) { + log.error(ex.getMessage()); + webPBar.setString("Source file Header error!"); + } + }//GEN-LAST:event_jHeaderReadActionPerformed + + private void jImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jImportActionPerformed + + jImport.setEnabled(false); + + workProcess work = new workProcess(); + Thread thread2 = new Thread(work); + thread2.start(); + + }//GEN-LAST:event_jImportActionPerformed + + private void jFileNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileNameActionPerformed + jImport.setEnabled(false); + jHeaderRead.setEnabled(true); + }//GEN-LAST:event_jFileNameActionPerformed + + private void jbtnFileChooseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnFileChooseActionPerformed + resetFields(); + setWorker(); + + JFileChooser chooser = new JFileChooser(last_folder == null ? "C:\\" : last_folder); + FileNameExtensionFilter filter = new FileNameExtensionFilter("csv files", "csv"); + chooser.setFileFilter(filter); + chooser.showOpenDialog(null); + File csvFile = chooser.getSelectedFile(); + + if (csvFile == null) { + return; + } + + File current_folder = chooser.getCurrentDirectory(); + + if (last_folder == null || !last_folder.equals(current_folder.getAbsolutePath())) { + AppConfig CSVConfig = new AppConfig(config_file); + CSVConfig.load(); + CSVConfig.setProperty("CSV.last_folder", current_folder.getAbsolutePath()); + last_folder = current_folder.getAbsolutePath(); + try { + CSVConfig.save(); + } catch (IOException ex) { + log.error(ex.getMessage()); + } + } + + String csv = csvFile.getName(); + if (!(csv.trim().equals(""))) { + csvFileName = csvFile.getAbsolutePath(); + jFileName.setText(csvFileName); + } + }//GEN-LAST:event_jbtnFileChooseActionPerformed + + private void jComboCategoryFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboCategoryFocusGained + jComboCategory.removeAllItems(); + int i = 1; + jComboCategory.addItem(""); + while (i < Headers.size()) { + if ((Headers.get(i) != jComboBarcode.getSelectedItem()) + & (Headers.get(i) != jComboReference.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboBuy.getSelectedItem()) + & (Headers.get(i) != jComboSell.getSelectedItem()) + & (Headers.get(i) != jComboTax.getSelectedItem()) + & (Headers.get(i) != jComboSupplier.getSelectedItem())) { + jComboCategory.addItem(Headers.get(i)); + } + ++i; + } + jComboCategory.addItem(category_default); + }//GEN-LAST:event_jComboCategoryFocusGained + + private void jComboCategoryItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboCategoryItemStateChanged + + try { + if (jComboCategory.getSelectedItem() == "[ USE DEFAULT CATEGORY ]") { + m_CategoryModel = new ComboBoxValModel(m_sentcat.list()); + jComboDefaultCategory.setModel(m_CategoryModel); + } else { + m_CategoryModel = new ComboBoxValModel(m_sentcat.list()); + m_CategoryModel.add(reject_bad_category); + jComboDefaultCategory.setModel(m_CategoryModel); + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + checkFieldMapping(); + }//GEN-LAST:event_jComboCategoryItemStateChanged + + private void jComboDefaultCategoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboDefaultCategoryActionPerformed + checkFieldMapping(); + }//GEN-LAST:event_jComboDefaultCategoryActionPerformed + + private void jComboDefaultCategoryItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboDefaultCategoryItemStateChanged + // TODO add your handling code here: + }//GEN-LAST:event_jComboDefaultCategoryItemStateChanged + + private void jComboSellFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboSellFocusGained + jComboSell.removeAllItems(); + int i = 1; + jComboSell.addItem(""); + while (i < Headers.size()) { + if ((Headers.get(i) != jComboCategory.getSelectedItem()) + & (Headers.get(i) != jComboReference.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboBarcode.getSelectedItem()) + & (Headers.get(i) != jComboBuy.getSelectedItem()) + & (Headers.get(i) != jComboTax.getSelectedItem()) + & (Headers.get(i) != jComboSupplier.getSelectedItem())) { + + jComboSell.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboSellFocusGained + + private void jComboSellItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboSellItemStateChanged + checkFieldMapping(); + }//GEN-LAST:event_jComboSellItemStateChanged + + private void jComboBuyFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboBuyFocusGained + jComboBuy.removeAllItems(); + int i = 1; + jComboBuy.addItem(""); + while (i < Headers.size()) { + if ((Headers.get(i) != jComboCategory.getSelectedItem()) + & (Headers.get(i) != jComboReference.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboBarcode.getSelectedItem()) + & (Headers.get(i) != jComboSell.getSelectedItem()) + & (Headers.get(i) != jComboTax.getSelectedItem()) + & (Headers.get(i) != jComboSupplier.getSelectedItem())) { + jComboBuy.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboBuyFocusGained + + private void jComboBuyItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBuyItemStateChanged + checkFieldMapping(); + }//GEN-LAST:event_jComboBuyItemStateChanged + + private void jComboNameFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboNameFocusGained + jComboName.removeAllItems(); + int i = 1; + jComboName.addItem(""); + while (i < Headers.size()) { + if ((Headers.get(i) != jComboCategory.getSelectedItem()) + & (Headers.get(i) != jComboReference.getSelectedItem()) + & (Headers.get(i) != jComboBarcode.getSelectedItem()) + & (Headers.get(i) != jComboBuy.getSelectedItem()) + & (Headers.get(i) != jComboSell.getSelectedItem()) + & (Headers.get(i) != jComboTax.getSelectedItem()) + & (Headers.get(i) != jComboSupplier.getSelectedItem())) { + jComboName.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboNameFocusGained + + private void jComboNameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboNameItemStateChanged + checkFieldMapping(); + }//GEN-LAST:event_jComboNameItemStateChanged + + private void jComboBarcodeFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboBarcodeFocusGained + jComboBarcode.removeAllItems(); + int i = 1; + jComboBarcode.addItem(""); + while (i < Headers.size()) { + if ((Headers.get(i) != jComboCategory.getSelectedItem()) + & (Headers.get(i) != jComboReference.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboBuy.getSelectedItem()) + & (Headers.get(i) != jComboSell.getSelectedItem()) + & (Headers.get(i) != jComboTax.getSelectedItem()) + & (Headers.get(i) != jComboSupplier.getSelectedItem())) { + jComboBarcode.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboBarcodeFocusGained + + private void jComboBarcodeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBarcodeItemStateChanged + checkFieldMapping(); + }//GEN-LAST:event_jComboBarcodeItemStateChanged + + private void jComboReferenceFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboReferenceFocusGained + jComboReference.removeAllItems(); + int i = 1; + jComboReference.addItem(""); + while (i < Headers.size()) { + if ((Headers.get(i) != jComboCategory.getSelectedItem()) + & (Headers.get(i) != jComboBarcode.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboBuy.getSelectedItem()) + & (Headers.get(i) != jComboSell.getSelectedItem()) + & (Headers.get(i) != jComboTax.getSelectedItem()) + & (Headers.get(i) != jComboSupplier.getSelectedItem())) { + jComboReference.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboReferenceFocusGained + + private void jComboReferenceItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboReferenceItemStateChanged + checkFieldMapping(); + }//GEN-LAST:event_jComboReferenceItemStateChanged + + private void jbtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnResetActionPerformed + resetFields(); + progress = -1; + webPBar.setString("Waiting..."); + }//GEN-LAST:event_jbtnResetActionPerformed + + private void jComboTaxFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboTaxFocusGained + jComboTax.removeAllItems(); + int i = 1; + jComboTax.addItem(""); + while (i < Headers.size()) { + if ((Headers.get(i) != jComboCategory.getSelectedItem()) + & (Headers.get(i) != jComboReference.getSelectedItem()) + & (Headers.get(i) != jComboBarcode.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboBuy.getSelectedItem()) + & (Headers.get(i) != jComboSell.getSelectedItem()) + & (Headers.get(i) != jComboSupplier.getSelectedItem())) { + jComboTax.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboTaxFocusGained + + private void jComboTaxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboTaxItemStateChanged + checkFieldMapping(); + }//GEN-LAST:event_jComboTaxItemStateChanged + + private void jComboSupplierItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboSupplierItemStateChanged + + try { + if (jComboSupplier.getSelectedItem() == "[ USE DEFAULT SUPPLIER ]") { + m_SupplierModel = new ComboBoxValModel(m_sentsupp.list()); + jComboDefaultSupplier.setModel(m_SupplierModel); + } else { + m_SupplierModel = new ComboBoxValModel(m_sentsupp.list()); + m_SupplierModel.add(reject_bad_supplier); + jComboDefaultSupplier.setModel(m_SupplierModel); + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + checkFieldMapping(); + }//GEN-LAST:event_jComboSupplierItemStateChanged + + private void jComboSupplierFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jComboSupplierFocusGained + jComboSupplier.removeAllItems(); + int i = 1; + jComboSupplier.addItem(""); + while (i < Headers.size()) { + if ((Headers.get(i) != jComboCategory.getSelectedItem()) + & (Headers.get(i) != jComboReference.getSelectedItem()) + & (Headers.get(i) != jComboBarcode.getSelectedItem()) + & (Headers.get(i) != jComboName.getSelectedItem()) + & (Headers.get(i) != jComboBuy.getSelectedItem()) + & (Headers.get(i) != jComboSell.getSelectedItem()) + & (Headers.get(i) != jComboTax.getSelectedItem())) { + + jComboSupplier.addItem(Headers.get(i)); + } + ++i; + } + }//GEN-LAST:event_jComboSupplierFocusGained + + private void jComboDefaultSupplierItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboDefaultSupplierItemStateChanged + // TODO add your handling code here: + }//GEN-LAST:event_jComboDefaultSupplierItemStateChanged + + private void jComboDefaultSupplierActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboDefaultSupplierActionPerformed + checkFieldMapping(); + }//GEN-LAST:event_jComboDefaultSupplierActionPerformed + + private void jComboSupplierActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboSupplierActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jComboSupplierActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox<String> jCBiso; + private javax.swing.JCheckBox jCheckInCatalogue; + private javax.swing.JCheckBox jCheckSellIncTax; + private javax.swing.JComboBox jComboBarcode; + private javax.swing.JComboBox jComboBuy; + private javax.swing.JComboBox jComboCategory; + private javax.swing.JComboBox jComboDefaultCategory; + private javax.swing.JComboBox jComboDefaultSupplier; + private javax.swing.JComboBox jComboName; + private javax.swing.JComboBox jComboReference; + private javax.swing.JComboBox jComboSell; + private javax.swing.JComboBox jComboSeparator; + private javax.swing.JComboBox jComboSupplier; + private javax.swing.JComboBox jComboTax; + private javax.swing.JPanel jFileChooserPanel; + private javax.swing.JTextField jFileName; + private javax.swing.JButton jHeaderRead; + private javax.swing.JButton jImport; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel15; + private javax.swing.JLabel jLabel16; + private javax.swing.JLabel jLabel17; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel19; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel20; + private javax.swing.JLabel jLabel21; + private javax.swing.JLabel jLabel22; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JLabel jLblImportNotice; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JTextField jTextBadCats; + private javax.swing.JTextField jTextBadPrice; + private javax.swing.JTextField jTextInvalid; + private javax.swing.JTextField jTextMissing; + private javax.swing.JTextField jTextNew; + private javax.swing.JTextField jTextNoChange; + private javax.swing.JTextField jTextRecords; + private javax.swing.JTextField jTextUpdate; + private javax.swing.JLabel jTextUpdates; + private javax.swing.JButton jbtnFileChoose; + private javax.swing.JButton jbtnReset; + private com.alee.laf.progressbar.WebProgressBar webPBar; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/imports/StockQtyImport.form b/src/main/java/com/unicenta/pos/imports/StockQtyImport.form new file mode 100644 index 0000000..da2c9dc --- /dev/null +++ b/src/main/java/com/unicenta/pos/imports/StockQtyImport.form @@ -0,0 +1,443 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="opaque" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 350]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jFileChooserPanel" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace min="0" pref="0" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="m_jLocation" min="-2" pref="295" max="-2" attributes="0"/> + <Group type="102" attributes="0"> + <Component id="jFileRead" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jImport" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jbtnReset" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="webPBar" min="-2" pref="284" max="-2" attributes="0"/> + <Component id="jPanel2" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="19" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jFileChooserPanel" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jLocation" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="2" attributes="0"> + <Component id="jFileRead" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jImport" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jbtnReset" alignment="2" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="webPBar" min="-2" pref="32" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jPanel2" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> + <Component id="jLabel2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jFileChooserPanel"> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel1" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jFileName" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel18" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboSeparator" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="jbtnFileChoose" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jFileName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="2" attributes="0"> + <Component id="jLabel18" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jComboSeparator" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jbtnFileChoose" alignment="2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvfile" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jFileName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jFileNameActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel18"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvdelimit" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jbtnFileChoose"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/fileopen.png"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 32]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 32]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnFileChooseActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboSeparator"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="jFileRead"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvread" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jFileReadActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JPanelCSVSelect_jHeaderRead"/> + </AuxValues> + </Component> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> + <TitledBorder title="Status"> + <Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder roundedCorners="true"> + <Color PropertyName="color" blue="99" green="99" red="99" type="rgb"/> + </LineBorder> + </Border> + <ResourceString PropertyName="titleX" bundle="pos_messages.properties" key="title.CSVImport" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + <Font PropertyName="font" name="Arial" size="14" style="1"/> + <Color PropertyName="color" blue="66" green="66" red="66" type="rgb"/> + </TitledBorder> + </Border> + </Property> + </Properties> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel9" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jTextRecords" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jTextUpdates" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jTextUpdate" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="0" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jTextRecords" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jTextUpdates" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jTextUpdate" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" pref="47" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel9"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvrecordsfound" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jTextUpdates"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvchanged" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTextRecords"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTextUpdate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="com.alee.laf.progressbar.WebProgressBar" name="webPBar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="13" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[240, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jLocation"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.location" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jImport"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvimpostbtn" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jImportActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jbtnReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.reset" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnResetActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.csvnotice" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="verticalAlignment" type="int" value="1"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="99" green="99" red="99" type="rgb"/> + </LineBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[710, 110]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/imports/StockQtyImport.java b/src/main/java/com/unicenta/pos/imports/StockQtyImport.java new file mode 100644 index 0000000..9eb914b --- /dev/null +++ b/src/main/java/com/unicenta/pos/imports/StockQtyImport.java @@ -0,0 +1,897 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + + +package com.unicenta.pos.imports; + +import com.csvreader.CsvReader; +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.PreparedSentence; +import com.unicenta.data.loader.SerializerWriteBasicExt; +import com.unicenta.data.loader.Session; +import com.unicenta.pos.forms.*; +import com.unicenta.pos.inventory.ProductStock; +import com.unicenta.pos.ticket.ProductInfoExt; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.filechooser.FileNameExtensionFilter; +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.List; +import java.util.Properties; +import java.util.UUID; + + +/** + * User Interface and code for CSV type data import to update Products + * Current Stock quantity levels in table: stockcurrent + */ +@Slf4j +public class StockQtyImport extends JPanel implements JPanelView { + // the workspace + private AppProperties m_props; + private Properties m_propsdb = null; + private CsvReader products; + private DocumentListener documentListener; + + // the db connection session + private Session s; + private Connection con; + private DataLogicSales m_dlSales; + private DataLogicSystem m_dlSystem; + private ProductInfoExt prodInfo; + private ProductStock prodStock; + + // Location + private String Location = "0"; + private String m_sInventoryLocation; + + // Product properties + private String productBarcode; + private Double productQty; + private double oldQty = 0; + private double newQty = 0; + private String recordType = null; + + // the csv filename + private String last_folder; + private File config_file; + private String csvFileName; + + //Status area messages + private Integer progress = 0; + private int currentRecord; + private int rowCount = 0; + private int qtyUpdates = 0; + + /** + * Constructs a new StockQtyImport object + * + * @param oApp AppView + */ + public StockQtyImport(AppView oApp) { + this(oApp.getProperties()); + } + + /** + * Constructs a new StockQtyImport object + * + * @param props AppProperties + */ + @SuppressWarnings("empty-statement") + public StockQtyImport(AppProperties props) { + + initComponents(); + +// Get current db session connection + AppProperties m_props = props; + + try { + s = AppViewConnection.createSession(props); + con = s.getConnection(); + } catch (BasicException | SQLException e) { + ; + } + +// Set db tables + m_dlSales = new DataLogicSales(); + m_dlSales.init(s); + m_dlSystem = new DataLogicSystem(); + m_dlSystem.init(s); + +// Get terminal's current resource property settings + Properties m_propsdb = m_dlSystem.getResourceAsProperties(m_props.getHost() + "/properties"); + +// Get terminal's set Location property <entry key="location">0</entry> + m_sInventoryLocation = m_propsdb.getProperty("location"); + try { + Location = m_dlSystem.findLocationName(m_sInventoryLocation); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + +// last used folder stored in unicentaopos.properties + last_folder = props.getProperty("CSV.last_folder"); + config_file = props.getConfigFile(); + + jFileName.getDocument().addDocumentListener(documentListener); + documentListener = new DocumentListener() { + @Override + public void changedUpdate(DocumentEvent documentEvent) { + jFileRead.setEnabled(true); + } + + @Override + public void insertUpdate(DocumentEvent documentEvent) { + if (!"".equals(jFileName.getText().trim())) { + jFileRead.setEnabled(true); + } + } + + @Override + public void removeUpdate(DocumentEvent documentEvent) { + if (jFileName.getText().trim().equals("")) { + jFileRead.setEnabled(false); + } + } + }; + } + + /** + * Enables form components + */ + private void enableForm() { + jFileRead.setEnabled(true); + jImport.setEnabled(true); + jbtnReset.setEnabled(true); + m_jLocation.setEnabled(true); + } + + /** + * This forms Title + * + * @return The name of the panel + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.CSVImport"); + } + + /** + * Returns this object + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * Get this form object ready + * + * @throws com.unicenta.basic.BasicException + */ + @Override + public void activate() throws BasicException { + // Current Location + m_jLocation.setText("Current Location : " + Location); + + // Set the column delimiter + jComboSeparator.removeAllItems(); + jComboSeparator.addItem(","); + jComboSeparator.addItem(";"); + jComboSeparator.addItem("~"); + jComboSeparator.addItem("^"); + } + + /** + * Resets all the form fields + */ + public void resetForm() { + + m_jLocation.setEnabled(false); + jImport.setEnabled(false); + jbtnReset.setEnabled(true); + jFileRead.setEnabled(false); + jFileName.setText(null); + csvFileName = ""; + +// Status area + progress = 0; + webPBar.setValue(progress); + jTextUpdate.setText(""); + jTextRecords.setText(""); + qtyUpdates = 0; + } + + /** + * Deactivates and resets all form fields. + * + * @return + */ + @Override + public boolean deactivate() { + resetForm(); + return (true); + } + + /** + * Check file can be opened, read and closed + * No Headers in the CSVFileName are required, + * + * @param CSVFileName Name of the file (including the path) to open and read + * @throws IOException If there is an issue reading the CSV file + */ + private void checkFile(String CSVFileName) throws IOException { + + File f = new File(CSVFileName); + if (f.exists()) { + products = new CsvReader(CSVFileName, ',', Charset.forName("UTF-8")); + products.setDelimiter(((String) jComboSeparator.getSelectedItem()).charAt(0)); + + rowCount = 0; + int i = 0; + + while (products.readRecord()) { + ++rowCount; + } + jTextRecords.setText(Long.toString(rowCount)); + products.close(); + + JOptionPane.showMessageDialog(null, "File Check " + + CSVFileName, + "File read OK", + JOptionPane.WARNING_MESSAGE); + + enableForm(); + + } else { + JOptionPane.showMessageDialog(null, "Unable to locate " + + CSVFileName, + "File not found", + JOptionPane.WARNING_MESSAGE); + } + } + + /** + * Imports the external file + * + * @param CSVFileName Name of the file (including path) to import. + * @throws IOException If there are file reading issues. + */ + private void ImportCsvFile(String CSVFileName) throws IOException { + + File f = new File(CSVFileName); + if (f.exists()) { + webPBar.setString("Starting..."); + webPBar.setVisible(true); + jImport.setEnabled(true); + +// Read file + products = new CsvReader(CSVFileName, ',', Charset.forName("UTF-8")); + products.setDelimiter(((String) jComboSeparator.getSelectedItem()).charAt(0)); + currentRecord = 0; + +// Prime: read the csv record and update to zero matching stockcurrent values + while (products.readRecord()) { + recordType = "delete"; + deleteRecord(recordType); + } + products.close(); + +// Work: read the file again and update stockcurrent values + products = new CsvReader(CSVFileName, ',', Charset.forName("UTF-8")); + products.setDelimiter(((String) jComboSeparator.getSelectedItem()).charAt(0)); + currentRecord = 0; + + while (products.readRecord()) { + currentRecord++; + progress = currentRecord; + recordType = "update"; + updateRecord(recordType); + } + products.close(); + + } else { + JOptionPane.showMessageDialog(null, + "Unable to locate " + + CSVFileName, + "File not found", + JOptionPane.WARNING_MESSAGE); + } + + jTextUpdate.setText(Integer.toString(qtyUpdates)); + + JOptionPane.showMessageDialog(null, + "Import Complete", + "Imported", + JOptionPane.WARNING_MESSAGE); + + progress = 100; + webPBar.setValue(progress); + webPBar.setString("Imported" + progress); + } + + /** + * Update the record in the database with the new Quantities + * + * @param pId Unique product id of the record to be updated + */ + private void updateRecord(String pId) throws IOException { + prodInfo = new ProductInfoExt(); + prodStock = new ProductStock(); + try { + + String sCode = products.get(0); + + prodInfo = m_dlSales.getProductInfoByCode(sCode); + + if (prodInfo != null) { + prodStock = m_dlSales.getProductStockState(prodInfo.getID(), m_sInventoryLocation); + productBarcode = products.get(0); + oldQty = prodStock.getUnits(); + newQty = Double.valueOf(products.get(1)); + productQty = oldQty + newQty; + updateStockCurrent(m_sInventoryLocation, prodInfo.getID(), productQty); + CSVStockUpdate(Location, productBarcode, newQty); + qtyUpdates++; + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + /** + * Delete the record in the database with the new Quantities + * + * @param pId Unique product id of the record to be updated + */ + private void deleteRecord(String pId) throws IOException { + prodInfo = new ProductInfoExt(); + prodStock = new ProductStock(); + try { + + String sCode = products.get(0); + + prodInfo = m_dlSales.getProductInfoByCode(sCode); + + if (prodInfo != null) { + prodStock = m_dlSales.getProductStockState(prodInfo.getID(), m_sInventoryLocation); + productQty = 0.; + + deleteStockCurrent(m_sInventoryLocation, prodInfo.getID(), productQty); + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + /** + * FUTURE - Add non existing minimal Products + * + * @param LocationID + * @param ProductID + * @param Units + * @throws com.unicenta.basic.BasicException + */ + public void addStockCurrent(String LocationID, String ProductID, Double Units) throws BasicException { + + Object[] values = new Object[3]; + values[0] = LocationID; + values[1] = ProductID; + values[2] = (double) Units; + + PreparedSentence sentence = new PreparedSentence(s, + "INSERT INTO stockcurrent ( " + + "LOCATION, PRODUCT, UNITS) VALUES (?, ?, ?)" + , new SerializerWriteBasicExt((new Datas[]{ + Datas.STRING, + Datas.STRING, + Datas.DOUBLE + }), + new int[]{0, 1, 2 + })); + + sentence.exec(values); + } + + /** + * Update existing Product Current Quantity + * + * @param LocationID + * @param ProductID + * @param Units + * @throws com.unicenta.basic.BasicException + */ + public void updateStockCurrent(String LocationID, String ProductID, Double Units) throws BasicException { + + Object[] newValues = new Object[3]; + newValues[0] = (double) Units; + newValues[1] = LocationID; + newValues[2] = ProductID; + + PreparedSentence sentence = new PreparedSentence(s, + "UPDATE stockcurrent SET " + + "UNITS = ? " + + "WHERE LOCATION = ? " + + "AND PRODUCT = ?" + , new SerializerWriteBasicExt((new Datas[]{ + Datas.DOUBLE, + Datas.STRING, + Datas.STRING + }), + new int[]{ + 0, 1, 2} + )); + + sentence.exec(newValues); + } + + /** + * Reset existing Product Current Quantity to Zero + * + * @param LocationID + * @param ProductID + * @param Units + * @throws com.unicenta.basic.BasicException + */ + public void deleteStockCurrent(String LocationID, String ProductID, Double Units) throws BasicException { + + Object[] oldValues = new Object[3]; + oldValues[0] = (double) Units; + oldValues[1] = LocationID; + oldValues[2] = ProductID; + + PreparedSentence sentence = new PreparedSentence(s, + "UPDATE stockcurrent SET " + + "UNITS = ? " + + "WHERE LOCATION = ? " + + "AND PRODUCT = ?" + , new SerializerWriteBasicExt((new Datas[]{ + Datas.DOUBLE, + Datas.STRING, + Datas.STRING + }), + new int[]{ + 0, 1, 2} + )); + + sentence.exec(oldValues); + } + + /** + * Add Product Update log entry - Updates only + * + * @param LocationID + * @param Units + */ + public void CSVStockUpdate(String LocationID, String Code, Double Units) { + + Object[] myprod = new Object[6]; + myprod[0] = UUID.randomUUID().toString(); // ID string + myprod[1] = Integer.toString(currentRecord); // Record number + myprod[2] = "Qty update"; // Error description + myprod[3] = Location; // Location ID + myprod[4] = productBarcode; // Product Barcode + myprod[5] = newQty; // Product Quantity + + try { + m_dlSystem.execCSVStockUpdate(myprod); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + /** + * Pushes the Import process into a new thread so it doesn't interfere with + * the UI responsiveness. + */ + private void setWorker() { + progress = 0; + webPBar.setStringPainted(true); + + final SwingWorker<Integer, Integer> pbWorker; + pbWorker = new SwingWorker<Integer, Integer>() { + + @Override + protected final Integer doInBackground() throws Exception { + while ((progress >= 0) && (progress < 100)) { + Thread.sleep(50); + this.publish(progress); + } + this.publish(100); + this.done(); + return 100; + } + + @Override + protected final void process(final List<Integer> chunks) { + webPBar.setValue(chunks.get(0)); + if (progress > 100) { + progress = 100; + webPBar.setString("Imported 100%"); + } else { + webPBar.setString("Imported " + progress + "%"); + } + } + }; + pbWorker.execute(); + } + + /** + * Runs the setWorker. + */ + private class workProcess implements Runnable { + + @Override + public void run() { + try { + ImportCsvFile(jFileName.getText()); + } catch (IOException ex) { + log.error(ex.getMessage()); + } + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jFileChooserPanel = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jFileName = new javax.swing.JTextField(); + jLabel18 = new javax.swing.JLabel(); + jbtnFileChoose = new javax.swing.JButton(); + jComboSeparator = new javax.swing.JComboBox(); + jFileRead = new javax.swing.JButton(); + jPanel2 = new javax.swing.JPanel(); + jLabel9 = new javax.swing.JLabel(); + jTextUpdates = new javax.swing.JLabel(); + jTextRecords = new javax.swing.JTextField(); + jTextUpdate = new javax.swing.JTextField(); + webPBar = new com.alee.laf.progressbar.WebProgressBar(); + m_jLocation = new javax.swing.JLabel(); + jImport = new javax.swing.JButton(); + jbtnReset = new javax.swing.JButton(); + jLabel2 = new javax.swing.JLabel(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setOpaque(false); + setPreferredSize(new java.awt.Dimension(700, 350)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLabel1.setText(bundle.getString("label.csvfile")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(100, 30)); + + jFileName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jFileName.setPreferredSize(new java.awt.Dimension(300, 30)); + jFileName.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jFileNameActionPerformed(evt); + } + }); + + jLabel18.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel18.setText(bundle.getString("label.csvdelimit")); // NOI18N + jLabel18.setPreferredSize(new java.awt.Dimension(100, 30)); + + jbtnFileChoose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/fileopen.png"))); // NOI18N + jbtnFileChoose.setMaximumSize(new java.awt.Dimension(64, 32)); + jbtnFileChoose.setMinimumSize(new java.awt.Dimension(64, 32)); + jbtnFileChoose.setPreferredSize(new java.awt.Dimension(80, 45)); + jbtnFileChoose.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnFileChooseActionPerformed(evt); + } + }); + + jComboSeparator.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jComboSeparator.setPreferredSize(new java.awt.Dimension(50, 30)); + + javax.swing.GroupLayout jFileChooserPanelLayout = new javax.swing.GroupLayout(jFileChooserPanel); + jFileChooserPanel.setLayout(jFileChooserPanelLayout); + jFileChooserPanelLayout.setHorizontalGroup( + jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jFileChooserPanelLayout.createSequentialGroup() + .addGroup(jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jFileChooserPanelLayout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jFileName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jFileChooserPanelLayout.createSequentialGroup() + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jbtnFileChoose, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + jFileChooserPanelLayout.setVerticalGroup( + jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jFileChooserPanelLayout.createSequentialGroup() + .addGroup(jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jFileName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jComboSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnFileChoose, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + jFileRead.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jFileRead.setText(bundle.getString("label.csvread")); // NOI18N + jFileRead.setEnabled(false); + jFileRead.setPreferredSize(new java.awt.Dimension(85, 45)); + jFileRead.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jFileReadActionPerformed(evt); + } + }); + + jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true), bundle.getString("title.CSVImport"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14), new java.awt.Color(102, 102, 102))); // NOI18N + + jLabel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel9.setText(bundle.getString("label.csvrecordsfound")); // NOI18N + jLabel9.setPreferredSize(new java.awt.Dimension(150, 30)); + + jTextUpdates.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextUpdates.setText(bundle.getString("label.csvchanged")); // NOI18N + jTextUpdates.setPreferredSize(new java.awt.Dimension(150, 30)); + + jTextRecords.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextRecords.setForeground(new java.awt.Color(102, 102, 102)); + jTextRecords.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jTextRecords.setBorder(null); + jTextRecords.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jTextRecords.setEnabled(false); + jTextRecords.setPreferredSize(new java.awt.Dimension(100, 30)); + + jTextUpdate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextUpdate.setForeground(new java.awt.Color(102, 102, 102)); + jTextUpdate.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + jTextUpdate.setBorder(null); + jTextUpdate.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jTextUpdate.setEnabled(false); + jTextUpdate.setPreferredSize(new java.awt.Dimension(100, 30)); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTextRecords, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jTextUpdates, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTextUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(0, 0, 0) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextRecords, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jTextUpdates, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(47, 47, 47)) + ); + + webPBar.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N + webPBar.setPreferredSize(new java.awt.Dimension(240, 30)); + + m_jLocation.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jLocation.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jLocation.setText(bundle.getString("label.location")); // NOI18N + m_jLocation.setPreferredSize(new java.awt.Dimension(100, 30)); + + jImport.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jImport.setText(bundle.getString("label.csvimpostbtn")); // NOI18N + jImport.setEnabled(false); + jImport.setPreferredSize(new java.awt.Dimension(85, 45)); + jImport.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jImportActionPerformed(evt); + } + }); + + jbtnReset.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnReset.setText(bundle.getString("button.reset")); // NOI18N + jbtnReset.setPreferredSize(new java.awt.Dimension(85, 45)); + jbtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnResetActionPerformed(evt); + } + }); + + jLabel2.setBackground(new java.awt.Color(255, 255, 255)); + jLabel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel2.setText(bundle.getString("label.csvnotice")); // NOI18N + jLabel2.setVerticalAlignment(javax.swing.SwingConstants.TOP); + jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153))); + jLabel2.setOpaque(true); + jLabel2.setPreferredSize(new java.awt.Dimension(710, 110)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(10, 10, 10) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jFileChooserPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(0, 0, 0) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(m_jLocation, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addComponent(jFileRead, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jImport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jbtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(webPBar, javax.swing.GroupLayout.PREFERRED_SIZE, 284, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(19, 19, 19) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jFileChooserPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jLocation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jFileRead, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jImport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addComponent(webPBar, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(10, 10, 10) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jFileReadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileReadActionPerformed + try { + checkFile(jFileName.getText()); + webPBar.setString("Source file OK"); + m_jLocation.setEnabled(true); + } catch (IOException ex) { + log.error(ex.getMessage()); + webPBar.setString("Source file error!"); + m_jLocation.setEnabled(false); + } + }//GEN-LAST:event_jFileReadActionPerformed + + private void jFileNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileNameActionPerformed + jImport.setEnabled(false); + jFileRead.setEnabled(true); + }//GEN-LAST:event_jFileNameActionPerformed + + private void jbtnFileChooseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnFileChooseActionPerformed + resetForm(); + setWorker(); + + JFileChooser chooser = new JFileChooser(last_folder == null ? "C:\\" : last_folder); + FileNameExtensionFilter filter = new FileNameExtensionFilter("csv files", "csv"); + chooser.setFileFilter(filter); + chooser.showOpenDialog(null); + File csvFile = chooser.getSelectedFile(); + + if (csvFile == null) { + return; + } + + File current_folder = chooser.getCurrentDirectory(); + + if (last_folder == null || !last_folder.equals(current_folder.getAbsolutePath())) { + AppConfig CSVConfig = new AppConfig(config_file); + CSVConfig.load(); + CSVConfig.setProperty("CSV.last_folder", current_folder.getAbsolutePath()); + last_folder = current_folder.getAbsolutePath(); + try { + CSVConfig.save(); + } catch (IOException ex) { + log.error(ex.getMessage()); + } + } + + String csv = csvFile.getName(); + if (!(csv.trim().equals(""))) { + csvFileName = csvFile.getAbsolutePath(); + jFileName.setText(csvFileName); + jFileRead.setEnabled(true); + } + }//GEN-LAST:event_jbtnFileChooseActionPerformed + + private void jbtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnResetActionPerformed + resetForm(); + progress = 0; + webPBar.setString("Waiting..."); + }//GEN-LAST:event_jbtnResetActionPerformed + + private void jImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jImportActionPerformed + + jFileRead.setEnabled(false); + jImport.setEnabled(false); + + workProcess work = new workProcess(); + Thread thread2 = new Thread(work); + thread2.start(); + }//GEN-LAST:event_jImportActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox jComboSeparator; + private javax.swing.JPanel jFileChooserPanel; + private javax.swing.JTextField jFileName; + private javax.swing.JButton jFileRead; + private javax.swing.JButton jImport; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel9; + private javax.swing.JPanel jPanel2; + private javax.swing.JTextField jTextRecords; + private javax.swing.JTextField jTextUpdate; + private javax.swing.JLabel jTextUpdates; + private javax.swing.JButton jbtnFileChoose; + private javax.swing.JButton jbtnReset; + private javax.swing.JLabel m_jLocation; + private com.alee.laf.progressbar.WebProgressBar webPBar; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/instance/AppMessage.java b/src/main/java/com/unicenta/pos/instance/AppMessage.java new file mode 100644 index 0000000..194e0a5 --- /dev/null +++ b/src/main/java/com/unicenta/pos/instance/AppMessage.java @@ -0,0 +1,36 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.instance; + +import java.rmi.Remote; +import java.rmi.RemoteException; + +/** + * + * @author adrianromero + */ +public interface AppMessage extends Remote { + + /** + * + * @throws RemoteException + */ + public void restoreWindow() throws RemoteException; +} diff --git a/src/main/java/com/unicenta/pos/instance/InstanceManager.java b/src/main/java/com/unicenta/pos/instance/InstanceManager.java new file mode 100644 index 0000000..b43a9c4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/instance/InstanceManager.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.instance; + +import java.rmi.AlreadyBoundException; +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.rmi.server.UnicastRemoteObject; + +/** + * + * @author adrianromero + */ +public class InstanceManager { + + private final Registry m_registry; + private final AppMessage m_message; + + /** Creates a new instance of InstanceManager + * @param message + * @throws java.rmi.RemoteException + * @throws java.rmi.AlreadyBoundException */ + public InstanceManager(AppMessage message) throws RemoteException, AlreadyBoundException { + + m_registry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT); + + m_message = message; + + AppMessage stub = (AppMessage) UnicastRemoteObject.exportObject(m_message, 0); + m_registry.bind("AppMessage", stub); + + // jLabel1.setText("Server ready"); + } +} diff --git a/src/main/java/com/unicenta/pos/instance/InstanceQuery.java b/src/main/java/com/unicenta/pos/instance/InstanceQuery.java new file mode 100644 index 0000000..9fbf002 --- /dev/null +++ b/src/main/java/com/unicenta/pos/instance/InstanceQuery.java @@ -0,0 +1,51 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.instance; + +import java.rmi.NotBoundException; +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; + +/** + * + * @author adrianromero + */ +public class InstanceQuery { + + private final AppMessage m_appstub; + + /** Creates a new instance of InstanceQuery + * @throws java.rmi.RemoteException + * @throws java.rmi.NotBoundException */ + public InstanceQuery() throws RemoteException, NotBoundException { + + Registry registry = LocateRegistry.getRegistry(); + m_appstub = (AppMessage) registry.lookup("AppMessage"); + } + + /** + * + * @return + */ + public AppMessage getAppMessage() { + return m_appstub; + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeFilter.form b/src/main/java/com/unicenta/pos/inventory/AttributeFilter.form new file mode 100644 index 0000000..5f9f639 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeFilter.form @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel8" min="-2" pref="110" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jAttr" min="-2" pref="220" max="-2" attributes="0"/> + <EmptySpace min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="jAttr" max="32767" attributes="0"/> + <Component id="jLabel8" max="32767" attributes="0"/> + </Group> + <EmptySpace pref="17" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.attribute" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jAttr"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[220, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jAttrActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeFilter.java b/src/main/java/com/unicenta/pos/inventory/AttributeFilter.java new file mode 100644 index 0000000..069bd9f --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeFilter.java @@ -0,0 +1,177 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.*; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.reports.ReportEditorCreator; +import java.awt.Component; +import java.awt.event.ActionListener; +import java.util.List; + +/** + * + * @author adrianromero + */ +public class AttributeFilter extends javax.swing.JPanel implements ReportEditorCreator { + + private SentenceList attsent; + private ComboBoxValModel attmodel; + + /** Creates new form AttributeUseFilter */ + public AttributeFilter() { + initComponents(); + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + + attsent = new StaticSentence(app.getSession() + , "SELECT ID, NAME FROM attribute ORDER BY NAME" + , null + , new SerializerRead() {@Override + public Object readValues(DataRead dr) throws BasicException { + return new AttributeInfo(dr.getString(1), dr.getString(2)); + }}); + attmodel = new ComboBoxValModel(); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + List a = attsent.list(); + attmodel = new ComboBoxValModel(a); + attmodel.setSelectedFirst(); + jAttr.setModel(attmodel); + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + return SerializerWriteString.INSTANCE; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @param l + */ + public void addActionListener(ActionListener l) { + jAttr.addActionListener(l); + } + + /** + * + * @param l + */ + public void removeActionListener(ActionListener l) { + jAttr.removeActionListener(l); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + AttributeInfo att = (AttributeInfo) attmodel.getSelectedItem(); + + return att == null ? null : att.getId(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel8 = new javax.swing.JLabel(); + jAttr = new javax.swing.JComboBox(); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.attribute")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(110, 30)); + + jAttr.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jAttr.setPreferredSize(new java.awt.Dimension(220, 30)); + jAttr.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jAttrActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jAttr, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jAttr, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap(17, Short.MAX_VALUE)) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jAttrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAttrActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jAttrActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox jAttr; + private javax.swing.JLabel jLabel8; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeInfo.java b/src/main/java/com/unicenta/pos/inventory/AttributeInfo.java new file mode 100644 index 0000000..4bee510 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeInfo.java @@ -0,0 +1,62 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.data.loader.IKeyed; + +/** + * + * @author adrianromero + */ +public class AttributeInfo implements IKeyed { + + private String id; + private String name; + + /** Creates new CategoryInfo + * @param id + * @param name */ + public AttributeInfo(String id, String name) { + this.id = id; + this.name = name; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return id; + } + + /** + * + * @return + */ + public String getId() { + return id; + } + + @Override + public String toString() { + return name; + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeSetFilter.form b/src/main/java/com/unicenta/pos/inventory/AttributeSetFilter.form new file mode 100644 index 0000000..9a66a1a --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeSetFilter.form @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[354, 61]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel8" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jAttrSet" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jAttrSet" alignment="3" max="32767" attributes="0"/> + </Group> + <EmptySpace pref="20" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.attributeset" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jAttrSet"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[220, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeSetFilter.java b/src/main/java/com/unicenta/pos/inventory/AttributeSetFilter.java new file mode 100644 index 0000000..a71e4b7 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeSetFilter.java @@ -0,0 +1,170 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.*; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.reports.ReportEditorCreator; +import java.awt.Component; +import java.awt.event.ActionListener; +import java.util.List; + +/** + * + * @author adrianromero + */ +public class AttributeSetFilter extends javax.swing.JPanel implements ReportEditorCreator { + + private SentenceList attusesent; + private ComboBoxValModel attusemodel; + + /** Creates new form AttributeUseFilter */ + public AttributeSetFilter() { + initComponents(); + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + + attusesent = new StaticSentence(app.getSession() + , "SELECT ID, NAME FROM attributeset ORDER BY NAME" + , null + , new SerializerRead() {@Override + public Object readValues(DataRead dr) throws BasicException { + return new AttributeSetInfo(dr.getString(1), dr.getString(2)); + }}); + attusemodel = new ComboBoxValModel(); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + List a = attusesent.list(); + attusemodel = new ComboBoxValModel(a); + attusemodel.setSelectedFirst(); + jAttrSet.setModel(attusemodel); + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + return SerializerWriteString.INSTANCE; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @param l + */ + public void addActionListener(ActionListener l) { + jAttrSet.addActionListener(l); + } + + /** + * + * @param l + */ + public void removeActionListener(ActionListener l) { + jAttrSet.removeActionListener(l); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + AttributeSetInfo attset = (AttributeSetInfo) attusemodel.getSelectedItem(); + + return attset == null ? null : attset.getId(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel8 = new javax.swing.JLabel(); + jAttrSet = new javax.swing.JComboBox(); + + setPreferredSize(new java.awt.Dimension(354, 61)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.attributeset")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(110, 30)); + + jAttrSet.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jAttrSet.setPreferredSize(new java.awt.Dimension(220, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jAttrSet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jAttrSet, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap(20, Short.MAX_VALUE)) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox jAttrSet; + private javax.swing.JLabel jLabel8; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeSetInfo.java b/src/main/java/com/unicenta/pos/inventory/AttributeSetInfo.java new file mode 100644 index 0000000..0f8973f --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeSetInfo.java @@ -0,0 +1,72 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.data.loader.IKeyed; + +/** + * + * @author adrianromero + */ +public class AttributeSetInfo implements IKeyed { + + private String id; + private String name; + + /** + * + * @param id + * @param name + */ + public AttributeSetInfo(String id, String name) { + this.id = id; + this.name = name; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return id; + } + + /** + * + * @return + */ + public String getId() { + return id; + } + + /** + * + * @return + */ + public String getName() { + return name; + } + + @Override + public String toString() { + return name; + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeSetsEditor.form b/src/main/java/com/unicenta/pos/inventory/AttributeSetsEditor.form new file mode 100644 index 0000000..b774be8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeSetsEditor.form @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jName" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.namem" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[220, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeSetsEditor.java b/src/main/java/com/unicenta/pos/inventory/AttributeSetsEditor.java new file mode 100644 index 0000000..bf00912 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeSetsEditor.java @@ -0,0 +1,179 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; +import java.util.UUID; +import javax.swing.JOptionPane; + +/** + * + * @author adrianromero + */ +public final class AttributeSetsEditor extends javax.swing.JPanel implements EditorRecord { + + private Object id; + + /** Creates new form AttributesEditor + * @param dirty */ + public AttributeSetsEditor(DirtyManager dirty) { + initComponents(); + + m_jName.getDocument().addDocumentListener(dirty); + + writeValueEOF(); + } + + /** + * + */ + @Override + public void writeValueEOF() { + id = null; + m_jName.setText(null); + m_jName.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + id = UUID.randomUUID().toString(); + m_jName.setText(null); + m_jName.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + + Object[] attrset = (Object[]) value; + id = attrset[0]; + m_jName.setText(Formats.STRING.formatValue(attrset[1])); + m_jName.setEnabled(false); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + + Object[] attrset = (Object[]) value; + id = attrset[0]; + m_jName.setText(Formats.STRING.formatValue(attrset[1])); + m_jName.setEnabled(true); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] attrset = new Object[2]; + + attrset[0] = id; + attrset[1] = m_jName.getText(); + + if (m_jName.getText().contains("&")) { + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.ampersand")); + } + + return attrset; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + */ + @Override + public void refresh() { + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel2 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.namem")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(220, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel2; + private javax.swing.JTextField m_jName; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeSetsPanel.java b/src/main/java/com/unicenta/pos/inventory/AttributeSetsPanel.java new file mode 100644 index 0000000..859662f --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeSetsPanel.java @@ -0,0 +1,80 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.data.loader.Datas; +import com.unicenta.data.model.*; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.JPanelTable2; + +/** + * + * @author adrianromero + */ +public class AttributeSetsPanel extends JPanelTable2 { + + private EditorRecord editor; + + /** Creates a new instance of JPanelCategories */ + public AttributeSetsPanel() { + } + + /** + * + */ + @Override + protected void init() { + + row = new Row( + new Field("ID", Datas.STRING, Formats.STRING), + new Field(AppLocal.getIntString("label.name"), Datas.STRING, Formats.STRING, true, true, true) + ); + + Table table = new Table( + "attributeset", + new PrimaryKey("ID"), + new Column("NAME")); + + lpr = row.getListProvider(app.getSession(), table); + spr = row.getSaveProvider(app.getSession(), table); + + editor = new AttributeSetsEditor(dirty); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return editor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.AttributeSets"); + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeUseEditor.form b/src/main/java/com/unicenta/pos/inventory/AttributeUseEditor.form new file mode 100644 index 0000000..1b9ae99 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeUseEditor.form @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jLineno" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jAttribute" min="-2" pref="170" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel3" alignment="3" min="-2" pref="25" max="-2" attributes="0"/> + <Component id="jLineno" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jAttribute" alignment="3" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.order" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jLineno"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.attribute" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jAttribute"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeUseEditor.java b/src/main/java/com/unicenta/pos/inventory/AttributeUseEditor.java new file mode 100644 index 0000000..8e0db9c --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeUseEditor.java @@ -0,0 +1,261 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.SerializerRead; +import com.unicenta.data.loader.StaticSentence; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import java.awt.Component; +import java.util.UUID; + +/** + * + * @author adrianromero + */ +public class AttributeUseEditor extends javax.swing.JPanel implements EditorRecord { + + private SentenceList attributesent; + private ComboBoxValModel attributemodel; + + private Object id; + private Object attuseid; + + private Object insertid; + + /** Creates new form AttributeSetEditor + * @param app + * @param dirty */ + public AttributeUseEditor(AppView app, DirtyManager dirty) { + + attributesent = new StaticSentence(app.getSession() + , "SELECT ID, NAME FROM attribute ORDER BY NAME" + , null + , new SerializerRead() {@Override + public Object readValues(DataRead dr) throws BasicException { + return new AttributeInfo(dr.getString(1), dr.getString(2)); + }} + ); + attributemodel = new ComboBoxValModel(); + + initComponents(); + + jLineno.getDocument().addDocumentListener(dirty); + jAttribute.addActionListener(dirty); + } + + /** + * + * @param insertid + */ + public void setInsertId(String insertid) { + + this.insertid = insertid; + } + + /** + * + * @throws BasicException + */ + public void activate() throws BasicException { + + attributemodel = new ComboBoxValModel(attributesent.list()); + jAttribute.setModel(attributemodel); + } + + /** + * + */ + @Override + public void refresh() { + } + + /** + * + */ + @Override + public void writeValueEOF() { + + id = null; + attuseid = null; + attributemodel.setSelectedKey(null); + jLineno.setText(null); + + jAttribute.setEnabled(false); + jLineno.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + + id = UUID.randomUUID().toString(); + attuseid = insertid; + attributemodel.setSelectedKey(null); + jLineno.setText(null); + + jAttribute.setEnabled(true); + jLineno.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + + Object[] obj = (Object[]) value; + + id = obj[0]; + attuseid = obj[1]; + attributemodel.setSelectedKey(obj[2]); + jLineno.setText(Formats.INT.formatValue(obj[3])); + + jAttribute.setEnabled(true); + jLineno.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + + Object[] obj = (Object[]) value; + + id = obj[0]; + attuseid = obj[1]; + attributemodel.setSelectedKey(obj[2]); + jLineno.setText(Formats.INT.formatValue(obj[3])); + + jAttribute.setEnabled(false); + jLineno.setEnabled(false); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + Object[] value = new Object[5]; + + value[0] = id; + value[1] = attuseid; + value[2] = attributemodel.getSelectedKey(); + value[3] = Formats.INT.parseValue(jLineno.getText()); + value[4] = attributemodel.getSelectedText(); + + return value; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel3 = new javax.swing.JLabel(); + jLineno = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + jAttribute = new javax.swing.JComboBox(); + + setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.order")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLineno.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLineno.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.attribute")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(110, 30)); + + jAttribute.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jAttribute.setPreferredSize(new java.awt.Dimension(0, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLineno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jAttribute, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLineno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jAttribute, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox jAttribute; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JTextField jLineno; + // End of variables declaration//GEN-END:variables + + +} diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeUsePanel.java b/src/main/java/com/unicenta/pos/inventory/AttributeUsePanel.java new file mode 100644 index 0000000..7fd6f81 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeUsePanel.java @@ -0,0 +1,134 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.model.*; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.JPanelTable2; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * + * @author adrianromero + */ +public class AttributeUsePanel extends JPanelTable2 { + + private AttributeUseEditor editor; + private AttributeSetFilter filter; + + /** + * + */ + @Override + protected void init() { + + filter = new AttributeSetFilter(); + filter.init(app); + filter.addActionListener(new ReloadActionListener()); + + row = new Row( + new Field("ID", Datas.STRING, Formats.STRING), + new Field("ATRIBUTESET_ID", Datas.STRING, Formats.STRING), + new Field("ATTRIBUTE_ID", Datas.STRING, Formats.STRING), + new Field(AppLocal.getIntString("label.order"), Datas.INT, Formats.INT, false, true, true), + new Field(AppLocal.getIntString("label.name"), Datas.STRING, Formats.STRING, true, true, true) + ); + + Table table = new Table( + "attributeuse", + new PrimaryKey("ID"), + new Column("attributeset_ID"), + new Column("ATTRIBUTE_ID"), + new Column("LINENO")); + + lpr = row.getListProvider(app.getSession(), + "SELECT ATTUSE.ID, ATTUSE.attributeset_ID, ATTUSE.ATTRIBUTE_ID, ATTUSE.LINENO, ATT.NAME " + + "FROM attributeuse ATTUSE, attribute ATT " + + "WHERE ATTUSE.ATTRIBUTE_ID = ATT.ID AND ATTUSE.attributeset_ID = ? ORDER BY LINENO", filter); + spr = row.getSaveProvider(app.getSession(), table); + + editor = new AttributeUseEditor(app, dirty); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + filter.activate(); + editor.activate(); + + //super.activate(); + startNavigation(); + reload(); + } + + /** + * + * @return + */ + @Override + public Component getFilter(){ + return filter.getComponent(); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return editor; + } + + private void reload() throws BasicException { + + String attsetid = (String) filter.createValue(); + editor.setInsertId(attsetid); // must be set before load + bd.setEditable(attsetid != null); + bd.actionLoad(); + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.AttributeUse"); + } + + private class ReloadActionListener implements ActionListener { + @Override + public void actionPerformed(ActionEvent e) { + try { + reload(); + } catch (BasicException w) { + } + } + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeValuesEditor.form b/src/main/java/com/unicenta/pos/inventory/AttributeValuesEditor.form new file mode 100644 index 0000000..2d3ec9d --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeValuesEditor.form @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" pref="80" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jValue" min="-2" pref="200" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jValue" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.value" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jValue"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[220, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeValuesEditor.java b/src/main/java/com/unicenta/pos/inventory/AttributeValuesEditor.java new file mode 100644 index 0000000..e968e5e --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeValuesEditor.java @@ -0,0 +1,196 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; +import java.util.UUID; + +/** + * + * @author adrian + */ +public class AttributeValuesEditor extends javax.swing.JPanel implements EditorRecord { + + private Object id; + private Object attid; + + private Object insertid; + + /** Creates new form AttributesValuesEditor + * @param dirty */ + public AttributeValuesEditor(DirtyManager dirty) { + + initComponents(); + + jValue.getDocument().addDocumentListener(dirty); + } + + /** + * + * @param insertid + */ + public void setInsertId(String insertid) { + + this.insertid = insertid; + } + + /** + * + */ + @Override + public void refresh() { + } + + /** + * + */ + @Override + public void writeValueEOF() { + + id = null; + attid = null; + jValue.setText(null); + + jValue.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + + id = UUID.randomUUID().toString(); + attid = insertid; + jValue.setText(null); + + jValue.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + + Object[] obj = (Object[]) value; + + id = obj[0]; + attid = obj[1]; + jValue.setText(Formats.STRING.formatValue(obj[2])); + + jValue.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + + Object[] obj = (Object[]) value; + + id = obj[0]; + attid = obj[1]; + jValue.setText(Formats.STRING.formatValue(obj[2])); + + jValue.setEnabled(false); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + return new Object[] { + id, + attid, + Formats.STRING.formatValue(jValue.getText()) + }; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel2 = new javax.swing.JLabel(); + jValue = new javax.swing.JTextField(); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.value")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + + jValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jValue.setPreferredSize(new java.awt.Dimension(220, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jValue, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel2; + private javax.swing.JTextField jValue; + // End of variables declaration//GEN-END:variables + + +} diff --git a/src/main/java/com/unicenta/pos/inventory/AttributeValuesPanel.java b/src/main/java/com/unicenta/pos/inventory/AttributeValuesPanel.java new file mode 100644 index 0000000..27c61d7 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributeValuesPanel.java @@ -0,0 +1,128 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.model.*; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.JPanelTable2; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * + * @author adrianromero + */ +public class AttributeValuesPanel extends JPanelTable2 { + + private AttributeValuesEditor editor; + private AttributeFilter filter; + + /** + * + */ + @Override + protected void init() { + + filter = new AttributeFilter(); + filter.init(app); + filter.addActionListener(new ReloadActionListener()); + + row = new Row( + new Field("ID", Datas.STRING, Formats.STRING), + new Field("ATTRIBUTE_ID", Datas.STRING, Formats.STRING), + new Field(AppLocal.getIntString("label.value"), Datas.STRING, Formats.STRING, true, true, true) + ); + + Table table = new Table( + "attributevalue", + new PrimaryKey("ID"), + new Column("ATTRIBUTE_ID"), + new Column("VALUE")); + + lpr = row.getListProvider(app.getSession(), + "SELECT ID, ATTRIBUTE_ID, VALUE FROM attributevalue WHERE ATTRIBUTE_ID = ? ORDER BY VALUE ", filter); + spr = row.getSaveProvider(app.getSession(), table); + + editor = new AttributeValuesEditor(dirty); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + filter.activate(); + + //super.activate(); + startNavigation(); + reload(); + } + + /** + * + * @return + */ + @Override + public Component getFilter(){ + return filter.getComponent(); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return editor; + } + + private void reload() throws BasicException { + + String attid = (String) filter.createValue(); + editor.setInsertId(attid); // must be set before load + bd.setEditable(attid != null); + bd.actionLoad(); + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.AttributeValues"); + } + + private class ReloadActionListener implements ActionListener { + @Override + public void actionPerformed(ActionEvent e) { + try { + reload(); + } catch (BasicException w) { + } + } + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/inventory/AttributesEditor.form b/src/main/java/com/unicenta/pos/inventory/AttributesEditor.form new file mode 100644 index 0000000..da093ec --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributesEditor.form @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jName" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.name" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[220, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/AttributesEditor.java b/src/main/java/com/unicenta/pos/inventory/AttributesEditor.java new file mode 100644 index 0000000..fe7ea25 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributesEditor.java @@ -0,0 +1,179 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; +import java.util.UUID; +import javax.swing.JOptionPane; + +/** + * + * @author adrian + */ +public final class AttributesEditor extends javax.swing.JPanel implements EditorRecord { + + private Object id; + + /** Creates new form AttributesEditor + * @param dirty */ + public AttributesEditor(DirtyManager dirty) { + initComponents(); + + m_jName.getDocument().addDocumentListener(dirty); + + writeValueEOF(); + } + + /** + * + */ + @Override + public void writeValueEOF() { + id = null; + m_jName.setText(null); + m_jName.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + id = UUID.randomUUID().toString(); + m_jName.setText(null); + m_jName.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + + Object[] attr = (Object[]) value; + id = attr[0]; + m_jName.setText(Formats.STRING.formatValue(attr[1])); + m_jName.setEnabled(false); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + + Object[] attr = (Object[]) value; + id = attr[0]; + m_jName.setText(Formats.STRING.formatValue(attr[1])); + m_jName.setEnabled(true); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] attr = new Object[2]; + + attr[0] = id; + attr[1] = m_jName.getText(); + + if (m_jName.getText().contains("&")) { + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.ampersand")); + } + + return attr; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + */ + @Override + public void refresh() { + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel2 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.name")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(220, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel2; + private javax.swing.JTextField m_jName; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/AttributesPanel.java b/src/main/java/com/unicenta/pos/inventory/AttributesPanel.java new file mode 100644 index 0000000..11b7afa --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AttributesPanel.java @@ -0,0 +1,80 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.data.loader.Datas; +import com.unicenta.data.model.*; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.JPanelTable2; + +/** + * + * @author adrian + */ +public class AttributesPanel extends JPanelTable2 { + + private EditorRecord editor; + + /** Creates a new instance of JPanelCategories */ + public AttributesPanel() { + } + + /** + * + */ + @Override + protected void init() { + + row = new Row( + new Field("ID", Datas.STRING, Formats.STRING), + new Field(AppLocal.getIntString("label.name"), Datas.STRING, Formats.STRING, true, true, true) + ); + + Table table = new Table( + "attribute", + new PrimaryKey("ID"), + new Column("NAME")); + + lpr = row.getListProvider(app.getSession(), table); + spr = row.getSaveProvider(app.getSession(), table); + + editor = new AttributesEditor(dirty); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return editor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Attributes"); + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/AuxiliarEditor.form b/src/main/java/com/unicenta/pos/inventory/AuxiliarEditor.form new file mode 100644 index 0000000..9773a4b --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AuxiliarEditor.form @@ -0,0 +1,206 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 100]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="m_jProduct" min="-2" pref="264" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jSearch" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="m_jBarcode" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jEnter2" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="m_jReference" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jEnter1" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jReference" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jEnter1" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jEnter2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jBarcode" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jSearch" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="m_jProduct" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodref" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jReference"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jReferenceActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jEnter1"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" value=" "/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jEnter1ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jEnter2"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/barcode.png"/> + </Property> + <Property name="text" type="java.lang.String" value=" "/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jEnter2ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jSearch"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/search24.png"/> + </Property> + <Property name="text" type="java.lang.String" value=" "/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jSearchActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jProduct"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jProductActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jBarcode"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBarcodeActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbarcode" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/AuxiliarEditor.java b/src/main/java/com/unicenta/pos/inventory/AuxiliarEditor.java new file mode 100644 index 0000000..51e66f8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AuxiliarEditor.java @@ -0,0 +1,427 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.panels.JProductFinder; +import com.unicenta.pos.ticket.ProductInfoExt; +import java.awt.Component; +import java.awt.Toolkit; +import java.util.UUID; + +/** + * + * @author jaroslawwozniak + */ +public class AuxiliarEditor extends javax.swing.JPanel implements EditorRecord { + + private DataLogicSales m_dlSales; + + private Object id; + private Object product; + private Object product2; + private Object name; + + private Object insertproduct; + + /** Creates new form AuxiliarEditor + * @param app + * @param dirty */ + public AuxiliarEditor(AppView app, DirtyManager dirty) { + + m_dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + initComponents(); + + m_jProduct.getDocument().addDocumentListener(dirty); + } + + /** + * + * @param prod + */ + public void setInsertProduct(ProductInfoExt prod) { + + if (prod == null) { + insertproduct = null; + } else { + insertproduct = prod.getID(); + } + } + + /** + * + */ + @Override + public void refresh() { + } + + /** + * + */ + @Override + public void writeValueEOF() { + + id = null; + product = null; + product2 = null; + name = null; + m_jReference.setText(null); + m_jBarcode.setText(null); + m_jProduct.setText(null); + + m_jReference.setEnabled(false); + m_jBarcode.setEnabled(false); + m_jProduct.setEnabled(false); + m_jEnter1.setEnabled(false); + m_jEnter2.setEnabled(false); + m_jSearch.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + + id = UUID.randomUUID().toString(); + product = insertproduct; + product2 = null; + name = null; + m_jReference.setText(null); + m_jBarcode.setText(null); + m_jProduct.setText(null); + + m_jReference.setEnabled(true); + m_jBarcode.setEnabled(true); + m_jProduct.setEnabled(true); + m_jEnter1.setEnabled(true); + m_jEnter2.setEnabled(true); + m_jSearch.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + Object[] obj = (Object[]) value; + + id = obj[0]; + product = obj[1]; + product2 = obj[2]; + name = obj[5]; + m_jReference.setText(Formats.STRING.formatValue(obj[3])); + m_jBarcode.setText(Formats.STRING.formatValue(obj[4])); + m_jProduct.setText(Formats.STRING.formatValue(obj[3]) + " - " + Formats.STRING.formatValue(obj[5])); + + m_jReference.setEnabled(true); + m_jBarcode.setEnabled(true); + m_jProduct.setEnabled(true); + m_jEnter1.setEnabled(true); + m_jEnter2.setEnabled(true); + m_jSearch.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + Object[] obj = (Object[]) value; + + id = obj[0]; + product = obj[1]; + product2 = obj[2]; + name = obj[5]; + m_jReference.setText(Formats.STRING.formatValue(obj[3])); + m_jBarcode.setText(Formats.STRING.formatValue(obj[4])); + m_jProduct.setText(Formats.STRING.formatValue(obj[3]) + " - " + Formats.STRING.formatValue(obj[5])); + + + m_jReference.setEnabled(false); + m_jBarcode.setEnabled(false); + m_jProduct.setEnabled(false); + m_jEnter1.setEnabled(false); + m_jEnter2.setEnabled(false); + m_jSearch.setEnabled(false); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + return new Object[] { + id, + product, + product2, + m_jReference.getText(), + m_jBarcode.getText(), + name, + }; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + private void assignProduct(ProductInfoExt prod) { + + if (m_jSearch.isEnabled()) { + if (prod == null) { + product2 = null; + m_jReference.setText(null); + m_jBarcode.setText(null); + m_jProduct.setText(null); + name = null; + } else { + product2 = prod.getID(); + m_jReference.setText(prod.getReference()); + m_jBarcode.setText(prod.getCode()); + m_jProduct.setText(prod.getReference() + " - " + prod.getName()); + name = prod.getName(); + } + } + + } + + private void assignProductByCode() { + try { + ProductInfoExt prod = m_dlSales.getProductInfoByCode(m_jBarcode.getText()); + assignProduct(prod); + if (prod == null) { + Toolkit.getDefaultToolkit().beep(); + } + } catch (BasicException eData) { + assignProduct(null); + MessageInf msg = new MessageInf(eData); + msg.show(this); + } + } + + + private void assignProductByReference() { + try { + ProductInfoExt prod = m_dlSales.getProductInfoByReference(m_jReference.getText()); + assignProduct(prod); + if (prod == null) { + Toolkit.getDefaultToolkit().beep(); + } + } catch (BasicException eData) { + assignProduct(null); + MessageInf msg = new MessageInf(eData); + msg.show(this); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel3 = new javax.swing.JLabel(); + m_jReference = new javax.swing.JTextField(); + m_jEnter1 = new javax.swing.JButton(); + m_jEnter2 = new javax.swing.JButton(); + m_jSearch = new javax.swing.JButton(); + m_jProduct = new javax.swing.JTextField(); + m_jBarcode = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + + setPreferredSize(new java.awt.Dimension(700, 100)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.prodref")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jReference.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jReference.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jReference.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jReferenceActionPerformed(evt); + } + }); + + m_jEnter1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + m_jEnter1.setText(" "); + m_jEnter1.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jEnter1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jEnter1ActionPerformed(evt); + } + }); + + m_jEnter2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/barcode.png"))); // NOI18N + m_jEnter2.setText(" "); + m_jEnter2.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jEnter2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jEnter2ActionPerformed(evt); + } + }); + + m_jSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/search24.png"))); // NOI18N + m_jSearch.setText(" "); + m_jSearch.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jSearch.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jSearchActionPerformed(evt); + } + }); + + m_jProduct.setEditable(false); + m_jProduct.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jProduct.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jProduct.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jProductActionPerformed(evt); + } + }); + + m_jBarcode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jBarcode.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jBarcode.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBarcodeActionPerformed(evt); + } + }); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.prodbarcode")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.prodname")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(110, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(m_jProduct, javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(m_jBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jEnter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(m_jReference, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jEnter1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jReference, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jEnter1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jEnter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jProduct, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void m_jSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jSearchActionPerformed + + assignProduct(JProductFinder.showMessage(this, m_dlSales, JProductFinder.PRODUCT_AUXILIAR)); + +}//GEN-LAST:event_m_jSearchActionPerformed + + private void m_jReferenceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jReferenceActionPerformed + this.assignProductByReference(); + }//GEN-LAST:event_m_jReferenceActionPerformed + + private void m_jEnter2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jEnter2ActionPerformed + this.assignProductByCode(); + }//GEN-LAST:event_m_jEnter2ActionPerformed + + private void m_jEnter1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jEnter1ActionPerformed + this.assignProductByReference(); + }//GEN-LAST:event_m_jEnter1ActionPerformed + + private void m_jBarcodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBarcodeActionPerformed + this.assignProductByCode(); + }//GEN-LAST:event_m_jBarcodeActionPerformed + + private void m_jProductActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jProductActionPerformed + + }//GEN-LAST:event_m_jProductActionPerformed + + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JTextField m_jBarcode; + private javax.swing.JButton m_jEnter1; + private javax.swing.JButton m_jEnter2; + private javax.swing.JTextField m_jProduct; + private javax.swing.JTextField m_jReference; + private javax.swing.JButton m_jSearch; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/AuxiliarPanel.java b/src/main/java/com/unicenta/pos/inventory/AuxiliarPanel.java new file mode 100644 index 0000000..6f65f4b --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/AuxiliarPanel.java @@ -0,0 +1,134 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.model.*; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.AuxiliarFilter; +import com.unicenta.pos.panels.JPanelTable2; +import com.unicenta.pos.ticket.ProductInfoExt; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * + * @author jaroslawwozniak + * @author adrianromero + */ +public class AuxiliarPanel extends JPanelTable2 { + + private AuxiliarEditor editor; + private AuxiliarFilter filter; + + /** + * + */ + @Override + protected void init() { + + filter = new AuxiliarFilter(); + filter.init(app); + filter.addActionListener(new ReloadActionListener()); + + row = new Row( + new Field("ID", Datas.STRING, Formats.STRING), + new Field("PRODUCT1", Datas.STRING, Formats.STRING), + new Field("PRODUCT2", Datas.STRING, Formats.STRING), + new Field(AppLocal.getIntString("label.prodref"), Datas.STRING, Formats.STRING, true, true, true), + new Field(AppLocal.getIntString("label.prodbarcode"), Datas.STRING, Formats.STRING, false, true, true), + new Field(AppLocal.getIntString("label.prodname"), Datas.STRING, Formats.STRING, true, true, true) + ); + Table table = new Table( + "products_com", + new PrimaryKey("ID"), + new Column("PRODUCT"), + new Column("PRODUCT2")); + + lpr = row.getListProvider(app.getSession(), + "SELECT COM.ID, COM.PRODUCT, COM.PRODUCT2, P.REFERENCE, P.CODE, P.NAME " + + "FROM products_com COM, products P " + + "WHERE COM.PRODUCT2 = P.ID AND COM.PRODUCT = ?", filter); + spr = row.getSaveProvider(app.getSession(), table); + + editor = new AuxiliarEditor(app, dirty); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + filter.activate(); + + //super.activate(); + startNavigation(); + reload(filter); + } + + /** + * + * @return + */ + @Override + public Component getFilter(){ + return filter.getComponent(); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return editor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Auxiliar"); + } + + private void reload(AuxiliarFilter filter) throws BasicException { + ProductInfoExt prod = filter.getProductInfoExt(); + editor.setInsertProduct(prod); // must be set before load + bd.setEditable(prod != null); + bd.actionLoad(); + } + + private class ReloadActionListener implements ActionListener { + @Override + public void actionPerformed(ActionEvent e) { + try { + reload((AuxiliarFilter) e.getSource()); + } catch (BasicException w) { + } + } + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/BundleEditor.form b/src/main/java/com/unicenta/pos/inventory/BundleEditor.form new file mode 100644 index 0000000..a954ec1 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/BundleEditor.form @@ -0,0 +1,207 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 120]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jBarcode" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jReference" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="m_jEnter1" max="32767" attributes="0"/> + <Component id="m_jEnter2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" attributes="0"> + <Component id="m_jQuantity" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jLabel1" pref="0" max="32767" attributes="0"/> + </Group> + <Component id="m_jProduct" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/> + <Component id="m_jSearch" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="2" attributes="0"> + <Component id="jLabel3" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jReference" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jEnter1" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jProduct" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jSearch" alignment="2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="2" attributes="0"> + <Component id="m_jBarcode" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jLabel4" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jEnter2" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jQuantity" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jLabel1" alignment="2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodref" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jReference"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jReferenceActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jEnter1"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jEnter1ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jEnter2"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/barcode.png"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jEnter2ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jSearch"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/search24.png"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jSearchActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jProduct"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jProductActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jBarcode"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBarcodeActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbarcode" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Quantity"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jQuantity"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/BundleEditor.java b/src/main/java/com/unicenta/pos/inventory/BundleEditor.java new file mode 100644 index 0000000..e29481f --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/BundleEditor.java @@ -0,0 +1,412 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2013 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.panels.JProductFinder; +import com.unicenta.pos.ticket.ProductInfoExt; +import java.awt.Component; +import java.awt.Toolkit; +import java.util.UUID; + +/** + * + * @author jaroslawwozniak + */ +public class BundleEditor extends javax.swing.JPanel implements EditorRecord { + + private DataLogicSales m_dlSales; + + private Object id; + private Object product; + private Object productBundle; + private Object name; + private Object quantity; + + private Object insertproduct; + + /** Creates new form BundleEditor */ + public BundleEditor(AppView app, DirtyManager dirty) { + + m_dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + initComponents(); + + m_jProduct.getDocument().addDocumentListener(dirty); + m_jQuantity.getDocument().addDocumentListener(dirty); + } + + public void setInsertProduct(ProductInfoExt prod) { + + if (prod == null) { + insertproduct = null; + } else { + insertproduct = prod.getID(); + } + } + + @Override + public void refresh() { + } + + @Override + public void writeValueEOF() { + + id = null; + product = null; + productBundle = null; + quantity = null; + name = null; + m_jReference.setText(null); + m_jBarcode.setText(null); + m_jProduct.setText(null); + m_jQuantity.setText(null); + + m_jReference.setEnabled(false); + m_jBarcode.setEnabled(false); + m_jProduct.setEnabled(false); + m_jQuantity.setEnabled(false); + m_jEnter1.setEnabled(false); + m_jEnter2.setEnabled(false); + m_jSearch.setEnabled(false); + } + + @Override + public void writeValueInsert() { + + id = UUID.randomUUID().toString(); + product = insertproduct; + productBundle = null; + name = null; + quantity = null; + m_jReference.setText(null); + m_jBarcode.setText(null); + m_jProduct.setText(null); + m_jQuantity.setText(null); + + m_jReference.setEnabled(true); + m_jBarcode.setEnabled(true); + m_jProduct.setEnabled(true); + m_jQuantity.setEnabled(true); + m_jEnter1.setEnabled(true); + m_jEnter2.setEnabled(true); + m_jSearch.setEnabled(true); + } + + @Override + public void writeValueEdit(Object value) { + Object[] obj = (Object[]) value; + + id = obj[0]; + product = obj[1]; + productBundle = obj[2]; + quantity = obj[3]; + name = obj[6]; + m_jReference.setText(Formats.STRING.formatValue(obj[4])); + m_jBarcode.setText(Formats.STRING.formatValue(obj[5])); + m_jProduct.setText(Formats.STRING.formatValue(obj[4]) + " - " + Formats.STRING.formatValue(obj[6])); + m_jQuantity.setText(Formats.DOUBLE.formatValue(obj[3])); + + m_jReference.setEnabled(true); + m_jBarcode.setEnabled(true); + m_jProduct.setEnabled(true); + m_jQuantity.setEnabled(true); + m_jEnter1.setEnabled(true); + m_jEnter2.setEnabled(true); + m_jSearch.setEnabled(true); + } + + @Override + public void writeValueDelete(Object value) { + Object[] obj = (Object[]) value; + + id = obj[0]; + product = obj[1]; + productBundle = obj[2]; + quantity = obj[3]; + name = obj[6]; + m_jReference.setText(Formats.STRING.formatValue(obj[4])); + m_jBarcode.setText(Formats.STRING.formatValue(obj[5])); + m_jProduct.setText(Formats.STRING.formatValue(obj[4]) + " - " + Formats.STRING.formatValue(obj[6])); + m_jQuantity.setText(Formats.DOUBLE.formatValue(obj[3])); + + m_jReference.setEnabled(false); + m_jBarcode.setEnabled(false); + m_jProduct.setEnabled(false); + m_jEnter1.setEnabled(false); + m_jEnter2.setEnabled(false); + m_jSearch.setEnabled(false); + } + + @Override + public Object createValue() throws BasicException { + return new Object[] { + id, + product, + productBundle, + Formats.DOUBLE.parseValue(m_jQuantity.getText()), + m_jReference.getText(), + m_jBarcode.getText(), + name, + }; + } + + @Override + public Component getComponent() { + return this; + } + + private void assignProduct(ProductInfoExt prod) { + + if (m_jSearch.isEnabled()) { + if (prod == null) { + productBundle = null; + quantity = null; + m_jReference.setText(null); + m_jBarcode.setText(null); + m_jProduct.setText(null); + name = null; + } else { + productBundle = prod.getID(); + quantity = null; + m_jReference.setText(prod.getReference()); + m_jBarcode.setText(prod.getCode()); + m_jProduct.setText(prod.getReference() + " - " + prod.getName()); + name = prod.getName(); + } + } + + } + + private void assignProductByCode() { + try { + ProductInfoExt prod = m_dlSales.getProductInfoByCode(m_jBarcode.getText()); + assignProduct(prod); + if (prod == null) { + Toolkit.getDefaultToolkit().beep(); + } + } catch (BasicException eData) { + assignProduct(null); + MessageInf msg = new MessageInf(eData); + msg.show(this); + } + } + + + private void assignProductByReference() { + try { + ProductInfoExt prod = m_dlSales.getProductInfoByReference(m_jReference.getText()); + assignProduct(prod); + if (prod == null) { + Toolkit.getDefaultToolkit().beep(); + } + } catch (BasicException eData) { + assignProduct(null); + MessageInf msg = new MessageInf(eData); + msg.show(this); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel3 = new javax.swing.JLabel(); + m_jReference = new javax.swing.JTextField(); + m_jEnter1 = new javax.swing.JButton(); + m_jEnter2 = new javax.swing.JButton(); + m_jSearch = new javax.swing.JButton(); + m_jProduct = new javax.swing.JTextField(); + m_jBarcode = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + m_jQuantity = new javax.swing.JTextField(); + + setPreferredSize(new java.awt.Dimension(700, 120)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.prodref")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jReference.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jReference.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jReference.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jReferenceActionPerformed(evt); + } + }); + + m_jEnter1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + m_jEnter1.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jEnter1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jEnter1ActionPerformed(evt); + } + }); + + m_jEnter2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/barcode.png"))); // NOI18N + m_jEnter2.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jEnter2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jEnter2ActionPerformed(evt); + } + }); + + m_jSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/search24.png"))); // NOI18N + m_jSearch.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jSearch.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jSearchActionPerformed(evt); + } + }); + + m_jProduct.setEditable(false); + m_jProduct.setPreferredSize(new java.awt.Dimension(200, 30)); + m_jProduct.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jProductActionPerformed(evt); + } + }); + + m_jBarcode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jBarcode.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jBarcode.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBarcodeActionPerformed(evt); + } + }); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.prodbarcode")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText("Quantity"); + jLabel1.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jQuantity.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jQuantity.setPreferredSize(new java.awt.Dimension(100, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jReference, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(10, 10, 10) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(m_jEnter1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(m_jEnter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(m_jQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) + .addComponent(m_jProduct, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jReference, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jEnter1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jProduct, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(m_jBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jEnter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void m_jSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jSearchActionPerformed + + assignProduct(JProductFinder.showMessage(this, m_dlSales, JProductFinder.PRODUCT_BUNDLE)); + +}//GEN-LAST:event_m_jSearchActionPerformed + + private void m_jReferenceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jReferenceActionPerformed + this.assignProductByReference(); + }//GEN-LAST:event_m_jReferenceActionPerformed + + private void m_jEnter2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jEnter2ActionPerformed + this.assignProductByCode(); + }//GEN-LAST:event_m_jEnter2ActionPerformed + + private void m_jEnter1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jEnter1ActionPerformed + this.assignProductByReference(); + }//GEN-LAST:event_m_jEnter1ActionPerformed + + private void m_jBarcodeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBarcodeActionPerformed + this.assignProductByCode(); + }//GEN-LAST:event_m_jBarcodeActionPerformed + + private void m_jProductActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jProductActionPerformed + + }//GEN-LAST:event_m_jProductActionPerformed + + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JTextField m_jBarcode; + private javax.swing.JButton m_jEnter1; + private javax.swing.JButton m_jEnter2; + private javax.swing.JTextField m_jProduct; + private javax.swing.JTextField m_jQuantity; + private javax.swing.JTextField m_jReference; + private javax.swing.JButton m_jSearch; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/BundlePanel.java b/src/main/java/com/unicenta/pos/inventory/BundlePanel.java new file mode 100644 index 0000000..2237db7 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/BundlePanel.java @@ -0,0 +1,118 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.model.*; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.BundleFilter; +import com.unicenta.pos.panels.JPanelTable2; +import com.unicenta.pos.ticket.ProductInfoExt; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * + * @author Jack + */ +public class BundlePanel extends JPanelTable2 { + + private BundleEditor editor; + private BundleFilter filter; + + @Override + protected void init() { + + filter = new BundleFilter(); + filter.init(app); + filter.addActionListener(new ReloadActionListener()); + + row = new Row( + new Field("ID", Datas.STRING, Formats.STRING), + new Field("PRODUCT", Datas.STRING, Formats.STRING), + new Field("PRODUCT_BUNDLE", Datas.STRING, Formats.STRING), + new Field("QUANTITY", Datas.DOUBLE, Formats.DOUBLE), + new Field(AppLocal.getIntString("label.prodref"), Datas.STRING, Formats.STRING, true, true, true), + new Field(AppLocal.getIntString("label.prodbarcode"), Datas.STRING, Formats.STRING, false, true, true), + new Field(AppLocal.getIntString("label.prodname"), Datas.STRING, Formats.STRING, true, true, true) + ); + Table table = new Table( + "products_bundle", + new PrimaryKey("ID"), + new Column("PRODUCT"), + new Column("PRODUCT_BUNDLE"), + new Column("QUANTITY")); + + lpr = row.getListProvider(app.getSession(), + "SELECT " + + "B.ID, B.PRODUCT, " + + "B.PRODUCT_BUNDLE, B.QUANTITY, " + + "P.REFERENCE, P.CODE, P.NAME " + + "FROM products_bundle B, products P " + + "WHERE B.PRODUCT_BUNDLE = P.ID AND B.PRODUCT = ?", filter); + spr = row.getSaveProvider(app.getSession(), table); + + editor = new BundleEditor(app, dirty); + } + + @Override + public void activate() throws BasicException { + filter.activate(); + + startNavigation(); + reload(filter); + } + + @Override + public Component getFilter(){ + return filter.getComponent(); + } + + @Override + public EditorRecord getEditor() { + return editor; + } + + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Bundle"); + } + + private void reload(BundleFilter filter) throws BasicException { + ProductInfoExt prod = filter.getProductInfoExt(); + editor.setInsertProduct(prod); + bd.setEditable(prod != null); + bd.actionLoad(); + } + + private class ReloadActionListener implements ActionListener { + @Override + public void actionPerformed(ActionEvent e) { + try { + reload((BundleFilter) e.getSource()); + } catch (BasicException w) { + } + } + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/inventory/CategoriesEditor.form b/src/main/java/com/unicenta/pos/inventory/CategoriesEditor.form new file mode 100644 index 0000000..53a9df2 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/CategoriesEditor.form @@ -0,0 +1,383 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <NonVisualComponents> + <Container class="javax.swing.JInternalFrame" name="jInternalFrame1"> + <Properties> + <Property name="visible" type="boolean" value="true"/> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </NonVisualComponents> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[750, 500]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jScrollPane2" min="-2" pref="657" max="-2" attributes="0"/> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLblInCat" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="webSwtch_InCatalog" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="1" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblName" min="-2" max="-2" attributes="0"/> + <Component id="jLblCategory" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jLblTextTip" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jName" min="-2" max="-2" attributes="0"/> + <Component id="m_jTextTip" min="-2" max="-2" attributes="0"/> + <Component id="m_jCategory" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLblCatShowName" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="m_jCatNameShow" min="-2" pref="30" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jLblCatOrder" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCatOrder" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jBtnShowTrans" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jLblProdCount" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jImage" min="-2" pref="270" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace min="-2" pref="26" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jCategory" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblCategory" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jTextTip" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblTextTip" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblInCat" min="-2" max="-2" attributes="0"/> + <Component id="webSwtch_InCatalog" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblCatShowName" min="-2" max="-2" attributes="0"/> + <Component id="m_jCatNameShow" min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLblCatOrder" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCatOrder" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="jLblProdCount" max="32767" attributes="0"/> + <Component id="jBtnShowTrans" alignment="0" pref="32" max="32767" attributes="0"/> + </Group> + </Group> + <Component id="m_jImage" max="32767" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jScrollPane2" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLblName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/info.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.namem" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jLblNameMouseClicked"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodcategory" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblTextTip"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.texttip" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jTextTip"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblCatShowName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.subcategorytitle" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="m_jCatNameShow"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="selected" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[30, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblCatOrder"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.ccatorder" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jCatOrder"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblInCat"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.CatalogueStatusYes" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="horizontalTextPosition" type="int" value="2"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.extended.button.WebSwitch" name="webSwtch_InCatalog"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="webSwtch_InCatalogActionPerformed"/> + </Events> + </Component> + <Component class="com.unicenta.data.gui.JImageEditor" name="m_jImage"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[270, 200]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jBtnShowTrans"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.CatProds" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnShowTransActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLblProdCount"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[237, 30]"/> + </Property> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[650, 300]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="com.alee.laf.table.WebTable" name="jTableCategoryStock"> + <Properties> + <Property name="autoCreateRowSorter" type="boolean" value="true"/> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="2" rowCount="20"> + <Column editable="true" title="Name" type="java.lang.Object"/> + <Column editable="true" title="Barcode" type="java.lang.Object"/> + </Table> + </Property> + <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> + <TableColumnModel selectionModel="0"> + <Column maxWidth="-1" minWidth="-1" prefWidth="250" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="gridColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="cc" red="66" type="rgb"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[310, 500]"/> + </Property> + <Property name="rowHeight" type="int" value="25"/> + <Property name="selectionBackground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="d7" green="78" red="0" type="rgb"/> + </Property> + <Property name="showVerticalLines" type="boolean" value="false"/> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="true" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/CategoriesEditor.java b/src/main/java/com/unicenta/pos/inventory/CategoriesEditor.java new file mode 100644 index 0000000..b7670ec --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/CategoriesEditor.java @@ -0,0 +1,675 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.alee.extended.time.ClockType; +import com.alee.extended.time.WebClock; +import com.alee.managers.notification.NotificationIcon; +import com.alee.managers.notification.NotificationManager; +import com.alee.managers.notification.WebNotification; +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.JMessageDialog; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.SentenceExec; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.catalog.CategoryStock; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.JTableHeader; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/** + * @author adrianromero + */ +@Slf4j +public final class CategoriesEditor extends JPanel implements EditorRecord { + + private Object m_oId; + private Object m_id; + public String cId; + + private final SentenceList m_sentcat; + private ComboBoxValModel m_CategoryModel; + + private final SentenceExec m_sentadd; + private final SentenceExec m_sentdel; + + private List<CategoryStock> categoryStockList; + private CategoriesEditor.StockTableModel stockModel; + + private final DataLogicSales dlSales; + + /** + * Creates new form JPanelCategories + * + * @param app + * @param dirty + */ + public CategoriesEditor(AppView app, DirtyManager dirty) { + +// DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + initComponents(); + + // El modelo de categorias + m_sentcat = dlSales.getCategoriesList(); + m_CategoryModel = new ComboBoxValModel(); + + m_sentadd = dlSales.getCatalogCategoryAdd(); + m_sentdel = dlSales.getCatalogCategoryDel(); + + m_jName.getDocument().addDocumentListener(dirty); + m_jCategory.addActionListener(dirty); + m_jImage.addPropertyChangeListener("image", dirty); + m_jCatNameShow.addActionListener(dirty); + m_jTextTip.getDocument().addDocumentListener(dirty); + m_jCatOrder.getDocument().addDocumentListener(dirty); + webSwtch_InCatalog.addActionListener(dirty); + + writeValueEOF(); + } + + /** + * + */ + @Override + public void refresh() { + + List a; + + try { + a = m_sentcat.list(); + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotloadlists"), eD); + msg.show(this); + a = new ArrayList(); + } + + a.add(0, null); + m_CategoryModel = new ComboBoxValModel(a); + m_jCategory.setModel(m_CategoryModel); + + jLblProdCount.setText(null); + } + + /** + * + */ + @Override + public void writeValueEOF() { + m_id = null; + m_jName.setText(null); + m_CategoryModel.setSelectedKey(null); + m_jImage.setImage(null); + m_jName.setEnabled(false); + m_jCategory.setEnabled(false); + m_jImage.setEnabled(false); + webSwtch_InCatalog.isSelected(); + m_jTextTip.setText(null); + m_jTextTip.setEnabled(false); + m_jCatNameShow.setSelected(false); + m_jCatNameShow.setEnabled(false); +// Added JG Feb 2017 + m_jCatOrder.setText(null); + m_jCatOrder.setEnabled(false); + + } + + /** + * + */ + @Override + public void writeValueInsert() { + m_id = UUID.randomUUID().toString(); + m_jName.setText(null); + m_CategoryModel.setSelectedKey(null); + m_jImage.setImage(null); + m_jName.setEnabled(true); + m_jCategory.setEnabled(true); + m_jImage.setEnabled(true); + webSwtch_InCatalog.setEnabled(false); + m_jTextTip.setText(null); + m_jTextTip.setEnabled(true); + m_jCatNameShow.setSelected(true); + m_jCatNameShow.setEnabled(true); +// Added JG Feb 2017 + m_jCatOrder.setText(null); + m_jCatOrder.setEnabled(true); + + } + + /** + * @param value + */ + @Override + public void writeValueDelete(Object value) { + Object[] cat = (Object[]) value; + m_id = cat[0]; + m_jName.setText(Formats.STRING.formatValue(cat[1])); + m_CategoryModel.setSelectedKey(cat[2]); + m_jImage.setImage((BufferedImage) cat[3]); + m_jTextTip.setText(Formats.STRING.formatValue(cat[4])); + m_jCatNameShow.setSelected(((Boolean) cat[5]).booleanValue()); + m_jCatOrder.setText(Formats.STRING.formatValue(cat[6])); + + m_jName.setEnabled(false); + m_jCategory.setEnabled(false); + m_jImage.setEnabled(false); + webSwtch_InCatalog.setEnabled(false); + m_jTextTip.setEnabled(false); + m_jCatNameShow.setEnabled(false); + m_jCatOrder.setEnabled(false); + + stockModel = new CategoriesEditor.StockTableModel(getProductOfName((String) m_oId)); + + } + + /** + * @param value + */ + @Override + public void writeValueEdit(Object value) { + Object[] cat = (Object[]) value; + m_id = cat[0]; + m_jName.setText(Formats.STRING.formatValue(cat[1])); + m_CategoryModel.setSelectedKey(cat[2]); + m_jImage.setImage((BufferedImage) cat[3]); + m_jTextTip.setText(Formats.STRING.formatValue(cat[4])); + m_jCatNameShow.setSelected(((Boolean) cat[5])); + + if (m_jCatOrder.getText().length() == 0) { + m_jCatOrder.setText(null); + } + m_jCatOrder.setText(Formats.STRING.formatValue(cat[6])); + + m_jName.setEnabled(true); + m_jCategory.setEnabled(true); + m_jImage.setEnabled(true); + webSwtch_InCatalog.setEnabled(true); + m_jTextTip.setEnabled(true); + m_jCatNameShow.setEnabled(true); +// Added JG Feb 2017 + m_jCatOrder.setEnabled(true); + + resetTranxTable(); + } + + /** + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] cat = new Object[8]; + + cat[0] = m_id; + cat[1] = m_jName.getText(); + cat[2] = m_CategoryModel.getSelectedKey(); + cat[3] = m_jImage.getImage(); + cat[4] = m_jTextTip.getText(); + cat[5] = m_jCatNameShow.isSelected(); + if (m_jCatOrder.getText().length() == 0) { + m_jCatOrder.setText(null); + } + cat[6] = m_jCatOrder.getText(); + + if (m_jName.getText().contains("&")) { + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.ampersand")); + } + + return cat; + } + + /** + * @return + */ + @Override + public Component getComponent() { + return this; + } + + public void resetTranxTable() { + + jTableCategoryStock.getColumnModel().getColumn(0).setPreferredWidth(250); + + // set font for headers + Font f = new Font("Arial", Font.BOLD, 14); + JTableHeader header = jTableCategoryStock.getTableHeader(); + header.setFont(f); + + jTableCategoryStock.getTableHeader().setReorderingAllowed(true); + jTableCategoryStock.setAutoCreateRowSorter(true); + jTableCategoryStock.repaint(); + } + + private List<CategoryStock> getProductOfName(String pId) { + + try { + categoryStockList = dlSales.getCategorysProductList(pId); + + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + + List<CategoryStock> categoryList = new ArrayList<>(); + + for (CategoryStock categoryStock : categoryStockList) { + String categoryId = categoryStock.getCategoryId(); + if (categoryId.equals(pId)) { + categoryList.add(categoryStock); + } + } + + repaint(); + refresh(); + + return categoryList; + } + + class StockTableModel extends AbstractTableModel { + String nam = AppLocal.getIntString("label.prodname"); + String cod = AppLocal.getIntString("label.prodbarcode"); + + List<CategoryStock> stockList; + String[] columnNames = {nam, cod}; + + public StockTableModel(List<CategoryStock> list) { + stockList = list; + } + + @Override + public int getColumnCount() { + return 2; + } + + @Override + public int getRowCount() { + return stockList.size(); + } + + @Override + public Object getValueAt(int row, int column) { + CategoryStock categoryStock = stockList.get(row); + + switch (column) { + case 0: + return categoryStock.getProductName(); + case 1: + return categoryStock.getProductCode(); + case 2: + return categoryStock.getProductId(); + default: + return ""; + } + } + + @Override + public String getColumnName(int col) { + return columnNames[col]; + } + } + + + public void Notify(String msg) { + final WebNotification notification = new WebNotification(); + notification.setIcon(NotificationIcon.information); + notification.setDisplayTime(4000); + + final WebClock clock = new WebClock(); + clock.setClockType(ClockType.timer); + clock.setTimeLeft(5000); + clock.setTimePattern(msg); + notification.setContent(clock); + + NotificationManager.showNotification(notification); + clock.start(); + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jInternalFrame1 = new javax.swing.JInternalFrame(); + jLblName = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + jLblCategory = new javax.swing.JLabel(); + m_jCategory = new javax.swing.JComboBox(); + jLblTextTip = new javax.swing.JLabel(); + m_jTextTip = new javax.swing.JTextField(); + jLblCatShowName = new javax.swing.JLabel(); + m_jCatNameShow = new javax.swing.JCheckBox(); + jLblCatOrder = new javax.swing.JLabel(); + m_jCatOrder = new javax.swing.JTextField(); + jLblInCat = new javax.swing.JLabel(); + webSwtch_InCatalog = new com.alee.extended.button.WebSwitch(); + m_jImage = new com.unicenta.data.gui.JImageEditor(); + jBtnShowTrans = new javax.swing.JButton(); + jLblProdCount = new javax.swing.JLabel(); + jScrollPane2 = new javax.swing.JScrollPane(); + jTableCategoryStock = new com.alee.laf.table.WebTable(); + + jInternalFrame1.setVisible(true); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setPreferredSize(new java.awt.Dimension(750, 500)); + + jLblName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblName.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/info.png"))); // NOI18N + jLblName.setText(AppLocal.getIntString("label.namem")); // NOI18N + jLblName.setPreferredSize(new java.awt.Dimension(125, 30)); + jLblName.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLblNameMouseClicked(evt); + } + }); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLblCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblCategory.setText(AppLocal.getIntString("label.prodcategory")); // NOI18N + jLblCategory.setPreferredSize(new java.awt.Dimension(125, 30)); + + m_jCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCategory.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLblTextTip.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLblTextTip.setText(bundle.getString("label.texttip")); // NOI18N + jLblTextTip.setPreferredSize(new java.awt.Dimension(125, 30)); + + m_jTextTip.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTextTip.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLblCatShowName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblCatShowName.setText(bundle.getString("label.subcategorytitle")); // NOI18N + jLblCatShowName.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jCatNameShow.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCatNameShow.setSelected(true); + m_jCatNameShow.setPreferredSize(new java.awt.Dimension(30, 30)); + + jLblCatOrder.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblCatOrder.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + jLblCatOrder.setText(bundle.getString("label.ccatorder")); // NOI18N + jLblCatOrder.setPreferredSize(new java.awt.Dimension(60, 30)); + + m_jCatOrder.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCatOrder.setHorizontalAlignment(javax.swing.JTextField.CENTER); + m_jCatOrder.setPreferredSize(new java.awt.Dimension(60, 30)); + + jLblInCat.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblInCat.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLblInCat.setText(bundle.getString("label.CatalogueStatusYes")); // NOI18N + jLblInCat.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); + jLblInCat.setPreferredSize(new java.awt.Dimension(125, 30)); + + webSwtch_InCatalog.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + webSwtch_InCatalog.setPreferredSize(new java.awt.Dimension(80, 30)); + webSwtch_InCatalog.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + webSwtch_InCatalogActionPerformed(evt); + } + }); + + m_jImage.setPreferredSize(new java.awt.Dimension(270, 200)); + + jBtnShowTrans.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jBtnShowTrans.setText(bundle.getString("button.CatProds")); // NOI18N + jBtnShowTrans.setToolTipText(""); + jBtnShowTrans.setPreferredSize(new java.awt.Dimension(140, 30)); + jBtnShowTrans.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnShowTransActionPerformed(evt); + } + }); + + jLblProdCount.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblProdCount.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLblProdCount.setOpaque(true); + jLblProdCount.setPreferredSize(new java.awt.Dimension(237, 30)); + + jScrollPane2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jScrollPane2.setPreferredSize(new java.awt.Dimension(650, 300)); + + jTableCategoryStock.setAutoCreateRowSorter(true); + jTableCategoryStock.setModel(new javax.swing.table.DefaultTableModel( + new Object[][]{ + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null}, + {null, null} + }, + new String[]{ + "Name", "Barcode" + } + )); + jTableCategoryStock.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTableCategoryStock.setGridColor(new java.awt.Color(102, 204, 255)); + jTableCategoryStock.setPreferredSize(new java.awt.Dimension(310, 500)); + jTableCategoryStock.setRowHeight(25); + jTableCategoryStock.setSelectionBackground(new java.awt.Color(0, 120, 215)); + jTableCategoryStock.setShowVerticalLines(false); + jScrollPane2.setViewportView(jTableCategoryStock); + if (jTableCategoryStock.getColumnModel().getColumnCount() > 0) { + jTableCategoryStock.getColumnModel().getColumn(0).setPreferredWidth(250); + } + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 657, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLblInCat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(webSwtch_InCatalog, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLblTextTip, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jTextTip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addComponent(jLblCatShowName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(m_jCatNameShow, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLblCatOrder, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCatOrder, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jBtnShowTrans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLblProdCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))) + .addComponent(m_jImage, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(26, 26, 26)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jTextTip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblTextTip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblInCat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webSwtch_InCatalog, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblCatShowName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCatNameShow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblCatOrder, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCatOrder, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLblProdCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jBtnShowTrans, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE))) + .addComponent(m_jImage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void webSwtch_InCatalogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_webSwtch_InCatalogActionPerformed + if (webSwtch_InCatalog.isSelected()) { + + try { + Object param = m_id; + m_sentdel.exec(param); + m_sentadd.exec(param); + jLblInCat.setText(AppLocal.getIntString("label.CatalogueStatusYes")); + Notify(AppLocal.getIntString("notify.added")); + } catch (BasicException e) { + JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotexecute"), e)); + } + } else { + + try { + m_sentdel.exec(m_id); + jLblInCat.setText(AppLocal.getIntString("label.CatalogueStatusNo")); + Notify(AppLocal.getIntString("notify.removed")); + } catch (BasicException e) { + JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotexecute"), e)); + } + } + }//GEN-LAST:event_webSwtch_InCatalogActionPerformed + + private void jLblNameMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLblNameMouseClicked + + if (evt.getClickCount() == 2) { + String uuidString = m_id.toString(); + StringSelection stringSelection = new StringSelection(uuidString); + Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); + clpbrd.setContents(stringSelection, null); + + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.uuidcopy")); + } + }//GEN-LAST:event_jLblNameMouseClicked + + private void jBtnShowTransActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnShowTransActionPerformed + String pId = m_id.toString(); + if (pId != null) { + stockModel = new CategoriesEditor.StockTableModel(getProductOfName(pId)); + jTableCategoryStock.setModel(stockModel); + + if (stockModel.getRowCount() > 0) { + jTableCategoryStock.setVisible(true); + String ProdCount = String.valueOf(stockModel.getRowCount()); + jLblProdCount.setText(ProdCount + " for " + m_jName.getText()); + } else { + jTableCategoryStock.setVisible(false); + JOptionPane.showMessageDialog(null, + "No Products for this Category", "Products", JOptionPane.INFORMATION_MESSAGE); + } + resetTranxTable(); + } + }//GEN-LAST:event_jBtnShowTransActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jBtnShowTrans; + private javax.swing.JInternalFrame jInternalFrame1; + private javax.swing.JLabel jLblCatOrder; + private javax.swing.JLabel jLblCatShowName; + private javax.swing.JLabel jLblCategory; + private javax.swing.JLabel jLblInCat; + private javax.swing.JLabel jLblName; + private javax.swing.JLabel jLblProdCount; + private javax.swing.JLabel jLblTextTip; + private javax.swing.JScrollPane jScrollPane2; + private com.alee.laf.table.WebTable jTableCategoryStock; + private javax.swing.JCheckBox m_jCatNameShow; + private javax.swing.JTextField m_jCatOrder; + private javax.swing.JComboBox m_jCategory; + private com.unicenta.data.gui.JImageEditor m_jImage; + private javax.swing.JTextField m_jName; + private javax.swing.JTextField m_jTextTip; + private com.alee.extended.button.WebSwitch webSwtch_InCatalog; + // End of variables declaration//GEN-END:variables + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/inventory/CategoriesPanel.java b/src/main/java/com/unicenta/pos/inventory/CategoriesPanel.java new file mode 100644 index 0000000..f44cbf0 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/CategoriesPanel.java @@ -0,0 +1,120 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +/** + * + * @author adrianromero + */ +public class CategoriesPanel extends JPanelTable { + + private TableDefinition tcategories; + private CategoriesEditor jeditor; + + /** Creates a new instance of JPanelCategories */ + public CategoriesPanel() { + } + + /** + * + */ + @Override + protected void init() { + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + tcategories = dlSales.getTableCategories(); + jeditor = new CategoriesEditor(app, dirty); + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return new ListProviderCreator(tcategories); + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(tcategories); + } + + /** + * + * @return + */ + @Override + public Vectorer getVectorer() { + return tcategories.getVectorerBasic(new int[]{1}); + } + + /** + * + * @return + */ + @Override + public ComparatorCreator getComparatorCreator() { + return tcategories.getComparatorCreator(new int[]{1}); + } + + /** + * + * @return + */ + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(tcategories.getRenderStringBasic(new int[]{1})); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Categories"); + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/CodeType.java b/src/main/java/com/unicenta/pos/inventory/CodeType.java new file mode 100644 index 0000000..118c7e6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/CodeType.java @@ -0,0 +1,75 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.data.loader.IKeyed; + +/** + * + * @author adrianromero + */ +public class CodeType implements IKeyed { + + /** + * + */ + public static final CodeType EAN13 = new CodeType("EAN13", "EAN13"); + + /** + * + */ + public static final CodeType CODE128 = new CodeType("CODE128", "CODE128"); + + /** + * + */ + protected String m_sKey; + + /** + * + */ + protected String m_sValue; + + private CodeType(String key, String value) { + m_sKey = key; + m_sValue = value; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return m_sKey; + } + + /** + * + * @return + */ + public String getValue() { + return m_sValue; + } + @Override + public String toString() { + return m_sValue; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/inventory/InvEditLine.form b/src/main/java/com/unicenta/pos/inventory/InvEditLine.form new file mode 100644 index 0000000..90744c8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/InvEditLine.form @@ -0,0 +1,112 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="25" max="-2" attributes="0"/> + <Component id="webLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" attributes="0"> + <Component id="webButtonCancel" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="webButtonOK" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="webTxtPriceBuy" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace pref="27" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="27" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="webLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="webTxtPriceBuy" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="webButtonOK" min="-2" pref="45" max="-2" attributes="0"/> + <Component id="webButtonCancel" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace pref="19" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="com.alee.laf.label.WebLabel" name="webLabel1"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.invline" replaceFormat="AppLocal.getIntString("button.exit")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.text.WebTextField" name="webTxtPriceBuy"> + <Properties> + <Property name="text" type="java.lang.String" value="webTextField1"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.button.WebButton" name="webButtonOK"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="webButtonOKActionPerformed"/> + </Events> + </Component> + <Component class="com.alee.laf.button.WebButton" name="webButtonCancel"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="webButtonCancelActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/InvEditLine.java b/src/main/java/com/unicenta/pos/inventory/InvEditLine.java new file mode 100644 index 0000000..1e3ecf6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/InvEditLine.java @@ -0,0 +1,137 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.pos.forms.AppLocal; +import com.alee.laf.*; + + +/** + * + * @author jack + */ +public class InvEditLine extends javax.swing.JDialog { + private boolean ok; + + /** + * Creates new form InvEditLine + * @param parent + * @param modal + */ + public InvEditLine(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + } + public boolean isOK() { + boolean ok = false; + return ok; + } + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + webLabel1 = new com.alee.laf.label.WebLabel(); + webTxtPriceBuy = new com.alee.laf.text.WebTextField(); + webButtonOK = new com.alee.laf.button.WebButton(); + webButtonCancel = new com.alee.laf.button.WebButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + webLabel1.setText(AppLocal.getIntString("button.exit")); // NOI18N + webLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + webLabel1.setPreferredSize(new java.awt.Dimension(130, 30)); + + webTxtPriceBuy.setText("webTextField1"); + webTxtPriceBuy.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + webTxtPriceBuy.setPreferredSize(new java.awt.Dimension(200, 30)); + + webButtonOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + webButtonOK.setPreferredSize(new java.awt.Dimension(80, 45)); + webButtonOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + webButtonOKActionPerformed(evt); + } + }); + + webButtonCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + webButtonCancel.setPreferredSize(new java.awt.Dimension(80, 45)); + webButtonCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + webButtonCancelActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(25, 25, 25) + .addComponent(webLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(webButtonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(webButtonOK, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(webTxtPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(27, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(27, 27, 27) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(webLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webTxtPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(webButtonOK, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webButtonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(19, Short.MAX_VALUE)) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void webButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_webButtonOKActionPerformed + ok = true; + String invlinevalue = (String)webTxtPriceBuy.getText(); + dispose(); + }//GEN-LAST:event_webButtonOKActionPerformed + + private void webButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_webButtonCancelActionPerformed + dispose(); + }//GEN-LAST:event_webButtonCancelActionPerformed + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private com.alee.laf.button.WebButton webButtonCancel; + private com.alee.laf.button.WebButton webButtonOK; + private com.alee.laf.label.WebLabel webLabel1; + private com.alee.laf.text.WebTextField webTxtPriceBuy; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/inventory/InventoryLine.java b/src/main/java/com/unicenta/pos/inventory/InventoryLine.java new file mode 100644 index 0000000..181784e --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/InventoryLine.java @@ -0,0 +1,212 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.format.Formats; +import com.unicenta.pos.ticket.ProductInfoExt; +import com.unicenta.pos.util.StringUtils; + +/** + * + * @author adrianromero + */ +public class InventoryLine { + + private double m_dMultiply; + private double m_dPrice; + + private String m_sProdID; + private String m_sProdName; + + private String attsetid; + private String attsetinstid; + private String attsetinstdesc; + + /** Creates a new instance of InventoryLine + * @param oProduct */ + public InventoryLine(ProductInfoExt oProduct) { + m_sProdID = oProduct.getID(); + m_sProdName = oProduct.getName(); + m_dMultiply = 1.0; + m_dPrice = oProduct.getPriceBuy(); + + attsetid = oProduct.getAttributeSetID(); + attsetinstid = null; + attsetinstdesc = null; + } + + /** + * + * @param oProduct + * @param dpor + * @param dprice + */ + public InventoryLine(ProductInfoExt oProduct, double dpor, double dprice) { + m_sProdID = oProduct.getID(); + m_sProdName = oProduct.getName(); + m_dMultiply = dpor; + m_dPrice = dprice; + attsetid = oProduct.getAttributeSetID(); + attsetinstid = null; + attsetinstdesc = null; + } + + /** + * + * @return + */ + public String getProductID() { + return m_sProdID; + } + + /** + * + * @return + */ + public String getProductName() { + return m_sProdName; + } + + /** + * + * @param sValue + */ + public void setProductName(String sValue) { + if (m_sProdID == null) { + m_sProdName = sValue; + } + } + + /** + * + * @return + */ + public double getMultiply() { + return m_dMultiply; + } + + /** + * + * @param dValue + */ + public void setMultiply(double dValue) { + m_dMultiply = dValue; + } + + /** + * + * @return + */ + public double getPrice() { + return m_dPrice; + } + + /** + * + * @param dValue + */ + public void setPrice(double dValue) { + m_dPrice = dValue; + } + + /** + * + * @return + */ + public double getSubValue() { + return m_dMultiply * m_dPrice; + } + + /** + * + * @return + */ + public String getProductAttSetInstId() { + return attsetinstid; + } + + /** + * + * @param value + */ + public void setProductAttSetInstId(String value) { + attsetinstid = value; + } + + /** + * + * @return + */ + public String getProductAttSetId() { + return attsetid; + } + + /** + * + * @return + */ + public String getProductAttSetInstDesc() { + return attsetinstdesc; + } + + /** + * + * @param value + */ + public void setProductAttSetInstDesc(String value) { + attsetinstdesc = value; + } + + /** + * + * @return + */ + public String printName() { + return StringUtils.encodeXML(m_sProdName); + } + + /** + * + * @return + */ + public String printPrice() { + if (m_dMultiply == 1.0) { + return ""; + } else { + return Formats.CURRENCY.formatValue(new Double(getPrice())); + } + } + + /** + * + * @return + */ + public String printMultiply() { + return Formats.DOUBLE.formatValue(new Double(m_dMultiply)); + } + + /** + * + * @return + */ + public String printSubValue() { + return Formats.CURRENCY.formatValue(new Double(getSubValue())); + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/InventoryRecord.java b/src/main/java/com/unicenta/pos/inventory/InventoryRecord.java new file mode 100644 index 0000000..3ec2598 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/InventoryRecord.java @@ -0,0 +1,204 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.format.Formats; +import com.unicenta.pos.suppliers.SupplierInfo; +import com.unicenta.pos.util.StringUtils; +import java.util.Date; +import java.util.Iterator; +import java.util.List; + + +/** + * + * @author adrianromero + */ +public class InventoryRecord { + + private final Date m_dDate; + private final MovementReason m_reason; + private final LocationInfo m_locationOri; + private final List<InventoryLine> m_invlines; + private final String user; + private final SupplierInfo m_Supplier; + private final String m_SupplierDoc; + + /** Creates a new instance of InventoryRecord + * @param d + * @param reason + * @param location + * @param invlines + * @param currentUser + * @param supplier + * @param supplierdoc + */ + public InventoryRecord(Date d, MovementReason reason, + LocationInfo location, String currentUser, + SupplierInfo supplier, + List<InventoryLine> invlines, String supplierdoc) { + + m_dDate = d; + m_reason = reason; + m_locationOri = location; + m_invlines = invlines; + user = currentUser; + m_Supplier = supplier; + m_SupplierDoc = supplierdoc; + + } + + + /** + * + * @return + */ + public Date getDate() { + return m_dDate; + } + /** + * + * @return + */ + public String printDate() { + return Formats.TIMESTAMP.formatValue(m_dDate); + } + + /** + * + * @return + */ + public MovementReason getReason() { + return m_reason; + } + /** + * + * @return + */ + public String printReason() { + return StringUtils.encodeXML(m_reason.toString()); + } + + /** + * + * @return + */ + public String getUser() { + return user; + } + public String printUser() { + return StringUtils.encodeXML(user.toString()); + } + + /** + * + * @return + */ + public LocationInfo getLocation() { + return m_locationOri; + } + /** + * + * @return + */ + public String printLocation() { + return StringUtils.encodeXML(m_locationOri.toString()); + } + + /** + * + * @return + */ + public SupplierInfo getSupplier() { + return m_Supplier; + } + public String printSupplier() { + return StringUtils.encodeXML(m_Supplier.toString()); + } + + /** + * + * @return + */ + public String getSupplierDoc() { + return m_SupplierDoc; + } + public String printSupplierDoc() { + return StringUtils.encodeXML(m_SupplierDoc.toString()); + } + + /** + * + * @return + */ + public List<InventoryLine> getLines() { + return m_invlines; + } + + /** + * + * @return + */ + public boolean isInput() { + return m_reason.isInput(); + } + + /** + * + * @return + */ + public double getSubTotal() { + double dSuma = 0.0; + InventoryLine oLine; + for (Iterator<InventoryLine> i = m_invlines.iterator(); i.hasNext();) { + oLine = i.next(); + dSuma += oLine.getSubValue(); + } + return dSuma; + } + /** + * + * @return + */ + public String printSubTotal() { + return Formats.CURRENCY.formatValue(getSubTotal()); + } + + /** + * + * @return + */ + public double getTotalArticles() { + double dSum = 0.0; + InventoryLine oLine; + for (Iterator<InventoryLine> i = m_invlines.iterator(); i.hasNext();) { + oLine = i.next(); + dSum += oLine.getMultiply(); + } + return dSum; + } + /** + * + * @return + */ + public String printTotalArticles() { + return Formats.DOUBLE.formatValue(getTotalArticles()); + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/JDlgUploadProducts.form b/src/main/java/com/unicenta/pos/inventory/JDlgUploadProducts.form new file mode 100644 index 0000000..dc68ecd --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/JDlgUploadProducts.form @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="caption.upload" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-95,0,0,1,-38"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="2"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="jcmdCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jcmdOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="message.preparescanner" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="0" y="20" width="460" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/JDlgUploadProducts.java b/src/main/java/com/unicenta/pos/inventory/JDlgUploadProducts.java new file mode 100644 index 0000000..f16a7c1 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/JDlgUploadProducts.java @@ -0,0 +1,212 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.user.BrowsableEditableData; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.scanpal2.DeviceScanner; +import com.unicenta.pos.scanpal2.DeviceScannerException; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Window; +import javax.swing.JFrame; +import javax.swing.ListModel; + +/** + * + * @author adrianromero + */ +public class JDlgUploadProducts extends javax.swing.JDialog { + + // private AppView m_App; + private DeviceScanner m_scanner; + private BrowsableEditableData m_bd; + + /** Creates new form JDlgUploadProducts */ + private JDlgUploadProducts(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + /** Creates new form JDlgUploadProducts */ + private JDlgUploadProducts(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + private void init(DeviceScanner scanner, BrowsableEditableData bd) { + + initComponents(); + + getRootPane().setDefaultButton(jcmdOK); + + m_scanner = scanner; + m_bd = bd; + + //show(); + setVisible(true); + + // return; + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window)parent; + } else { + return getWindow(parent.getParent()); + } + } + + /** + * + * @param parent + * @param scanner + * @param bd + */ + public static void showMessage(Component parent, DeviceScanner scanner, BrowsableEditableData bd) { + + Window window = getWindow(parent); + + JDlgUploadProducts myMsg; + if (window instanceof Frame) { + myMsg = new JDlgUploadProducts((Frame) window, true); + } else { + myMsg = new JDlgUploadProducts((Dialog) window, true); + } + + myMsg.init(scanner, bd); + } + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel2 = new javax.swing.JPanel(); + jcmdCancel = new javax.swing.JButton(); + jcmdOK = new javax.swing.JButton(); + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("caption.upload")); // NOI18N + setResizable(false); + + jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N + jcmdCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel2.add(jcmdCancel); + + jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + jcmdOK.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel2.add(jcmdOK); + + getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); + + jPanel1.setLayout(null); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setText(AppLocal.getIntString("message.preparescanner")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(450, 30)); + jPanel1.add(jLabel1); + jLabel1.setBounds(0, 20, 460, 30); + + getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); + + setSize(new java.awt.Dimension(474, 161)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + dispose(); + }//GEN-LAST:event_jcmdCancelActionPerformed + + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + + // Ponemos el estado de leyendo productos + String stext = jLabel1.getText(); + jLabel1.setText(AppLocal.getIntString("label.uploadingproducts")); + jcmdOK.setEnabled(false); + jcmdCancel.setEnabled(false); + + // Ejecutamos la descarga... + try { + m_scanner.connectDevice(); + m_scanner.startUploadProduct(); + + ListModel l = m_bd.getListModel(); + for (int i = 0; i < l.getSize(); i++) { + Object[] myprod = (Object[]) l.getElementAt(i); + m_scanner.sendProduct( + (String) myprod[3], // name + (String) myprod[2], // barcode + (Double) myprod[6] // buy price + ); + } + m_scanner.stopUploadProduct(); + MessageInf msg = new MessageInf(MessageInf.SGN_SUCCESS, AppLocal.getIntString("message.scannerok")); + msg.show(this); + } catch (DeviceScannerException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.scannerfail"), e); + msg.show(this); + } finally { + m_scanner.disconnectDevice(); + } + + // Deshacemos el estado de leyendo productos + jLabel1.setText(stext); + jcmdOK.setEnabled(true); + jcmdCancel.setEnabled(true); + + dispose(); + + }//GEN-LAST:event_jcmdOKActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/JInventoryLines.form b/src/main/java/com/unicenta/pos/inventory/JInventoryLines.form new file mode 100644 index 0000000..9fa95ed --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/JInventoryLines.form @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[455, 402]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="m_tableinventory"> + <Properties> + <Property name="autoCreateColumnsFromModel" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="autoResizeMode" type="int" value="0"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + <Property name="selectionBackground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="cc" green="99" red="0" type="rgb"/> + </Property> + <Property name="showVerticalLines" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="m_tableinventoryMousePressed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/JInventoryLines.java b/src/main/java/com/unicenta/pos/inventory/JInventoryLines.java new file mode 100644 index 0000000..bdd02f9 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/JInventoryLines.java @@ -0,0 +1,362 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; +import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.List; +import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableColumnModel; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +/** + * + * @author adrianromero + */ +public class JInventoryLines extends javax.swing.JPanel { + + private InventoryTableModel m_inventorylines; + + /** Creates new form JInventoryLines */ + public JInventoryLines() { + + initComponents(); + + DefaultTableColumnModel columns = new DefaultTableColumnModel(); + TableColumn c; + + c = new TableColumn(0, 150 + , new DataCellRenderer(javax.swing.SwingConstants.LEFT) + , new DefaultCellEditor(new JTextField())); + c.setHeaderValue(AppLocal.getIntString("label.item")); + columns.addColumn(c); + c = new TableColumn(1, 75 + , new DataCellRenderer(javax.swing.SwingConstants.RIGHT) + , new DefaultCellEditor(new JTextField())); + c.setHeaderValue(AppLocal.getIntString("label.units2")); + columns.addColumn(c); + c = new TableColumn(2, 100 + , new DataCellRenderer(javax.swing.SwingConstants.RIGHT) + , new DefaultCellEditor(new JTextField())); + c.setHeaderValue(AppLocal.getIntString("label.price")); + columns.addColumn(c); + c = new TableColumn(3, 100 + , new DataCellRenderer(javax.swing.SwingConstants.RIGHT) + , new DefaultCellEditor(new JTextField())); + c.setHeaderValue(AppLocal.getIntString("label.prodvaluebuy")); + columns.addColumn(c); + + m_tableinventory.setColumnModel(columns); + + m_tableinventory.getTableHeader().setReorderingAllowed(false); + m_tableinventory.setRowHeight(30); + m_tableinventory.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + m_tableinventory.setIntercellSpacing(new java.awt.Dimension(0, 1)); + + m_inventorylines = new InventoryTableModel(); + m_tableinventory.setModel(m_inventorylines); + + + } + + /** + * + */ + public void clear() { + m_inventorylines.clear(); + } + + /** + * + * @param i + */ + public void addLine(InventoryLine i) { + m_inventorylines.addRow(i); + setSelectedIndex(m_inventorylines.getRowCount() - 1); + } + + /** + * + * @param index + */ + public void deleteLine(int index) { + m_inventorylines.removeRow(index); + + // Escojo una a seleccionar + if (index >= m_inventorylines.getRowCount()) { + index = m_inventorylines.getRowCount() - 1; + } + + if ((index >= 0) && (index < m_inventorylines.getRowCount())) { + // Solo seleccionamos si podemos. + setSelectedIndex(index); + } + } + + /** + * + * @param index + * @param i + */ + public void setLine(int index, InventoryLine i) { + m_inventorylines.setRow(index, i); + setSelectedIndex(index); + } + + /** + * + * @param index + * @return + */ + public InventoryLine getLine(int index) { + return m_inventorylines.getRow(index); + } + + /** + * + * @return + */ + public List<InventoryLine> getLines() { + return m_inventorylines.getLines(); + } + + /** + * + * @return + */ + public int getCount() { + return m_inventorylines.getRowCount(); + } + + /** + * + * @return + */ + public int getSelectedRow() { + return m_tableinventory.getSelectedRow(); + } + + /** + * + * @param i + */ + public void setSelectedIndex(int i){ + + // Seleccionamos + m_tableinventory.getSelectionModel().setSelectionInterval(i, i); + + // Hacemos visible la seleccion. + Rectangle oRect = m_tableinventory.getCellRect(i, 0, true); + m_tableinventory.scrollRectToVisible(oRect); + } + + /** + * + */ + public void goDown() { + + int i = m_tableinventory.getSelectionModel().getMaxSelectionIndex(); + if (i < 0){ + i = 0; // No hay ninguna seleccionada + } else { + i ++; + if (i >= m_inventorylines.getRowCount()) { + i = m_inventorylines.getRowCount() - 1; + } + } + + if ((i >= 0) && (i < m_inventorylines.getRowCount())) { + // Solo seleccionamos si podemos. + + setSelectedIndex(i); + } + } + + /** + * + */ + public void goUp() { + int i = m_tableinventory.getSelectionModel().getMinSelectionIndex(); + if (i < 0){ + i = m_inventorylines.getRowCount() - 1; // No hay ninguna seleccionada + } else { + i --; + if (i < 0) { + i = 0; + } + } + + if ((i >= 0) && (i < m_inventorylines.getRowCount())) { + // Solo seleccionamos si podemos. + setSelectedIndex(i); + } + } + + private static class InventoryTableModel extends AbstractTableModel { +// JG 16 May 2013 use diamond inference + private final ArrayList<InventoryLine> m_rows = new ArrayList<>(); + + @Override + public int getRowCount() { + return m_rows.size(); + } + @Override + public int getColumnCount() { + return 4; + } + @Override + public String getColumnName(int column) { + //return AppLocal.getIntString(m_acolumns[column].name); + return "a"; + } + @Override + public Object getValueAt(int row, int column) { + + InventoryLine i = m_rows.get(row); + switch (column) { + case 0: return "<html>" + i.getProductName() + ( + i.getProductAttSetInstDesc() == null + ? "" + : "<br>" + i.getProductAttSetInstDesc()); + case 1: return "x" + Formats.DOUBLE.formatValue(i.getMultiply()); + case 2: return Formats.CURRENCY.formatValue(i.getPrice()); + case 3: return Formats.CURRENCY.formatValue(i.getSubValue()); + default: return null; + } + + } + + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + + public void clear() { + int old = getRowCount(); + if (old > 0) { + m_rows.clear(); + fireTableRowsDeleted(0, old - 1); + } + } + + public List<InventoryLine> getLines() { + return m_rows; + } + + public InventoryLine getRow(int index) { + return m_rows.get(index); + } + + public void setRow(int index, InventoryLine oLine){ + + m_rows.set(index, oLine); + fireTableRowsUpdated(index, index); + } + + public void addRow(InventoryLine oLine) { + + insertRow(m_rows.size(), oLine); + } + + public void insertRow(int index, InventoryLine oLine) { + + m_rows.add(index, oLine); + fireTableRowsInserted(index, index); + } + + public void removeRow(int row) { + m_rows.remove(row); + fireTableRowsDeleted(row, row); + } + } + private static class DataCellRenderer extends DefaultTableCellRenderer { + + private int m_iAlignment; + + public DataCellRenderer(int align) { + m_iAlignment = align; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){ + + JLabel aux = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + aux.setVerticalAlignment(javax.swing.SwingConstants.TOP); + aux.setHorizontalAlignment(m_iAlignment); + if (!isSelected) { + aux.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.disabledBackground")); + } + return aux; + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + m_tableinventory = new javax.swing.JTable(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setLayout(new java.awt.BorderLayout()); + + jScrollPane1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jScrollPane1.setPreferredSize(new java.awt.Dimension(455, 402)); + + m_tableinventory.setAutoCreateColumnsFromModel(false); + m_tableinventory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_tableinventory.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); + m_tableinventory.setFocusable(false); + m_tableinventory.setRequestFocusEnabled(false); + m_tableinventory.setSelectionBackground(new java.awt.Color(0, 153, 204)); + m_tableinventory.setShowVerticalLines(false); + m_tableinventory.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(java.awt.event.MouseEvent evt) { + m_tableinventoryMousePressed(evt); + } + }); + jScrollPane1.setViewportView(m_tableinventory); + + add(jScrollPane1, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + private void m_tableinventoryMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_m_tableinventoryMousePressed + + }//GEN-LAST:event_m_tableinventoryMousePressed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTable m_tableinventory; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/LocationInfo.java b/src/main/java/com/unicenta/pos/inventory/LocationInfo.java new file mode 100644 index 0000000..fde67ed --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/LocationInfo.java @@ -0,0 +1,117 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.loader.SerializableRead; + +/** + * + * @author adrianromero + * Created on February 13, 2007, 10:13 AM + * + */ +public class LocationInfo implements SerializableRead, IKeyed { + + private static final long serialVersionUID = 9032683595230L; + private String m_sID; + private String m_sName; + private String m_sAddress; + + /** Creates a new instance of LocationInfo */ + public LocationInfo() { + m_sID = null; + m_sName = null; + m_sAddress = null; + } + + /** + * + * @return + */ + public Object getKey() { + return m_sID; + } + + /** + * + * @param dr + * @throws BasicException + */ + public void readValues(DataRead dr) throws BasicException { + m_sID = dr.getString(1); + m_sName = dr.getString(2); + m_sAddress = dr.getString(3); + } + + /** + * + * @param sID + */ + public void setID(String sID) { + m_sID = sID; + } + + /** + * + * @return + */ + public String getID() { + return m_sID; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + + /** + * + * @param sName + */ + public void setName(String sName) { + m_sName = sName; + } + + /** + * + * @return + */ + public String getAddress() { + return m_sAddress; + } + + /** + * + * @param sAddress + */ + public void setAddress(String sAddress) { + m_sAddress = sAddress; + } + + public String toString(){ + return m_sName; + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/LocationsPanel.java b/src/main/java/com/unicenta/pos/inventory/LocationsPanel.java new file mode 100644 index 0000000..627e71d --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/LocationsPanel.java @@ -0,0 +1,120 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +/** + * + * @author adrianromero + */ +public class LocationsPanel extends JPanelTable { + + private TableDefinition tlocations; + private LocationsView jeditor; + + /** Creates a new instance of LocationsPanel */ + public LocationsPanel() { + } + + /** + * + */ + @Override + protected void init() { + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + tlocations = dlSales.getTableLocations(); + jeditor = new LocationsView(dirty); + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return new ListProviderCreator(tlocations); + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(tlocations); + } + + /** + * + * @return + */ + @Override + public Vectorer getVectorer() { + return tlocations.getVectorerBasic(new int[]{1, 2}); + } + + /** + * + * @return + */ + @Override + public ComparatorCreator getComparatorCreator() { + return tlocations.getComparatorCreator(new int[] {1, 2}); + } + + /** + * + * @return + */ + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(tlocations.getRenderStringBasic(new int[]{1})); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Locations"); + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/LocationsView.form b/src/main/java/com/unicenta/pos/inventory/LocationsView.form new file mode 100644 index 0000000..3db3357 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/LocationsView.form @@ -0,0 +1,105 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jAddress" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jAddress" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/info.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.locationname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jLabel2MouseClicked"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[220, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.locationaddress" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jAddress"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[220, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/LocationsView.java b/src/main/java/com/unicenta/pos/inventory/LocationsView.java new file mode 100644 index 0000000..4d052fe --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/LocationsView.java @@ -0,0 +1,227 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; +import java.awt.datatransfer.StringSelection; +import java.util.UUID; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import javax.swing.JOptionPane; + +/** + * + * @author adrianromero + */ +public final class LocationsView extends javax.swing.JPanel implements EditorRecord { + + // private DirtyManager m_Dirty = new DirtyManager(); + private String m_sID; + + /** Creates new form LocationsEditor + * @param dirty */ + public LocationsView(DirtyManager dirty) { + initComponents(); + + m_jName.getDocument().addDocumentListener(dirty); + m_jAddress.getDocument().addDocumentListener(dirty); + + writeValueEOF(); + } + + /** + * + */ + @Override + public void writeValueEOF() { + + m_sID = null; + m_jName.setText(null); + m_jAddress.setText(null); + + m_jName.setEnabled(false); + m_jAddress.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + + m_sID = UUID.randomUUID().toString(); + m_jName.setText(null); + m_jAddress.setText(null); + + m_jName.setEnabled(true); + m_jAddress.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + + Object[] location = (Object[]) value; + m_sID = Formats.STRING.formatValue(location[0]); + m_jName.setText(Formats.STRING.formatValue(location[1])); + m_jAddress.setText(Formats.STRING.formatValue(location[2])); + + m_jName.setEnabled(false); + m_jAddress.setEnabled(false); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + + Object[] location = (Object[]) value; + m_sID = Formats.STRING.formatValue(location[0]); + m_jName.setText(Formats.STRING.formatValue(location[1])); + m_jAddress.setText(Formats.STRING.formatValue(location[2])); + + m_jName.setEnabled(true); + m_jAddress.setEnabled(true); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + Object[] location = new Object[3]; + location[0] = m_sID; + location[1] = m_jName.getText(); + location[2] = m_jAddress.getText(); + return location; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + */ + @Override + public void refresh() { + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel2 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + m_jAddress = new javax.swing.JTextField(); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/info.png"))); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.locationname")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + jLabel2.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel2MouseClicked(evt); + } + }); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(220, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.locationaddress")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jAddress.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jAddress.setPreferredSize(new java.awt.Dimension(220, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MouseClicked + + if (evt.getClickCount() == 2) { + String uuidString = m_sID; + StringSelection stringSelection = new StringSelection(uuidString); + Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); + clpbrd.setContents(stringSelection, null); + + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.uuidcopy")); + } + }//GEN-LAST:event_jLabel2MouseClicked + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JTextField m_jAddress; + private javax.swing.JTextField m_jName; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/MaterialFilter.form b/src/main/java/com/unicenta/pos/inventory/MaterialFilter.form new file mode 100644 index 0000000..60c0ba6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/MaterialFilter.form @@ -0,0 +1,160 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32767, 160]"/> + </Property> + <Property name="opaque" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 160]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,123,0,0,2,101"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> + <TitledBorder title="By Form"> + <ResourceString PropertyName="titleX" bundle="pos_messages.properties" key="label.byform" replaceFormat="AppLocal.getIntString("{key}")"/> + </TitledBorder> + </Border> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[32767, 140]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 140]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricebuy" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="50" width="130" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="150" y="20" width="150" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="310" y="20" width="180" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jPriceBuy"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="310" y="50" width="60" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboPriceBuy"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="150" y="50" width="150" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="20" width="130" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.stockproduct" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="80" width="130" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboProduct"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="150" y="80" width="220" height="25"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/MaterialFilter.java b/src/main/java/com/unicenta/pos/inventory/MaterialFilter.java new file mode 100644 index 0000000..1e0bdf2 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/MaterialFilter.java @@ -0,0 +1,164 @@ +// Opentpv is a point of sales application designed for touch screens. +// Copyright (c) 2009-20162008 Open Sistemas de Información Internet, S.L. +// Copyright (c) 2009-20162007-2008 Openbravo, S.L. +// http://www.opensistemas.com +// e-mail: imasd@opensistemas.com +// +// This program 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 2 of the License, or +// (at your option) any later version. +// +// This program 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 this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.ListQBFModelNumber; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.user.EditorCreator; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; + +/** + * + * @author Luis Ig. Bacas Riveiro lbacas@opensistemas.com + * @author Pablo J. Urbano Santos purbano@opensistemas.com + */ +public class MaterialFilter extends javax.swing.JPanel implements EditorCreator { + + private SentenceList m_sentprods; + private ComboBoxValModel m_ProdsModel; + + /** Creates new form JQBFProduct + * @param dlSales */ + public MaterialFilter(DataLogicSales dlSales) { + initComponents(); + + //El modelo de productos + m_sentprods = dlSales.getProductList(); + m_ProdsModel = new ComboBoxValModel(); + + m_jCboName.setModel(new ListQBFModelNumber()); + m_jCboPriceBuy.setModel(new ListQBFModelNumber()); + } + + /** + * + * @throws BasicException + */ + public void activate() throws BasicException { + java.util.List prodlist = m_sentprods.list(); + prodlist.add(0, null); + m_ProdsModel.refresh(prodlist); + m_jCboProduct.setModel(m_ProdsModel); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + return new Object[] { + m_jCboName.getSelectedItem(), m_jName.getText(), + m_jCboPriceBuy.getSelectedItem(), Formats.CURRENCY.parseValue(m_jPriceBuy.getText()), + m_ProdsModel.getSelectedKey() == null ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_EQUALS, m_ProdsModel.getSelectedKey() + }; + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLabel4 = new javax.swing.JLabel(); + m_jCboName = new javax.swing.JComboBox(); + m_jName = new javax.swing.JTextField(); + m_jPriceBuy = new javax.swing.JTextField(); + m_jCboPriceBuy = new javax.swing.JComboBox(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + m_jCboProduct = new javax.swing.JComboBox(); + + setMaximumSize(new java.awt.Dimension(32767, 160)); + setOpaque(false); + setPreferredSize(new java.awt.Dimension(500, 160)); + setRequestFocusEnabled(false); + setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS)); + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(AppLocal.getIntString("label.byform"))); // NOI18N + jPanel1.setMaximumSize(new java.awt.Dimension(32767, 140)); + jPanel1.setPreferredSize(new java.awt.Dimension(500, 140)); + jPanel1.setRequestFocusEnabled(false); + jPanel1.setLayout(null); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.prodpricebuy")); // NOI18N + jPanel1.add(jLabel4); + jLabel4.setBounds(20, 50, 130, 25); + + m_jCboName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel1.add(m_jCboName); + m_jCboName.setBounds(150, 20, 150, 25); + + m_jName.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel1.add(m_jName); + m_jName.setBounds(310, 20, 180, 25); + + m_jPriceBuy.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel1.add(m_jPriceBuy); + m_jPriceBuy.setBounds(310, 50, 60, 25); + + m_jCboPriceBuy.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel1.add(m_jCboPriceBuy); + m_jCboPriceBuy.setBounds(150, 50, 150, 25); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.prodname")); // NOI18N + jPanel1.add(jLabel2); + jLabel2.setBounds(20, 20, 130, 25); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.stockproduct")); // NOI18N + jPanel1.add(jLabel3); + jLabel3.setBounds(20, 80, 130, 25); + + m_jCboProduct.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel1.add(m_jCboProduct); + m_jCboProduct.setBounds(150, 80, 220, 25); + + add(jPanel1); + }// </editor-fold>//GEN-END:initComponents + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JPanel jPanel1; + private javax.swing.JComboBox m_jCboName; + private javax.swing.JComboBox m_jCboPriceBuy; + private javax.swing.JComboBox m_jCboProduct; + private javax.swing.JTextField m_jName; + private javax.swing.JTextField m_jPriceBuy; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/MaterialProdInfo.java b/src/main/java/com/unicenta/pos/inventory/MaterialProdInfo.java new file mode 100644 index 0000000..85716f0 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/MaterialProdInfo.java @@ -0,0 +1,169 @@ +// Openbravo POS is a point of sales application designed for touch screens. +// Copyright (c) 2009-20162008 Open Sistemas de Información Internet, S.L. +// http://www.opensistemas.com +// http://sourceforge.net/projects/openbravopos +// +// This program 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 2 of the License, or +// (at your option) any later version. +// +// This program 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 this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.loader.SerializableRead; +import com.unicenta.pos.ticket.ProductInfoExt; + +/** + * Clase para la gestion de los materiales de un producto (escandallo) + * @author Luis Ig. Bacas Riveiro lbacas@opensistemas.com + * @author Pablo J. Urbano Santos purbano@opensistemas.com + */ +public class MaterialProdInfo implements SerializableRead, IKeyed { + private String m_sID; + private String m_sName; + private double m_dPriceBuy; + private double m_dAmount; + private String m_sUnit; + + /** + * + */ + public MaterialProdInfo() { + m_sID = null; + m_sName = null; + m_dPriceBuy = 0.0; + m_dAmount = 0.0; + m_sUnit = null; + } + + /** + * + * @param p + */ + public MaterialProdInfo(ProductInfoExt p) { + m_sID = p.getID(); + m_sName = p.getName(); + m_dPriceBuy = p.getPriceBuy(); + m_dAmount = 1.0; + } + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_sID = dr.getString(1); + m_sName = dr.getString(2); + m_dPriceBuy = dr.getDouble(3).doubleValue(); + m_dAmount = (dr.getDouble(4) == null) ? 1.0 : dr.getDouble(4).doubleValue(); + m_sUnit = dr.getString(5); + } + + /** + * + * @param id + */ + public void setID (String id) { + m_sID = id; + } + + /** + * + * @return + */ + public String getID() { + return m_sID; + } + + /** + * + * @param name + */ + public void setName (String name) { + m_sName = name; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + + /** + * + * @param price + */ + public void setPriceBuy (double price) { + m_dPriceBuy = price; + } + + /** + * + * @return + */ + public double getPriceBuy() { + return m_dPriceBuy; + } + + /** + * + * @param amount + */ + public void setAmount (double amount) { + m_dAmount = amount; + } + + /** + * + * @return + */ + public double getAmount() { + return m_dAmount; + } + + /** + * + * @param unit + */ + public void setUnit (String unit) { + m_sUnit = unit; + } + + /** + * + * @return + */ + public String getUnit() { + return m_sUnit; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return m_sID; + } + + @Override + public final String toString() { + return (m_sName +" - "+m_dAmount+" "+m_sUnit); + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/MovementReason.java b/src/main/java/com/unicenta/pos/inventory/MovementReason.java new file mode 100644 index 0000000..c3478ca --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/MovementReason.java @@ -0,0 +1,85 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.pos.panels.ComboItemLocal; + +/** + * + * @author adrianromero + */ +public class MovementReason extends ComboItemLocal { + +// IN values + public static final MovementReason IN_PURCHASE = new MovementReason(+1, "stock.in.purchase"); + public static final MovementReason IN_REFUND = new MovementReason(+2, "stock.in.refund"); + public static final MovementReason IN_MOVEMENT = new MovementReason(+4, "stock.in.movement"); + +// OUT values + public static final MovementReason OUT_SALE = new MovementReason(-1, "stock.out.sale"); + public static final MovementReason OUT_REFUND = new MovementReason(-2, "stock.out.refund"); + public static final MovementReason OUT_BREAK = new MovementReason(-3, "stock.out.break"); + public static final MovementReason OUT_MOVEMENT = new MovementReason(-4, "stock.out.movement"); + + public static final MovementReason OUT_SAMPLE = new MovementReason(-5, "stock.out.sample"); + public static final MovementReason OUT_FREE = new MovementReason(-6, "stock.out.free"); + public static final MovementReason OUT_USED = new MovementReason(-7, "stock.out.used"); + public static final MovementReason OUT_SUBTRACT = new MovementReason(-8, "stock.out.subtract"); + +// TRANSFER + public static final MovementReason OUT_CROSSING = new MovementReason(1000, "stock.out.crossing"); + + private MovementReason(Integer iKey, String sKeyValue) { + super(iKey, sKeyValue); + } + + public boolean isInput() { + return m_iKey.intValue() > 0; + } + + public Double samesignum(Double d) { + + if (d == null || m_iKey == null) { + return d; + } else if ((m_iKey.intValue() > 0 && d.doubleValue() < 0.0) || + (m_iKey.intValue() < 0 && d.doubleValue() > 0.0)) { + return -d.doubleValue(); + } else { + return d; + } + } + + /** + * + * @param dBuyPrice + * @param dSellPrice + * @return + */ + public Double getPrice(Double dBuyPrice, Double dSellPrice) { + + if (this == IN_PURCHASE || this == OUT_REFUND || this == OUT_BREAK) { + return dBuyPrice; + } else if (this == OUT_SALE || this == IN_REFUND) { + return dSellPrice; + } else { + return null; + } + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/PriceImportPanel.java b/src/main/java/com/unicenta/pos/inventory/PriceImportPanel.java new file mode 100644 index 0000000..0c2e058 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/PriceImportPanel.java @@ -0,0 +1,148 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// Portions Contributed by: John D L 2013 +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.EditorListener; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.panels.JPanelTable2; +import com.unicenta.pos.ticket.ProductFilter; +import java.awt.Component; +import javax.swing.JButton; + +/** + * + * @author adrianromero + * Created on 1 de marzo de 2007, 22:15 + * + */ +public class PriceImportPanel extends JPanelTable2 implements EditorListener { + + private ProductsEditor jeditor; + private ProductFilter jproductfilter; + + private DataLogicSales m_dlSales = null; + + /** Creates a new instance of ProductsPanel2 */ + public PriceImportPanel() { + } + + /** + * + */ + @Override + protected void init() { + m_dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + // el panel del filtro + jproductfilter = new ProductFilter(); + jproductfilter.init(app); + + row = m_dlSales.getProductsRow(); + + lpr = new ListProviderCreator(m_dlSales.getProductCatQBF(), jproductfilter); + + spr = new SaveProvider( + m_dlSales.getProductCatUpdate(), + m_dlSales.getProductCatInsert(), + m_dlSales.getProductCatDelete()); + + // el panel del editor + jeditor = new ProductsEditor(app, dirty); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public Component getFilter() { + return jproductfilter.getComponent(); + } + + /** + * + * @return + */ + @Override + public Component getToolbarExtras() { + + JButton btnScanPal = new JButton(); + btnScanPal.setText("ScanPal"); + btnScanPal.setVisible(app.getDeviceScanner() != null); + btnScanPal.addActionListener(new java.awt.event.ActionListener() { + @Override + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnScanPalActionPerformed(evt); + } + }); + + return btnScanPal; + } + + private void btnScanPalActionPerformed(java.awt.event.ActionEvent evt) { + + JDlgUploadProducts.showMessage(this, app.getDeviceScanner(), bd); + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.StockImport"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + jeditor.activate(); + jproductfilter.activate(); + + super.activate(); + } + + /** + * + * @param value + */ + @Override + public void updateValue(Object value) { + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/ProductStock.java b/src/main/java/com/unicenta/pos/inventory/ProductStock.java new file mode 100644 index 0000000..826f54c --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/ProductStock.java @@ -0,0 +1,186 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.SerializerRead; +import java.util.Date; + +/** + * + * @author JG uniCenta May 15 + * Used in Product stock tab to display all this Product's + * location values + */ +public class ProductStock { + + String pId; + String location; + Double units; + Double minimum; + Double maximum; + Double pricebuy; + Double pricesell; + Date memodate; + + /** + * Main method to return a product's "live" stock position + */ + public ProductStock() { + } + + /** + * + * @param pId + * @param location + * @param units + * @param minimum + * @param maximum + * @param pricebuy + * @param pricesell + * @param memodate + */ + public ProductStock(String pId, String location, Double units, Double minimum, + Double maximum, Double pricebuy, Double pricesell, Date memodate) { + + this.pId = pId; + this.location = location; + this.units = units; + this.minimum = minimum; + this.maximum = maximum; + this.pricebuy = pricebuy; + this.pricesell = pricesell; + this.memodate = memodate; + } + + /** + * + * @return product id string + */ + public String getProductId() { + return pId; + } + public void setProductId(String pId) { + this.pId = pId; + } + + /** + * + * @return product's location string + */ + public String getLocation() { + return location; + } + public void setLocation(String location) { + this.location = location; + } + + /** + * + * @return product's quantity string value + */ + public Double getUnits() { + return units; + } + public void setUnits(Double units) { + this.units = units; + } + + /** + * + * @return + */ + public Double getMinimum() { + return minimum; + } + public void setMinimum(Double minimum) { + this.minimum = minimum; + } + + /** + * + * @return maximum value + */ + public Double getMaximum() { + return maximum; + } + public void setMaximum(Double maximum) { + this.maximum = maximum; + } + + /** + * + * @return price buy + */ + public Double getPriceBuy() { + return pricebuy; + } + public void setPriceBuy(Double pricebuy) { + this.pricebuy = pricebuy; + } + + /** + * + * @return price sell + */ + public Double getPriceSell() { + return pricesell; + } + public void setPriceSell(Double pricesell) { + this.pricesell = pricesell; + } + /** + * + * @return memodate Date value + */ + public Date getMemoDate() { + return memodate; + } + public void setMemoDate(Date memodate) { + this.memodate = memodate; + } + + + /** + * + * @return stock for this product + */ + public static SerializerRead getSerializerRead() { + return new SerializerRead() { + + @Override + public Object readValues(DataRead dr) throws BasicException { + + String pId = dr.getString(1); + String location = dr.getString(2); + Double units = dr.getDouble(3); + Double minimum = dr.getDouble(4); + Double maximum = dr.getDouble(5); + Double pricebuy = dr.getDouble(6); + Double pricesell = dr.getDouble(7); + Date memodate = dr.getTimestamp(8); + + return + new ProductStock(pId, location, units, minimum, maximum, pricebuy, pricesell, memodate); + } + }; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/inventory/ProductsBundleInfo.java b/src/main/java/com/unicenta/pos/inventory/ProductsBundleInfo.java new file mode 100644 index 0000000..0601a02 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/ProductsBundleInfo.java @@ -0,0 +1,92 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.SerializerRead; + +/** + * + * @author Jack G + */ +public class ProductsBundleInfo { + private static final long serialVersionUID = 7587646873036L; + + protected String id; + protected String productId; + protected String productBundleId; + protected Double quantity; + + /** + * + * @param id + * @param productId + * @param productBundleId + * @param quantity + */ + public ProductsBundleInfo(String id, String productId, String productBundleId, Double quantity) { + this.id = id; + this.productId = productId; + this.productBundleId = productBundleId; + this.quantity = quantity; + } + + + public void setM_ID(String id) { + this.id = id; + } + + public void setM_sProduct(String productId) { + this.productId = productId; + } + + public void setM_sProductBundle(String productBundleId) { + this.productBundleId = productBundleId; + } + + public void setM_dQuantity(Double m_dQuantity) { + this.quantity = quantity; + } + + public String getId() { + return id; + } + + public String getProductId() { + return productId; + } + + public String getProductBundleId() { + return productBundleId; + } + + public Double getQuantity() { + return quantity; + } + + + public static SerializerRead getSerializerRead() { + return (DataRead dr) -> new ProductsBundleInfo(dr.getString(1) + , dr.getString(2) + , dr.getString(3) + , dr.getDouble(4)); + } + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/inventory/ProductsEditor.form b/src/main/java/com/unicenta/pos/inventory/ProductsEditor.form new file mode 100644 index 0000000..1f16c9c --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/ProductsEditor.form @@ -0,0 +1,1823 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-76,0,0,2,-122"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="m_jTitle"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="verticalAlignment" type="int" value="3"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="horizontalTextPosition" type="int" value="4"/> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[260, 25]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="365" y="5" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JTabbedPane" name="jTabbedPane1"> + <Properties> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[680, 420]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="10" y="10" width="630" height="-1"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.product.general.tab" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> + <JTabbedPaneConstraints tabName="General"> + <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodgeneral" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </JTabbedPaneConstraints> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="jLabel2" max="32767" attributes="0"/> + <Component id="jLabel5" max="32767" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="10" pref="10" max="-2" attributes="0"/> + <Component id="jLabel13" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel7" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel16" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="m_jPriceSell" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jGrossProfit" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="103" alignment="0" groupAlignment="1" attributes="0"> + <Component id="m_jUom" min="-2" max="-2" attributes="0"/> + <Group type="102" attributes="0"> + <Component id="jLabel22" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="m_jmargin" max="32767" attributes="0"/> + <Component id="jLabel19" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + <EmptySpace min="-2" pref="115" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jName" alignment="0" max="-2" attributes="0"/> + <Group type="102" attributes="0"> + <Component id="m_jAtt" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="m_jVerpatrib" min="-2" pref="120" max="-2" attributes="0"/> + </Group> + <Component id="m_jTax" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="m_jPriceSellTax" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jLabel26" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="m_jCategory" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + <EmptySpace min="-2" pref="50" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jRef" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel6" min="-2" pref="78" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCode" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCodetype" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jPriceBuy" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel17" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jSupplier" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jBtnSupplier" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jRef" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCode" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCodetype" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jName" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jCategory" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jAtt" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jVerpatrib" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jTax" min="-2" max="-2" attributes="0"/> + <Component id="jLabel7" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel16" min="-2" max="-2" attributes="0"/> + <Component id="m_jPriceSellTax" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel26" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jUom" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jPriceSell" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <Component id="m_jPriceBuy" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel22" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel19" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jGrossProfit" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jmargin" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel17" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jSupplier" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jBtnSupplier" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" pref="14" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/info.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodrefm" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jLabel1MouseClicked"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jRef"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="m_jRefFocusLost"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbarcodem" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jCode"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="m_jCodeFocusLost"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCodetype"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="5"> + <StringItem index="0" value="EAN-13"/> + <StringItem index="1" value="EAN-8"/> + <StringItem index="2" value="CODE128"/> + <StringItem index="3" value="Upc-A"/> + <StringItem index="4" value="Upc-E"/> + </StringArray> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodnamem" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="m_jNameFocusLost"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodcategorym" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel13"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.attributes" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jAtt"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.taxcategorym" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jTax"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel16"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpriceselltaxm" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jPriceSellTax"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricesell" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jPriceSell"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel19"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.margin" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jmargin"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Text Cursor"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricebuym" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jPriceBuy"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="text" type="java.lang.String" value="0"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="m_jVerpatrib"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.mandatory" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="horizontalTextPosition" type="int" value="10"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[49, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="none"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jGrossProfit"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel22"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.grossprofit" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="horizontalTextPosition" type="int" value="0"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel26"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.UOM" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jUom"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel17"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodsupplier" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jSupplier"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jBtnSupplier"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/customer_add_sml.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.supplier" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnSupplierActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.product.stock.tab" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> + <JTabbedPaneConstraints tabName="Stock"> + <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodstock" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </JTabbedPaneConstraints> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jLabel18" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="jLabel8" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jCatalogOrder" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="m_jInCatalog" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="webLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jPrintTo" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="1" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel14" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jConstant" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel9" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jLabel10" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="m_jstockvolume" max="-2" attributes="0"/> + <Component id="m_jstockcost" max="-2" attributes="0"/> + </Group> + </Group> + <Component id="jLabel23" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel15" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel33" min="-2" max="-2" attributes="0"/> + <Component id="jLabel11" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel12" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel20" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="m_jService" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="m_jCheckWarrantyReceipt" min="-2" max="-2" attributes="0"/> + <Component id="m_jComment" min="-2" max="-2" attributes="0"/> + <Component id="m_jScale" min="-2" max="-2" attributes="0"/> + <Component id="m_jVprice" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" attributes="0"> + <Component id="m_jPrintKB" min="-2" pref="30" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jSendStatus" min="-2" pref="30" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jStockUnits" min="-2" pref="24" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jScrollPane2" min="-2" pref="372" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Component id="jLblDate" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jbtndate" min="-2" pref="40" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="-2" attributes="0"/> + <Component id="m_jdate" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="jBtnShowTrans" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jstockcost" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel14" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="m_jConstant" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jstockvolume" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jLabel10" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel23" min="-2" pref="30" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel8" min="-2" max="-2" attributes="0"/> + <Component id="m_jInCatalog" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jCatalogOrder" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel18" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="webLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jPrintTo" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jBtnShowTrans" min="-2" pref="30" max="-2" attributes="0"/> + <Component id="m_jbtndate" min="-2" pref="30" max="-2" attributes="0"/> + <Component id="m_jdate" min="-2" max="-2" attributes="0"/> + <Component id="jLblDate" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jScrollPane2" min="-2" pref="206" max="-2" attributes="0"/> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel15" min="-2" max="-2" attributes="0"/> + <Component id="m_jService" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel33" min="-2" max="-2" attributes="0"/> + <Component id="m_jCheckWarrantyReceipt" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel11" min="-2" max="-2" attributes="0"/> + <Component id="m_jComment" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel12" min="-2" max="-2" attributes="0"/> + <Component id="m_jScale" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel20" min="-2" max="-2" attributes="0"/> + <Component id="m_jVprice" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="1" attributes="0"> + <Component id="m_jPrintKB" min="-2" pref="25" max="-2" attributes="0"/> + <Component id="m_jSendStatus" min="-2" pref="25" max="-2" attributes="0"/> + </Group> + <Component id="m_jStockUnits" alignment="1" min="-2" pref="25" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace min="-2" pref="42" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel9"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodstockcost" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jstockcost"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel10"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodstockvol" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jstockvolume"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodincatalog" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="m_jInCatalog"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + <Property name="selected" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[30, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jInCatalogActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel18"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodorder" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jCatalogOrder"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel15"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.service" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="m_jService"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="A Service Item will not be deducted from the Inventory"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[30, 30]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" value="null"/> + </AccessibilityProperties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel11"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodaux" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="m_jComment"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[30, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel12"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodscale" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="m_jScale"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[30, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="m_jConstant"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[30, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel14"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodconstant" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel20"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.variableprice" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="m_jVprice"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[30, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel33"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.warranty" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.warranty" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="m_jCheckWarrantyReceipt"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.productreceipt" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[30, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel23"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodminmax" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="verticalAlignment" type="int" value="1"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[531, 20]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.label.WebLabel" name="webLabel1"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.printto" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.printto" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jPrintTo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="7"> + <StringItem index="0" value="0"/> + <StringItem index="1" value="1"/> + <StringItem index="2" value="2"/> + <StringItem index="3" value="3"/> + <StringItem index="4" value="4"/> + <StringItem index="5" value="5"/> + <StringItem index="6" value="6"/> + </StringArray> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jBtnShowTrans"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.ProductStock" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnShowTransActionPerformed"/> + </Events> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="com.alee.laf.table.WebTable" name="jTableProductStock"> + <Properties> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="4" rowCount="8"> + <Column editable="true" title="Location" type="java.lang.Object"/> + <Column editable="true" title="Current" type="java.lang.Object"/> + <Column editable="true" title="Minimum" type="java.lang.Object"/> + <Column editable="true" title="Maximum" type="java.lang.Object"/> + </Table> + </Property> + <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> + <TableColumnModel selectionModel="0"> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="rowHeight" type="int" value="25"/> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="true" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JCheckBox" name="m_jPrintKB"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="m_jSendStatus"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jStockUnits"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="text" type="java.lang.String" value="0"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblDate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.proddate" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="m_jbtndate"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/date.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Open Calendar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtndateActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jdate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.product.properties.tab" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> + <JTabbedPaneConstraints tabName="Properties"> + <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.properties" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </JTabbedPaneConstraints> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[680, 400]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="txtAttributes"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Monospaced" size="14" style="0"/> + </Property> + <Property name="lineWrap" type="boolean" value="true"/> + <Property name="wrapStyleWord" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[580, 300]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="jBtnXml"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.injectxml" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.xmlheader" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnXmlActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="First"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel6"> + <Properties> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.product.image.tab" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> + <JTabbedPaneConstraints tabName="Image"> + <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.image" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </JTabbedPaneConstraints> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel34" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="115" max="32767" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="m_jImage" max="32767" attributes="0"/> + <EmptySpace min="-2" pref="243" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jImage" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel34" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel34"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.imagesize" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.data.gui.JImageEditor" name="m_jImage"> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.product.button.tab" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> + <JTabbedPaneConstraints tabName="Button"> + <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.button" replaceFormat="AppLocal.getIntString("label.button")"/> + </Property> + </JTabbedPaneConstraints> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel28" min="-2" pref="230" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="272" max="-2" attributes="0"/> + <Component id="jBtnReset" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" groupAlignment="1" max="-2" attributes="0"> + <Component id="jScrollPane3" alignment="0" max="32767" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel21" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="m_jTextTip" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jBtnStyle" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jBtnBreak" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jBtnColour" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jBtnLarge" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jBtnSmall" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="13" max="-2" attributes="0"/> + <Component id="colourChooser" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="49" max="-2" attributes="0"/> + <Component id="jButtonHTML" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="jBtnBold" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jBtnItalic" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Component id="jBtnImage" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + <EmptySpace min="63" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel28" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jBtnReset" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="jScrollPane3" min="-2" pref="100" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jBtnSmall" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jBtnColour" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jBtnLarge" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jBtnBold" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jBtnItalic" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jBtnImage" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jBtnStyle" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jBtnBreak" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jButtonHTML" min="-2" max="-2" attributes="0"/> + <Component id="colourChooser" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel21" min="-2" max="-2" attributes="0"/> + <Component id="m_jTextTip" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace pref="58" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel28"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbuttonhtml" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="ProductsEditor_jLabel17"/> + </AuxValues> + </Component> + <Component class="javax.swing.JButton" name="jButtonHTML"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.htmltest" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[1, 1, 1, 1]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[96, 72]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[96, 72]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[96, 72]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonHTMLActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel21"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.texttip" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jTextTip"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 30]"/> + </Property> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane3"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="com.alee.laf.text.WebTextArea" name="m_jDisplay"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="lineWrap" type="boolean" value="true"/> + <Property name="rows" type="int" value="4"/> + <Property name="wrapStyleWord" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 100]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="jBtnBreak"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.prodhtmldisplayBreak" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="<html><center><h4>Inserts a Line Break<br> (a new line) for the button text"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 35]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnBreakActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jBtnColour"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="cc" red="0" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.prodhtmldisplayColour" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="<html><center><h4>Set the colour <br>for the button text"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 35]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnColourActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jBtnLarge"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.prodhtmldisplayLarge" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="<html><center><h4>Set the button<br> text to Large"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 35]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnLargeActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jBtnSmall"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.prodhtmldisplaySmall" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="<html><center><h4>Set the button<br>text to Small"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 35]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnSmallActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jBtnBold"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.prodhtmldisplayBold" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="<html><center><h4>Set the button<br> text to Italic"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 35]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnBoldActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jBtnItalic"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.prodhtmldisplayItalic" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="<html><center><h4>Set the button<br> text to Italic"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 35]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnItalicActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jBtnImage"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.prodhtmldisplayImage" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="<html><center><h4>Insert image from<br>local disk or internet URL"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 35]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnImageActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jBtnReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.prodhtmldisplayReset" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 35]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnResetActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jBtnStyle"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.prodhtmldisplayStyle" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="<html><center><h4>Insert <style> tag to change<br>button background colour"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 35]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnStyleActionPerformed"/> + </Events> + </Component> + <Container class="com.alee.extended.colorchooser.WebColorPicker" name="colourChooser"> + <Properties> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.prodhtmldisplayColourChooser" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="colourChooserActionPerformed"/> + </Events> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/ProductsEditor.java b/src/main/java/com/unicenta/pos/inventory/ProductsEditor.java new file mode 100644 index 0000000..416cb63 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/ProductsEditor.java @@ -0,0 +1,2371 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.beans.JCalendarDialog; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.SentenceFind; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.Session; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.*; +import com.unicenta.pos.sales.TaxesLogic; +import com.unicenta.pos.suppliers.DataLogicSuppliers; +import com.unicenta.pos.suppliers.JDialogNewSupplier; +import lombok.extern.slf4j.Slf4j; + +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.AbstractTableModel; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.io.File; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +/** + * @author Jack Gerrard + */ +@Slf4j +public final class ProductsEditor extends javax.swing.JPanel implements EditorRecord { + + private AppProperties m_props; + + private static final long serialVersionUID = 1L; + private Object m_oId; + + private final SentenceList m_sentcat; + private ComboBoxValModel m_CategoryModel; + + private final SentenceList taxcatsent; + private ComboBoxValModel taxcatmodel; + + private final SentenceList attsent; + private ComboBoxValModel attmodel; + + private final SentenceList m_sentsuppliers; + private ComboBoxValModel m_SuppliersModel; + + private final SentenceList taxsent; + private TaxesLogic taxeslogic; + + private Object pricesell; + private boolean priceselllock = false; + + private boolean reportlock = false; + private int btn; + + private List<ProductStock> productStockList; + private ProductsEditor.StockTableModel stockModel; + + private SentenceList m_sentuom; + private ComboBoxValModel m_UomModel; + + private DirtyManager m_Dirty; + private DataLogicSales dlSales; + private DataLogicSystem m_dlSystem; + private DataLogicSuppliers m_dlSuppliers; + + private AppView appView; + + private final SentenceFind loadimage; // JG 3 feb 16 speedup + + private Session s; + private Connection con; + private Statement stmt; + private PreparedStatement pstmt; + private String SQL; + private ResultSet rs; + private AppView m_App; + + protected DataLogicSystem dlSystem; + + + /** + * Creates new form JEditProduct + * + * @param app + * @param dirty + */ + public ProductsEditor(AppView app, DirtyManager dirty) { + + setAppView(app); + dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + m_dlSystem = (DataLogicSystem) app.getBean("com.unicenta.pos.forms.DataLogicSystem"); + m_dlSuppliers = (DataLogicSuppliers) app.getBean("com.unicenta.pos.suppliers.DataLogicSuppliers"); + + initComponents(); + + loadimage = dlSales.getProductImage(); // JG 3 feb 16 speedup + + taxsent = dlSales.getTaxList(); + + m_sentcat = dlSales.getCategoriesList(); + m_CategoryModel = new ComboBoxValModel(); + + taxcatsent = dlSales.getTaxCategoriesList(); + taxcatmodel = new ComboBoxValModel(); + + attsent = dlSales.getAttributeSetList(); + attmodel = new ComboBoxValModel(); + + m_sentsuppliers = m_dlSuppliers.getSupplierList(); + m_SuppliersModel = new ComboBoxValModel(); + + m_sentuom = dlSales.getUomList(); + m_UomModel = new ComboBoxValModel(); + +// Tab General + m_jRef.getDocument().addDocumentListener(dirty); + m_jCode.getDocument().addDocumentListener(dirty); + m_jCodetype.addActionListener(dirty); + m_jName.getDocument().addDocumentListener(dirty); + m_jCategory.addActionListener(dirty); + m_jAtt.addActionListener(dirty); + m_jVerpatrib.addActionListener(dirty); + m_jTax.addActionListener(dirty); + m_jUom.addActionListener(dirty); + m_jPriceBuy.getDocument().addDocumentListener(dirty); + m_jPriceSell.getDocument().addDocumentListener(dirty); + m_jPrintTo.addActionListener(dirty); + +// Tab Stock + m_jInCatalog.addActionListener(dirty); + m_jConstant.addActionListener(dirty); + m_jCatalogOrder.getDocument().addDocumentListener(dirty); + m_jSupplier.addActionListener(dirty); + + m_jService.addActionListener(dirty); + m_jCheckWarrantyReceipt.addActionListener(dirty); + m_jComment.addActionListener(dirty); + m_jScale.addActionListener(dirty); + m_jVprice.addActionListener(dirty); + m_jstockcost.getDocument().addDocumentListener(dirty); + m_jstockvolume.getDocument().addDocumentListener(dirty); + m_jPrintKB.addActionListener(dirty); + m_jSendStatus.addActionListener(dirty); + +// Tab Image + m_jImage.addPropertyChangeListener("image", dirty); + +// Tab Button + m_jDisplay.getDocument().addDocumentListener(dirty); + m_jTextTip.getDocument().addDocumentListener(dirty); + colourChooser.addActionListener(dirty); + m_jDisplay.addCaretListener(null); + +// Tab Properties + txtAttributes.getDocument().addDocumentListener(dirty); + + FieldsManager fm = new FieldsManager(); + m_jPriceBuy.getDocument().addDocumentListener(fm); + m_jPriceSell.getDocument().addDocumentListener(new PriceSellManager()); + m_jTax.addActionListener(fm); + m_jPriceSellTax.getDocument().addDocumentListener(new PriceTaxManager()); + m_jmargin.getDocument().addDocumentListener(new MarginManager()); + m_jGrossProfit.getDocument().addDocumentListener(new MarginManager()); + + m_jdate.getDocument().addDocumentListener(dirty); + + init(); + } + + private void init() { + writeValueEOF(); + } + + /** + * Instantiate object + * + * @throws BasicException + */ + @SuppressWarnings("unchecked") + public void activate() throws BasicException { + + taxeslogic = new TaxesLogic(taxsent.list()); + + m_CategoryModel = new ComboBoxValModel(m_sentcat.list()); + m_jCategory.setModel(m_CategoryModel); + + taxcatmodel = new ComboBoxValModel(taxcatsent.list()); + m_jTax.setModel(taxcatmodel); + + attmodel = new ComboBoxValModel(attsent.list()); + attmodel.add(0, null); + m_jAtt.setModel(attmodel); + + m_SuppliersModel = new ComboBoxValModel(m_sentsuppliers.list()); + m_jSupplier.setModel(m_SuppliersModel); + + m_UomModel = new ComboBoxValModel(m_sentuom.list()); + m_jUom.setModel(m_UomModel); + + String pId = null; + } + + /** + * + */ + @Override + public void refresh() { + } + + /** + * + */ + @Override + public void writeValueEOF() { + + reportlock = true; + + m_jTitle.setText(AppLocal.getIntString("label.recordeof")); + +// Tab General + m_oId = null; + m_jRef.setText(null); + m_jCode.setText(null); + m_jCodetype.setSelectedIndex(0); + m_jName.setText(null); + m_CategoryModel.setSelectedKey(null); + taxcatmodel.setSelectedKey(null); + attmodel.setSelectedKey(null); + m_jVerpatrib.setSelected(false); + m_UomModel.setSelectedKey(0); + m_jPriceBuy.setText("0"); + setPriceSell(null); + m_SuppliersModel.setSelectedKey(0); + +// Tab Stock + m_jInCatalog.setSelected(false); + m_jConstant.setSelected(false); + m_jCatalogOrder.setText(null); + m_jPrintTo.setSelectedIndex(1); + m_jService.setSelected(false); + m_jCheckWarrantyReceipt.setSelected(false); + m_jComment.setSelected(false); + m_jScale.setSelected(false); + m_jVprice.setSelected(false); + m_jstockcost.setText("0"); + m_jstockvolume.setText("0"); + m_jPrintKB.setVisible(false); + m_jSendStatus.setVisible(false); + m_jStockUnits.setVisible(false); + m_jdate.setText(null); + +// Tab Image + m_jImage.setImage(null); + +// Tab Button + m_jDisplay.setText(null); + m_jTextTip.setText(null); +// colourChooser.setText("#000000"); + +// Tab Properties + txtAttributes.setText(null); + + reportlock = false; + +// Tab General + m_jRef.setEnabled(false); + m_jCode.setEnabled(false); + m_jCodetype.setEnabled(false); + m_jName.setEnabled(false); + m_jCategory.setEnabled(false); + m_jAtt.setEnabled(false); + m_jVerpatrib.setEnabled(false); + m_jTax.setEnabled(false); + m_jUom.setEnabled(false); + m_jPriceBuy.setEnabled(false); + m_jPriceSell.setEnabled(false); + m_jPriceSellTax.setEnabled(false); + m_jmargin.setEnabled(false); + m_jSupplier.setEnabled(false); + +// Tab Stock + m_jInCatalog.setEnabled(false); + m_jConstant.setEnabled(false); + m_jCatalogOrder.setEnabled(false); + m_jPrintTo.setEnabled(false); + m_jService.setEnabled(false); + m_jCheckWarrantyReceipt.setEnabled(false); + m_jComment.setEnabled(false); + m_jScale.setEnabled(false); + m_jVprice.setEnabled(false); + m_jstockcost.setEnabled(false); + m_jstockvolume.setEnabled(false); + jTableProductStock.setEnabled(false); + m_jdate.setEnabled(false); + +// Tab Image + m_jImage.setEnabled(false); + +// Tab Button + m_jDisplay.setEnabled(false); + m_jTextTip.setEnabled(false); + colourChooser.setEnabled(false); + +// Tab Properties + txtAttributes.setEnabled(false); + + calculateMargin(); + calculatePriceSellTax(); + calculateGP(); + + } + + @Override + public void writeValueInsert() { + + final int selectedIndex = 0; + + reportlock = true; + + m_jTitle.setText(AppLocal.getIntString("label.recordnew")); + +// Tab General + m_oId = UUID.randomUUID().toString(); + m_jRef.setText(null); + m_jCode.setText(null); + m_jCodetype.setSelectedIndex(0); + m_jName.setText(null); + m_CategoryModel.setSelectedKey("000"); + attmodel.setSelectedKey(null); + m_jVerpatrib.setSelected(false); + taxcatmodel.setSelectedKey("001"); + m_UomModel.setSelectedKey("0"); + m_jPriceBuy.setText("0"); + setPriceSell(null); +// m_SuppliersModel.setSelectedKey(0); + m_jSupplier.setSelectedIndex(selectedIndex); + +// Tab Stock + m_jInCatalog.setSelected(true); + m_jConstant.setSelected(false); + m_jCatalogOrder.setText(null); + m_jPrintTo.setSelectedIndex(1); + m_jService.setSelected(false); + m_jCheckWarrantyReceipt.setSelected(false); + m_jComment.setSelected(false); + m_jScale.setSelected(false); + m_jVprice.setSelected(false); + m_jstockcost.setText("0"); + m_jstockvolume.setText("0"); + m_jdate.setText(null); + +// Tab Image + m_jImage.setImage(null); + +// Tab Button + m_jDisplay.setText(null); + m_jTextTip.setText(null); + colourChooser.setEnabled(false); + +// Tab Properties + txtAttributes.setText(null); + + reportlock = false; + +// Tab General + m_jRef.setEnabled(true); + m_jCode.setEnabled(true); + m_jCodetype.setEnabled(true); + m_jName.setEnabled(true); + m_jCategory.setEnabled(true); + m_jTax.setEnabled(true); + m_jAtt.setEnabled(true); + m_jVerpatrib.setEnabled(true); + m_jUom.setEnabled(true); + m_jPriceBuy.setEnabled(true); + m_jPriceSell.setEnabled(true); + m_jPriceSellTax.setEnabled(true); + m_jmargin.setEnabled(true); + m_jSupplier.setEnabled(true); + +// Tab Stock + m_jInCatalog.setEnabled(true); + m_jConstant.setEnabled(true); + m_jCatalogOrder.setEnabled(false); + m_jPrintTo.setEnabled(true); + m_jService.setEnabled(true); + m_jCheckWarrantyReceipt.setEnabled(true); + m_jComment.setEnabled(true); + m_jScale.setEnabled(true); + m_jVprice.setEnabled(true); + m_jstockcost.setEnabled(true); + m_jstockvolume.setEnabled(true); + jTableProductStock.setEnabled(false); + m_jdate.setEnabled(true); + +// Tab Image + m_jImage.setEnabled(true); + +// Tab Button + m_jDisplay.setEnabled(true); + m_jTextTip.setEnabled(true); + colourChooser.setEnabled(true); + +// Tab Properties + txtAttributes.setEnabled(true); + + calculateMargin(); + calculatePriceSellTax(); + calculateGP(); + + } + + /** + * @return myprod + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] myprod = new Object[32]; + + myprod[0] = m_oId == null ? UUID.randomUUID().toString() : m_oId; + myprod[1] = m_jRef.getText(); + myprod[2] = m_jCode.getText(); + myprod[3] = m_jCodetype.getSelectedItem(); + myprod[4] = m_jName.getText(); + myprod[5] = Formats.CURRENCY.parseValue(m_jPriceBuy.getText()); + myprod[6] = pricesell; + myprod[7] = m_CategoryModel.getSelectedKey(); + myprod[8] = taxcatmodel.getSelectedKey(); + myprod[9] = attmodel.getSelectedKey(); + myprod[10] = Formats.CURRENCY.parseValue(m_jstockcost.getText()); + myprod[11] = Formats.DOUBLE.parseValue(m_jstockvolume.getText()); + myprod[12] = m_jImage.getImage(); + myprod[13] = m_jComment.isSelected(); + myprod[14] = m_jScale.isSelected(); + myprod[15] = m_jConstant.isSelected(); + myprod[16] = m_jPrintKB.isSelected(); + myprod[17] = m_jSendStatus.isSelected(); + myprod[18] = m_jService.isSelected(); + myprod[19] = Formats.BYTEA.parseValue(txtAttributes.getText()); + myprod[20] = m_jDisplay.getText(); + myprod[21] = m_jVprice.isSelected(); + myprod[22] = m_jVerpatrib.isSelected(); + myprod[23] = m_jTextTip.getText(); + myprod[24] = m_jCheckWarrantyReceipt.isSelected(); + myprod[25] = Formats.DOUBLE.parseValue(m_jStockUnits.getText()); + myprod[26] = m_jPrintTo.getSelectedItem().toString(); + myprod[27] = m_SuppliersModel.getSelectedKey(); + myprod[28] = m_UomModel.getSelectedKey(); + myprod[29] = Formats.TIMESTAMP.parseValue(m_jdate.getText()); + + myprod[30] = m_jInCatalog.isSelected(); + myprod[31] = Formats.INT.parseValue(m_jCatalogOrder.getText()); + + if (m_jName.getText().contains("&")) { + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.ampersand")); + } + + return myprod; + } + + /** + * @param value + */ + @Override + public void writeValueEdit(Object value) { + + reportlock = true; + + Object[] myprod = (Object[]) value; + + m_jTitle.setText(Formats.STRING.formatValue(myprod[1]) + + " - " + Formats.STRING.formatValue(myprod[4])); + m_oId = myprod[0]; + m_jRef.setText(Formats.STRING.formatValue(myprod[1])); + m_jCode.setText(Formats.STRING.formatValue(myprod[2])); + m_jCodetype.setSelectedItem(myprod[3]); + m_jName.setText(Formats.STRING.formatValue(myprod[4])); + m_jPriceBuy.setText(Formats.CURRENCY.formatValue(myprod[5])); + setPriceSell(myprod[6]); + m_CategoryModel.setSelectedKey(myprod[7]); + taxcatmodel.setSelectedKey(myprod[8]); + attmodel.setSelectedKey(myprod[9]); + m_jstockcost.setText(Formats.CURRENCY.formatValue(myprod[10])); + m_jstockvolume.setText(Formats.DOUBLE.formatValue(myprod[11])); +// JG 3 feb 16 speedup m_jImage.setImage((BufferedImage) myprod[12]); + m_jImage.setImage(findImage(m_oId)); + m_jComment.setSelected(((Boolean) myprod[13])); + m_jScale.setSelected(((Boolean) myprod[14])); + m_jConstant.setSelected(((Boolean) myprod[15])); + m_jPrintKB.setSelected(((Boolean) myprod[16])); + m_jSendStatus.setSelected(((Boolean) myprod[17])); + m_jService.setSelected(((Boolean) myprod[18])); + txtAttributes.setText(Formats.BYTEA.formatValue(myprod[19])); + m_jDisplay.setText(Formats.STRING.formatValue(myprod[20])); + m_jVprice.setSelected(((Boolean) myprod[21])); + m_jVerpatrib.setSelected(((Boolean) myprod[22])); + m_jTextTip.setText(Formats.STRING.formatValue(myprod[23])); + m_jCheckWarrantyReceipt.setSelected(((Boolean) myprod[24])); + m_jStockUnits.setText(Formats.DOUBLE.formatValue(myprod[25])); + m_jPrintTo.setSelectedItem(myprod[26]); + m_SuppliersModel.setSelectedKey(myprod[27]); + m_UomModel.setSelectedKey(myprod[28]); + + m_jdate.setText(Formats.DATE.formatValue(myprod[29])); + + m_jInCatalog.setSelected(((Boolean) myprod[30])); + m_jCatalogOrder.setText(Formats.INT.formatValue(myprod[31])); + + txtAttributes.setCaretPosition(0); + reportlock = false; + +// Tab General + m_jRef.setEnabled(true); + m_jCode.setEnabled(true); + m_jCodetype.setEnabled(true); + m_jName.setEnabled(true); + m_jCategory.setEnabled(true); + m_jTax.setEnabled(true); + m_jAtt.setEnabled(true); + m_jVerpatrib.setEnabled(true); + m_jUom.setEnabled(true); + m_jPriceBuy.setEnabled(true); + m_jPriceSell.setEnabled(true); + m_jPriceSellTax.setEnabled(true); + m_jmargin.setEnabled(true); + m_jSupplier.setEnabled(true); + +// Tab Stock + m_jInCatalog.setEnabled(true); + m_jConstant.setEnabled(true); + m_jCatalogOrder.setEnabled(m_jInCatalog.isSelected()); + m_jPrintTo.setEnabled(true); + m_jService.setEnabled(true); + m_jCheckWarrantyReceipt.setEnabled(true); + m_jComment.setEnabled(true); + m_jScale.setEnabled(true); + m_jVprice.setEnabled(true); + m_jstockcost.setEnabled(true); + m_jstockvolume.setEnabled(true); + m_jdate.setEnabled(true); + jTableProductStock.setVisible(false); + jTableProductStock.setEnabled(true); + +// Tab Image + m_jImage.setEnabled(true); + +// Tab Button + m_jDisplay.setEnabled(true); + m_jTextTip.setEnabled(true); + colourChooser.setEnabled(true); + setButtonHTML(); + + resetTranxTable(); + jTableProductStock.repaint(); + +// Tab Properties + txtAttributes.setEnabled(true); + + calculateMargin(); + calculatePriceSellTax(); + calculateGP(); + + } + + /** + * @param value + */ + @Override + public void writeValueDelete(Object value) { + + reportlock = true; + Object[] myprod = (Object[]) value; + m_jTitle.setText(Formats.STRING.formatValue(myprod[1]) + + " - " + Formats.STRING.formatValue(myprod[4]) + + " " + AppLocal.getIntString("label.recorddeleted")); + + m_oId = myprod[0]; + m_jRef.setText(Formats.STRING.formatValue(myprod[1])); + m_jCode.setText(Formats.STRING.formatValue(myprod[2])); + m_jCodetype.setSelectedItem(myprod[3]); + m_jName.setText(Formats.STRING.formatValue(myprod[4])); + m_jPriceBuy.setText(Formats.CURRENCY.formatValue(myprod[5])); + setPriceSell(myprod[6]); + m_CategoryModel.setSelectedKey(myprod[7]); + taxcatmodel.setSelectedKey(myprod[8]); + attmodel.setSelectedKey(myprod[9]); + m_jstockcost.setText(Formats.CURRENCY.formatValue(myprod[10])); + m_jstockvolume.setText(Formats.DOUBLE.formatValue(myprod[11])); +// JG 3 feb 16 speed test m_jImage.setImage((BufferedImage) myprod[12]); + m_jImage.setImage(findImage(m_oId)); + m_jComment.setSelected(((Boolean) myprod[13])); + m_jScale.setSelected(((Boolean) myprod[14])); + m_jConstant.setSelected(((Boolean) myprod[15])); + m_jPrintKB.setSelected(((Boolean) myprod[16])); + m_jService.setSelected(((Boolean) myprod[17])); + m_jSendStatus.setSelected(((Boolean) myprod[18])); + txtAttributes.setText(Formats.BYTEA.formatValue(myprod[19])); + m_jDisplay.setText(Formats.STRING.formatValue(myprod[20])); + m_jVprice.setSelected(((Boolean) myprod[21])); + m_jVerpatrib.setSelected(((Boolean) myprod[22])); + m_jTextTip.setText(Formats.STRING.formatValue(myprod[23])); + m_jCheckWarrantyReceipt.setSelected(((Boolean) myprod[24])); + m_jStockUnits.setText(Formats.DOUBLE.formatValue(myprod[25])); + m_jPrintTo.setSelectedItem(myprod[26]); + m_SuppliersModel.setSelectedKey(myprod[27]); + m_UomModel.setSelectedKey(myprod[28]); + m_jdate.setText(Formats.DATE.formatValue(myprod[29])); + + m_jInCatalog.setSelected(((Boolean) myprod[30])); + m_jCatalogOrder.setText(Formats.INT.formatValue(myprod[31])); + + txtAttributes.setCaretPosition(0); + + reportlock = false; + +// Tab General + m_jRef.setEnabled(false); + m_jCode.setEnabled(false); + m_jCodetype.setEnabled(false); + m_jName.setEnabled(false); + m_jCategory.setEnabled(false); + m_jTax.setEnabled(false); + m_jAtt.setEnabled(false); + m_jVerpatrib.setEnabled(false); + m_jUom.setEnabled(false); + m_jPriceBuy.setEnabled(false); + m_jPriceSell.setEnabled(false); + m_jPriceSellTax.setEnabled(false); + m_jmargin.setEnabled(false); + m_jPrintTo.setEnabled(false); + +// Tab Stock + m_jInCatalog.setEnabled(false); + m_jConstant.setEnabled(false); + m_jCatalogOrder.setEnabled(false); + m_jSupplier.setEnabled(false); + m_jService.setEnabled(false); + m_jCheckWarrantyReceipt.setEnabled(false); + m_jComment.setEnabled(false); + m_jScale.setEnabled(false); + m_jVprice.setEnabled(false); + m_jstockcost.setEnabled(false); + m_jstockvolume.setEnabled(false); + stockModel = new ProductsEditor.StockTableModel(getProductOfName((String) m_oId)); + jTableProductStock.setModel(stockModel); + jTableProductStock.setEnabled(false); + m_jdate.setEnabled(false); + +// Tab Image + m_jImage.setEnabled(false); + +// Tab Button + m_jDisplay.setEnabled(false); + m_jTextTip.setEnabled(false); + colourChooser.setEnabled(false); + +// Tab Properties + txtAttributes.setEnabled(false); + + calculateMargin(); + calculatePriceSellTax(); + calculateGP(); + } + + + public void resetTranxTable() { + + jTableProductStock.getColumnModel().getColumn(0).setPreferredWidth(100); + jTableProductStock.getColumnModel().getColumn(1).setPreferredWidth(50); + jTableProductStock.getColumnModel().getColumn(2).setPreferredWidth(50); + jTableProductStock.getColumnModel().getColumn(3).setPreferredWidth(50); + + jTableProductStock.repaint(); + + } + + /** + * @return this + */ + @Override + public Component getComponent() { + return this; + } + + private void setCode() { + + Long lDateTime = new Date().getTime(); + + if (!reportlock) { + reportlock = true; + + if (m_jRef == null) { + m_jCode.setText(Long.toString(lDateTime)); + } else { + if (m_jCode.getText() == null || "".equals(m_jCode.getText())) { + m_jCode.setText(m_jRef.getText()); + } + } + reportlock = false; + } + } + + private List<ProductStock> getProductOfName(String pId) { + + try { + productStockList = dlSales.getProductStockList(pId); + + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + + List<ProductStock> productList = new ArrayList<>(); + + for (ProductStock productStock : productStockList) { + String productId = productStock.getProductId(); + if (productId.equals(pId)) { + productList.add(productStock); + } + } + + repaint(); + refresh(); + + return productList; + } + + public AppView getAppView() { + return appView; + } + + public void setAppView(AppView appView) { + this.appView = appView; + } + + class StockTableModel extends AbstractTableModel { + String loc = AppLocal.getIntString("label.tblProdHeaderCol1"); + String qty = AppLocal.getIntString("label.tblProdHeaderCol2"); + String min = AppLocal.getIntString("label.tblProdHeaderCol3"); + String max = AppLocal.getIntString("label.tblProdHeaderCol4"); + + List<ProductStock> stockList; + String[] columnNames = {loc, qty, min, max}; + + public StockTableModel(List<ProductStock> list) { + stockList = list; + } + + @Override + public int getColumnCount() { + return 4; + } + + @Override + public int getRowCount() { + return stockList.size(); + } + + @Override + public Object getValueAt(int row, int column) { + ProductStock productStock = stockList.get(row); + + switch (column) { + case 0: + return productStock.getLocation(); + case 1: + return productStock.getUnits(); + case 2: + return productStock.getMinimum(); + case 3: + return productStock.getMaximum(); + case 4: + return productStock.getProductId(); + default: + return ""; + } + } + + @Override + public String getColumnName(int col) { + return columnNames[col]; + } + } + + + private void setDisplay(int btn) { + + String htmlString = (m_jDisplay.getText()); + String ohtmlString = "<html><center>" + m_jName.getText(); + + switch (btn) { + case 1: + m_jDisplay.insert("<br>", m_jDisplay.getCaretPosition()); + break; + case 2: + String hexcolor = color2HexString(colourChooser.getColor()); + m_jDisplay.insert("<font color=" + hexcolor + ">" + , m_jDisplay.getCaretPosition()); + break; + case 3: + m_jDisplay.insert("<font size=+2>" + , m_jDisplay.getCaretPosition()); + break; + case 4: + m_jDisplay.insert("<font size=-2>" + , m_jDisplay.getCaretPosition()); + break; + case 5: + m_jDisplay.insert("<b> </b>" + , m_jDisplay.getCaretPosition()); + break; + case 6: + m_jDisplay.insert("<i> </i>" + , m_jDisplay.getCaretPosition()); + break; + case 7: +// defaults to file:/ for local disk +// http:// also usable for remote image + JFileChooser fc = new JFileChooser(); + FileFilter imageFilter = new FileNameExtensionFilter( + "Image files", ImageIO.getReaderFileSuffixes()); + fc.setFileFilter(imageFilter); + int returnValue = fc.showOpenDialog(null); + File selectedFile = fc.getSelectedFile(); + if (selectedFile != null) { + m_jDisplay.insert("<img src=file:" + selectedFile.getAbsolutePath() + ">" + , m_jDisplay.getCaretPosition()); + } + break; + + case 8: + htmlString = ohtmlString; + m_jDisplay.setText(htmlString); + break; + case 9: + m_jDisplay.insert("<div style=background-color:black;color:white;padding:10px;>" + , m_jDisplay.getCaretPosition()); + break; + default: + htmlString += ""; + m_jDisplay.setText(htmlString); + } + } + + private void setButtonHTML() { + + jButtonHTML.setText(m_jDisplay.getText()); + } + + public String color2HexString(Color color) { + return "#" + Integer.toHexString(color.getRGB() & 0x00ffffff); + } + + // 3 feb 16 speed test + private BufferedImage findImage(Object id) { + try { + return (BufferedImage) loadimage.find(id); + } catch (BasicException e) { + return null; + } + } + + // end of speed test + private void calculateMargin() { + + if (!reportlock) { + reportlock = true; + + Double dPriceBuy = readCurrency(m_jPriceBuy.getText()); + Double dPriceSell = (Double) pricesell; + + if (dPriceBuy == null || dPriceSell == null) { + m_jmargin.setText(null); + } else { + m_jmargin.setText(Formats.PERCENT.formatValue(dPriceSell.doubleValue() / dPriceBuy.doubleValue() - 1.0)); + } + reportlock = false; + } + } + + private void calculatePriceSellTax() { + + if (!reportlock) { + reportlock = true; + + Double dPriceSell = (Double) pricesell; + + if (dPriceSell == null) { + m_jPriceSellTax.setText(null); + } else { + double dTaxRate = taxeslogic.getTaxRate((TaxCategoryInfo) taxcatmodel.getSelectedItem()); + m_jPriceSellTax.setText(Formats.CURRENCY.formatValue(dPriceSell.doubleValue() * (1.0 + dTaxRate))); + } + reportlock = false; + } + } + + private void calculateGP() { + + if (!reportlock) { + reportlock = true; + + Double dPriceBuy = readCurrency(m_jPriceBuy.getText()); + Double dPriceSell = (Double) pricesell; + + if (dPriceBuy == null || dPriceSell == null) { + m_jGrossProfit.setText(null); + } else { + m_jGrossProfit.setText(Formats.PERCENT.formatValue( + (dPriceSell.doubleValue() - dPriceBuy.doubleValue()) + / dPriceSell.doubleValue())); + } + reportlock = false; + } + } + + + private void calculatePriceSellfromMargin() { + + if (!reportlock) { + reportlock = true; + + Double dPriceBuy = readCurrency(m_jPriceBuy.getText()); + Double dMargin = readPercent(m_jmargin.getText()); + + if (dMargin == null || dPriceBuy == null) { + setPriceSell(null); + } else { + setPriceSell(dPriceBuy.doubleValue() * (1.0 + dMargin.doubleValue())); + } + + reportlock = false; + } + + } + + private void calculatePriceSellfromPST() { + + if (!reportlock) { + reportlock = true; + + Double dPriceSellTax = readCurrency(m_jPriceSellTax.getText()); + + if (dPriceSellTax == null) { + setPriceSell(null); + } else { + double dTaxRate = taxeslogic.getTaxRate((TaxCategoryInfo) taxcatmodel.getSelectedItem()); + setPriceSell(dPriceSellTax.doubleValue() / (1.0 + dTaxRate)); + } + + reportlock = false; + } + } + + + private void setPriceSell(Object value) { + + if (!priceselllock) { + priceselllock = true; + pricesell = value; + m_jPriceSell.setText(Formats.CURRENCY.formatValue(pricesell)); + priceselllock = false; + } + } + + private class PriceSellManager implements DocumentListener { + @Override + public void changedUpdate(DocumentEvent e) { + if (!priceselllock) { + priceselllock = true; + pricesell = readCurrency(m_jPriceSell.getText()); + priceselllock = false; + } + calculateMargin(); + calculatePriceSellTax(); + calculateGP(); + } + + @Override + public void insertUpdate(DocumentEvent e) { + if (!priceselllock) { + priceselllock = true; + pricesell = readCurrency(m_jPriceSell.getText()); + priceselllock = false; + } + calculateMargin(); + calculatePriceSellTax(); + calculateGP(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + if (!priceselllock) { + priceselllock = true; + pricesell = readCurrency(m_jPriceSell.getText()); + priceselllock = false; + } + calculateMargin(); + calculatePriceSellTax(); + calculateGP(); + } + } + + private class FieldsManager implements DocumentListener, ActionListener { + @Override + public void changedUpdate(DocumentEvent e) { + calculateMargin(); + calculatePriceSellTax(); + calculateGP(); + + } + + @Override + public void insertUpdate(DocumentEvent e) { + calculateMargin(); + calculatePriceSellTax(); + calculateGP(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + calculateMargin(); + calculatePriceSellTax(); + calculateGP(); + } + + @Override + public void actionPerformed(ActionEvent e) { + calculateMargin(); + calculatePriceSellTax(); + calculateGP(); + } + } + + private class PriceTaxManager implements DocumentListener { + @Override + public void changedUpdate(DocumentEvent e) { + calculatePriceSellfromPST(); + calculateMargin(); + calculateGP(); + } + + @Override + public void insertUpdate(DocumentEvent e) { + calculatePriceSellfromPST(); + calculateMargin(); + calculateGP(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + calculatePriceSellfromPST(); + calculateMargin(); + calculateGP(); + } + } + + private class MarginManager implements DocumentListener { + @Override + public void changedUpdate(DocumentEvent e) { + calculatePriceSellfromMargin(); + calculatePriceSellTax(); + calculateGP(); + } + + @Override + public void insertUpdate(DocumentEvent e) { + calculatePriceSellfromMargin(); + calculatePriceSellTax(); + calculateGP(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + calculatePriceSellfromMargin(); + calculatePriceSellTax(); + calculateGP(); + } + } + + private static Double readCurrency(String sValue) { + try { + return (Double) Formats.CURRENCY.parseValue(sValue); + } catch (BasicException e) { + return null; + } + } + + private static Double readPercent(String sValue) { + try { + return (Double) Formats.PERCENT.parseValue(sValue); + } catch (BasicException e) { + return null; + } + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jTitle = new javax.swing.JLabel(); + jTabbedPane1 = new javax.swing.JTabbedPane(); + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + m_jRef = new javax.swing.JTextField(); + jLabel6 = new javax.swing.JLabel(); + m_jCode = new javax.swing.JTextField(); + m_jCodetype = new javax.swing.JComboBox(); + jLabel2 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + jLabel5 = new javax.swing.JLabel(); + m_jCategory = new javax.swing.JComboBox(); + jLabel13 = new javax.swing.JLabel(); + m_jAtt = new javax.swing.JComboBox(); + jLabel7 = new javax.swing.JLabel(); + m_jTax = new javax.swing.JComboBox(); + jLabel16 = new javax.swing.JLabel(); + m_jPriceSellTax = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + m_jPriceSell = new javax.swing.JTextField(); + jLabel19 = new javax.swing.JLabel(); + m_jmargin = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + m_jPriceBuy = new javax.swing.JTextField(); + m_jVerpatrib = new javax.swing.JCheckBox(); + m_jGrossProfit = new javax.swing.JTextField(); + jLabel22 = new javax.swing.JLabel(); + jLabel26 = new javax.swing.JLabel(); + m_jUom = new javax.swing.JComboBox(); + jLabel17 = new javax.swing.JLabel(); + m_jSupplier = new javax.swing.JComboBox(); + jBtnSupplier = new javax.swing.JButton(); + jPanel2 = new javax.swing.JPanel(); + jLabel9 = new javax.swing.JLabel(); + m_jstockcost = new javax.swing.JTextField(); + jLabel10 = new javax.swing.JLabel(); + m_jstockvolume = new javax.swing.JTextField(); + jLabel8 = new javax.swing.JLabel(); + m_jInCatalog = new javax.swing.JCheckBox(); + jLabel18 = new javax.swing.JLabel(); + m_jCatalogOrder = new javax.swing.JTextField(); + jLabel15 = new javax.swing.JLabel(); + m_jService = new javax.swing.JCheckBox(); + jLabel11 = new javax.swing.JLabel(); + m_jComment = new javax.swing.JCheckBox(); + jLabel12 = new javax.swing.JLabel(); + m_jScale = new javax.swing.JCheckBox(); + m_jConstant = new javax.swing.JCheckBox(); + jLabel14 = new javax.swing.JLabel(); + jLabel20 = new javax.swing.JLabel(); + m_jVprice = new javax.swing.JCheckBox(); + jLabel33 = new javax.swing.JLabel(); + m_jCheckWarrantyReceipt = new javax.swing.JCheckBox(); + jLabel23 = new javax.swing.JLabel(); + webLabel1 = new com.alee.laf.label.WebLabel(); + m_jPrintTo = new javax.swing.JComboBox(); + jBtnShowTrans = new javax.swing.JButton(); + jScrollPane2 = new javax.swing.JScrollPane(); + jTableProductStock = new com.alee.laf.table.WebTable(); + m_jPrintKB = new javax.swing.JCheckBox(); + m_jSendStatus = new javax.swing.JCheckBox(); + m_jStockUnits = new javax.swing.JTextField(); + jLblDate = new javax.swing.JLabel(); + m_jbtndate = new javax.swing.JButton(); + m_jdate = new javax.swing.JTextField(); + jPanel3 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + txtAttributes = new javax.swing.JTextArea(); + jBtnXml = new javax.swing.JButton(); + jPanel6 = new javax.swing.JPanel(); + jLabel34 = new javax.swing.JLabel(); + m_jImage = new com.unicenta.data.gui.JImageEditor(); + jPanel4 = new javax.swing.JPanel(); + jLabel28 = new javax.swing.JLabel(); + jButtonHTML = new javax.swing.JButton(); + jLabel21 = new javax.swing.JLabel(); + m_jTextTip = new javax.swing.JTextField(); + jScrollPane3 = new javax.swing.JScrollPane(); + m_jDisplay = new com.alee.laf.text.WebTextArea(); + jBtnBreak = new javax.swing.JButton(); + jBtnColour = new javax.swing.JButton(); + jBtnLarge = new javax.swing.JButton(); + jBtnSmall = new javax.swing.JButton(); + jBtnBold = new javax.swing.JButton(); + jBtnItalic = new javax.swing.JButton(); + jBtnImage = new javax.swing.JButton(); + jBtnReset = new javax.swing.JButton(); + jBtnStyle = new javax.swing.JButton(); + colourChooser = new com.alee.extended.colorchooser.WebColorPicker(); + + setLayout(null); + + m_jTitle.setBackground(new java.awt.Color(255, 255, 255)); + m_jTitle.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTitle.setForeground(new java.awt.Color(102, 102, 102)); + m_jTitle.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jTitle.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); + m_jTitle.setFocusable(false); + m_jTitle.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + m_jTitle.setOpaque(true); + m_jTitle.setPreferredSize(new java.awt.Dimension(260, 25)); + add(m_jTitle); + m_jTitle.setBounds(365, 5, 260, 25); + + jTabbedPane1.setToolTipText(""); + jTabbedPane1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTabbedPane1.setPreferredSize(new java.awt.Dimension(680, 420)); + + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jPanel1.setToolTipText(bundle.getString("tooltip.product.general.tab")); // NOI18N + jPanel1.setPreferredSize(new java.awt.Dimension(0, 0)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/info.png"))); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.prodrefm")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(110, 30)); + jLabel1.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel1MouseClicked(evt); + } + }); + + m_jRef.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jRef.setToolTipText(""); + m_jRef.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jRef.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + m_jRefFocusLost(evt); + } + }); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.prodbarcodem")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jCode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCode.setPreferredSize(new java.awt.Dimension(125, 30)); + m_jCode.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + m_jCodeFocusLost(evt); + } + }); + + m_jCodetype.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCodetype.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"EAN-13", "EAN-8", "CODE128", "Upc-A", "Upc-E"})); + m_jCodetype.setPreferredSize(new java.awt.Dimension(80, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.prodnamem")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(450, 30)); + m_jName.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + m_jNameFocusLost(evt); + } + }); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.prodcategorym")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCategory.setBorder(null); + m_jCategory.setPreferredSize(new java.awt.Dimension(450, 30)); + + jLabel13.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel13.setText(AppLocal.getIntString("label.attributes")); // NOI18N + jLabel13.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jAtt.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jAtt.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.taxcategorym")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jTax.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTax.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel16.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel16.setText(AppLocal.getIntString("label.prodpriceselltaxm")); // NOI18N + jLabel16.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jPriceSellTax.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceSellTax.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jPriceSellTax.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLabel4.setText(AppLocal.getIntString("label.prodpricesell")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jPriceSell.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceSell.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jPriceSell.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel19.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel19.setText(bundle.getString("label.margin")); // NOI18N + jLabel19.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jmargin.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jmargin.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jmargin.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR)); + m_jmargin.setEnabled(false); + m_jmargin.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.prodpricebuym")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jPriceBuy.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceBuy.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jPriceBuy.setText("0"); + m_jPriceBuy.setPreferredSize(new java.awt.Dimension(200, 30)); + + m_jVerpatrib.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jVerpatrib.setText(bundle.getString("label.mandatory")); // NOI18N + m_jVerpatrib.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); + m_jVerpatrib.setPreferredSize(new java.awt.Dimension(49, 30)); + m_jVerpatrib.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + none(evt); + } + }); + + m_jGrossProfit.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jGrossProfit.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jGrossProfit.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + m_jGrossProfit.setEnabled(false); + m_jGrossProfit.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel22.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel22.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel22.setText(bundle.getString("label.grossprofit")); // NOI18N + jLabel22.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + jLabel22.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel26.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel26.setText(AppLocal.getIntString("label.UOM")); // NOI18N + jLabel26.setPreferredSize(new java.awt.Dimension(70, 30)); + + m_jUom.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jUom.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel17.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel17.setText(AppLocal.getIntString("label.prodsupplier")); // NOI18N + jLabel17.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jSupplier.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSupplier.setPreferredSize(new java.awt.Dimension(200, 30)); + + jBtnSupplier.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jBtnSupplier.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer_add_sml.png"))); // NOI18N + jBtnSupplier.setText(bundle.getString("label.supplier")); // NOI18N + jBtnSupplier.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnSupplierActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(10, 10, 10) + .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(m_jPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jGrossProfit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(m_jUom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(m_jmargin, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addGap(115, 115, 115)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(m_jAtt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(m_jVerpatrib, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jTax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(m_jPriceSellTax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jLabel26, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, Short.MAX_VALUE))) + .addGap(50, 50, 50)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jRef, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCodetype, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jSupplier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jBtnSupplier))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jRef, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCodetype, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jAtt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jVerpatrib, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jTax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jPriceSellTax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel26, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jUom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jGrossProfit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jmargin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSupplier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jBtnSupplier)) + .addGap(14, 14, 14)) + ); + + jTabbedPane1.addTab(AppLocal.getIntString("label.prodgeneral"), jPanel1); // NOI18N + + jPanel2.setToolTipText(bundle.getString("tooltip.product.stock.tab")); // NOI18N + jPanel2.setPreferredSize(new java.awt.Dimension(0, 0)); + + jLabel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + jLabel9.setText(AppLocal.getIntString("label.prodstockcost")); // NOI18N + jLabel9.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jstockcost.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jstockcost.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jstockcost.setPreferredSize(new java.awt.Dimension(85, 30)); + + jLabel10.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + jLabel10.setText(AppLocal.getIntString("label.prodstockvol")); // NOI18N + jLabel10.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jstockvolume.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jstockvolume.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jstockvolume.setPreferredSize(new java.awt.Dimension(85, 30)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.prodincatalog")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(130, 30)); + + m_jInCatalog.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + m_jInCatalog.setSelected(true); + m_jInCatalog.setPreferredSize(new java.awt.Dimension(30, 30)); + m_jInCatalog.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jInCatalogActionPerformed(evt); + } + }); + + jLabel18.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel18.setText(AppLocal.getIntString("label.prodorder")); // NOI18N + jLabel18.setPreferredSize(new java.awt.Dimension(130, 30)); + + m_jCatalogOrder.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCatalogOrder.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jCatalogOrder.setPreferredSize(new java.awt.Dimension(50, 30)); + + jLabel15.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel15.setText(bundle.getString("label.service")); // NOI18N + jLabel15.setPreferredSize(new java.awt.Dimension(130, 30)); + + m_jService.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + m_jService.setToolTipText("A Service Item will not be deducted from the Inventory"); + m_jService.setPreferredSize(new java.awt.Dimension(30, 30)); + + jLabel11.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel11.setText(AppLocal.getIntString("label.prodaux")); // NOI18N + jLabel11.setPreferredSize(new java.awt.Dimension(130, 30)); + + m_jComment.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + m_jComment.setPreferredSize(new java.awt.Dimension(30, 30)); + + jLabel12.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel12.setText(AppLocal.getIntString("label.prodscale")); // NOI18N + jLabel12.setPreferredSize(new java.awt.Dimension(130, 30)); + + m_jScale.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + m_jScale.setPreferredSize(new java.awt.Dimension(30, 30)); + + m_jConstant.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + m_jConstant.setPreferredSize(new java.awt.Dimension(30, 30)); + + jLabel14.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel14.setText(bundle.getString("label.prodconstant")); // NOI18N + jLabel14.setPreferredSize(new java.awt.Dimension(130, 30)); + + jLabel20.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel20.setText(bundle.getString("label.variableprice")); // NOI18N + jLabel20.setPreferredSize(new java.awt.Dimension(130, 30)); + + m_jVprice.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + m_jVprice.setPreferredSize(new java.awt.Dimension(30, 30)); + + jLabel33.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel33.setText(bundle.getString("label.warranty")); // NOI18N + jLabel33.setToolTipText(bundle.getString("label.warranty")); // NOI18N + jLabel33.setPreferredSize(new java.awt.Dimension(130, 30)); + + m_jCheckWarrantyReceipt.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCheckWarrantyReceipt.setText(bundle.getString("label.productreceipt")); // NOI18N + m_jCheckWarrantyReceipt.setPreferredSize(new java.awt.Dimension(30, 30)); + + jLabel23.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel23.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel23.setText(bundle.getString("label.prodminmax")); // NOI18N + jLabel23.setVerticalAlignment(javax.swing.SwingConstants.TOP); + jLabel23.setPreferredSize(new java.awt.Dimension(531, 20)); + + webLabel1.setText(bundle.getString("label.printto")); // NOI18N + webLabel1.setToolTipText(bundle.getString("tooltip.printto")); // NOI18N + webLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + webLabel1.setPreferredSize(new java.awt.Dimension(130, 30)); + + m_jPrintTo.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPrintTo.setModel(new javax.swing.DefaultComboBoxModel(new String[]{"0", "1", "2", "3", "4", "5", "6"})); + m_jPrintTo.setPreferredSize(new java.awt.Dimension(50, 30)); + + jBtnShowTrans.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jBtnShowTrans.setText(bundle.getString("button.ProductStock")); // NOI18N + jBtnShowTrans.setToolTipText(""); + jBtnShowTrans.setPreferredSize(new java.awt.Dimension(140, 25)); + jBtnShowTrans.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnShowTransActionPerformed(evt); + } + }); + + jScrollPane2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + + jTableProductStock.setModel(new javax.swing.table.DefaultTableModel( + new Object[][]{ + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null} + }, + new String[]{ + "Location", "Current", "Minimum", "Maximum" + } + )); + jTableProductStock.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTableProductStock.setRowHeight(25); + jScrollPane2.setViewportView(jTableProductStock); + + m_jPrintKB.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + + m_jSendStatus.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + + m_jStockUnits.setEditable(false); + m_jStockUnits.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jStockUnits.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jStockUnits.setText("0"); + m_jStockUnits.setBorder(null); + + jLblDate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblDate.setText(bundle.getString("label.proddate")); // NOI18N + jLblDate.setPreferredSize(new java.awt.Dimension(130, 30)); + + m_jbtndate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/date.png"))); // NOI18N + m_jbtndate.setToolTipText("Open Calendar"); + m_jbtndate.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtndateActionPerformed(evt); + } + }); + + m_jdate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jdate.setPreferredSize(new java.awt.Dimension(160, 30)); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jCatalogOrder, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jInCatalog, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(webLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jPrintTo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jConstant, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(m_jstockvolume, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jstockcost, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 0, 0)) + .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel33, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(m_jService, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCheckWarrantyReceipt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jComment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jVprice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(m_jPrintKB, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jSendStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jStockUnits, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(18, 18, 18) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addComponent(jLblDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jbtndate, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addComponent(m_jdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jBtnShowTrans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap()) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jstockcost, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jConstant, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jstockvolume, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jInCatalog, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jCatalogOrder, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(webLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jPrintTo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jBtnShowTrans, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jbtndate, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jService, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel33, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCheckWarrantyReceipt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jComment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jVprice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(m_jPrintKB, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSendStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jStockUnits, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGap(42, 42, 42)) + ); + + m_jService.getAccessibleContext().setAccessibleDescription("null"); + + jTabbedPane1.addTab(AppLocal.getIntString("label.prodstock"), jPanel2); // NOI18N + + jPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel3.setToolTipText(bundle.getString("tooltip.product.properties.tab")); // NOI18N + jPanel3.setPreferredSize(new java.awt.Dimension(0, 0)); + jPanel3.setLayout(new java.awt.BorderLayout()); + + jScrollPane1.setPreferredSize(new java.awt.Dimension(680, 400)); + + txtAttributes.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N + txtAttributes.setLineWrap(true); + txtAttributes.setWrapStyleWord(true); + txtAttributes.setPreferredSize(new java.awt.Dimension(580, 300)); + jScrollPane1.setViewportView(txtAttributes); + + jPanel3.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + jBtnXml.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jBtnXml.setText(bundle.getString("button.injectxml")); // NOI18N + jBtnXml.setToolTipText(bundle.getString("tooltip.xmlheader")); // NOI18N + jBtnXml.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnXmlActionPerformed(evt); + } + }); + jPanel3.add(jBtnXml, java.awt.BorderLayout.PAGE_START); + + jTabbedPane1.addTab(AppLocal.getIntString("label.properties"), jPanel3); // NOI18N + + jPanel6.setToolTipText(bundle.getString("tooltip.product.image.tab")); // NOI18N + jPanel6.setPreferredSize(new java.awt.Dimension(0, 0)); + + jLabel34.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel34.setText(bundle.getString("label.imagesize")); // NOI18N + jLabel34.setPreferredSize(new java.awt.Dimension(500, 30)); + + javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); + jPanel6.setLayout(jPanel6Layout); + jPanel6Layout.setHorizontalGroup( + jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() + .addComponent(jLabel34, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(115, Short.MAX_VALUE)) + .addGroup(jPanel6Layout.createSequentialGroup() + .addComponent(m_jImage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(243, 243, 243)))) + ); + jPanel6Layout.setVerticalGroup( + jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() + .addContainerGap() + .addComponent(m_jImage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel34, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + jTabbedPane1.addTab(bundle.getString("label.image"), jPanel6); // NOI18N + + jPanel4.setToolTipText(bundle.getString("tooltip.product.button.tab")); // NOI18N + jPanel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel4.setPreferredSize(new java.awt.Dimension(0, 0)); + + jLabel28.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel28.setText(bundle.getString("label.prodbuttonhtml")); // NOI18N + jLabel28.setPreferredSize(new java.awt.Dimension(250, 30)); + + jButtonHTML.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jButtonHTML.setText(bundle.getString("button.htmltest")); // NOI18N + jButtonHTML.setMargin(new java.awt.Insets(1, 1, 1, 1)); + jButtonHTML.setMaximumSize(new java.awt.Dimension(96, 72)); + jButtonHTML.setMinimumSize(new java.awt.Dimension(96, 72)); + jButtonHTML.setPreferredSize(new java.awt.Dimension(96, 72)); + jButtonHTML.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButtonHTMLActionPerformed(evt); + } + }); + + jLabel21.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel21.setText(bundle.getString("label.texttip")); // NOI18N + jLabel21.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jTextTip.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTextTip.setPreferredSize(new java.awt.Dimension(400, 30)); + + m_jDisplay.setColumns(20); + m_jDisplay.setLineWrap(true); + m_jDisplay.setRows(4); + m_jDisplay.setWrapStyleWord(true); + m_jDisplay.setPreferredSize(new java.awt.Dimension(160, 100)); + jScrollPane3.setViewportView(m_jDisplay); + + jBtnBreak.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jBtnBreak.setText(bundle.getString("button.prodhtmldisplayBreak")); // NOI18N + jBtnBreak.setToolTipText("<html><center><h4>Inserts a Line Break<br> (a new line) for the button text"); + jBtnBreak.setPreferredSize(new java.awt.Dimension(70, 35)); + jBtnBreak.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnBreakActionPerformed(evt); + } + }); + + jBtnColour.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jBtnColour.setForeground(new java.awt.Color(0, 204, 255)); + jBtnColour.setText(bundle.getString("button.prodhtmldisplayColour")); // NOI18N + jBtnColour.setToolTipText("<html><center><h4>Set the colour <br>for the button text"); + jBtnColour.setPreferredSize(new java.awt.Dimension(70, 35)); + jBtnColour.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnColourActionPerformed(evt); + } + }); + + jBtnLarge.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jBtnLarge.setText(bundle.getString("button.prodhtmldisplayLarge")); // NOI18N + jBtnLarge.setToolTipText("<html><center><h4>Set the button<br> text to Large"); + jBtnLarge.setPreferredSize(new java.awt.Dimension(70, 35)); + jBtnLarge.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnLargeActionPerformed(evt); + } + }); + + jBtnSmall.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jBtnSmall.setText(bundle.getString("button.prodhtmldisplaySmall")); // NOI18N + jBtnSmall.setToolTipText("<html><center><h4>Set the button<br>text to Small"); + jBtnSmall.setPreferredSize(new java.awt.Dimension(70, 35)); + jBtnSmall.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnSmallActionPerformed(evt); + } + }); + + jBtnBold.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jBtnBold.setText(bundle.getString("button.prodhtmldisplayBold")); // NOI18N + jBtnBold.setToolTipText("<html><center><h4>Set the button<br> text to Italic"); + jBtnBold.setPreferredSize(new java.awt.Dimension(70, 35)); + jBtnBold.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnBoldActionPerformed(evt); + } + }); + + jBtnItalic.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jBtnItalic.setText(bundle.getString("button.prodhtmldisplayItalic")); // NOI18N + jBtnItalic.setToolTipText("<html><center><h4>Set the button<br> text to Italic"); + jBtnItalic.setPreferredSize(new java.awt.Dimension(70, 35)); + jBtnItalic.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnItalicActionPerformed(evt); + } + }); + + jBtnImage.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jBtnImage.setText(bundle.getString("button.prodhtmldisplayImage")); // NOI18N + jBtnImage.setToolTipText("<html><center><h4>Insert image from<br>local disk or internet URL"); + jBtnImage.setPreferredSize(new java.awt.Dimension(70, 35)); + jBtnImage.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnImageActionPerformed(evt); + } + }); + + jBtnReset.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jBtnReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jBtnReset.setText(bundle.getString("button.prodhtmldisplayReset")); // NOI18N + jBtnReset.setPreferredSize(new java.awt.Dimension(100, 35)); + jBtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnResetActionPerformed(evt); + } + }); + + jBtnStyle.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jBtnStyle.setText(bundle.getString("button.prodhtmldisplayStyle")); // NOI18N + jBtnStyle.setToolTipText("<html><center><h4>Insert <style> tag to change<br>button background colour"); + jBtnStyle.setPreferredSize(new java.awt.Dimension(70, 35)); + jBtnStyle.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnStyleActionPerformed(evt); + } + }); + + colourChooser.setToolTipText(bundle.getString("tooltip.prodhtmldisplayColourChooser")); // NOI18N + colourChooser.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + colourChooserActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(jLabel28, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(272, 272, 272) + .addComponent(jBtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(m_jTextTip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(jBtnStyle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jBtnBreak, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(jBtnColour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jBtnLarge, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jBtnSmall, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel4Layout.createSequentialGroup() + .addGap(13, 13, 13) + .addComponent(colourChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(49, 49, 49) + .addComponent(jButtonHTML, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jBtnBold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jBtnItalic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jBtnImage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel28, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jBtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jBtnSmall, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jBtnColour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jBtnLarge, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jBtnBold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jBtnItalic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jBtnImage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jBtnStyle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jBtnBreak, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jButtonHTML, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(colourChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jTextTip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(58, Short.MAX_VALUE)) + ); + + jTabbedPane1.addTab(AppLocal.getIntString("label.button"), jPanel4); // NOI18N + + add(jTabbedPane1); + jTabbedPane1.setBounds(10, 10, 630, 420); + }// </editor-fold>//GEN-END:initComponents + + private void jButtonHTMLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonHTMLActionPerformed + setButtonHTML(); + }//GEN-LAST:event_jButtonHTMLActionPerformed + + private void none(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_none + + }//GEN-LAST:event_none + + private void m_jNameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_m_jNameFocusLost + setDisplay(btn); +// if (m_jName.getText().contains("&")) { +// JOptionPane.showMessageDialog(null, +// AppLocal.getIntString("message.ampersand")); +// } + }//GEN-LAST:event_m_jNameFocusLost + + private void m_jRefFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_m_jRefFocusLost + setCode(); + }//GEN-LAST:event_m_jRefFocusLost + + private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel1MouseClicked + + if (evt.getClickCount() == 2) { + String uuidString = m_oId.toString(); + StringSelection stringSelection = new StringSelection(uuidString); + Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); + clpbrd.setContents(stringSelection, null); + + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.uuidcopy")); + } + }//GEN-LAST:event_jLabel1MouseClicked + + private void jBtnXmlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnXmlActionPerformed + txtAttributes.setText( + "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?> \n" + + "<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">\n" + + "<properties>\n" + + " <entry key=\"identifier\">value</entry>\n" + + "</properties>"); + }//GEN-LAST:event_jBtnXmlActionPerformed + + private void jBtnSmallActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnSmallActionPerformed + btn = 4; + setDisplay(btn); + }//GEN-LAST:event_jBtnSmallActionPerformed + + private void jBtnBreakActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnBreakActionPerformed + btn = 1; + setDisplay(btn); + }//GEN-LAST:event_jBtnBreakActionPerformed + + private void jBtnColourActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnColourActionPerformed + btn = 2; + setDisplay(btn); + }//GEN-LAST:event_jBtnColourActionPerformed + + private void jBtnLargeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnLargeActionPerformed + btn = 3; + setDisplay(btn); + }//GEN-LAST:event_jBtnLargeActionPerformed + + private void jBtnBoldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnBoldActionPerformed + btn = 5; + setDisplay(btn); + }//GEN-LAST:event_jBtnBoldActionPerformed + + private void jBtnItalicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnItalicActionPerformed + btn = 6; + setDisplay(btn); + }//GEN-LAST:event_jBtnItalicActionPerformed + + private void jBtnImageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnImageActionPerformed + btn = 7; + setDisplay(btn); + }//GEN-LAST:event_jBtnImageActionPerformed + + private void jBtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnResetActionPerformed + btn = 8; + setDisplay(btn); + }//GEN-LAST:event_jBtnResetActionPerformed + + private void jBtnStyleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnStyleActionPerformed + btn = 9; + setDisplay(btn); + }//GEN-LAST:event_jBtnStyleActionPerformed + + private void jBtnSupplierActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnSupplierActionPerformed + JDialogNewSupplier dialog = JDialogNewSupplier.getDialog(this, appView); + dialog.setVisible(true); + + if (dialog.getSelectedSupplier() != null) { + try { + m_SuppliersModel = new ComboBoxValModel(m_sentsuppliers.list()); + m_jSupplier.setModel(m_SuppliersModel); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + }//GEN-LAST:event_jBtnSupplierActionPerformed + + private void colourChooserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colourChooserActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_colourChooserActionPerformed + + private void m_jCodeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_m_jCodeFocusLost + if (m_jCode.getText().length() < 8) { + m_jCodetype.setSelectedIndex(2); + } + }//GEN-LAST:event_m_jCodeFocusLost + + private void m_jbtndateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtndateActionPerformed + + Date date; + try { + date = (Date) Formats.TIMESTAMP.parseValue(m_jdate.getText()); + } catch (BasicException e) { + date = null; + } + date = JCalendarDialog.showCalendarTime(this, date); + if (date != null) { + m_jdate.setText(Formats.TIMESTAMP.formatValue(date)); + } + }//GEN-LAST:event_m_jbtndateActionPerformed + + private void jBtnShowTransActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnShowTransActionPerformed + String pId = m_oId.toString(); + if (pId != null) { + stockModel = new StockTableModel(getProductOfName(pId)); + jTableProductStock.setModel(stockModel); + if (stockModel.getRowCount() > 0) { + jTableProductStock.setVisible(true); + } else { + jTableProductStock.setVisible(false); + JOptionPane.showMessageDialog(null, + "No Stock Locations for this Product", "Locations", JOptionPane.INFORMATION_MESSAGE); + } + resetTranxTable(); + } + }//GEN-LAST:event_jBtnShowTransActionPerformed + + private void m_jInCatalogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jInCatalogActionPerformed + + if (m_jInCatalog.isSelected()) { + m_jCatalogOrder.setEnabled(true); + } else { + m_jCatalogOrder.setEnabled(false); + m_jCatalogOrder.setText(null); + } + }//GEN-LAST:event_m_jInCatalogActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private com.alee.extended.colorchooser.WebColorPicker colourChooser; + private javax.swing.JButton jBtnBold; + private javax.swing.JButton jBtnBreak; + private javax.swing.JButton jBtnColour; + private javax.swing.JButton jBtnImage; + private javax.swing.JButton jBtnItalic; + private javax.swing.JButton jBtnLarge; + private javax.swing.JButton jBtnReset; + private javax.swing.JButton jBtnShowTrans; + private javax.swing.JButton jBtnSmall; + private javax.swing.JButton jBtnStyle; + private javax.swing.JButton jBtnSupplier; + private javax.swing.JButton jBtnXml; + private javax.swing.JButton jButtonHTML; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel15; + private javax.swing.JLabel jLabel16; + private javax.swing.JLabel jLabel17; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel19; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel20; + private javax.swing.JLabel jLabel21; + private javax.swing.JLabel jLabel22; + private javax.swing.JLabel jLabel23; + private javax.swing.JLabel jLabel26; + private javax.swing.JLabel jLabel28; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel33; + private javax.swing.JLabel jLabel34; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JLabel jLblDate; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel6; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JScrollPane jScrollPane3; + private javax.swing.JTabbedPane jTabbedPane1; + private com.alee.laf.table.WebTable jTableProductStock; + private javax.swing.JComboBox m_jAtt; + private javax.swing.JTextField m_jCatalogOrder; + private javax.swing.JComboBox m_jCategory; + private javax.swing.JCheckBox m_jCheckWarrantyReceipt; + private javax.swing.JTextField m_jCode; + private javax.swing.JComboBox m_jCodetype; + private javax.swing.JCheckBox m_jComment; + private javax.swing.JCheckBox m_jConstant; + private com.alee.laf.text.WebTextArea m_jDisplay; + private javax.swing.JTextField m_jGrossProfit; + private com.unicenta.data.gui.JImageEditor m_jImage; + private javax.swing.JCheckBox m_jInCatalog; + private javax.swing.JTextField m_jName; + private javax.swing.JTextField m_jPriceBuy; + private javax.swing.JTextField m_jPriceSell; + private javax.swing.JTextField m_jPriceSellTax; + private javax.swing.JCheckBox m_jPrintKB; + private javax.swing.JComboBox m_jPrintTo; + private javax.swing.JTextField m_jRef; + private javax.swing.JCheckBox m_jScale; + private javax.swing.JCheckBox m_jSendStatus; + private javax.swing.JCheckBox m_jService; + private javax.swing.JTextField m_jStockUnits; + private javax.swing.JComboBox m_jSupplier; + private javax.swing.JComboBox m_jTax; + private javax.swing.JTextField m_jTextTip; + private javax.swing.JLabel m_jTitle; + private javax.swing.JComboBox m_jUom; + private javax.swing.JCheckBox m_jVerpatrib; + private javax.swing.JCheckBox m_jVprice; + private javax.swing.JButton m_jbtndate; + private javax.swing.JTextField m_jdate; + private javax.swing.JTextField m_jmargin; + private javax.swing.JTextField m_jstockcost; + private javax.swing.JTextField m_jstockvolume; + private javax.swing.JTextArea txtAttributes; + private com.alee.laf.label.WebLabel webLabel1; + // End of variables declaration//GEN-END:variables + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/inventory/ProductsPanel.java b/src/main/java/com/unicenta/pos/inventory/ProductsPanel.java new file mode 100644 index 0000000..a288dc0 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/ProductsPanel.java @@ -0,0 +1,144 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.EditorListener; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.panels.JPanelTable2; +import com.unicenta.pos.ticket.ProductFilter; + +import java.awt.Component; +import javax.swing.JButton; + +/** + * + * @author JG uniCenta + * + */ +public class ProductsPanel extends JPanelTable2 implements EditorListener { + + private ProductsEditor jeditor; + private ProductFilter jproductfilter; + + private DataLogicSales m_dlSales = null; + + public ProductsPanel() { + } + + /** + * + */ + @Override + protected void init() { + m_dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + jproductfilter = new ProductFilter(); + jproductfilter.init(app); + + row = m_dlSales.getProductsRow(); + + lpr = new ListProviderCreator(m_dlSales.getProductCatQBF(), jproductfilter); + + spr = new SaveProvider( + m_dlSales.getProductCatUpdate(), + m_dlSales.getProductCatInsert(), + m_dlSales.getProductCatDelete()); + + jeditor = new ProductsEditor(app, dirty); + } + + /** + * + * @return value + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return value + */ + @Override + public Component getFilter() { + return jproductfilter.getComponent(); + } + + /** + * + * @return btnScanPal + */ + @Override + public Component getToolbarExtras() { + + JButton btnScanPal = new JButton(); + btnScanPal.setText("ScanPal"); + btnScanPal.setVisible(app.getDeviceScanner() != null); + btnScanPal.addActionListener(new java.awt.event.ActionListener() { + @Override + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnScanPalActionPerformed(evt); + } + }); + + return btnScanPal; + } + + private void btnScanPalActionPerformed(java.awt.event.ActionEvent evt) { + + JDlgUploadProducts.showMessage(this, app.getDeviceScanner(), bd); + } + + /** + * + * @return value + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Products"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + jeditor.activate(); + jproductfilter.activate(); + + super.activate(); + } + + /** + * + * @param value + */ + @Override + public void updateValue(Object value) { + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/inventory/ProductsWarehouseEditor.form b/src/main/java/com/unicenta/pos/inventory/ProductsWarehouseEditor.form new file mode 100644 index 0000000..25705cb --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/ProductsWarehouseEditor.form @@ -0,0 +1,157 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jMinimum" min="-2" pref="80" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jMaximum" min="-2" pref="80" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jQuantity" min="-2" pref="80" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jTitle" min="-2" pref="314" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jTitle" min="-2" pref="30" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jQuantity" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jMinimum" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jMaximum" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="m_jTitle"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.units" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jQuantity"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.minimum" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jMinimum"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.maximum" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jMaximum"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/ProductsWarehouseEditor.java b/src/main/java/com/unicenta/pos/inventory/ProductsWarehouseEditor.java new file mode 100644 index 0000000..4b9896f --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/ProductsWarehouseEditor.java @@ -0,0 +1,271 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-130 + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; + +/** + * + * @author adrianromero + */ +public class ProductsWarehouseEditor extends javax.swing.JPanel implements EditorRecord { + + /** + * + */ + public Object id; + public Object prodid; + public Object prodref; + public Object prodname; + public Object location; + + /** Creates new form ProductsWarehouseEditor + * @param dirty */ + public ProductsWarehouseEditor(DirtyManager dirty) { + initComponents(); + + m_jMinimum.getDocument().addDocumentListener(dirty); + m_jMaximum.getDocument().addDocumentListener(dirty); + } + + public ProductsWarehouseEditor() { + throw new UnsupportedOperationException("Not supported yet."); + } + + /** + * + */ + @Override + public void writeValueEOF() { + m_jTitle.setText(AppLocal.getIntString("label.recordeof")); + id = null; + prodid = null; + prodref = null; + prodname = null; + location = null; + m_jQuantity.setText(null); + m_jMinimum.setText(null); + m_jMaximum.setText(null); + m_jMinimum.setEnabled(false); + m_jMaximum.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + m_jTitle.setText(AppLocal.getIntString("label.recordnew")); + id = null; + prodid = null; + prodref = null; + prodname = null; + location = null; + m_jQuantity.setText(null); + m_jMinimum.setText(null); + m_jMaximum.setText(null); + m_jMinimum.setEnabled(true); + m_jMaximum.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + Object[] myprod = (Object[]) value; + id = myprod[0]; + prodid = myprod[1]; + prodref = myprod[2]; + prodname = myprod[3]; + location = myprod[4]; + m_jTitle.setText(Formats.STRING.formatValue(myprod[2]) + " - " + Formats.STRING.formatValue(myprod[3])); + m_jQuantity.setText(Formats.DOUBLE.formatValue(myprod[7])); + m_jMinimum.setText(Formats.DOUBLE.formatValue(myprod[5])); + m_jMaximum.setText(Formats.DOUBLE.formatValue(myprod[6])); + m_jMinimum.setEnabled(true); + m_jMaximum.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + Object[] myprod = (Object[]) value; + id = myprod[0]; + prodid = myprod[1]; + prodref = myprod[2]; + prodname = myprod[3]; + location = myprod[4]; + m_jTitle.setText(Formats.STRING.formatValue(myprod[2]) + " - " + Formats.STRING.formatValue(myprod[3])); + m_jQuantity.setText(Formats.DOUBLE.formatValue(myprod[7])); + m_jMinimum.setText(Formats.DOUBLE.formatValue(myprod[5])); + m_jMaximum.setText(Formats.DOUBLE.formatValue(myprod[6])); + m_jMinimum.setEnabled(false); + m_jMaximum.setEnabled(false); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + return new Object[] { + id, + prodid, + prodref, + prodname, + location, + Formats.DOUBLE.parseValue(m_jMinimum.getText()), + Formats.DOUBLE.parseValue(m_jMaximum.getText()), + Formats.DOUBLE.parseValue(m_jQuantity.getText()) + }; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + */ + @Override + public void refresh() { + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jTitle = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + m_jQuantity = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + m_jMinimum = new javax.swing.JTextField(); + jLabel5 = new javax.swing.JLabel(); + m_jMaximum = new javax.swing.JTextField(); + + m_jTitle.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTitle.setPreferredSize(new java.awt.Dimension(300, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.units")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jQuantity.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jQuantity.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jQuantity.setEnabled(false); + m_jQuantity.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.minimum")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jMinimum.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jMinimum.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jMinimum.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.maximum")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jMaximum.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jMaximum.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jMaximum.setPreferredSize(new java.awt.Dimension(0, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jMinimum, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jMaximum, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 314, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(m_jTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jMinimum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jMaximum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JTextField m_jMaximum; + private javax.swing.JTextField m_jMinimum; + private javax.swing.JTextField m_jQuantity; + private javax.swing.JLabel m_jTitle; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/ProductsWarehousePanel.java b/src/main/java/com/unicenta/pos/inventory/ProductsWarehousePanel.java new file mode 100644 index 0000000..1ae90e6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/ProductsWarehousePanel.java @@ -0,0 +1,173 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.*; +import com.unicenta.data.model.Field; +import com.unicenta.data.model.Row; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.JPanelTable2; +import com.unicenta.pos.reports.JParamsLocation; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.UUID; + +/** + * + * @author adrianromero + */ +public class ProductsWarehousePanel extends JPanelTable2 { + + private JParamsLocation m_paramslocation; + private ProductsWarehouseEditor jeditor; + + /** Creates a new instance of ProductsWarehousePanel */ + public ProductsWarehousePanel() { + } + + /** + * + */ + @Override + protected void init() { + + m_paramslocation = new JParamsLocation(); + m_paramslocation.init(app); + m_paramslocation.addActionListener(new ReloadActionListener()); + + row = new Row( + new Field("ID", Datas.STRING, Formats.STRING), + new Field("PRODUCT_ID", Datas.STRING, Formats.STRING), + new Field(AppLocal.getIntString("label.prodref"), Datas.STRING, Formats.STRING, true, true, true), + new Field(AppLocal.getIntString("label.prodname"), Datas.STRING, Formats.STRING, true, true, true), + new Field("LOCATION", Datas.STRING, Formats.STRING), + new Field("STOCKSECURITY", Datas.DOUBLE, Formats.DOUBLE), + new Field("STOCKMAXIMUM", Datas.DOUBLE, Formats.DOUBLE), + new Field("UNITS", Datas.DOUBLE, Formats.DOUBLE) + ); + + lpr = new ListProviderCreator(new PreparedSentence(app.getSession(), + "SELECT L.ID, P.ID, P.REFERENCE, P.NAME," + + "L.STOCKSECURITY, L.STOCKMAXIMUM, COALESCE(S.SUMUNITS, 0) " + + "FROM products P " + + "LEFT OUTER JOIN (SELECT ID, PRODUCT, LOCATION, STOCKSECURITY, STOCKMAXIMUM " + + "FROM stocklevel WHERE LOCATION = ?) L ON P.ID = L.PRODUCT " + + "LEFT OUTER JOIN (SELECT PRODUCT, SUM(UNITS) AS SUMUNITS " + + "FROM stockcurrent WHERE LOCATION = ? GROUP BY PRODUCT) S ON P.ID = S.PRODUCT " + + "ORDER BY P.NAME", + new SerializerWriteBasicExt(new Datas[] {Datas.OBJECT, Datas.STRING}, new int[]{1, 1}), + new WarehouseSerializerRead() + ), + m_paramslocation); + + SentenceExec updatesent = new SentenceExecTransaction(app.getSession()) { + @Override + public int execInTransaction(Object params) throws BasicException { + Object[] values = (Object[]) params; + if (values[0] == null) { + // INSERT + values[0] = UUID.randomUUID().toString(); + return new PreparedSentence(app.getSession() + , "INSERT INTO stocklevel (ID, LOCATION, PRODUCT, STOCKSECURITY, STOCKMAXIMUM) VALUES (?, ?, ?, ?, ?)" + , new SerializerWriteBasicExt(row.getDatas(), new int[] {0, 4, 1, 5, 6})).exec(params); + } else { + // UPDATE + return new PreparedSentence(app.getSession() + , "UPDATE stocklevel SET STOCKSECURITY = ?, STOCKMAXIMUM = ? WHERE ID = ?" + , new SerializerWriteBasicExt(row.getDatas(), new int[] {5, 6, 0})).exec(params); + } + } + }; + + spr = new SaveProvider(updatesent, null, null); + + jeditor = new ProductsWarehouseEditor(dirty); + } + + /** + * + * @return + */ + @Override + public Component getFilter() { + return m_paramslocation.getComponent(); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + m_paramslocation.activate(); + super.activate(); + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.ProductsWarehouse"); + } + + private class ReloadActionListener implements ActionListener { + @Override + public void actionPerformed(ActionEvent e) { + try { + ProductsWarehousePanel.this.bd.actionLoad(); + } catch (BasicException w) { + } + } + } + + private class WarehouseSerializerRead implements SerializerRead { + @Override + public Object readValues(DataRead dr) throws BasicException { + return new Object[] { + dr.getString(1), + dr.getString(2), + dr.getString(3), + dr.getString(4), + ((Object[]) m_paramslocation.createValue())[1], + dr.getDouble(5), + dr.getDouble(6), + dr.getDouble(7) + }; + } + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/StockDiaryEditor.form b/src/main/java/com/unicenta/pos/inventory/StockDiaryEditor.form new file mode 100644 index 0000000..dbaa681 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/StockDiaryEditor.form @@ -0,0 +1,665 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[550, 250]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1000, 550]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,38,0,0,3,-24"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[2147483647, 2147483647]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[780, 260]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 600]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="First"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLblDate" min="-2" pref="110" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jdate" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jbtndate" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jLblReason" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLblLocation" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="m_jreason" alignment="0" max="-2" attributes="0"/> + <Component id="m_jLocation" max="-2" attributes="0"/> + </Group> + </Group> + <Component id="jLblMoveTo" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLblLocation1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="m_jLocationDes" alignment="0" max="-2" attributes="0"/> + <Component id="m_jSupplier" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLblAtt" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jattributes" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jEditAttributes" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLBCode" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jcodebar" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jEnter" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLblUnits" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_junits" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLblPrice" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jprice" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblName" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLblRef" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jreference" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="114" pref="114" max="-2" attributes="0"/> + <Component id="jproduct" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jEnter1" min="-2" max="-2" attributes="0"/> + <Component id="jEditProduct" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="catcontainer" pref="612" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jdate" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblDate" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="m_jbtndate" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jreason" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblReason" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jLocation" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblLocation" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLblMoveTo" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jLocationDes" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jSupplier" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblLocation1" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="jLblName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jproduct" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jEditProduct" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="m_jreference" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblRef" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="m_jEnter1" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="jattributes" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblAtt" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jEditAttributes" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jEnter" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jcodebar" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLBCode" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblUnits" min="-2" max="-2" attributes="0"/> + <Component id="m_junits" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblPrice" min="-2" max="-2" attributes="0"/> + <Component id="m_jprice" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace min="0" pref="47" max="32767" attributes="0"/> + </Group> + <Component id="catcontainer" max="32767" attributes="0"/> + </Group> + <EmptySpace pref="48" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLblDate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.stockdate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[23, 20]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[23, 20]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jdate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 20]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="m_jbtndate"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/date.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Open Calendar"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtndateActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLblReason"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.stockreason" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[36, 20]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[36, 20]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jreason"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jreasonActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLblName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 20]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 20]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jproduct"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value=" "/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jproductActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jEditProduct"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/search24.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Search Product List"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jEditProductActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLblLocation"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" value="Location"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jLocation"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLBCode"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbarcode" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 20]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 20]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jcodebar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jcodebarActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jEnter"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/barcode.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Get Barcode"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[54, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[54, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jEnterActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLblRef"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodref" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 20]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 20]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jreference"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jreferenceActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jEnter1"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/products.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Enter Product ID"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jEnter1ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLblAtt"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.attributes" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[48, 20]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[48, 20]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jattributes"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jattributesActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jEditAttributes"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/attributes.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Product Attributes"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[65, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[65, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jEditAttributesActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLblUnits"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.units" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 20]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 20]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_junits"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblPrice"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.price" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jprice"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + </Component> + <Container class="javax.swing.JPanel" name="catcontainer"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[2147483647, 2147483647]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 250]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[600, 0]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleParent" type="javax.accessibility.Accessible" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="jPanel1"/> + </Property> + </AccessibilityProperties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + <Component class="javax.swing.JComboBox" name="m_jLocationDes"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jLocationDesActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLblMoveTo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.moveto" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jSupplier"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblLocation1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.suppliername" replaceFormat="AppLocal.getIntString("button.exit")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/StockDiaryEditor.java b/src/main/java/com/unicenta/pos/inventory/StockDiaryEditor.java new file mode 100644 index 0000000..3964299 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/StockDiaryEditor.java @@ -0,0 +1,993 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.forms.DataLogicSystem; +import com.unicenta.pos.suppliers.DataLogicSuppliers; +import com.unicenta.pos.panels.JProductFinder; +import java.awt.Component; +import com.unicenta.basic.BasicException; +import com.unicenta.beans.DateUtils; +import com.unicenta.beans.JCalendarDialog; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.format.Formats; +import com.unicenta.pos.catalog.CatalogSelector; +import com.unicenta.pos.catalog.JCatalog; +import com.unicenta.pos.printer.TicketParser; +import com.unicenta.pos.sales.JProductAttEdit; +import com.unicenta.pos.ticket.ProductInfoExt; +import java.awt.BorderLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Date; +import java.util.UUID; +import javax.swing.JOptionPane; + +public final class StockDiaryEditor extends javax.swing.JPanel implements EditorRecord { + + private final AppView m_App; + private final DataLogicSystem m_dlSystem; + private final DataLogicSales m_dlSales; + private final DataLogicSuppliers m_dlSuppliers; + private final TicketParser m_TTP; + + private final CatalogSelector m_cat; + private final ComboBoxValModel m_ReasonModel; + + private final SentenceList m_sentlocations; + private ComboBoxValModel m_LocationsModel; + private ComboBoxValModel m_LocationsModelDes; + + private final SentenceList m_sentsuppliers; + private ComboBoxValModel m_SuppliersModel; + private String m_sID; + + private String productid; + private String productref; + private String productcode; + private String productname; + private String attsetid; + private String attsetinstid; + private String attsetinstdesc; + private String sAppUser; + + + private final String user; + + + /** Creates new form StockDiaryEditor + * @param app + * @param dirty */ + public StockDiaryEditor(AppView app, DirtyManager dirty) { + + m_App = app; + m_dlSystem = (DataLogicSystem) m_App.getBean("com.unicenta.pos.forms.DataLogicSystem"); + m_dlSales = (DataLogicSales) m_App.getBean("com.unicenta.pos.forms.DataLogicSales"); + m_dlSuppliers = (DataLogicSuppliers) m_App.getBean("com.unicenta.pos.suppliers.DataLogicSuppliers"); + m_TTP = new TicketParser(m_App.getDeviceTicket(), m_dlSystem); + + initComponents(); + + user = m_App.getAppUserView().getUser().getName(); + m_sentlocations = m_dlSales.getLocationsList(); + m_LocationsModel = new ComboBoxValModel(); + m_LocationsModel = new ComboBoxValModel(); + m_LocationsModelDes = new ComboBoxValModel(); + + m_sentsuppliers = m_dlSuppliers.getSupplierList(); + m_SuppliersModel = new ComboBoxValModel(); + + m_ReasonModel = new ComboBoxValModel(); + m_ReasonModel.add(MovementReason.IN_PURCHASE); + m_ReasonModel.add(MovementReason.IN_REFUND); + m_ReasonModel.add(MovementReason.IN_MOVEMENT); + m_ReasonModel.add(MovementReason.OUT_SALE); + m_ReasonModel.add(MovementReason.OUT_REFUND); + m_ReasonModel.add(MovementReason.OUT_BREAK); + m_ReasonModel.add(MovementReason.OUT_MOVEMENT); + m_ReasonModel.add(MovementReason.OUT_CROSSING); + + m_jreason.setModel(m_ReasonModel); + + m_cat = new JCatalog(m_dlSales); + m_cat.addActionListener(new CatalogListener()); + + catcontainer.add(m_cat.getComponent(), BorderLayout.CENTER); + + m_jdate.getDocument().addDocumentListener(dirty); + m_jreason.addActionListener(dirty); + m_jLocation.addActionListener(dirty); + m_jLocationDes.addActionListener(dirty); + + jproduct.getDocument().addDocumentListener(dirty); + jattributes.getDocument().addDocumentListener(dirty); + m_junits.getDocument().addDocumentListener(dirty); + m_jprice.getDocument().addDocumentListener(dirty); + + m_jSupplier.addActionListener(dirty); + + writeValueEOF(); + } + + /** + * + * @throws BasicException + */ + public void activate() throws BasicException { + m_cat.loadCatalog(); + + java.util.List l = m_sentlocations.list(); + m_LocationsModel = new ComboBoxValModel(m_sentlocations.list()); + m_jLocation.setModel(m_LocationsModel); + m_LocationsModelDes = new ComboBoxValModel(l); + m_jLocationDes.setModel(m_LocationsModelDes); + + java.util.List sl = m_sentsuppliers.list(); + m_SuppliersModel = new ComboBoxValModel(m_sentsuppliers.list()); + m_jSupplier.setModel(m_SuppliersModel); + + } + + /** + * + */ + @Override + public void refresh() { + } + + /** + * + */ + @Override + public void writeValueEOF() { + m_sID = null; + m_jdate.setText(null); + m_ReasonModel.setSelectedKey(null); + m_LocationsModel.setSelectedKey(m_App.getInventoryLocation()); + m_LocationsModelDes.setSelectedKey(m_App.getInventoryLocation()); + m_SuppliersModel.setSelectedKey(null); + + productid = null; + productref = null; + productcode = null; + productname = null; + m_jreference.setText(null); + m_jcodebar.setText(null); + jproduct.setText(null); + attsetid = null; + attsetinstid = null; + attsetinstdesc = null; + jattributes.setText(null); + m_junits.setText(null); + m_jprice.setText(null); + m_jdate.setEnabled(false); + m_jbtndate.setEnabled(false); + m_jreason.setEnabled(false); + m_jreference.setEnabled(false); + m_jEnter1.setEnabled(false); + m_jcodebar.setEnabled(false); + m_jEnter.setEnabled(false); + m_jLocation.setEnabled(false); + jproduct.setEnabled(false); + jEditProduct.setEnabled(false); + jattributes.setEnabled(false); + jEditAttributes.setEnabled(false); + m_junits.setEnabled(false); + m_jprice.setEnabled(false); + m_cat.setComponentEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + m_sID = UUID.randomUUID().toString(); + m_jdate.setText(Formats.TIMESTAMP.formatValue(DateUtils.getTodayMinutes())); + m_ReasonModel.setSelectedItem(MovementReason.IN_PURCHASE); + m_LocationsModel.setSelectedKey(m_App.getInventoryLocation()); + m_LocationsModelDes.setSelectedKey(m_App.getInventoryLocation()); + m_SuppliersModel.setSelectedKey(null); + + productid = null; + productref = null; + productcode = null; + productname = null; + m_jreference.setText(null); + m_jcodebar.setText(null); + jproduct.setText(null); + attsetid = null; + attsetinstid = null; + attsetinstdesc = null; + jattributes.setText(null); + m_jcodebar.setText(null); + m_junits.setText(null); + m_jprice.setText(null); + m_jdate.setEnabled(true); + m_jbtndate.setEnabled(true); + m_jreason.setEnabled(true); + m_jreference.setEnabled(true); + m_jEnter1.setEnabled(true); + m_jcodebar.setEnabled(true); + m_jEnter.setEnabled(true); + m_jLocation.setEnabled(true); + m_jSupplier.setEnabled(true); + jproduct.setEnabled(true); + jEditProduct.setEnabled(true); + jattributes.setEnabled(true); + jEditAttributes.setEnabled(true); + m_junits.setEnabled(true); + m_jprice.setEnabled(true); + m_cat.setComponentEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + Object[] diary = (Object[]) value; + m_sID = (String) diary[0]; + m_jdate.setText(Formats.TIMESTAMP.formatValue(diary[1])); + m_ReasonModel.setSelectedKey(diary[2]); + m_LocationsModel.setSelectedKey(diary[3]); + productid = (String) diary[4]; + attsetinstid = (String) diary[5]; + m_junits.setText(Formats.DOUBLE.formatValue(signum((Double) diary[6], (Integer) diary[2]))); + m_jprice.setText(Formats.CURRENCY.formatValue(diary[7])); + productref = (String) diary[8]; + productcode = (String) diary[9]; + productname =(String) diary[10]; + attsetid = (String) diary[11]; + attsetinstdesc = (String) diary[12]; + m_SuppliersModel.setSelectedKey(diary[13]); + + m_jreference.setText(productref); + m_jcodebar.setText(productcode); + jproduct.setText(productname); + jattributes.setText(attsetinstdesc); + + m_jdate.setEnabled(false); + m_jbtndate.setEnabled(false); + m_jreason.setEnabled(false); + m_jreference.setEnabled(false); + m_jEnter1.setEnabled(false); + m_jcodebar.setEnabled(false); + m_jEnter.setEnabled(false); + m_jLocation.setEnabled(false); + m_jLocationDes.setEnabled(false); + m_jSupplier.setEnabled(false); + jproduct.setEnabled(false); + jEditProduct.setEnabled(false); + jattributes.setEnabled(false); + jEditAttributes.setEnabled(false); + m_junits.setEnabled(false); + m_jprice.setEnabled(false); + m_cat.setComponentEnabled(false); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + Object[] diary = (Object[]) value; + m_sID = (String) diary[0]; + m_jdate.setText(Formats.TIMESTAMP.formatValue(diary[1])); + m_ReasonModel.setSelectedKey(diary[2]); + m_LocationsModel.setSelectedKey(diary[3]); + productid = (String) diary[4]; + attsetinstid = (String) diary[5]; + m_junits.setText(Formats.DOUBLE.formatValue(signum((Double) diary[6], (Integer) diary[2]))); + m_jprice.setText(Formats.CURRENCY.formatValue(diary[7])); + sAppUser = (String) diary[8]; + productref = (String) diary[9]; + productcode = (String) diary[10]; + productname =(String) diary[11]; + attsetid = (String) diary[12]; + attsetinstdesc = (String) diary[13]; + m_SuppliersModel.setSelectedKey(diary[14]); + + m_jreference.setText(productref); + m_jcodebar.setText(productcode); + jproduct.setText(productname); + jattributes.setText(attsetinstdesc); + + m_jdate.setEnabled(false); + m_jbtndate.setEnabled(false); + m_jreason.setEnabled(false); + m_jreference.setEnabled(false); + m_jEnter1.setEnabled(false); + m_jcodebar.setEnabled(false); + m_jEnter.setEnabled(false); + m_jLocation.setEnabled(false); + m_jLocationDes.setEnabled(false); + m_jSupplier.setEnabled(false); + jproduct.setEnabled(true); + jEditProduct.setEnabled(true); + jattributes.setEnabled(false); + jEditAttributes.setEnabled(false); + m_junits.setEnabled(false); + m_jprice.setEnabled(false); + m_cat.setComponentEnabled(false); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + return new Object[] { + m_sID, + Formats.TIMESTAMP.parseValue(m_jdate.getText()), + m_ReasonModel.getSelectedKey(), + m_LocationsModel.getSelectedKey(), + productid, + attsetinstid, + samesignum((Double) Formats.DOUBLE.parseValue(m_junits.getText()), (Integer) m_ReasonModel.getSelectedKey()), + Formats.CURRENCY.parseValue(m_jprice.getText()), + m_App.getAppUserView().getUser().getName(), + productref, + productcode, + productname, + attsetid, + attsetinstdesc, +// m_SuppliersModel.getSelectedKey() + }; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } +// private ProductInfoExt getProduct(String id) { +// try { +// return m_dlSales.getProductInfo(id); +// } catch (BasicException e) { +// return null; +// } +// } + + private Double signum(Double d, Integer i) { + if (d == null || i == null) { + return d; + } else if (i < 0) { + return -d; + } else { + return d; + } + } + + private Double samesignum(Double d, Integer i) { + + if (d == null || i == null) { + return d; + } else if ((i > 0 && d < 0.0) || + (i < 0 && d > 0.0)) { + return -d; + } else { + return d; + } + } + + private void assignProduct(ProductInfoExt prod) { + + if (jproduct.isEnabled()) { + if (prod == null) { + productid = null; + productref = null; + productcode = null; + productname = null; + attsetid = null; + attsetinstid = null; + attsetinstdesc = null; + jproduct.setText(null); + m_jcodebar.setText(null); + m_jreference.setText(null); + jattributes.setText(null); +// m_jSupplier = null; + } else { + productid = prod.getID(); + productref = prod.getReference(); + productcode = prod.getCode(); + productname = prod.toString(); + attsetid = prod.getAttributeSetID(); + attsetinstid = null; + attsetinstdesc = null; + jproduct.setText(productname); + m_jcodebar.setText(productcode); + m_jreference.setText(productref); + jattributes.setText(null); + + // calculo el precio sugerido para la entrada. + MovementReason reason = (MovementReason) m_ReasonModel.getSelectedItem(); + Double dPrice = reason.getPrice(prod.getPriceBuy(), prod.getPriceSell()); + m_jprice.setText(Formats.CURRENCY.formatValue(dPrice)); + } + } + } + + private void assignProductByCode() { + try { + ProductInfoExt oProduct = m_dlSales.getProductInfoByCode(m_jcodebar.getText()); + if (oProduct == null) { + assignProduct(null); + Toolkit.getDefaultToolkit().beep(); + } else { + assignProduct(oProduct); + } + } catch (BasicException eData) { + assignProduct(null); + MessageInf msg = new MessageInf(eData); + msg.show(this); + } + } + + private void assignProductByReference() { + try { + ProductInfoExt oProduct = m_dlSales.getProductInfoByReference(m_jreference.getText()); + if (oProduct == null) { + assignProduct(null); + Toolkit.getDefaultToolkit().beep(); + } else { + assignProduct(oProduct); + } + } catch (BasicException eData) { + assignProduct(null); + MessageInf msg = new MessageInf(eData); + msg.show(this); + } + } + + private class CatalogListener implements ActionListener { + @Override + public void actionPerformed(ActionEvent e) { + assignProduct((ProductInfoExt) e.getSource()); + } + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLblDate = new javax.swing.JLabel(); + m_jdate = new javax.swing.JTextField(); + m_jbtndate = new javax.swing.JButton(); + jLblReason = new javax.swing.JLabel(); + m_jreason = new javax.swing.JComboBox(); + jLblName = new javax.swing.JLabel(); + jproduct = new javax.swing.JTextField(); + jEditProduct = new javax.swing.JButton(); + jLblLocation = new javax.swing.JLabel(); + m_jLocation = new javax.swing.JComboBox(); + jLBCode = new javax.swing.JLabel(); + m_jcodebar = new javax.swing.JTextField(); + m_jEnter = new javax.swing.JButton(); + jLblRef = new javax.swing.JLabel(); + m_jreference = new javax.swing.JTextField(); + m_jEnter1 = new javax.swing.JButton(); + jLblAtt = new javax.swing.JLabel(); + jattributes = new javax.swing.JTextField(); + jEditAttributes = new javax.swing.JButton(); + jLblUnits = new javax.swing.JLabel(); + m_junits = new javax.swing.JTextField(); + jLblPrice = new javax.swing.JLabel(); + m_jprice = new javax.swing.JTextField(); + catcontainer = new javax.swing.JPanel(); + m_jLocationDes = new javax.swing.JComboBox(); + jLblMoveTo = new javax.swing.JLabel(); + m_jSupplier = new javax.swing.JComboBox(); + jLblLocation1 = new javax.swing.JLabel(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setMinimumSize(new java.awt.Dimension(550, 250)); + setPreferredSize(new java.awt.Dimension(1000, 550)); + setLayout(new java.awt.BorderLayout()); + + jPanel1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel1.setMaximumSize(new java.awt.Dimension(2147483647, 2147483647)); + jPanel1.setMinimumSize(new java.awt.Dimension(780, 260)); + jPanel1.setPreferredSize(new java.awt.Dimension(400, 600)); + + jLblDate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblDate.setText(AppLocal.getIntString("label.stockdate")); // NOI18N + jLblDate.setMaximumSize(new java.awt.Dimension(23, 20)); + jLblDate.setMinimumSize(new java.awt.Dimension(23, 20)); + jLblDate.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jdate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jdate.setMinimumSize(new java.awt.Dimension(40, 20)); + m_jdate.setPreferredSize(new java.awt.Dimension(170, 30)); + + m_jbtndate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/date.png"))); // NOI18N + m_jbtndate.setToolTipText("Open Calendar"); + m_jbtndate.setPreferredSize(new java.awt.Dimension(64, 45)); + m_jbtndate.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtndateActionPerformed(evt); + } + }); + + jLblReason.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblReason.setText(AppLocal.getIntString("label.stockreason")); // NOI18N + jLblReason.setMaximumSize(new java.awt.Dimension(36, 20)); + jLblReason.setMinimumSize(new java.awt.Dimension(36, 20)); + jLblReason.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jreason.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jreason.setPreferredSize(new java.awt.Dimension(170, 30)); + m_jreason.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jreasonActionPerformed(evt); + } + }); + + jLblName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblName.setText(AppLocal.getIntString("label.prodname")); // NOI18N + jLblName.setMaximumSize(new java.awt.Dimension(40, 20)); + jLblName.setMinimumSize(new java.awt.Dimension(40, 20)); + jLblName.setPreferredSize(new java.awt.Dimension(110, 30)); + + jproduct.setEditable(false); + jproduct.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jproduct.setText(" "); + jproduct.setPreferredSize(new java.awt.Dimension(170, 30)); + jproduct.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jproductActionPerformed(evt); + } + }); + + jEditProduct.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/search24.png"))); // NOI18N + jEditProduct.setToolTipText("Search Product List"); + jEditProduct.setPreferredSize(new java.awt.Dimension(64, 45)); + jEditProduct.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jEditProductActionPerformed(evt); + } + }); + + jLblLocation.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblLocation.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLblLocation.setText("Location"); + jLblLocation.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jLocation.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jLocation.setPreferredSize(new java.awt.Dimension(170, 30)); + + jLBCode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLBCode.setText(AppLocal.getIntString("label.prodbarcode")); // NOI18N + jLBCode.setMaximumSize(new java.awt.Dimension(40, 20)); + jLBCode.setMinimumSize(new java.awt.Dimension(40, 20)); + jLBCode.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jcodebar.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jcodebar.setPreferredSize(new java.awt.Dimension(170, 30)); + m_jcodebar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jcodebarActionPerformed(evt); + } + }); + + m_jEnter.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/barcode.png"))); // NOI18N + m_jEnter.setToolTipText("Get Barcode"); + m_jEnter.setFocusPainted(false); + m_jEnter.setFocusable(false); + m_jEnter.setMaximumSize(new java.awt.Dimension(54, 33)); + m_jEnter.setMinimumSize(new java.awt.Dimension(54, 33)); + m_jEnter.setPreferredSize(new java.awt.Dimension(64, 45)); + m_jEnter.setRequestFocusEnabled(false); + m_jEnter.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jEnterActionPerformed(evt); + } + }); + + jLblRef.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblRef.setText(AppLocal.getIntString("label.prodref")); // NOI18N + jLblRef.setMaximumSize(new java.awt.Dimension(40, 20)); + jLblRef.setMinimumSize(new java.awt.Dimension(40, 20)); + jLblRef.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jreference.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jreference.setPreferredSize(new java.awt.Dimension(170, 30)); + m_jreference.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jreferenceActionPerformed(evt); + } + }); + + m_jEnter1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/products.png"))); // NOI18N + m_jEnter1.setToolTipText("Enter Product ID"); + m_jEnter1.setFocusPainted(false); + m_jEnter1.setFocusable(false); + m_jEnter1.setMaximumSize(new java.awt.Dimension(64, 33)); + m_jEnter1.setMinimumSize(new java.awt.Dimension(64, 33)); + m_jEnter1.setPreferredSize(new java.awt.Dimension(64, 45)); + m_jEnter1.setRequestFocusEnabled(false); + m_jEnter1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jEnter1ActionPerformed(evt); + } + }); + + jLblAtt.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblAtt.setText(AppLocal.getIntString("label.attributes")); // NOI18N + jLblAtt.setMaximumSize(new java.awt.Dimension(48, 20)); + jLblAtt.setMinimumSize(new java.awt.Dimension(48, 20)); + jLblAtt.setPreferredSize(new java.awt.Dimension(110, 30)); + + jattributes.setEditable(false); + jattributes.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jattributes.setPreferredSize(new java.awt.Dimension(170, 30)); + jattributes.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jattributesActionPerformed(evt); + } + }); + + jEditAttributes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/attributes.png"))); // NOI18N + jEditAttributes.setToolTipText("Product Attributes"); + jEditAttributes.setMaximumSize(new java.awt.Dimension(65, 33)); + jEditAttributes.setMinimumSize(new java.awt.Dimension(65, 33)); + jEditAttributes.setPreferredSize(new java.awt.Dimension(64, 45)); + jEditAttributes.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jEditAttributesActionPerformed(evt); + } + }); + + jLblUnits.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblUnits.setText(AppLocal.getIntString("label.units")); // NOI18N + jLblUnits.setMaximumSize(new java.awt.Dimension(40, 20)); + jLblUnits.setMinimumSize(new java.awt.Dimension(40, 20)); + jLblUnits.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_junits.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_junits.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_junits.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLblPrice.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblPrice.setText(AppLocal.getIntString("label.price")); // NOI18N + jLblPrice.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jprice.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jprice.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jprice.setPreferredSize(new java.awt.Dimension(170, 30)); + + catcontainer.setBackground(new java.awt.Color(255, 255, 255)); + catcontainer.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + catcontainer.setMaximumSize(new java.awt.Dimension(2147483647, 2147483647)); + catcontainer.setMinimumSize(new java.awt.Dimension(0, 250)); + catcontainer.setPreferredSize(new java.awt.Dimension(600, 0)); + catcontainer.setLayout(new java.awt.BorderLayout()); + + m_jLocationDes.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jLocationDes.setEnabled(false); + m_jLocationDes.setPreferredSize(new java.awt.Dimension(170, 30)); + m_jLocationDes.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jLocationDesActionPerformed(evt); + } + }); + + jLblMoveTo.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblMoveTo.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLblMoveTo.setText(bundle.getString("label.moveto")); // NOI18N + jLblMoveTo.setEnabled(false); + jLblMoveTo.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jSupplier.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSupplier.setPreferredSize(new java.awt.Dimension(170, 30)); + + jLblLocation1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblLocation1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLblLocation1.setText(AppLocal.getIntString("button.exit")); // NOI18N + jLblLocation1.setPreferredSize(new java.awt.Dimension(110, 30)); + + org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .add(jLblDate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(m_jdate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(m_jbtndate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(jLblReason, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jPanel1Layout.createSequentialGroup() + .add(jLblLocation, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) + .add(m_jreason, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(m_jLocation, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + .add(jLblMoveTo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jPanel1Layout.createSequentialGroup() + .add(jLblLocation1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) + .add(m_jLocationDes, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(m_jSupplier, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + .add(jPanel1Layout.createSequentialGroup() + .add(jLblAtt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jattributes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jEditAttributes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(jPanel1Layout.createSequentialGroup() + .add(jLBCode, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(m_jcodebar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(m_jEnter, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(jPanel1Layout.createSequentialGroup() + .add(jLblUnits, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(m_junits, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(jPanel1Layout.createSequentialGroup() + .add(jLblPrice, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(m_jprice, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(jPanel1Layout.createSequentialGroup() + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jLblName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jPanel1Layout.createSequentialGroup() + .add(jLblRef, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(m_jreference, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(jPanel1Layout.createSequentialGroup() + .add(114, 114, 114) + .add(jproduct, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(m_jEnter1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jEditProduct, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(catcontainer, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 612, Short.MAX_VALUE) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(m_jdate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jLblDate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(m_jbtndate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(m_jreason, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jLblReason, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(m_jLocation, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jLblLocation, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(jLblMoveTo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(m_jLocationDes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(m_jSupplier, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jLblLocation1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(jLblName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jproduct, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(jEditProduct, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(m_jreference, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jLblRef, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(m_jEnter1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(jattributes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jLblAtt, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(jEditAttributes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(m_jEnter, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jPanel1Layout.createSequentialGroup() + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(m_jcodebar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jLBCode, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(18, 18, 18) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jLblUnits, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(m_junits, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(18, 18, 18) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jLblPrice, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(m_jprice, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) + .add(0, 47, Short.MAX_VALUE)) + .add(catcontainer, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap(48, Short.MAX_VALUE)) + ); + + catcontainer.getAccessibleContext().setAccessibleParent(jPanel1); + + add(jPanel1, java.awt.BorderLayout.PAGE_START); + }// </editor-fold>//GEN-END:initComponents + + private void m_jEnter1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jEnter1ActionPerformed + + assignProductByReference(); + + }//GEN-LAST:event_m_jEnter1ActionPerformed + + private void m_jreferenceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jreferenceActionPerformed + + assignProductByReference(); + + }//GEN-LAST:event_m_jreferenceActionPerformed + + private void m_jcodebarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jcodebarActionPerformed + + assignProductByCode(); + + }//GEN-LAST:event_m_jcodebarActionPerformed + + private void m_jEnterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jEnterActionPerformed + + assignProductByCode(); + + }//GEN-LAST:event_m_jEnterActionPerformed + + private void jEditAttributesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jEditAttributesActionPerformed + + if (productid == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.productnotselected")); + msg.show(this); + } else { + try { + JProductAttEdit attedit = JProductAttEdit.getAttributesEditor(this, m_App.getSession()); + attedit.editAttributes(attsetid, attsetinstid); + attedit.setVisible(true); + + if (attedit.isOK()) { + attsetinstid = attedit.getAttributeSetInst(); + attsetinstdesc = attedit.getAttributeSetInstDescription(); + jattributes.setText(attsetinstdesc); + } + } catch (BasicException ex) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindattributes"), ex); + msg.show(this); + } + } +}//GEN-LAST:event_jEditAttributesActionPerformed + + private void m_jbtndateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtndateActionPerformed + + Date date; + try { + date = (Date) Formats.TIMESTAMP.parseValue(m_jdate.getText()); + } catch (BasicException e) { + date = null; + } + date = JCalendarDialog.showCalendarTime(this, date); + if (date != null) { + m_jdate.setText(Formats.TIMESTAMP.formatValue(date)); + } + + }//GEN-LAST:event_m_jbtndateActionPerformed + + private void jEditProductActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jEditProductActionPerformed + + assignProduct(JProductFinder.showMessage(this, m_dlSales)); + +}//GEN-LAST:event_jEditProductActionPerformed + + private void jattributesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jattributesActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jattributesActionPerformed + + private void m_jLocationDesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jLocationDesActionPerformed + + }//GEN-LAST:event_m_jLocationDesActionPerformed + + private void jproductActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jproductActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jproductActionPerformed + + private void m_jreasonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jreasonActionPerformed +/* +* JG May 2017 for FUTURE - moved out of StockManagement +* for time being just let's show a message + if (m_ReasonModel.getSelectedItem() == MovementReason.OUT_CROSSING) { + m_jLocationDes.setEnabled(true); + jLblMoveTo.setEnabled(true); + }else{ + m_jLocationDes.setEnabled(false); + jLblMoveTo.setEnabled(false); + } +*/ + if (m_ReasonModel.getSelectedItem() == MovementReason.OUT_CROSSING) { + JOptionPane.showMessageDialog(this, "Transfer option in development. Please us (In) + (Out) Movement options"); + } + }//GEN-LAST:event_m_jreasonActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel catcontainer; + private javax.swing.JButton jEditAttributes; + private javax.swing.JButton jEditProduct; + private javax.swing.JLabel jLBCode; + private javax.swing.JLabel jLblAtt; + private javax.swing.JLabel jLblDate; + private javax.swing.JLabel jLblLocation; + private javax.swing.JLabel jLblLocation1; + private javax.swing.JLabel jLblMoveTo; + private javax.swing.JLabel jLblName; + private javax.swing.JLabel jLblPrice; + private javax.swing.JLabel jLblReason; + private javax.swing.JLabel jLblRef; + private javax.swing.JLabel jLblUnits; + private javax.swing.JPanel jPanel1; + private javax.swing.JTextField jattributes; + private javax.swing.JTextField jproduct; + private javax.swing.JButton m_jEnter; + private javax.swing.JButton m_jEnter1; + private javax.swing.JComboBox m_jLocation; + private javax.swing.JComboBox m_jLocationDes; + private javax.swing.JComboBox m_jSupplier; + private javax.swing.JButton m_jbtndate; + private javax.swing.JTextField m_jcodebar; + private javax.swing.JTextField m_jdate; + private javax.swing.JTextField m_jprice; + private javax.swing.JComboBox m_jreason; + private javax.swing.JTextField m_jreference; + private javax.swing.JTextField m_junits; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/StockDiaryPanel.java b/src/main/java/com/unicenta/pos/inventory/StockDiaryPanel.java new file mode 100644 index 0000000..2078ff1 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/StockDiaryPanel.java @@ -0,0 +1,104 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +//import com.unicenta.pos.suppliers.DataLogicSuppliers; +import com.unicenta.pos.panels.JPanelTable; +import com.unicenta.pos.suppliers.DataLogicSuppliers; + +/** + * + * @author adrianromero + */ +public class StockDiaryPanel extends JPanelTable { + + private StockDiaryEditor jeditor; + private DataLogicSales m_dlSales; +// private DataLogicSuppliers m_dlSuppliers; + + /** Creates a new instance of JPanelDiaryEditor */ + public StockDiaryPanel() { + } + + /** + * + */ + @Override + protected void init() { + m_dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); +// DataLogicSuppliers m_dlSuppliers = (DataLogicSuppliers) app.getBean("com.unicenta.pos.suppliers.DataLogicSuppliers"); + jeditor = new StockDiaryEditor(app, dirty); + + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return null; + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(null + , m_dlSales.getStockDiaryInsert() + , m_dlSales.getStockDiaryDelete()); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.StockDiary"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + jeditor.activate(); // primero activo el editor + super.activate(); // segundo activo el padre + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/StockManagement.form b/src/main/java/com/unicenta/pos/inventory/StockManagement.form new file mode 100644 index 0000000..bd681fc --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/StockManagement.form @@ -0,0 +1,828 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[550, 250]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1000, 350]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,50,0,0,3,-24"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1020, 320]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="First"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.stockdate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="5" y="5" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jdate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="90" y="5" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="m_jbtndate"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/date.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Open Calendar"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtndateActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="50" y="5" width="40" height="30"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.stockreason" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="5" y="40" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JComboBox" name="m_jreason"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="maximumRowCount" type="int" value="13"/> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jreasonActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="90" y="40" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.locationplace" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="5" y="75" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JComboBox" name="m_jLocation"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jLocationActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="90" y="75" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JComboBox" name="m_jLocationDes"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="90" y="110" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel10"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.supplier" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="5" y="145" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JComboBox" name="m_jSupplier"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jSupplierActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="90" y="145" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel9"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.supplierdocment" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="" replaceFormat="AppLocal.getIntString("button.exit")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="5" y="180" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jSupplierDoc"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.supplierdocument" replaceFormat="AppLocal.getIntString("button.exit")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="90" y="180" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="cc" green="cc" red="cc" type="rgb"/> + </LineBorder> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[455, 245]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="250" y="5" width="-1" height="190"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + <Component class="javax.swing.JLabel" name="m_jcodebar"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="1" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="1"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ed" green="c5" red="4c" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder/> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 25]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="m_jcodebarMouseClicked"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="780" y="270" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="m_jEnter"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/barcode.png"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[54, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jEnterActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="920" y="260" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="jTextField1"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ee" green="ee" id="Panel.background" palette="3" red="ee" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="caretColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ee" green="ee" id="Panel.background" palette="3" red="ee" type="palette"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1, 1]"/> + </Property> + </Properties> + <Events> + <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="jTextField1KeyTyped"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="1" y="1" width="-1" height="0"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="5" right="5" top="0"/> + </Border> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 250]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="705" y="0" width="-1" height="-1"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout"> + <Property name="columns" type="int" value="1"/> + <Property name="horizontalGap" type="int" value="5"/> + <Property name="rows" type="int" value="0"/> + <Property name="verticalGap" type="int" value="5"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jDelete"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/editdelete.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.saleremoveline" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jDeleteActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jList"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/search32.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.saleproductfind" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jListActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jEditLine"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/sale_editline.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.saleeditline" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jEditLineActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jEditAttributes"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/attributes.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.saleattributes" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jEditAttributesActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jBtnDelete"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/sale_delete.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.deleteticket" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Delete current Ticket"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBtnDeleteActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 250]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 250]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="760" y="0" width="230" height="260"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="230" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="10" max="32767" attributes="0"/> + <Component id="jNumberKeys" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="10" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="260" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jNumberKeys" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="com.unicenta.beans.JNumberKeys" name="jNumberKeys"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[210, 240]"/> + </Property> + </Properties> + <Events> + <EventHandler event="keyPerformed" listener="com.unicenta.beans.JNumberEventListener" parameters="com.unicenta.beans.JNumberEvent" handler="jNumberKeysKeyPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="5" y="220" width="650" height="70"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="com.alee.laf.table.WebTable" name="jTableProductStock"> + <Properties> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="6" rowCount="8"> + <Column editable="true" title="Location" type="java.lang.Object"/> + <Column editable="true" title="Current" type="java.lang.Object"/> + <Column editable="true" title="Maximum" type="java.lang.Object"/> + <Column editable="true" title="Minimum" type="java.lang.Object"/> + <Column editable="true" title="PriceSell" type="java.lang.Object"/> + <Column editable="true" title="PriceValue" type="java.lang.Object"/> + </Table> + </Property> + <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> + <TableColumnModel selectionModel="0"> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="rowHeight" type="int" value="25"/> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="true" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="m_jBtnShowStock"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/pay.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.salecheckstock" replaceFormat="AppLocal.getIntString("tooltip.salecheckstock")"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBtnShowStockActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="660" y="250" width="40" height="40"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lblTotalQtyValue"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="horizontalTextPosition" type="int" value="2"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="118" y="290" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lbTotalValue"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="horizontalTextPosition" type="int" value="2"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="547" y="290" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="com.alee.laf.label.WebLabel" name="webLblQty"> + <Properties> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.stock.quantity" replaceFormat="AppLocal.getIntString("label.stock.quantity")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="1"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[90, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="5" y="290" width="100" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="com.alee.laf.label.WebLabel" name="webLblValue"> + <Properties> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.stock.value" replaceFormat="AppLocal.getIntString("label.stock.value")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="1"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="355" y="290" width="170" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="catcontainer"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 250]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 250]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleParent" type="javax.accessibility.Accessible" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="jPanel8"/> + </Property> + </AccessibilityProperties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/StockManagement.java b/src/main/java/com/unicenta/pos/inventory/StockManagement.java new file mode 100644 index 0000000..67beacc --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/StockManagement.java @@ -0,0 +1,1345 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.beans.DateUtils; +import com.unicenta.beans.JCalendarDialog; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.LocalRes; +import com.unicenta.data.loader.SentenceExec; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.format.Formats; +import com.unicenta.pos.catalog.CatalogSelector; +import com.unicenta.pos.catalog.JCatalog; +import com.unicenta.pos.forms.*; +import com.unicenta.pos.panels.JProductFinder; +import com.unicenta.pos.printer.TicketParser; +import com.unicenta.pos.printer.TicketPrinterException; +import com.unicenta.pos.sales.JProductAttEdit2; +import com.unicenta.pos.scripting.ScriptEngine; +import com.unicenta.pos.scripting.ScriptException; +import com.unicenta.pos.scripting.ScriptFactory; +import com.unicenta.pos.suppliers.DataLogicSuppliers; +import com.unicenta.pos.suppliers.SupplierInfo; +import com.unicenta.pos.ticket.ProductInfoExt; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableModel; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +/** + * Date : Aug 2017 + * Updated : Dec 2016 § + * + * @author jack gerrard + */ +@Slf4j +public class StockManagement extends JPanel implements JPanelView { + + private final AppView m_App; + private final String user; + + private final DataLogicSystem m_dlSystem; + private final DataLogicSales m_dlSales; + private final DataLogicSuppliers m_dlSuppliers; + private final TicketParser m_TTP; + + private final CatalogSelector m_cat; + private final ComboBoxValModel m_ReasonModel; + + private final SentenceList m_sentlocations; + private ComboBoxValModel m_LocationsModel; + private ComboBoxValModel m_LocationsModelDes; + + private final SentenceList m_sentsuppliers; + private ComboBoxValModel m_SuppliersModel; + + private final JInventoryLines m_invlines; + + private int NUMBER_STATE = 0; + private int MULTIPLY = 0; + private static final int DEFAULT = 0; + private static final int ACTIVE = 1; + private static final int DECIMAL = 2; + + private List<ProductStock> productStockList; + private aStockTableModel stockModel; + + private final static int NUMBERZERO = 0; + private final static int NUMBERVALID = 1; + + private final static int NUMBER_INPUTZERO = 0; + private final static int NUMBER_INPUTZERODEC = 1; + private final static int NUMBER_INPUTINT = 2; + private final static int NUMBER_INPUTDEC = 3; + private final static int NUMBER_PORZERO = 4; + private final static int NUMBER_PORZERODEC = 5; + private final static int NUMBER_PORINT = 6; + private final static int NUMBER_PORDEC = 7; + + private int m_iNumberStatus; + private int m_iNumberStatusInput; + private int m_iNumberStatusPor; + private StringBuffer m_sBarcode; + + + /** + * Creates new form StockManagement + * + * @param app + */ + public StockManagement(AppView app) { + + m_App = app; + m_dlSystem = (DataLogicSystem) m_App.getBean("com.unicenta.pos.forms.DataLogicSystem"); + m_dlSales = (DataLogicSales) m_App.getBean("com.unicenta.pos.forms.DataLogicSales"); + m_dlSuppliers = (DataLogicSuppliers) m_App.getBean("com.unicenta.pos.suppliers.DataLogicSuppliers"); + m_TTP = new TicketParser(m_App.getDeviceTicket(), m_dlSystem); + + initComponents(); + + user = m_App.getAppUserView().getUser().getName(); + + jNumberKeys.setEnabled(true); + + lblTotalQtyValue.setText(null); + lbTotalValue.setText(null); + + m_sentlocations = m_dlSales.getLocationsList(); + m_LocationsModel = new ComboBoxValModel(); + m_LocationsModelDes = new ComboBoxValModel(); + + m_ReasonModel = new ComboBoxValModel(); + + m_ReasonModel.add(MovementReason.IN_PURCHASE); //Supplier Purchase + m_ReasonModel.add(MovementReason.OUT_SALE); //Sale + m_ReasonModel.add(MovementReason.IN_REFUND); //Customer Refund + m_ReasonModel.add(MovementReason.OUT_REFUND); //Supplier Return + m_ReasonModel.add(MovementReason.IN_MOVEMENT); //Adjust Add + m_ReasonModel.add(MovementReason.OUT_MOVEMENT); //Adjust Subtract + m_ReasonModel.add(MovementReason.OUT_SUBTRACT); //Rectify error per JM requirement + m_ReasonModel.add(MovementReason.OUT_BREAK); //Breakage + m_ReasonModel.add(MovementReason.OUT_FREE); //Given Free + m_ReasonModel.add(MovementReason.OUT_SAMPLE); //Given Sample + m_ReasonModel.add(MovementReason.OUT_USED); //Used item + m_ReasonModel.add(MovementReason.OUT_CROSSING); //Inter-Location move + + m_jreason.setModel(m_ReasonModel); + + m_sentsuppliers = m_dlSuppliers.getSupplierList(); + m_SuppliersModel = new ComboBoxValModel(); + + m_cat = new JCatalog(m_dlSales); + m_cat.addActionListener(new CatalogListener()); + catcontainer.add(m_cat.getComponent(), BorderLayout.CENTER); + + m_invlines = new JInventoryLines(); + jPanel5.add(m_invlines, BorderLayout.CENTER); + + jTableProductStock.setVisible(false); + + } + + /** + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.StockMovement"); + } + + /** + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + m_cat.loadCatalog(); + + java.util.List l = m_sentlocations.list(); + m_LocationsModel = new ComboBoxValModel(l); + m_jLocation.setModel(m_LocationsModel); + m_LocationsModelDes = new ComboBoxValModel(l); + m_jLocationDes.setModel(m_LocationsModelDes); + + java.util.List sl = m_sentsuppliers.list(); + m_SuppliersModel = new ComboBoxValModel(sl); + m_jSupplier.setModel(m_SuppliersModel); + + stateToInsert(); + + java.awt.EventQueue.invokeLater(() -> { + jTextField1.requestFocus(); + }); + } + + /** + * + */ + public void stateToInsert() { + + m_jdate.setText(Formats.TIMESTAMP.formatValue(DateUtils.getTodayMinutes())); + m_ReasonModel.setSelectedItem(MovementReason.IN_PURCHASE); + m_LocationsModel.setSelectedKey(m_App.getInventoryLocation()); +// m_LocationsModel.setSelectedFirst(); + m_LocationsModelDes.setSelectedKey(m_App.getInventoryLocation()); + m_jcodebar.setText(null); + m_SuppliersModel.setSelectedFirst(); + m_jSupplierDoc.setText(null); + m_invlines.clear(); + resetTranxTable(); + } + + /** + * @return + */ + @Override + public boolean deactivate() { + + if (m_invlines.getCount() > 0) { + int res = JOptionPane.showConfirmDialog(this, + LocalRes.getIntString("message.wannasave"), + LocalRes.getIntString("title.editor"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE); + if (res == JOptionPane.YES_OPTION) { + saveData(); + return true; + } else return res == JOptionPane.NO_OPTION; + } else { + return true; + } + } + + private void addLine(ProductInfoExt oProduct, double dpor, double dprice) { + m_invlines.addLine(new InventoryLine(oProduct, dpor, dprice)); + showStockTable(); + } + + private void deleteLine(int index) { + if (index < 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + m_invlines.deleteLine(index); + clearStockTable(); + showStockTable(); + lblTotalQtyValue.setText(null); + lbTotalValue.setText(null); + + } + } + + private void incProduct(ProductInfoExt product, double units) { + + MovementReason reason = (MovementReason) m_ReasonModel.getSelectedItem(); + addLine(product, units, reason.isInput() + ? product.getPriceBuy() + : product.getPriceSell()); + } + + private void incProductByCode(String sCode) { + incProductByCode(sCode, 1.0); + } + + private void incProductByCode(String sCode, double dQuantity) { + + try { + ProductInfoExt oProduct = m_dlSales.getProductInfoByCode(sCode); + if (oProduct == null) { + Toolkit.getDefaultToolkit().beep(); + } else { + incProduct(oProduct, dQuantity); + } + } catch (BasicException eData) { + MessageInf msg = new MessageInf(eData); + msg.show(this); + } + } + + private List<ProductStock> getProductOfName(String pId) { + + try { + productStockList = m_dlSales.getProductStockList(pId); + + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + + List<ProductStock> productList = new ArrayList<>(); + + productStockList.stream().forEach((productStock) -> { + String productId = productStock.getProductId(); + if (productId.equals(pId)) { + productList.add(productStock); + } + }); + + repaint(); + + return productList; + } + + public void resetTranxTable() { + + jTableProductStock.getColumnModel().getColumn(0).setPreferredWidth(50); + jTableProductStock.getColumnModel().getColumn(1).setPreferredWidth(50); + jTableProductStock.getColumnModel().getColumn(2).setPreferredWidth(50); + jTableProductStock.getColumnModel().getColumn(3).setPreferredWidth(50); + jTableProductStock.getColumnModel().getColumn(4).setPreferredWidth(50); + jTableProductStock.getColumnModel().getColumn(5).setPreferredWidth(50); + + jTableProductStock.repaint(); + } + + public void clearStockTable() { + + aStockTableModel model = (aStockTableModel) jTableProductStock.getModel(); + + while (model.getRowCount() > 0) { + for (int i = 0; i < model.getRowCount(); ++i) { + model.stockList.removeAll(productStockList); + } + lblTotalQtyValue.setText(null); + lbTotalValue.setText(null); + } + + jTableProductStock.repaint(); + } + + public void showStockTable() { + + String pId = null; + int i = m_invlines.getSelectedRow(); + + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + InventoryLine line = m_invlines.getLine(i); + pId = line.getProductID(); + } + if (pId != null) { + stockModel = new StockManagement.aStockTableModel(getProductOfName(pId)); + + jTableProductStock.setModel((TableModel) stockModel); + if (stockModel.getRowCount() > 0) { + jTableProductStock.setVisible(true); + } else { + jTableProductStock.setVisible(false); + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.nostocklocation"), + AppLocal.getIntString("message.title.nostocklocation"), + JOptionPane.INFORMATION_MESSAGE); + } + sumStockTable(); + resetTranxTable(); + } + + } + + public void sumStockTable() { + double totalQty = 0; + double totalVal = 0; + double lQty = 0; + double lVal = 0; + + for (int i = 0; i < stockModel.getRowCount(); i++) { + totalQty += Double.parseDouble(stockModel.getValueAt(i, 1).toString()); + totalVal += Double.parseDouble(stockModel.getValueAt(i, 5).toString()); +// deliberately explicit + totalVal = Math.round(totalVal * 100); + totalVal = totalVal / 100; + } + + int i = m_invlines.getSelectedRow(); + lQty = m_invlines.getLine(i).getMultiply(); + lVal = m_invlines.getLine(i).getPrice() * lQty; +// deliberately explicit + lVal = Math.round(lVal * 100); + lVal = lVal / 100; + + MovementReason reason = (MovementReason) m_ReasonModel.getSelectedItem(); + + if (reason == MovementReason.OUT_BREAK + || reason == MovementReason.OUT_FREE || reason == MovementReason.OUT_REFUND + || reason == MovementReason.OUT_SALE || reason == MovementReason.OUT_SAMPLE + || reason == MovementReason.OUT_SAMPLE || reason == MovementReason.OUT_SUBTRACT + || reason == MovementReason.OUT_USED) { + lblTotalQtyValue.setText(Double.toString(totalQty -= lQty)); + lbTotalValue.setText(Double.toString(totalVal -= lVal)); + } else { + lblTotalQtyValue.setText(Double.toString(lQty += totalQty)); + lbTotalValue.setText(Double.toString(lVal += totalVal)); + } + + + } + + private void addUnits(double dUnits) { + int i = m_invlines.getSelectedRow(); + if (i >= 0) { + InventoryLine inv = m_invlines.getLine(i); + double dunits = inv.getMultiply() + dUnits; + if (dunits <= 0.0) { + deleteLine(i); + } else { + inv.setMultiply(inv.getMultiply() + dUnits); + m_invlines.setLine(i, inv); + } + + sumStockTable(); + } + } + + private void setUnits(double dUnits) { + int i = m_invlines.getSelectedRow(); + if (i >= 0) { + InventoryLine inv = m_invlines.getLine(i); + inv.setMultiply(dUnits); + m_invlines.setLine(i, inv); + } + } + + private void stateTransition(char cTrans) { + if (cTrans == '\n') { + m_jEnter.doClick(); + } + if (cTrans == '\u007f') { + m_jcodebar.setText(null); + NUMBER_STATE = DEFAULT; + } else if (cTrans == '*') { + MULTIPLY = ACTIVE; + } else if (cTrans == '+') { + if (MULTIPLY != DEFAULT && NUMBER_STATE != DEFAULT) { + setUnits(Double.parseDouble(m_jcodebar.getText())); + m_jcodebar.setText(null); + } else { + if (m_jcodebar.getText() == null || m_jcodebar.getText().equals("")) { + addUnits(1.0); + } else { + addUnits(Double.parseDouble(m_jcodebar.getText())); + m_jcodebar.setText(null); + } + } + NUMBER_STATE = DEFAULT; + MULTIPLY = DEFAULT; + } else if (cTrans == '-') { + if (m_jcodebar.getText() == null || m_jcodebar.getText().equals("")) { + addUnits(-1.0); + } else { + addUnits(-Double.parseDouble(m_jcodebar.getText())); + m_jcodebar.setText(null); + } + NUMBER_STATE = DEFAULT; + MULTIPLY = DEFAULT; + } else if (cTrans == '.') { + if (m_jcodebar.getText() == null || m_jcodebar.getText().equals("")) { + m_jcodebar.setText("0."); + } else if (NUMBER_STATE != DECIMAL) { + m_jcodebar.setText(m_jcodebar.getText() + cTrans); + } + NUMBER_STATE = DECIMAL; + } else if (cTrans == ' ' || cTrans == '=') { + if (m_invlines.getCount() == 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + saveData(); + jNumberKeys.setEnabled(true); + } + } else if (Character.isDigit(cTrans)) { + if (m_jcodebar.getText() == null) { + m_jcodebar.setText("" + cTrans); + } else { + m_jcodebar.setText(m_jcodebar.getText() + cTrans); + } + if (NUMBER_STATE != DECIMAL) { + NUMBER_STATE = ACTIVE; + } + } else if (Character.isAlphabetic(cTrans)) { + if (m_jcodebar.getText() == null) { + m_jcodebar.setText("" + cTrans); + } else { + m_jcodebar.setText(m_jcodebar.getText() + cTrans); + } + if (NUMBER_STATE != DECIMAL) { + NUMBER_STATE = ACTIVE; + } + + } else { + Toolkit.getDefaultToolkit().beep(); + } + } + + /** + * @param prod + */ + protected void buttonTransition(ProductInfoExt prod) { + +// if (m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERZERO) { + incProduct(prod); +// } else { +// Toolkit.getDefaultToolkit().beep(); +// } + } + + private void saveData() { + try { + + Date d = (Date) Formats.TIMESTAMP.parseValue(m_jdate.getText()); + MovementReason reason = (MovementReason) m_ReasonModel.getSelectedItem(); + + if (reason == MovementReason.OUT_CROSSING) { + saveData(new InventoryRecord( + d, MovementReason.OUT_MOVEMENT, + (LocationInfo) m_LocationsModel.getSelectedItem(), + m_App.getAppUserView().getUser().getName(), + (SupplierInfo) m_SuppliersModel.getSelectedItem(), + m_invlines.getLines(), + m_jSupplierDoc.getText() + )); + saveData(new InventoryRecord( + d, MovementReason.IN_MOVEMENT, + (LocationInfo) m_LocationsModelDes.getSelectedItem(), + m_App.getAppUserView().getUser().getName(), + (SupplierInfo) m_SuppliersModel.getSelectedItem(), + m_invlines.getLines(), + m_jSupplierDoc.getText() + )); + } else { + saveData(new InventoryRecord( + d, reason, + (LocationInfo) m_LocationsModel.getSelectedItem(), + m_App.getAppUserView().getUser().getName(), + (SupplierInfo) m_SuppliersModel.getSelectedItem(), + m_invlines.getLines(), + m_jSupplierDoc.getText() + )); + } + + stateToInsert(); + } catch (BasicException eData) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, + AppLocal.getIntString("message.cannotsaveinventorydata"), eData); + msg.show(this); + } + } + + private void saveData(InventoryRecord rec) throws BasicException { + + SentenceExec sent = m_dlSales.getStockDiaryInsert1(); + + for (int i = 0; i < m_invlines.getCount(); i++) { + InventoryLine inv = rec.getLines().get(i); + + sent.exec(new Object[]{ + UUID.randomUUID().toString(), + rec.getDate(), + rec.getReason().getKey(), + rec.getLocation().getID(), + inv.getProductID(), + inv.getProductAttSetInstId(), + rec.getReason().samesignum(inv.getMultiply()), + inv.getPrice(), + rec.getUser(), + rec.getSupplier().getID(), + rec.getSupplierDoc() + }); + } + + clearStockTable(); + printTicket(rec); + } + + private void printTicket(InventoryRecord invrec) { + + String sresource = m_dlSystem.getResourceAsXML("Printer.Inventory"); + if (sresource == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotprintticket")); + msg.show(this); + } else { + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); + script.put("inventoryrecord", invrec); + m_TTP.printTicket(script.eval(sresource).toString()); + + } catch (ScriptException | TicketPrinterException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotprintticket"), e); + msg.show(this); + } + } + } + + class aStockTableModel extends AbstractTableModel { + + String loc = AppLocal.getIntString("label.tblProdHeaderCol1"); + String qty = AppLocal.getIntString("label.tblProdHeaderCol2"); + String max = AppLocal.getIntString("label.tblProdHeaderCol3"); + String min = AppLocal.getIntString("label.tblProdHeaderCol4"); + String buy = AppLocal.getIntString("label.tblProdHeaderCol5"); + String val = AppLocal.getIntString("label.tblProdHeaderCol6"); + + List<ProductStock> stockList; + + String[] columnNames = {loc, qty, max, min, buy, val}; + + + public aStockTableModel(List<ProductStock> list) { + stockList = list; + } + + @Override + public int getColumnCount() { + return 6; + } + + @Override + public int getRowCount() { + return stockList.size(); + } + + @Override + public Object getValueAt(int row, int column) { + ProductStock productStock = stockList.get(row); + + switch (column) { + case 0: + return productStock.getLocation(); + case 1: + return productStock.getUnits(); + case 2: + return productStock.getMinimum(); + case 3: + return productStock.getMaximum(); + case 4: + return productStock.getPriceSell(); + case 5: + return productStock.getUnits() * productStock.getPriceSell(); + case 6: + return productStock.getProductId(); + default: + return ""; + } + + } + + public Object setValueAt(int row, int column) { + ProductStock productStock = stockList.get(row); + + switch (column) { + case 0: + return productStock.getLocation(); + case 1: + return productStock.getUnits(); + case 2: + return productStock.getMinimum(); + case 3: + return productStock.getMaximum(); + case 4: + return productStock.getPriceSell(); + case 5: + return productStock.getUnits() * productStock.getPriceSell(); + case 6: + return productStock.getProductId(); + default: + return ""; + } + } + + @Override + public String getColumnName(int col) { + return columnNames[col]; + } + + } + + + private class CatalogListener implements ActionListener { + + @Override + public void actionPerformed(ActionEvent e) { + + String sQty = m_jcodebar.getText(); + if (sQty != null) { + Double dQty = (Double.valueOf(sQty) == 0) ? 1.0 : Double.valueOf(sQty); + incProduct((ProductInfoExt) e.getSource(), dQty); + m_jcodebar.setText(null); + } else { + incProduct((ProductInfoExt) e.getSource(), 1.0); + } + } + } + + private void removeInvLine(int index) { + + if (index < 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + m_invlines.deleteLine(index); + clearStockTable(); + showStockTable(); + lblTotalQtyValue.setText(null); + lbTotalValue.setText(null); + + } + + } + + /** + * @param index + */ + public void deleteTicket(int index) { + + while (index < m_invlines.getCount()) { + m_invlines.deleteLine(index); + } + + } + + private void incProduct(ProductInfoExt prod) { + + incProduct(1.0, prod); + } + + private void incProduct(double dPor, ProductInfoExt prod) { + + addLine(prod, dPor, prod.getPriceBuy()); + } + + private void stateToZero() { + m_sBarcode = new StringBuffer(); + + m_iNumberStatus = NUMBER_INPUTZERO; + m_iNumberStatusInput = NUMBERZERO; + m_iNumberStatusPor = NUMBERZERO; + repaint(); + } + + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel8 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + m_jdate = new javax.swing.JTextField(); + m_jbtndate = new javax.swing.JButton(); + jLabel2 = new javax.swing.JLabel(); + m_jreason = new javax.swing.JComboBox(); + jLabel8 = new javax.swing.JLabel(); + m_jLocation = new javax.swing.JComboBox(); + m_jLocationDes = new javax.swing.JComboBox(); + jLabel10 = new javax.swing.JLabel(); + m_jSupplier = new javax.swing.JComboBox(); + jLabel9 = new javax.swing.JLabel(); + m_jSupplierDoc = new javax.swing.JTextField(); + jPanel5 = new javax.swing.JPanel(); + m_jcodebar = new javax.swing.JLabel(); + m_jEnter = new javax.swing.JButton(); + jTextField1 = new javax.swing.JTextField(); + jPanel2 = new javax.swing.JPanel(); + m_jDelete = new javax.swing.JButton(); + m_jList = new javax.swing.JButton(); + m_jEditLine = new javax.swing.JButton(); + m_jEditAttributes = new javax.swing.JButton(); + m_jBtnDelete = new javax.swing.JButton(); + jPanel1 = new javax.swing.JPanel(); + jNumberKeys = new com.unicenta.beans.JNumberKeys(); + jScrollPane2 = new javax.swing.JScrollPane(); + jTableProductStock = new com.alee.laf.table.WebTable(); + m_jBtnShowStock = new javax.swing.JButton(); + lblTotalQtyValue = new javax.swing.JLabel(); + lbTotalValue = new javax.swing.JLabel(); + webLblQty = new com.alee.laf.label.WebLabel(); + webLblValue = new com.alee.laf.label.WebLabel(); + catcontainer = new javax.swing.JPanel(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setMinimumSize(new java.awt.Dimension(550, 250)); + setPreferredSize(new java.awt.Dimension(1000, 350)); + setLayout(new java.awt.BorderLayout()); + + jPanel8.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel8.setPreferredSize(new java.awt.Dimension(1020, 320)); + jPanel8.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.stockdate")); // NOI18N + jLabel1.setMaximumSize(new java.awt.Dimension(40, 25)); + jLabel1.setMinimumSize(new java.awt.Dimension(40, 25)); + jLabel1.setPreferredSize(new java.awt.Dimension(70, 30)); + jPanel8.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 5, -1, -1)); + + m_jdate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jdate.setPreferredSize(new java.awt.Dimension(160, 30)); + jPanel8.add(m_jdate, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 5, -1, -1)); + + m_jbtndate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/date.png"))); // NOI18N + m_jbtndate.setToolTipText("Open Calendar"); + m_jbtndate.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtndateActionPerformed(evt); + } + }); + jPanel8.add(m_jbtndate, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 5, 40, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.stockreason")); // NOI18N + jLabel2.setMaximumSize(new java.awt.Dimension(40, 25)); + jLabel2.setMinimumSize(new java.awt.Dimension(40, 25)); + jLabel2.setPreferredSize(new java.awt.Dimension(70, 30)); + jPanel8.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 40, -1, -1)); + + m_jreason.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jreason.setMaximumRowCount(13); + m_jreason.setPreferredSize(new java.awt.Dimension(160, 30)); + m_jreason.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jreasonActionPerformed(evt); + } + }); + jPanel8.add(m_jreason, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 40, -1, -1)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.locationplace")); // NOI18N + jLabel8.setMaximumSize(new java.awt.Dimension(40, 25)); + jLabel8.setMinimumSize(new java.awt.Dimension(40, 25)); + jLabel8.setPreferredSize(new java.awt.Dimension(70, 30)); + jPanel8.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 75, -1, -1)); + + m_jLocation.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jLocation.setPreferredSize(new java.awt.Dimension(160, 30)); + m_jLocation.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jLocationActionPerformed(evt); + } + }); + jPanel8.add(m_jLocation, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 75, -1, -1)); + + m_jLocationDes.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jLocationDes.setPreferredSize(new java.awt.Dimension(160, 30)); + jPanel8.add(m_jLocationDes, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 110, -1, -1)); + + jLabel10.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel10.setText(AppLocal.getIntString("label.supplier")); // NOI18N + jLabel10.setMaximumSize(new java.awt.Dimension(40, 25)); + jLabel10.setMinimumSize(new java.awt.Dimension(40, 25)); + jLabel10.setPreferredSize(new java.awt.Dimension(70, 30)); + jPanel8.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 145, -1, -1)); + + m_jSupplier.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSupplier.setPreferredSize(new java.awt.Dimension(160, 30)); + m_jSupplier.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jSupplierActionPerformed(evt); + } + }); + jPanel8.add(m_jSupplier, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 145, -1, -1)); + + jLabel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel9.setText(AppLocal.getIntString("label.supplierdocment")); // NOI18N + jLabel9.setToolTipText("null"); + jLabel9.setMaximumSize(new java.awt.Dimension(40, 25)); + jLabel9.setMinimumSize(new java.awt.Dimension(40, 25)); + jLabel9.setPreferredSize(new java.awt.Dimension(70, 30)); + jPanel8.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 180, -1, -1)); + + m_jSupplierDoc.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSupplierDoc.setToolTipText(AppLocal.getIntString("button.exit")); // NOI18N + m_jSupplierDoc.setPreferredSize(new java.awt.Dimension(160, 30)); + jPanel8.add(m_jSupplierDoc, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 180, -1, -1)); + + jPanel5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204))); + jPanel5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel5.setPreferredSize(new java.awt.Dimension(455, 245)); + jPanel5.setLayout(new java.awt.BorderLayout()); + jPanel8.add(jPanel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 5, -1, 190)); + + m_jcodebar.setBackground(java.awt.Color.white); + m_jcodebar.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + m_jcodebar.setForeground(new java.awt.Color(76, 197, 237)); + m_jcodebar.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jcodebar.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1))); + m_jcodebar.setOpaque(true); + m_jcodebar.setPreferredSize(new java.awt.Dimension(130, 25)); + m_jcodebar.setRequestFocusEnabled(false); + m_jcodebar.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + m_jcodebarMouseClicked(evt); + } + }); + jPanel8.add(m_jcodebar, new org.netbeans.lib.awtextra.AbsoluteConstraints(780, 270, -1, -1)); + + m_jEnter.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jEnter.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/barcode.png"))); // NOI18N + m_jEnter.setFocusPainted(false); + m_jEnter.setFocusable(false); + m_jEnter.setPreferredSize(new java.awt.Dimension(54, 45)); + m_jEnter.setRequestFocusEnabled(false); + m_jEnter.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jEnterActionPerformed(evt); + } + }); + jPanel8.add(m_jEnter, new org.netbeans.lib.awtextra.AbsoluteConstraints(920, 260, -1, -1)); + + jTextField1.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background")); + jTextField1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextField1.setForeground(new java.awt.Color(255, 255, 255)); + jTextField1.setCaretColor(javax.swing.UIManager.getDefaults().getColor("Panel.background")); + jTextField1.setPreferredSize(new java.awt.Dimension(1, 1)); + jTextField1.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { + jTextField1KeyTyped(evt); + } + }); + jPanel8.add(jTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(1, 1, -1, 0)); + + jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5)); + jPanel2.setPreferredSize(new java.awt.Dimension(70, 250)); + jPanel2.setLayout(new java.awt.GridLayout(0, 1, 5, 5)); + + m_jDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/editdelete.png"))); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + m_jDelete.setToolTipText(bundle.getString("tooltip.saleremoveline")); // NOI18N + m_jDelete.setFocusPainted(false); + m_jDelete.setFocusable(false); + m_jDelete.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jDelete.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jDelete.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jDelete.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jDelete.setRequestFocusEnabled(false); + m_jDelete.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jDeleteActionPerformed(evt); + } + }); + jPanel2.add(m_jDelete); + + m_jList.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/search32.png"))); // NOI18N + m_jList.setToolTipText(bundle.getString("tooltip.saleproductfind")); // NOI18N + m_jList.setFocusPainted(false); + m_jList.setFocusable(false); + m_jList.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jList.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jList.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jList.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jList.setRequestFocusEnabled(false); + m_jList.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jListActionPerformed(evt); + } + }); + jPanel2.add(m_jList); + + m_jEditLine.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_editline.png"))); // NOI18N + m_jEditLine.setToolTipText(bundle.getString("tooltip.saleeditline")); // NOI18N + m_jEditLine.setFocusPainted(false); + m_jEditLine.setFocusable(false); + m_jEditLine.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jEditLine.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jEditLine.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jEditLine.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jEditLine.setRequestFocusEnabled(false); + m_jEditLine.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jEditLineActionPerformed(evt); + } + }); + jPanel2.add(m_jEditLine); + + m_jEditAttributes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/attributes.png"))); // NOI18N + m_jEditAttributes.setToolTipText(bundle.getString("tooltip.saleattributes")); // NOI18N + m_jEditAttributes.setFocusPainted(false); + m_jEditAttributes.setFocusable(false); + m_jEditAttributes.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jEditAttributes.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jEditAttributes.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jEditAttributes.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jEditAttributes.setRequestFocusEnabled(false); + m_jEditAttributes.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jEditAttributesActionPerformed(evt); + } + }); + jPanel2.add(m_jEditAttributes); + + m_jBtnDelete.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jBtnDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_delete.png"))); // NOI18N + m_jBtnDelete.setText(AppLocal.getIntString("button.deleteticket")); // NOI18N + m_jBtnDelete.setToolTipText("Delete current Ticket"); + m_jBtnDelete.setFocusPainted(false); + m_jBtnDelete.setFocusable(false); + m_jBtnDelete.setMargin(new java.awt.Insets(0, 4, 0, 4)); + m_jBtnDelete.setMaximumSize(new java.awt.Dimension(50, 40)); + m_jBtnDelete.setMinimumSize(new java.awt.Dimension(50, 40)); + m_jBtnDelete.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jBtnDelete.setRequestFocusEnabled(false); + m_jBtnDelete.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBtnDeleteActionPerformed(evt); + } + }); + jPanel2.add(m_jBtnDelete); + + jPanel8.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(705, 0, -1, -1)); + + jPanel1.setMinimumSize(new java.awt.Dimension(150, 250)); + jPanel1.setPreferredSize(new java.awt.Dimension(200, 250)); + + jNumberKeys.setPreferredSize(new java.awt.Dimension(210, 240)); + jNumberKeys.addJNumberEventListener(new com.unicenta.beans.JNumberEventListener() { + public void keyPerformed(com.unicenta.beans.JNumberEvent evt) { + jNumberKeysKeyPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 230, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(0, 10, Short.MAX_VALUE) + .addComponent(jNumberKeys, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 10, Short.MAX_VALUE))) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 260, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jNumberKeys, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + jPanel8.add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(760, 0, 230, 260)); + + jScrollPane2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + + jTableProductStock.setModel(new javax.swing.table.DefaultTableModel( + new Object[][]{ + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null} + }, + new String[]{ + "Location", "Current", "Maximum", "Minimum", "PriceSell", "PriceValue" + } + )); + jTableProductStock.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTableProductStock.setRowHeight(25); + jScrollPane2.setViewportView(jTableProductStock); + + jPanel8.add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 220, 650, 70)); + + m_jBtnShowStock.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jBtnShowStock.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/pay.png"))); // NOI18N + m_jBtnShowStock.setToolTipText(AppLocal.getIntString("tooltip.salecheckstock")); // NOI18N + m_jBtnShowStock.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBtnShowStockActionPerformed(evt); + } + }); + jPanel8.add(m_jBtnShowStock, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 250, 40, 40)); + + lblTotalQtyValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + lblTotalQtyValue.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + lblTotalQtyValue.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); + lblTotalQtyValue.setPreferredSize(new java.awt.Dimension(100, 30)); + jPanel8.add(lblTotalQtyValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(118, 290, -1, -1)); + + lbTotalValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + lbTotalValue.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + lbTotalValue.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); + lbTotalValue.setPreferredSize(new java.awt.Dimension(100, 30)); + jPanel8.add(lbTotalValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(547, 290, -1, -1)); + + webLblQty.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + webLblQty.setText(AppLocal.getIntString("label.stock.quantity")); // NOI18N + webLblQty.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N + webLblQty.setPreferredSize(new java.awt.Dimension(90, 30)); + jPanel8.add(webLblQty, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 290, 100, -1)); + + webLblValue.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + webLblValue.setText(AppLocal.getIntString("label.stock.value")); // NOI18N + webLblValue.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N + webLblValue.setPreferredSize(new java.awt.Dimension(180, 30)); + jPanel8.add(webLblValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(355, 290, 170, -1)); + + add(jPanel8, java.awt.BorderLayout.PAGE_START); + + catcontainer.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + catcontainer.setMinimumSize(new java.awt.Dimension(0, 250)); + catcontainer.setPreferredSize(new java.awt.Dimension(0, 250)); + catcontainer.setRequestFocusEnabled(false); + catcontainer.setLayout(new java.awt.BorderLayout()); + add(catcontainer, java.awt.BorderLayout.CENTER); + catcontainer.getAccessibleContext().setAccessibleParent(jPanel8); + }// </editor-fold>//GEN-END:initComponents + + private void jTextField1KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyTyped + jTextField1.setText(null); + stateTransition(evt.getKeyChar()); + }//GEN-LAST:event_jTextField1KeyTyped + + private void jNumberKeysKeyPerformed(com.unicenta.beans.JNumberEvent evt) {//GEN-FIRST:event_jNumberKeysKeyPerformed + + stateTransition(evt.getKey()); + + }//GEN-LAST:event_jNumberKeysKeyPerformed + + + private void m_jreasonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jreasonActionPerformed + + m_jLocationDes.setEnabled(m_ReasonModel.getSelectedItem() == MovementReason.OUT_CROSSING); + + }//GEN-LAST:event_m_jreasonActionPerformed + + private void m_jbtndateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtndateActionPerformed + + Date date; + try { + date = (Date) Formats.TIMESTAMP.parseValue(m_jdate.getText()); + } catch (BasicException e) { + date = null; + } + date = JCalendarDialog.showCalendarTime(this, date); + if (date != null) { + m_jdate.setText(Formats.TIMESTAMP.formatValue(date)); + } + }//GEN-LAST:event_m_jbtndateActionPerformed + + private void m_jEnterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jEnterActionPerformed + + incProductByCode(m_jcodebar.getText()); + m_jcodebar.setText(null); + if (m_jSupplier.getSelectedItem() != null) { +// saveData(); + } else { + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.supplierinvalid"), + AppLocal.getIntString("message.title.supplierinvalid"), + JOptionPane.WARNING_MESSAGE); + } + }//GEN-LAST:event_m_jEnterActionPerformed + + private void m_jSupplierActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jSupplierActionPerformed +/* if (m_jSupplier != null) { + catcontainer.setEnabled(false); + jNumberKeys.setEnabled(true); + m_jcodebar.setEnabled(true); + m_jEnter.setEnabled(true); + m_jSupplierDoc.setEnabled(true); + m_jcodebar.setEnabled(true); + m_jEditLine.setEnabled(true); + m_jEditAttributes.setEnabled(true); + m_jBtnShowStock.setEnabled(true); + } else { + catcontainer.setEnabled(true); + jNumberKeys.setEnabled(false); + m_jcodebar.setEnabled(false); + m_jEnter.setEnabled(false); + m_jSupplierDoc.setEnabled(false); + m_jcodebar.setEnabled(false); + m_jEditLine.setEnabled(false); + m_jEditAttributes.setEnabled(false); + m_jBtnShowStock.setEnabled(false); + + } +*/ + }//GEN-LAST:event_m_jSupplierActionPerformed + + private void m_jBtnShowStockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBtnShowStockActionPerformed + + showStockTable(); + + }//GEN-LAST:event_m_jBtnShowStockActionPerformed + + private void m_jDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jDeleteActionPerformed + + int i = m_invlines.getSelectedRow(); + + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + removeInvLine(i); + + } + }//GEN-LAST:event_m_jDeleteActionPerformed + + private void m_jListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jListActionPerformed + + ProductInfoExt prod = JProductFinder.showMessage(StockManagement.this, m_dlSales); + if (prod != null) { + buttonTransition(prod); + } + + }//GEN-LAST:event_m_jListActionPerformed + + private void m_jEditLineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jEditLineActionPerformed + + int i = m_invlines.getSelectedRow(); + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + InventoryLine line = m_invlines.getLine(i); + + JFrame frame = new JFrame("New Price Buy"); + String spricebuy = JOptionPane.showInputDialog(frame, + AppLocal.getIntString("message.enterbuyprice"), + JOptionPane.INFORMATION_MESSAGE); + + if (spricebuy != null) { + double dpricebuy = Double.parseDouble(spricebuy); + line.setPrice(dpricebuy); + m_invlines.setLine(i, line); + } + } + }//GEN-LAST:event_m_jEditLineActionPerformed + + private void m_jEditAttributesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jEditAttributesActionPerformed + + int i = m_invlines.getSelectedRow(); + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + try { + InventoryLine line = m_invlines.getLine(i); + JProductAttEdit2 attedit = JProductAttEdit2.getAttributesEditor(this, m_App.getSession()); + attedit.editAttributes(line.getProductAttSetId(), line.getProductAttSetInstId()); + attedit.setVisible(true); + if (attedit.isOK()) { + line.setProductAttSetInstId(attedit.getAttributeSetInst()); + line.setProductAttSetInstDesc(attedit.getAttributeSetInstDescription()); + m_invlines.setLine(i, line); + } + } catch (BasicException ex) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotfindattributes"), ex); + msg.show(this); + } + } + }//GEN-LAST:event_m_jEditAttributesActionPerformed + + private void m_jBtnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBtnDeleteActionPerformed + + int res = JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.wannadelete"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + + if (res == JOptionPane.YES_OPTION) { + + int i = 0; + while (i < m_invlines.getCount()) { + m_invlines.deleteLine(i); + } + + clearStockTable(); + showStockTable(); + + lblTotalQtyValue.setText(null); + lbTotalValue.setText(null); + + jTableProductStock.repaint(); + } + + }//GEN-LAST:event_m_jBtnDeleteActionPerformed + + private void m_jcodebarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_m_jcodebarMouseClicked + m_jcodebar.requestFocusInWindow(); + jTextField1.requestFocus(); + m_jcodebar.setEnabled(true); + m_jcodebar.setText(null); + }//GEN-LAST:event_m_jcodebarMouseClicked + + private void m_jLocationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jLocationActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_m_jLocationActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel catcontainer; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private com.unicenta.beans.JNumberKeys jNumberKeys; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel8; + private javax.swing.JScrollPane jScrollPane2; + private com.alee.laf.table.WebTable jTableProductStock; + private javax.swing.JTextField jTextField1; + private javax.swing.JLabel lbTotalValue; + private javax.swing.JLabel lblTotalQtyValue; + private javax.swing.JButton m_jBtnDelete; + private javax.swing.JButton m_jBtnShowStock; + private javax.swing.JButton m_jDelete; + private javax.swing.JButton m_jEditAttributes; + private javax.swing.JButton m_jEditLine; + private javax.swing.JButton m_jEnter; + private javax.swing.JButton m_jList; + private javax.swing.JComboBox m_jLocation; + private javax.swing.JComboBox m_jLocationDes; + private javax.swing.JComboBox m_jSupplier; + private javax.swing.JTextField m_jSupplierDoc; + private javax.swing.JButton m_jbtndate; + private javax.swing.JLabel m_jcodebar; + private javax.swing.JTextField m_jdate; + private javax.swing.JComboBox m_jreason; + private com.alee.laf.label.WebLabel webLblQty; + private com.alee.laf.label.WebLabel webLblValue; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/StockModel.java b/src/main/java/com/unicenta/pos/inventory/StockModel.java new file mode 100644 index 0000000..4ebdc12 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/StockModel.java @@ -0,0 +1,73 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-130 + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.BrowsableData; +import com.unicenta.format.Formats; +import javax.swing.table.AbstractTableModel; + +/** + * + * @author adrianromero + */ +public class StockModel extends AbstractTableModel { + + private BrowsableData m_bd; + private Formats[] m_formats; + private boolean[] m_bedit; + + /** Creates a new instance of StockModel + * @param bd + * @param f + * @param bedit */ + public StockModel(BrowsableData bd, Formats[] f, boolean[] bedit) { + m_bd = bd; + m_formats = f; + m_bedit = bedit; + } + @Override + public int getRowCount() { + return m_bd.getSize(); + } + @Override + public int getColumnCount() { + return m_formats.length; + } + @Override + public Object getValueAt(int row, int column) { + return m_formats[column].formatValue( + ((Object[]) m_bd.getElementAt(row))[column]); + } + @Override + public boolean isCellEditable(int row, int column) { + return m_bedit[column]; + } + @Override + public void setValueAt(Object aValue, int row, int column) { + Object[] record = (Object[]) m_bd.getElementAt(row); + try { + record[column] = m_formats[column].parseValue((String) aValue); + m_bd.updateRecord(row, record); + } catch (BasicException e) { + } + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/TaxCategoriesEditor.form b/src/main/java/com/unicenta/pos/inventory/TaxCategoriesEditor.form new file mode 100644 index 0000000..f604ab9 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/TaxCategoriesEditor.form @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" pref="80" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jName" min="-2" pref="200" max="-2" attributes="0"/> + <EmptySpace min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/info.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.name" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[34, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jLabel2MouseClicked"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[34, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/TaxCategoriesEditor.java b/src/main/java/com/unicenta/pos/inventory/TaxCategoriesEditor.java new file mode 100644 index 0000000..1016b05 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/TaxCategoriesEditor.java @@ -0,0 +1,197 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.util.UUID; +import javax.swing.JOptionPane; +import javax.swing.JPanel; + +/** + * + * @author JG uniCenta + */ +public final class TaxCategoriesEditor extends JPanel implements EditorRecord { + + private Object m_oId; + + /** Creates new form taxEditor + * @param dirty */ + public TaxCategoriesEditor(DirtyManager dirty) { + initComponents(); + + m_jName.getDocument().addDocumentListener(dirty); + + writeValueEOF(); + } + + /** + * + */ + @Override + public void writeValueEOF() { + m_oId = null; + m_jName.setText(null); + m_jName.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + m_oId = UUID.randomUUID().toString(); + m_jName.setText(null); + m_jName.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + + Object[] taxcustcat = (Object[]) value; + m_oId = taxcustcat[0]; + m_jName.setText(Formats.STRING.formatValue(taxcustcat[1])); + m_jName.setEnabled(false); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + + Object[] taxcustcat = (Object[]) value; + m_oId = taxcustcat[0]; + m_jName.setText(Formats.STRING.formatValue(taxcustcat[1])); + m_jName.setEnabled(true); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] taxcustcat = new Object[2]; + + taxcustcat[0] = m_oId; + taxcustcat[1] = m_jName.getText(); + + return taxcustcat; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + */ + @Override + public void refresh() { + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel2 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/info.png"))); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.name")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(34, 30)); + jLabel2.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel2MouseClicked(evt); + } + }); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(34, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MouseClicked + + if (evt.getClickCount() == 2) { + String uuidString = m_oId.toString(); + StringSelection stringSelection = new StringSelection(uuidString); + Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); + clpbrd.setContents(stringSelection, null); + + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.uuidcopy")); + } + }//GEN-LAST:event_jLabel2MouseClicked + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel2; + private javax.swing.JTextField m_jName; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/TaxCategoriesPanel.java b/src/main/java/com/unicenta/pos/inventory/TaxCategoriesPanel.java new file mode 100644 index 0000000..7dd8e7a --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/TaxCategoriesPanel.java @@ -0,0 +1,120 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +/** + * + * @author adrianromero + */ +public class TaxCategoriesPanel extends JPanelTable { + + private TableDefinition ttaxcategories; + private TaxCustCategoriesEditor jeditor; + + /** Creates a new instance of JPanelDuty */ + public TaxCategoriesPanel() { + } + + /** + * + */ + @Override + protected void init() { + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + ttaxcategories = dlSales.getTableTaxCategories(); + jeditor = new TaxCustCategoriesEditor(dirty); + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return new ListProviderCreator(ttaxcategories); + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(ttaxcategories); + } + + /** + * + * @return + */ + @Override + public Vectorer getVectorer() { + return ttaxcategories.getVectorerBasic(new int[]{1}); + } + + /** + * + * @return + */ + @Override + public ComparatorCreator getComparatorCreator() { + return ttaxcategories.getComparatorCreator(new int[] {1}); + } + + /** + * + * @return + */ + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(ttaxcategories.getRenderStringBasic(new int[]{1})); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.TaxCategories"); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/inventory/TaxCategoryInfo.java b/src/main/java/com/unicenta/pos/inventory/TaxCategoryInfo.java new file mode 100644 index 0000000..883c4f1 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/TaxCategoryInfo.java @@ -0,0 +1,91 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.data.loader.IKeyed; +import java.io.Serializable; + +/** + * + * @author adrianromero + * @version + */ +public class TaxCategoryInfo implements Serializable, IKeyed { + + private static final long serialVersionUID = 8959679342805L; + private String m_sID; + private String m_sName; + + /** + * + * @param sID + * @param sName + */ + public TaxCategoryInfo(String sID, String sName) { + m_sID = sID; + m_sName = sName; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return m_sID; + } + + /** + * + * @param sID + */ + public void setID(String sID) { + m_sID = sID; + } + + /** + * + * @return + */ + public String getID() { + return m_sID; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + + /** + * + * @param sName + */ + public void setName(String sName) { + m_sName = sName; + } + + @Override + public String toString(){ + return m_sName; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/inventory/TaxCustCategoriesEditor.form b/src/main/java/com/unicenta/pos/inventory/TaxCustCategoriesEditor.form new file mode 100644 index 0000000..afbd4ef --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/TaxCustCategoriesEditor.form @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/info.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.name" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jLabel2MouseClicked"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="20" width="80" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="100" y="20" width="200" height="25"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/TaxCustCategoriesEditor.java b/src/main/java/com/unicenta/pos/inventory/TaxCustCategoriesEditor.java new file mode 100644 index 0000000..289ca4b --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/TaxCustCategoriesEditor.java @@ -0,0 +1,182 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +/// Foundation, Inc., 51 Franklin Street, Fifth floor, Boston, MA 02110-1301 USA + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.util.UUID; +import javax.swing.JOptionPane; +import javax.swing.JPanel; + +/** + * + * @author JG uniCenta + */ +public final class TaxCustCategoriesEditor extends JPanel implements EditorRecord { + + private Object m_oId; + + /** Creates new form taxEditor + * @param dirty */ + public TaxCustCategoriesEditor(DirtyManager dirty) { + initComponents(); + + m_jName.getDocument().addDocumentListener(dirty); + + writeValueEOF(); + } + + /** + * + */ + @Override + public void writeValueEOF() { + m_oId = null; + m_jName.setText(null); + m_jName.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + m_oId = UUID.randomUUID().toString(); + m_jName.setText(null); + m_jName.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + + Object[] taxcustcat = (Object[]) value; + m_oId = taxcustcat[0]; + m_jName.setText(Formats.STRING.formatValue(taxcustcat[1])); + m_jName.setEnabled(false); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + + Object[] taxcustcat = (Object[]) value; + m_oId = taxcustcat[0]; + m_jName.setText(Formats.STRING.formatValue(taxcustcat[1])); + m_jName.setEnabled(true); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] taxcustcat = new Object[2]; + + taxcustcat[0] = m_oId; + taxcustcat[1] = m_jName.getText(); + + return taxcustcat; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + */ + @Override + public void refresh() { + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel2 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + + setLayout(null); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/info.png"))); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.name")); // NOI18N + jLabel2.setToolTipText(""); + jLabel2.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel2MouseClicked(evt); + } + }); + add(jLabel2); + jLabel2.setBounds(20, 20, 80, 25); + + m_jName.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + add(m_jName); + m_jName.setBounds(100, 20, 200, 25); + }// </editor-fold>//GEN-END:initComponents + + private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MouseClicked + + if (evt.getClickCount() == 2) { + String uuidString = m_oId.toString(); + StringSelection stringSelection = new StringSelection(uuidString); + Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); + clpbrd.setContents(stringSelection, null); + + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.uuidcopy")); + } + }//GEN-LAST:event_jLabel2MouseClicked + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel2; + private javax.swing.JTextField m_jName; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/TaxCustCategoriesPanel.java b/src/main/java/com/unicenta/pos/inventory/TaxCustCategoriesPanel.java new file mode 100644 index 0000000..874b739 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/TaxCustCategoriesPanel.java @@ -0,0 +1,120 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +/** + * + * @author adrianromero + */ +public class TaxCustCategoriesPanel extends JPanelTable { + + private TableDefinition ttaxcategories; + private TaxCustCategoriesEditor jeditor; + + /** Creates a new instance of JPanelDuty */ + public TaxCustCategoriesPanel() { + } + + /** + * + */ + @Override + protected void init() { + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + ttaxcategories = dlSales.getTableTaxCustCategories(); + jeditor = new TaxCustCategoriesEditor(dirty); + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return new ListProviderCreator(ttaxcategories); + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(ttaxcategories); + } + + /** + * + * @return + */ + @Override + public Vectorer getVectorer() { + return ttaxcategories.getVectorerBasic(new int[]{1}); + } + + /** + * + * @return + */ + @Override + public ComparatorCreator getComparatorCreator() { + return ttaxcategories.getComparatorCreator(new int[] {1}); + } + + /** + * + * @return + */ + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(ttaxcategories.getRenderStringBasic(new int[]{1})); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.TaxCustCategories"); + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/TaxCustCategoryInfo.java b/src/main/java/com/unicenta/pos/inventory/TaxCustCategoryInfo.java new file mode 100644 index 0000000..5c66f83 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/TaxCustCategoryInfo.java @@ -0,0 +1,88 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.data.loader.IKeyed; + +/** + * + * @author adrianromero + * @version + */ +public class TaxCustCategoryInfo implements IKeyed { + + private static final long serialVersionUID = 8936482715929L; + private String m_sID; + private String m_sName; + + /** Creates new TaxCustCategoryInfo + * @param id + * @param name */ + public TaxCustCategoryInfo(String id, String name) { + m_sID = id; + m_sName = name; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return m_sID; + } + + /** + * + * @param sID + */ + public void setID(String sID) { + m_sID = sID; + } + + /** + * + * @return + */ + public String getID() { + return m_sID; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + + /** + * + * @param sName + */ + public void setName(String sName) { + m_sName = sName; + } + + @Override + public String toString(){ + return m_sName; + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/TaxEditor.form b/src/main/java/com/unicenta/pos/inventory/TaxEditor.form new file mode 100644 index 0000000..0267d6f --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/TaxEditor.form @@ -0,0 +1,259 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jTaxCategory" min="-2" pref="200" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCustTaxCategory" min="-2" pref="200" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jTaxParent" min="-2" pref="200" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jRate" min="-2" pref="60" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="16" max="-2" attributes="0"/> + <Component id="jCascade" min="-2" pref="110" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jName" min="-2" pref="200" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jOrder" min="-2" pref="60" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace pref="50" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jTaxCategory" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCustTaxCategory" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jTaxParent" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jRate" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jCascade" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jOrder" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/info.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.name" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jLabel2MouseClicked"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.dutyrate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jRate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.taxcategory" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.custtaxcategory" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.taxparent" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="jCascade"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.cascade" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jTaxCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jTaxParent"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCustTaxCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.order" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jOrder"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/TaxEditor.java b/src/main/java/com/unicenta/pos/inventory/TaxEditor.java new file mode 100644 index 0000000..6d7449d --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/TaxEditor.java @@ -0,0 +1,428 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import java.awt.Component; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import javax.swing.JOptionPane; +import javax.swing.JPanel; + +/** + * + * @author JG uniCenta + */ +public class TaxEditor extends JPanel implements EditorRecord { + + private Object m_oId; + + private SentenceList taxcatsent; + private ComboBoxValModel taxcatmodel; + + private SentenceList taxcustcatsent; + private ComboBoxValModel taxcustcatmodel; + + private SentenceList taxparentsent; + private ComboBoxValModel taxparentmodel; + + /** Creates new form taxEditor + * @param app + * @param dirty */ + public TaxEditor(AppView app, DirtyManager dirty) { + + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + initComponents(); + + taxcatsent = dlSales.getTaxCategoriesList(); + taxcatmodel = new ComboBoxValModel(); + + taxcustcatsent = dlSales.getTaxCustCategoriesList(); + taxcustcatmodel = new ComboBoxValModel(); + + taxparentsent = dlSales.getTaxList(); + taxparentmodel = new ComboBoxValModel(); + + m_jName.getDocument().addDocumentListener(dirty); + m_jTaxCategory.addActionListener(dirty); + m_jCustTaxCategory.addActionListener(dirty); + m_jTaxParent.addActionListener(dirty); + m_jRate.getDocument().addDocumentListener(dirty); + jCascade.addActionListener(dirty); + jOrder.getDocument().addDocumentListener(dirty); + + writeValueEOF(); + } + + /** + * + * @throws BasicException + */ + public void activate() throws BasicException { + + List a = taxcatsent.list(); + taxcatmodel = new ComboBoxValModel(a); + m_jTaxCategory.setModel(taxcatmodel); + + a = taxcustcatsent.list(); + a.add(0, null); // The null item + taxcustcatmodel = new ComboBoxValModel(a); + m_jCustTaxCategory.setModel(taxcustcatmodel); + + + } + + /** + * + */ + @Override + public void refresh() { + + List a; + + try { + a = taxparentsent.list(); + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotloadlists"), eD); + msg.show(this); + a = new ArrayList(); + } + + a.add(0, null); // The null item + taxparentmodel = new ComboBoxValModel(a); + m_jTaxParent.setModel(taxparentmodel); + } + + /** + * + */ + @Override + public void writeValueEOF() { + m_oId = null; + m_jName.setText(null); + taxcatmodel.setSelectedKey(null); + taxcustcatmodel.setSelectedKey(null); + taxparentmodel.setSelectedKey(null); + m_jRate.setText(null); + jCascade.setSelected(false); + jOrder.setText(null); + + m_jName.setEnabled(false); + m_jTaxCategory.setEnabled(false); + m_jCustTaxCategory.setEnabled(false); + m_jTaxParent.setEnabled(false); + m_jRate.setEnabled(false); + jCascade.setEnabled(false); + jOrder.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + m_oId = UUID.randomUUID().toString(); + m_jName.setText(null); + taxcatmodel.setSelectedKey(null); + taxcustcatmodel.setSelectedKey(null); + taxparentmodel.setSelectedKey(null); + m_jRate.setText(null); + jCascade.setSelected(false); + jOrder.setText(null); + + m_jName.setEnabled(true); + m_jTaxCategory.setEnabled(true); + m_jCustTaxCategory.setEnabled(true); + m_jTaxParent.setEnabled(true); + m_jRate.setEnabled(true); + jCascade.setEnabled(true); + jOrder.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + + Object[] tax = (Object[]) value; + m_oId = tax[0]; + m_jName.setText(Formats.STRING.formatValue(tax[1])); + taxcatmodel.setSelectedKey(tax[2]); + taxcustcatmodel.setSelectedKey(tax[3]); + taxparentmodel.setSelectedKey(tax[4]); + m_jRate.setText(Formats.PERCENT.formatValue(tax[5])); + jCascade.setSelected((Boolean) tax[6]); + jOrder.setText(Formats.INT.formatValue(tax[7])); + + m_jName.setEnabled(false); + m_jTaxCategory.setEnabled(false); + m_jCustTaxCategory.setEnabled(false); + m_jTaxParent.setEnabled(false); + m_jRate.setEnabled(false); + jCascade.setEnabled(false); + jOrder.setEnabled(false); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + + Object[] tax = (Object[]) value; + m_oId = tax[0]; + m_jName.setText(Formats.STRING.formatValue(tax[1])); + taxcatmodel.setSelectedKey(tax[2]); + taxcustcatmodel.setSelectedKey(tax[3]); + taxparentmodel.setSelectedKey(tax[4]); + m_jRate.setText(Formats.PERCENT.formatValue(tax[5])); + jCascade.setSelected((Boolean) tax[6]); + jOrder.setText(Formats.INT.formatValue(tax[7])); + + m_jName.setEnabled(true); + m_jTaxCategory.setEnabled(true); + m_jCustTaxCategory.setEnabled(true); + m_jTaxParent.setEnabled(true); + m_jRate.setEnabled(true); + jCascade.setEnabled(true); + jOrder.setEnabled(true); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] tax = new Object[8]; + + tax[0] = m_oId; + tax[1] = m_jName.getText(); + tax[2] = taxcatmodel.getSelectedKey(); + tax[3] = taxcustcatmodel.getSelectedKey(); + tax[4] = taxparentmodel.getSelectedKey(); + tax[5] = Formats.PERCENT.parseValue(m_jRate.getText()); + tax[6] = Boolean.valueOf(jCascade.isSelected()); + tax[7] = Formats.INT.parseValue(jOrder.getText()); + + return tax; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jName = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + m_jRate = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jCascade = new javax.swing.JCheckBox(); + m_jTaxCategory = new javax.swing.JComboBox(); + m_jTaxParent = new javax.swing.JComboBox(); + m_jCustTaxCategory = new javax.swing.JComboBox(); + jLabel6 = new javax.swing.JLabel(); + jOrder = new javax.swing.JTextField(); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/info.png"))); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.name")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(170, 30)); + jLabel2.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel2MouseClicked(evt); + } + }); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.dutyrate")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(170, 30)); + + m_jRate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jRate.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.taxcategory")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(170, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.custtaxcategory")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(170, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.taxparent")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(170, 30)); + + jCascade.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jCascade.setText(AppLocal.getIntString("label.cascade")); // NOI18N + jCascade.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jTaxCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTaxCategory.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jTaxParent.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTaxParent.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jCustTaxCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCustTaxCategory.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.order")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(170, 30)); + + jOrder.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jOrder.setPreferredSize(new java.awt.Dimension(0, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jTaxCategory, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCustTaxCategory, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jTaxParent, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jRate, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(16, 16, 16) + .addComponent(jCascade, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jOrder, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(50, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jTaxCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCustTaxCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jTaxParent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jCascade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jOrder, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MouseClicked + + if (evt.getClickCount() == 2) { + String uuidString = m_oId.toString(); + StringSelection stringSelection = new StringSelection(uuidString); + Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); + clpbrd.setContents(stringSelection, null); + + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.uuidcopy")); + } + }//GEN-LAST:event_jLabel2MouseClicked + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBox jCascade; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JTextField jOrder; + private javax.swing.JComboBox m_jCustTaxCategory; + private javax.swing.JTextField m_jName; + private javax.swing.JTextField m_jRate; + private javax.swing.JComboBox m_jTaxCategory; + private javax.swing.JComboBox m_jTaxParent; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/inventory/TaxPanel.java b/src/main/java/com/unicenta/pos/inventory/TaxPanel.java new file mode 100644 index 0000000..e4d988e --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/TaxPanel.java @@ -0,0 +1,132 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +/** + * + * @author adrianromero + */ +public class TaxPanel extends JPanelTable { + + private TableDefinition ttaxes; + private TaxEditor jeditor; + + /** Creates a new instance of JPanelDuty */ + public TaxPanel() { + } + + /** + * + */ + @Override + protected void init() { + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + ttaxes = dlSales.getTableTaxes(); + jeditor = new TaxEditor(app, dirty); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + jeditor.activate(); + super.activate(); + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return new ListProviderCreator(ttaxes); + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(ttaxes); + } + + /** + * + * @return + */ + @Override + public Vectorer getVectorer() { + return ttaxes.getVectorerBasic(new int[]{1, 5, 7}); + } + + /** + * + * @return + */ + @Override + public ComparatorCreator getComparatorCreator() { + return ttaxes.getComparatorCreator(new int[] {1, 5, 7}); + } + + /** + * + * @return + */ + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(ttaxes.getRenderStringBasic(new int[]{1})); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Taxes"); + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/UomEditor.form b/src/main/java/com/unicenta/pos/inventory/UomEditor.form new file mode 100644 index 0000000..72401aa --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/UomEditor.form @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="36" max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jName" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="54" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="25" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace pref="35" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/info.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.name" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jLabel2MouseClicked"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/inventory/UomEditor.java b/src/main/java/com/unicenta/pos/inventory/UomEditor.java new file mode 100644 index 0000000..557bbdc --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/UomEditor.java @@ -0,0 +1,158 @@ +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import java.awt.Component; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.util.UUID; +import javax.swing.JOptionPane; + +public final class UomEditor extends javax.swing.JPanel implements EditorRecord { + private Object m_id; + + /** Creates new form JPanelUnits Of Measure + * @param app + * @param dirty */ + public UomEditor(AppView app, DirtyManager dirty) { + + initComponents(); + + m_jName.getDocument().addDocumentListener(dirty); + + writeValueEOF(); + } + + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel2 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/info.png"))); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.name")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(100, 30)); + jLabel2.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel2MouseClicked(evt); + } + }); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(200, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(36, 36, 36) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(54, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(25, 25, 25) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(35, Short.MAX_VALUE)) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MouseClicked + + if (evt.getClickCount() == 2) { + String uuidString = m_id.toString(); + StringSelection stringSelection = new StringSelection(uuidString); + Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); + clpbrd.setContents(stringSelection, null); + + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.uuidcopy")); + } + }//GEN-LAST:event_jLabel2MouseClicked + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel2; + private javax.swing.JTextField m_jName; + // End of variables declaration//GEN-END:variables + + @Override + public void writeValueEOF() { + m_id = null; + m_jName.setText(null); + m_jName.setEnabled(false); + } + + @Override + public void writeValueInsert() { + + m_id = UUID.randomUUID().toString(); + m_jName.setText(null); + m_jName.setEnabled(true); + + } + + @Override + public void writeValueEdit(Object value) { + Object[] obj = (Object[]) value; + + m_id = obj[0]; + m_jName.setText(Formats.STRING.formatValue(obj[1])); + m_jName.setEnabled(true); + + } + + @Override + public void writeValueDelete(Object value) { + Object[] obj = (Object[]) value; + + m_id = obj[0]; + m_jName.setText(Formats.STRING.formatValue(obj[1])); + m_jName.setEnabled(false); + + } + + @Override + public void refresh() { + } + + @Override + public Component getComponent() { + return this; + } + + @Override + public Object createValue() throws BasicException { + Object[] obj = new Object[2]; + obj[0] = m_id; + obj[1] = m_jName.getText(); + + return obj; + + } + + public boolean isDataValid() { + return true; + } +} diff --git a/src/main/java/com/unicenta/pos/inventory/UomInfo.java b/src/main/java/com/unicenta/pos/inventory/UomInfo.java new file mode 100644 index 0000000..6720324 --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/UomInfo.java @@ -0,0 +1,59 @@ +package com.unicenta.pos.inventory; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.loader.SerializerRead; + +public class UomInfo implements IKeyed { + + private String m_sID; + private String m_sName; + + + + /** Creates new CategoryInfo + * @param id + * @param name */ + public UomInfo(String id, String name) { + m_sID = id; + m_sName = name; + } + + + public void setID(String sID) { + m_sID = sID; + } + + public String getID() { + return m_sID; + } + + public String getName() { + return m_sName; + } + + public void setName(String sName) { + m_sName = sName; + } + + + @Override + public Object getKey() { + return m_sID; + } + + @Override + public String toString() { + return m_sName; + } + + public static SerializerRead getSerializerRead() { + return new SerializerRead() {@Override + public Object readValues(DataRead dr) throws BasicException { + return new UomInfo(dr.getString(1), dr.getString(2)); + }}; + } + + +} diff --git a/src/main/java/com/unicenta/pos/inventory/UomPanel.java b/src/main/java/com/unicenta/pos/inventory/UomPanel.java new file mode 100644 index 0000000..364ad4e --- /dev/null +++ b/src/main/java/com/unicenta/pos/inventory/UomPanel.java @@ -0,0 +1,59 @@ +package com.unicenta.pos.inventory; + +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +public class UomPanel extends JPanelTable { + + private TableDefinition tuom; + private UomEditor jeditor; + + @Override + protected void init() { + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + tuom = dlSales.getTableUom(); + jeditor = new UomEditor(app, dirty); + } + + @Override + public EditorRecord getEditor() { + return jeditor; + } + + @Override + public ListProvider getListProvider() { + return new ListProviderCreator(tuom); + } + + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(tuom); + } + + @Override + public Vectorer getVectorer() { + return tuom.getVectorerBasic(new int[]{1}); + } + + + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(tuom.getRenderStringBasic(new int[]{1})); + } + + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Uom"); + } + +} diff --git a/src/main/java/com/unicenta/pos/mant/Applications.java b/src/main/java/com/unicenta/pos/mant/Applications.java new file mode 100644 index 0000000..ce23f36 --- /dev/null +++ b/src/main/java/com/unicenta/pos/mant/Applications.java @@ -0,0 +1,122 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.mant; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.Serializable; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Transient; + +/** + * + * @author jack + */ +@Entity +@Table(name = "applications", catalog = "unicentaopos", schema = "") +@NamedQueries({ + @NamedQuery(name = "Applications.findAll", query = "SELECT a FROM Applications a"), + @NamedQuery(name = "Applications.findById", query = "SELECT a FROM Applications a WHERE a.id = :id"), + @NamedQuery(name = "Applications.findByName", query = "SELECT a FROM Applications a WHERE a.name = :name"), + @NamedQuery(name = "Applications.findByVersion", query = "SELECT a FROM Applications a WHERE a.version = :version")}) +public class Applications implements Serializable { + @Transient + private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this); + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @Column(name = "ID") + private String id; + @Basic(optional = false) + @Column(name = "NAME") + private String name; + @Basic(optional = false) + @Column(name = "VERSION") + private String version; + + public Applications() { + } + + public Applications(String id) { + this.id = id; + } + + public Applications(String id, String name, String version) { + this.id = id; + this.name = name; + this.version = version; + } + + public String getId() { + return id; + } + + public void setId(String id) { + String oldId = this.id; + this.id = id; + changeSupport.firePropertyChange("id", oldId, id); + } + + public String getName() { + return name; + } + + public void setName(String name) { + String oldName = this.name; + this.name = name; + changeSupport.firePropertyChange("name", oldName, name); + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + String oldVersion = this.version; + this.version = version; + changeSupport.firePropertyChange("version", oldVersion, version); + } + + @Override + public int hashCode() { + int hash = 0; + hash += (id != null ? id.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Applications)) { + return false; + } + Applications other = (Applications) object; + if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "com.unicenta.pos.mant.Applications[ id=" + id + " ]"; + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + changeSupport.addPropertyChangeListener(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + changeSupport.removePropertyChangeListener(listener); + } + +} diff --git a/src/main/java/com/unicenta/pos/mant/Floors.java b/src/main/java/com/unicenta/pos/mant/Floors.java new file mode 100644 index 0000000..4d9c015 --- /dev/null +++ b/src/main/java/com/unicenta/pos/mant/Floors.java @@ -0,0 +1,121 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.mant; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.Serializable; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Transient; + +/** + * + * @author jack + */ +@Entity +@Table(name = "floors", catalog = "unicentaopos", schema = "") +@NamedQueries({ + @NamedQuery(name = "Floors.findAll", query = "SELECT f FROM Floors f"), + @NamedQuery(name = "Floors.findById", query = "SELECT f FROM Floors f WHERE f.id = :id"), + @NamedQuery(name = "Floors.findByName", query = "SELECT f FROM Floors f WHERE f.name = :name")}) +public class Floors implements Serializable { + @Transient + private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this); + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @Column(name = "ID") + private String id; + @Basic(optional = false) + @Column(name = "NAME") + private String name; + @Lob + @Column(name = "IMAGE") + private byte[] image; + + public Floors() { + } + + public Floors(String id) { + this.id = id; + } + + public Floors(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + String oldId = this.id; + this.id = id; + changeSupport.firePropertyChange("id", oldId, id); + } + + public String getName() { + return name; + } + + public void setName(String name) { + String oldName = this.name; + this.name = name; + changeSupport.firePropertyChange("name", oldName, name); + } + + public byte[] getImage() { + return image; + } + + public void setImage(byte[] image) { + byte[] oldImage = this.image; + this.image = image; + changeSupport.firePropertyChange("image", oldImage, image); + } + + @Override + public int hashCode() { + int hash = 0; + hash += (id != null ? id.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Floors)) { + return false; + } + Floors other = (Floors) object; + if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "com.unicenta.pos.mant.Floors[ id=" + id + " ]"; + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + changeSupport.addPropertyChangeListener(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + changeSupport.removePropertyChangeListener(listener); + } + +} diff --git a/src/main/java/com/unicenta/pos/mant/FloorsEditor.form b/src/main/java/com/unicenta/pos/mant/FloorsEditor.form new file mode 100644 index 0000000..dcbc2bc --- /dev/null +++ b/src/main/java/com/unicenta/pos/mant/FloorsEditor.form @@ -0,0 +1,105 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[91, 125]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,12,0,0,2,-121"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 100]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.name" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="130" y="20" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="5" right="0" top="0"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="com.unicenta.data.gui.JImageEditor" name="m_jImage"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/mant/FloorsEditor.java b/src/main/java/com/unicenta/pos/mant/FloorsEditor.java new file mode 100644 index 0000000..fa4e394 --- /dev/null +++ b/src/main/java/com/unicenta/pos/mant/FloorsEditor.java @@ -0,0 +1,197 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.mant; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; +import java.awt.image.BufferedImage; +import java.util.UUID; +import javax.swing.JPanel; + + +/** + * + * @author adrianromero + */ +public final class FloorsEditor extends JPanel implements EditorRecord { + +// private DirtyManager m_Dirty = new DirtyManager(); + private String m_sID; + + /** Creates new form FloorsEditor + * @param dirty */ + public FloorsEditor(DirtyManager dirty) { + initComponents(); + + m_jName.getDocument().addDocumentListener(dirty); + m_jImage.addPropertyChangeListener("image", dirty); + + writeValueEOF(); + } + + /** + * + */ + @Override + public void writeValueEOF() { + + m_sID = null; + m_jName.setText(null); + m_jImage.setImage(null); + + m_jName.setEnabled(false); + m_jImage.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + + m_sID = UUID.randomUUID().toString(); + m_jName.setText(null); + m_jImage.setImage(null); + + m_jName.setEnabled(true); + m_jImage.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + + Object[] floor = (Object[]) value; + m_sID = Formats.STRING.formatValue(floor[0]); + m_jName.setText(Formats.STRING.formatValue(floor[1])); + m_jImage.setImage((BufferedImage) floor[2]); + + m_jName.setEnabled(false); + m_jImage.setEnabled(false); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + + Object[] floor = (Object[]) value; + m_sID = Formats.STRING.formatValue(floor[0]); + m_jName.setText(Formats.STRING.formatValue(floor[1])); + m_jImage.setImage((BufferedImage) floor[2]); + + m_jName.setEnabled(true); + m_jImage.setEnabled(true); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] floor = new Object[3]; + + floor[0] = m_sID; + floor[1] = m_jName.getText(); + floor[2] = m_jImage.getImage(); + return floor; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + */ + @Override + public void refresh() { + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLabel3 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + jPanel3 = new javax.swing.JPanel(); + m_jImage = new com.unicenta.data.gui.JImageEditor(); + + setMinimumSize(new java.awt.Dimension(91, 125)); + setLayout(new java.awt.BorderLayout()); + + jPanel1.setPreferredSize(new java.awt.Dimension(150, 100)); + jPanel1.setLayout(null); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.name")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(110, 30)); + jPanel1.add(jLabel3); + jLabel3.setBounds(20, 20, 110, 30); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(250, 30)); + jPanel1.add(m_jName); + m_jName.setBounds(130, 20, 250, 30); + + add(jPanel1, java.awt.BorderLayout.NORTH); + + jPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 0)); + jPanel3.setLayout(new java.awt.BorderLayout()); + + m_jImage.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel3.add(m_jImage, java.awt.BorderLayout.CENTER); + + add(jPanel3, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel3; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel3; + private com.unicenta.data.gui.JImageEditor m_jImage; + private javax.swing.JTextField m_jName; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/mant/FloorsInfo.java b/src/main/java/com/unicenta/pos/mant/FloorsInfo.java new file mode 100644 index 0000000..05375e8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/mant/FloorsInfo.java @@ -0,0 +1,101 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.mant; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.loader.SerializableRead; + +/** + * + * @author adrianromero + * Created on 26 de febrero de 2007, 23:49 + * + */ +public class FloorsInfo implements SerializableRead, IKeyed { + + private static final long serialVersionUID = 8906929819402L; + private String m_sID; + private String m_sName; + + /** Creates a new instance of FloorsInfo */ + public FloorsInfo() { + m_sID = null; + m_sName = null; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return m_sID; + } + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_sID = dr.getString(1); + m_sName = dr.getString(2); + } + + /** + * + * @param sID + */ + public void setID(String sID) { + m_sID = sID; + } + + /** + * + * @return + */ + public String getID() { + return m_sID; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + + /** + * + * @param sName + */ + public void setName(String sName) { + m_sName = sName; + } + + @Override + public String toString(){ + return m_sName; + } +} diff --git a/src/main/java/com/unicenta/pos/mant/JPanelFloors.java b/src/main/java/com/unicenta/pos/mant/JPanelFloors.java new file mode 100644 index 0000000..75bc329 --- /dev/null +++ b/src/main/java/com/unicenta/pos/mant/JPanelFloors.java @@ -0,0 +1,117 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.mant; + +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +/** + * + * @author adrianromero + */ +public class JPanelFloors extends JPanelTable { + + private TableDefinition tfloors; + private FloorsEditor jeditor; + + /** Creates a new instance of JPanelFloors */ + public JPanelFloors() { + } + + /** + * + */ + @Override + protected void init() { + tfloors = new TableDefinition(app.getSession(), + "floors" + , new String[] {"ID", "NAME", "IMAGE"} + , new String[] {"ID", AppLocal.getIntString("label.name"), "IMAGE"} + , new Datas[] {Datas.STRING, Datas.STRING, Datas.IMAGE} + , new Formats[] {Formats.NULL, Formats.STRING} + , new int[] {0} + ); + jeditor = new FloorsEditor(dirty); + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return new ListProviderCreator(tfloors); + } + + /** + * + * @return + */ + @Override + public Vectorer getVectorer() { + return tfloors.getVectorerBasic(new int[]{1}); + } + + /** + * + * @return + */ + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(tfloors.getRenderStringBasic(new int[]{1})); + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(tfloors); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Floors"); + } +} diff --git a/src/main/java/com/unicenta/pos/mant/JPanelPlaces.java b/src/main/java/com/unicenta/pos/mant/JPanelPlaces.java new file mode 100644 index 0000000..c9bfc4c --- /dev/null +++ b/src/main/java/com/unicenta/pos/mant/JPanelPlaces.java @@ -0,0 +1,141 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.mant; +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +/** + * + * @author adrianromero + */ +public class JPanelPlaces extends JPanelTable { + + private TableDefinition tplaces; + private PlacesEditor jeditor; + + /** Creates a new instance of JPanelPlaces */ + public JPanelPlaces() { + } + + /** + * + */ + @Override + protected void init() { + DataLogicSales dlSales = null; + dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + tplaces = new TableDefinition(app.getSession(), + "places" + , new String[] {"ID", "NAME", "SEATS", "X", "Y", "FLOOR", "WIDTH", "HEIGHT"} + , new String[] {"ID", AppLocal.getIntString("label.name"), + AppLocal.getIntString("label.seats"), "X", "Y", + AppLocal.getIntString("label.placefloor")} + , new Datas[] { + Datas.STRING, Datas.STRING, Datas.STRING, + Datas.INT, Datas.INT, + Datas.STRING, + Datas.INT, Datas.INT } + , new Formats[] { + Formats.STRING, Formats.STRING, Formats.STRING, + Formats.INT, Formats.INT, + Formats.NULL, + Formats.INT, Formats.INT } + , new int[] {0} + ); + jeditor = new PlacesEditor(dlSales, dirty); + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return new ListProviderCreator(tplaces); + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(tplaces); + } + + /** + * + * @return + */ + @Override + public Vectorer getVectorer() { + return tplaces.getVectorerBasic(new int[]{1}); + } + + /** + * + * @return + */ + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(tplaces.getRenderStringBasic(new int[]{1})); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Tables"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + jeditor.activate(); + super.activate(); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/mant/Places.java b/src/main/java/com/unicenta/pos/mant/Places.java new file mode 100644 index 0000000..36f9368 --- /dev/null +++ b/src/main/java/com/unicenta/pos/mant/Places.java @@ -0,0 +1,245 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.mant; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.Serializable; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Transient; + +/** + * + * @author jack + */ +@Entity +@Table(name = "places", catalog = "unicentaopos", schema = "") +@NamedQueries({ + @NamedQuery(name = "Places.findAll", query = "SELECT p FROM Places p"), + @NamedQuery(name = "Places.findById", query = "SELECT p FROM Places p WHERE p.id = :id"), + @NamedQuery(name = "Places.findByName", query = "SELECT p FROM Places p WHERE p.name = :name"), + @NamedQuery(name = "Places.findByX", query = "SELECT p FROM Places p WHERE p.x = :x"), + @NamedQuery(name = "Places.findByY", query = "SELECT p FROM Places p WHERE p.y = :y"), + @NamedQuery(name = "Places.findByFloor", query = "SELECT p FROM Places p WHERE p.floor = :floor"), + @NamedQuery(name = "Places.findByCustomer", query = "SELECT p FROM Places p WHERE p.customer = :customer"), + @NamedQuery(name = "Places.findByWaiter", query = "SELECT p FROM Places p WHERE p.waiter = :waiter"), + @NamedQuery(name = "Places.findByTicketid", query = "SELECT p FROM Places p WHERE p.ticketid = :ticketid"), + @NamedQuery(name = "Places.findByTablemoved", query = "SELECT p FROM Places p WHERE p.tablemoved = :tablemoved")}) +public class Places implements Serializable { + @Transient + private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this); + private static final long serialVersionUID = 1L; + @Id + @Basic(optional = false) + @Column(name = "ID") + private String id; + @Basic(optional = false) + @Column(name = "NAME") + private String name; + @Column(name = "SEATS") + private String seats; + @Basic(optional = false) + @Column(name = "X") + private int x; + @Basic(optional = false) + @Column(name = "Y") + private int y; + @Basic(optional = false) + @Column(name = "FLOOR") + private String floor; + @Column(name = "CUSTOMER") + private String customer; + @Column(name = "WAITER") + private String waiter; + @Column(name = "TICKETID") + private String ticketid; + @Basic(optional = false) + @Column(name = "TABLEMOVED") + private short tablemoved; + + @Column(name = "WIDTH") + private int width; + @Basic(optional = false) + @Column(name = "HEIGHT") + private int height; + + public Places() { + } + + public Places(String id) { + this.id = id; + } + + public Places(String id, String name, String seats, int x, int y, int width, int height, String floor, short tablemoved) { + this.id = id; + this.name = name; + this.seats = seats; + this.x = x; + this.y = y; + this.floor = floor; + this.tablemoved = tablemoved; + this.width = width; + this.height = height; + } + + public String getId() { + return id; + } + + public void setId(String id) { + String oldId = this.id; + this.id = id; + changeSupport.firePropertyChange("id", oldId, id); + } + + public String getName() { + return name; + } + public void setName(String name) { + String oldName = this.name; + this.name = name; + changeSupport.firePropertyChange("name", oldName, name); + } + + public String getSeats() { + return seats; + } + public void setSeats(String seats) { + String oldSeats = this.seats; + this.seats = seats; + changeSupport.firePropertyChange("seats", oldSeats, seats); + } + + public int getX() { + return x; + } + + public void setX(int x) { + int oldX = this.x; + this.x = x; + changeSupport.firePropertyChange("x", oldX, x); + } + + public int getY() { + return y; + } + + public void setY(int y) { + int oldY = this.y; + this.y = y; + changeSupport.firePropertyChange("y", oldY, y); + } + + public String getFloor() { + return floor; + } + + public void setFloor(String floor) { + String oldFloor = this.floor; + this.floor = floor; + changeSupport.firePropertyChange("floor", oldFloor, floor); + } + + public String getCustomer() { + return customer; + } + + public void setCustomer(String customer) { + String oldCustomer = this.customer; + this.customer = customer; + changeSupport.firePropertyChange("customer", oldCustomer, customer); + } + + public String getWaiter() { + return waiter; + } + + public void setWaiter(String waiter) { + String oldWaiter = this.waiter; + this.waiter = waiter; + changeSupport.firePropertyChange("waiter", oldWaiter, waiter); + } + + public String getTicketid() { + return ticketid; + } + + public void setTicketid(String ticketid) { + String oldTicketid = this.ticketid; + this.ticketid = ticketid; + changeSupport.firePropertyChange("ticketid", oldTicketid, ticketid); + } + + public short getTablemoved() { + return tablemoved; + } + + public void setTablemoved(short tablemoved) { + short oldTablemoved = this.tablemoved; + this.tablemoved = tablemoved; + changeSupport.firePropertyChange("tablemoved", oldTablemoved, tablemoved); + } + + public int getWidth() { + return width; + } + + public void setWidth(int width) { + int oldWidth = this.width; + this.width = width; + changeSupport.firePropertyChange("width", oldWidth, width); + } + + public int getHeight() { + return height; + } + + public void setHeight(int height) { + int oldHeight = this.height; + this.height = height; + changeSupport.firePropertyChange("height", oldHeight, height); + } + + @Override + public int hashCode() { + int hash = 0; + hash += (id != null ? id.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof Places)) { + return false; + } + Places other = (Places) object; + if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { + return false; + } + return true; + } + + @Override + public String toString() { + return "com.unicenta.pos.mant.Places[ id=" + id + " ]"; + } + + public void addPropertyChangeListener(PropertyChangeListener listener) { + changeSupport.addPropertyChangeListener(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + changeSupport.removePropertyChangeListener(listener); + } + +} diff --git a/src/main/java/com/unicenta/pos/mant/PlacesEditor.form b/src/main/java/com/unicenta/pos/mant/PlacesEditor.form new file mode 100644 index 0000000..c30054f --- /dev/null +++ b/src/main/java/com/unicenta/pos/mant/PlacesEditor.form @@ -0,0 +1,349 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jName" min="-2" pref="200" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="14" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jFloor" min="-2" pref="200" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jLabel10" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="jLabel11" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jHeight" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="m_jY" alignment="1" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="m_jX" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel3" min="-2" pref="40" max="-2" attributes="0"/> + <Component id="jLabel5" alignment="0" min="-2" pref="50" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" pref="12" max="-2" attributes="0"/> + <Component id="jLabel7" min="-2" pref="384" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel8" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jSeats" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel9" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jWidth" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jFloor" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jSeats" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jWidth" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jHeight" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jX" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jY" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="52" max="-2" attributes="0"/> + <Component id="jLabel7" min="-2" pref="96" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace pref="180" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.name" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.placefloor" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.placepositionx" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Across"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Down"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="message.places" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="verticalAlignment" type="int" value="1"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="99" green="99" red="99" type="rgb"/> + </LineBorder> + </Border> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[489, 40]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.seats" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel9"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.btnwidth" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel11"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.placepositiony" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel10"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.btnheight" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jFloor"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jSeats"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jWidth"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jHeight"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jX"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jY"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/mant/PlacesEditor.java b/src/main/java/com/unicenta/pos/mant/PlacesEditor.java new file mode 100644 index 0000000..adda7bb --- /dev/null +++ b/src/main/java/com/unicenta/pos/mant/PlacesEditor.java @@ -0,0 +1,418 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.mant; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import java.awt.Component; +import java.util.UUID; +import javax.swing.JPanel; + +/** + * + * @author adrianromero + */ +public final class PlacesEditor extends JPanel implements EditorRecord { + + private final SentenceList m_sentfloor; + private ComboBoxValModel m_FloorModel; + + private String m_sID; + + /** Creates new form PlacesEditor + * @param dlSales + * @param dirty */ + public PlacesEditor(DataLogicSales dlSales, DirtyManager dirty) { + initComponents(); + + m_sentfloor = dlSales.getFloorsList(); + m_FloorModel = new ComboBoxValModel(); + + m_jName.getDocument().addDocumentListener(dirty); + m_jSeats.getDocument().addDocumentListener(dirty); + m_jFloor.addActionListener(dirty); + m_jX.getDocument().addDocumentListener(dirty); + m_jY.getDocument().addDocumentListener(dirty); + + m_jWidth.getDocument().addDocumentListener(dirty); + m_jHeight.getDocument().addDocumentListener(dirty); + + writeValueEOF(); + } + + /** + * + * @throws BasicException + */ + public void activate() throws BasicException { + + m_FloorModel = new ComboBoxValModel(m_sentfloor.list()); + m_jFloor.setModel(m_FloorModel); + } + + /** + * + */ + @Override + public void refresh() { + } + + /** + * + */ + @Override + public void writeValueEOF() { + + m_sID = null; + m_jName.setText(null); + m_jSeats.setText(null); + m_FloorModel.setSelectedKey(null); + m_jX.setText(null); + m_jY.setText(null); + + m_jWidth.setText(null); + m_jHeight.setText(null); + + m_jName.setEnabled(false); + m_jSeats.setEnabled(false); + m_jFloor.setEnabled(false); + m_jX.setEnabled(false); + m_jY.setEnabled(false); + + m_jWidth.setEnabled(false); + m_jHeight.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + + m_sID = UUID.randomUUID().toString(); + m_jName.setText(null); + m_jSeats.setText(null); + m_FloorModel.setSelectedKey(null); + m_jX.setText(null); + m_jY.setText(null); + m_jWidth.setText(null); + m_jHeight.setText(null); + + m_jName.setEnabled(true); + m_jSeats.setEnabled(true); + m_jFloor.setEnabled(true); + m_jX.setEnabled(true); + m_jY.setEnabled(true); + m_jWidth.setEnabled(true); + m_jHeight.setEnabled(true); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + + Object[] place = (Object[]) value; + m_sID = Formats.STRING.formatValue(place[0]); + m_jName.setText(Formats.STRING.formatValue(place[1])); + m_jSeats.setText(Formats.STRING.formatValue(place[2])); + m_jX.setText(Formats.INT.formatValue(place[3])); + m_jY.setText(Formats.INT.formatValue(place[4])); + m_FloorModel.setSelectedKey(place[5]); + m_jWidth.setText(Formats.INT.formatValue(place[6])); + m_jHeight.setText(Formats.INT.formatValue(place[7])); + + m_jName.setEnabled(false); + m_jSeats.setEnabled(false); + m_jFloor.setEnabled(false); + m_jX.setEnabled(false); + m_jY.setEnabled(false); + m_jWidth.setEnabled(false); + m_jHeight.setEnabled(false); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + + Object[] place = (Object[]) value; + m_sID = Formats.STRING.formatValue(place[0]); + m_jName.setText(Formats.STRING.formatValue(place[1])); + m_jSeats.setText(Formats.STRING.formatValue(place[2])); + m_jX.setText(Formats.INT.formatValue(place[3])); + m_jY.setText(Formats.INT.formatValue(place[4])); + m_FloorModel.setSelectedKey(place[5]); + m_jWidth.setText(Formats.INT.formatValue(place[6])); + m_jHeight.setText(Formats.INT.formatValue(place[7])); + + m_jName.setEnabled(true); + m_jSeats.setEnabled(true); + m_jFloor.setEnabled(true); + m_jX.setEnabled(true); + m_jY.setEnabled(true); + m_jWidth.setEnabled(true); + m_jHeight.setEnabled(true); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + Object[] place = new Object[8]; + place[0] = m_sID; + place[1] = m_jName.getText(); + place[2] = m_jSeats.getText(); + place[3] = Formats.INT.parseValue(m_jX.getText()); + place[4] = Formats.INT.parseValue(m_jY.getText()); + place[5] = m_FloorModel.getSelectedKey(); + place[6] = Formats.INT.parseValue(m_jWidth.getText()); + place[7] = Formats.INT.parseValue(m_jHeight.getText()); + return place; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel2 = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel7 = new javax.swing.JLabel(); + jLabel8 = new javax.swing.JLabel(); + jLabel9 = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + jLabel10 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + m_jFloor = new javax.swing.JComboBox(); + m_jSeats = new javax.swing.JTextField(); + m_jWidth = new javax.swing.JTextField(); + m_jHeight = new javax.swing.JTextField(); + m_jX = new javax.swing.JTextField(); + m_jY = new javax.swing.JTextField(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.name")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.placefloor")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.placepositionx")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText("Across"); + jLabel5.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText("Down"); + jLabel3.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel7.setBackground(new java.awt.Color(255, 255, 255)); + jLabel7.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel7.setForeground(new java.awt.Color(102, 102, 102)); + jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLabel7.setText(bundle.getString("message.places")); // NOI18N + jLabel7.setVerticalAlignment(javax.swing.SwingConstants.TOP); + jLabel7.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153))); + jLabel7.setMinimumSize(new java.awt.Dimension(50, 40)); + jLabel7.setOpaque(true); + jLabel7.setPreferredSize(new java.awt.Dimension(489, 40)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.seats")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel9.setText(AppLocal.getIntString("label.btnwidth")); // NOI18N + jLabel9.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel11.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel11.setText(AppLocal.getIntString("label.placepositiony")); // NOI18N + jLabel11.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel10.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel10.setText(AppLocal.getIntString("label.btnheight")); // NOI18N + jLabel10.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jFloor.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jFloor.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jSeats.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSeats.setPreferredSize(new java.awt.Dimension(50, 30)); + + m_jWidth.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jWidth.setPreferredSize(new java.awt.Dimension(50, 30)); + + m_jHeight.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jHeight.setPreferredSize(new java.awt.Dimension(50, 30)); + + m_jX.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jX.setPreferredSize(new java.awt.Dimension(50, 30)); + + m_jY.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jY.setPreferredSize(new java.awt.Dimension(50, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(14, 14, 14) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jFloor, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jHeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jY, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(m_jX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(12, 12, 12) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 384, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jSeats, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jWidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jFloor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSeats, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jWidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jHeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addGap(52, 52, 52) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(180, Short.MAX_VALUE)) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JComboBox m_jFloor; + private javax.swing.JTextField m_jHeight; + private javax.swing.JTextField m_jName; + private javax.swing.JTextField m_jSeats; + private javax.swing.JTextField m_jWidth; + private javax.swing.JTextField m_jX; + private javax.swing.JTextField m_jY; + // End of variables declaration//GEN-END:variables + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/panels/AuxiliarFilter.form b/src/main/java/com/unicenta/pos/panels/AuxiliarFilter.form new file mode 100644 index 0000000..c7ddeae --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/AuxiliarFilter.form @@ -0,0 +1,208 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[750, 130]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleName" type="java.lang.String" value="By product"/> + </AccessibilityProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jReference1" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="m_jSearch" min="-2" pref="260" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="search" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="Enter1" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="22" max="-2" attributes="0"/> + <Component id="jLabel7" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jBarcode1" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="Enter2" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="m_jBarcode1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="Enter2" min="-2" max="-2" attributes="0"/> + <Component id="Enter1" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jReference1" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="search" min="-2" max="-2" attributes="0"/> + <Component id="m_jSearch" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodref" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 20]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 20]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jReference1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jReference1ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="Enter1"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/products24.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Enter Product ID"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="Enter1ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbarcode" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jBarcode1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBarcode1ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="Enter2"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/barcode.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Get Barcode"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="Enter2ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jSearch"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Default Cursor"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 30]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jSearchActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="search"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/search24.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Search Products"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="searchActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/panels/AuxiliarFilter.java b/src/main/java/com/unicenta/pos/panels/AuxiliarFilter.java new file mode 100644 index 0000000..3579e73 --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/AuxiliarFilter.java @@ -0,0 +1,362 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteString; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.reports.ReportEditorCreator; +import com.unicenta.pos.ticket.ProductInfoExt; +import java.awt.Component; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.EventListener; +import javax.swing.event.EventListenerList; + +/** + * + * @author jaroslawwozniak + * @author adrianromero + */ +public class AuxiliarFilter extends javax.swing.JPanel implements ReportEditorCreator { + + private ProductInfoExt product; + private DataLogicSales m_dlSales; + + /** + * + */ + protected EventListenerList listeners = new EventListenerList(); + + /** Creates new form AuxiliarFilter */ + public AuxiliarFilter() { + initComponents(); + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + m_dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + product = null; + m_jSearch.setText(null); + m_jBarcode1.setText(null); + m_jReference1.setText(null); + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + return SerializerWriteString.INSTANCE; + } + + /** + * + * @param l + */ + public void addActionListener(ActionListener l){ + listeners.add(ActionListener.class, l); + } + + /** + * + * @param l + */ + public void removeActionListener(ActionListener l) { + listeners.remove(ActionListener.class, l); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + return product == null ? null : product.getID(); + } + + /** + * + * @return + */ + public ProductInfoExt getProductInfoExt() { + return product; + } + + private void assignProduct(ProductInfoExt prod) { + + product = prod; + if (product == null) { + m_jSearch.setText(null); + m_jBarcode1.setText(null); + m_jReference1.setText(null); + } else { + m_jSearch.setText(product.getReference() + " - " + product.getName()); + m_jBarcode1.setText(product.getCode()); + m_jReference1.setText(product.getReference()); + } + + fireSelectedProduct(); + } + + /** + * + */ + protected void fireSelectedProduct() { + EventListener[] l = listeners.getListeners(ActionListener.class); + ActionEvent e = null; + for (int i = 0; i < l.length; i++) { + if (e == null) { + e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "SELECTED"); + } + ((ActionListener) l[i]).actionPerformed(e); + } + } + + private void assignProductByCode() { + try { + ProductInfoExt prod = m_dlSales.getProductInfoByCode(m_jBarcode1.getText()); + if (prod == null) { + Toolkit.getDefaultToolkit().beep(); + } + assignProduct(prod); + } catch (BasicException eData) { + MessageInf msg = new MessageInf(eData); + msg.show(this); + assignProduct(null); + } + } + + private void assignProductByReference() { + try { + ProductInfoExt prod = m_dlSales.getProductInfoByReference(m_jReference1.getText()); + if (prod == null) { + Toolkit.getDefaultToolkit().beep(); + } + assignProduct(prod); + } catch (BasicException eData) { + MessageInf msg = new MessageInf(eData); + msg.show(this); + assignProduct(null); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel6 = new javax.swing.JLabel(); + m_jReference1 = new javax.swing.JTextField(); + Enter1 = new javax.swing.JButton(); + jLabel7 = new javax.swing.JLabel(); + m_jBarcode1 = new javax.swing.JTextField(); + Enter2 = new javax.swing.JButton(); + m_jSearch = new javax.swing.JTextField(); + search = new javax.swing.JButton(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setPreferredSize(new java.awt.Dimension(750, 130)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.prodref")); // NOI18N + jLabel6.setMaximumSize(new java.awt.Dimension(50, 20)); + jLabel6.setMinimumSize(new java.awt.Dimension(50, 20)); + jLabel6.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jReference1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jReference1.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jReference1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jReference1ActionPerformed(evt); + } + }); + + Enter1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/products24.png"))); // NOI18N + Enter1.setToolTipText("Enter Product ID"); + Enter1.setPreferredSize(new java.awt.Dimension(80, 45)); + Enter1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + Enter1ActionPerformed(evt); + } + }); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.prodbarcode")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jBarcode1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jBarcode1.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jBarcode1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBarcode1ActionPerformed(evt); + } + }); + + Enter2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/barcode.png"))); // NOI18N + Enter2.setToolTipText("Get Barcode"); + Enter2.setPreferredSize(new java.awt.Dimension(80, 45)); + Enter2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + Enter2ActionPerformed(evt); + } + }); + + m_jSearch.setEditable(false); + m_jSearch.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSearch.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + m_jSearch.setFocusable(false); + m_jSearch.setPreferredSize(new java.awt.Dimension(70, 30)); + m_jSearch.setRequestFocusEnabled(false); + m_jSearch.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jSearchActionPerformed(evt); + } + }); + + search.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/search24.png"))); // NOI18N + search.setToolTipText("Search Products"); + search.setPreferredSize(new java.awt.Dimension(80, 45)); + search.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + searchActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jReference1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(search, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addComponent(Enter1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(22, 22, 22) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jBarcode1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(Enter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jBarcode1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(Enter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(Enter1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jReference1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(search, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap()) + ); + + getAccessibleContext().setAccessibleName("By product"); + }// </editor-fold>//GEN-END:initComponents + + private void m_jReference1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jReference1ActionPerformed + this.assignProductByReference(); + }//GEN-LAST:event_m_jReference1ActionPerformed + + private void searchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchActionPerformed + + assignProduct(JProductFinder.showMessage(this, m_dlSales, JProductFinder.PRODUCT_NORMAL)); + +}//GEN-LAST:event_searchActionPerformed + + private void Enter2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Enter2ActionPerformed + this.assignProductByCode(); + }//GEN-LAST:event_Enter2ActionPerformed + + private void Enter1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Enter1ActionPerformed + this.assignProductByReference(); + }//GEN-LAST:event_Enter1ActionPerformed + + private void m_jBarcode1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBarcode1ActionPerformed + this.assignProductByCode(); + }//GEN-LAST:event_m_jBarcode1ActionPerformed + + private void m_jSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jSearchActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_m_jSearchActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton Enter1; + private javax.swing.JButton Enter2; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JTextField m_jBarcode1; + private javax.swing.JTextField m_jReference1; + private javax.swing.JTextField m_jSearch; + private javax.swing.JButton search; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/panels/BundleFilter.form b/src/main/java/com/unicenta/pos/panels/BundleFilter.form new file mode 100644 index 0000000..e40e598 --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/BundleFilter.form @@ -0,0 +1,194 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleName" type="java.lang.String" value="By product"/> + </AccessibilityProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="1"/> + <Component id="jLabel7" alignment="0" min="-2" max="-2" attributes="1"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="m_jBarcode1" min="-2" max="-2" attributes="1"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="Enter2" min="-2" max="-2" attributes="1"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="m_jReference1" min="-2" max="-2" attributes="1"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="Enter1" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jSearch" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="search" min="-2" max="-2" attributes="1"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="2" attributes="0"> + <Component id="jLabel6" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jReference1" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="Enter1" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jSearch" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="search" alignment="2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="2" attributes="0"> + <Component id="jLabel7" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jBarcode1" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="Enter2" alignment="2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodref" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 20]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 20]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jReference1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jReference1ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="Enter1"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/products24.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Enter Product ID"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="Enter1ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbarcode" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jBarcode1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBarcode1ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="Enter2"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/barcode.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Get Barcode"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="Enter2ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jSearch"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Default Cursor"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="search"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/search24.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Search Products"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="searchActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/panels/BundleFilter.java b/src/main/java/com/unicenta/pos/panels/BundleFilter.java new file mode 100644 index 0000000..677e1fa --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/BundleFilter.java @@ -0,0 +1,310 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteString; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.reports.ReportEditorCreator; +import com.unicenta.pos.ticket.ProductInfoExt; +import java.awt.Component; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.EventListener; +import javax.swing.event.EventListenerList; + +/** + * + * @author Jack + */ +public class BundleFilter extends javax.swing.JPanel implements ReportEditorCreator { + + private ProductInfoExt product; + private DataLogicSales m_dlSales; + + protected EventListenerList listeners = new EventListenerList(); + + /** Creates new form BundleFilter */ + public BundleFilter() { + initComponents(); + } + + @Override + public void init(AppView app) { + m_dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + } + + @Override + public void activate() throws BasicException { + product = null; + m_jSearch.setText(null); + m_jBarcode1.setText(null); + m_jReference1.setText(null); + } + + @Override + public SerializerWrite getSerializerWrite() { + return SerializerWriteString.INSTANCE; + } + + public void addActionListener(ActionListener l){ + listeners.add(ActionListener.class, l); + } + + public void removeActionListener(ActionListener l) { + listeners.remove(ActionListener.class, l); + } + + @Override + public Component getComponent() { + return this; + } + + @Override + public Object createValue() throws BasicException { + return product == null ? null : product.getID(); + } + + public ProductInfoExt getProductInfoExt() { + return product; + } + + private void assignProduct(ProductInfoExt prod) { + + product = prod; + if (product == null) { + m_jSearch.setText(null); + m_jBarcode1.setText(null); + m_jReference1.setText(null); + } else { + m_jSearch.setText(product.getReference() + " - " + product.getName()); + m_jBarcode1.setText(product.getCode()); + m_jReference1.setText(product.getReference()); + } + + fireSelectedProduct(); + } + + + + protected void fireSelectedProduct() { + EventListener[] l = listeners.getListeners(ActionListener.class); + ActionEvent e = null; + for (int i = 0; i < l.length; i++) { + if (e == null) { + e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "SELECTED"); + } + ((ActionListener) l[i]).actionPerformed(e); + } + } + + private void assignProductByCode() { + try { + ProductInfoExt prod = m_dlSales.getProductInfoByCode(m_jBarcode1.getText()); + if (prod == null) { + Toolkit.getDefaultToolkit().beep(); + } + assignProduct(prod); + } catch (BasicException eData) { + MessageInf msg = new MessageInf(eData); + msg.show(this); + assignProduct(null); + } + } + + private void assignProductByReference() { + try { + ProductInfoExt prod = m_dlSales.getProductInfoByReference(m_jReference1.getText()); + if (prod == null) { + Toolkit.getDefaultToolkit().beep(); + } + assignProduct(prod); + } catch (BasicException eData) { + MessageInf msg = new MessageInf(eData); + msg.show(this); + assignProduct(null); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel6 = new javax.swing.JLabel(); + m_jReference1 = new javax.swing.JTextField(); + Enter1 = new javax.swing.JButton(); + jLabel7 = new javax.swing.JLabel(); + m_jBarcode1 = new javax.swing.JTextField(); + Enter2 = new javax.swing.JButton(); + m_jSearch = new javax.swing.JTextField(); + search = new javax.swing.JButton(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.prodref")); // NOI18N + jLabel6.setMaximumSize(new java.awt.Dimension(50, 20)); + jLabel6.setMinimumSize(new java.awt.Dimension(50, 20)); + jLabel6.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jReference1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jReference1.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jReference1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jReference1ActionPerformed(evt); + } + }); + + Enter1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/products24.png"))); // NOI18N + Enter1.setToolTipText("Enter Product ID"); + Enter1.setPreferredSize(new java.awt.Dimension(80, 45)); + Enter1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + Enter1ActionPerformed(evt); + } + }); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.prodbarcode")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jBarcode1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jBarcode1.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jBarcode1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBarcode1ActionPerformed(evt); + } + }); + + Enter2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/barcode.png"))); // NOI18N + Enter2.setToolTipText("Get Barcode"); + Enter2.setPreferredSize(new java.awt.Dimension(80, 45)); + Enter2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + Enter2ActionPerformed(evt); + } + }); + + m_jSearch.setEditable(false); + m_jSearch.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSearch.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + m_jSearch.setFocusable(false); + m_jSearch.setPreferredSize(new java.awt.Dimension(200, 30)); + m_jSearch.setRequestFocusEnabled(false); + + search.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/search24.png"))); // NOI18N + search.setToolTipText("Search Products"); + search.setPreferredSize(new java.awt.Dimension(80, 45)); + search.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + searchActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(m_jBarcode1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(Enter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(m_jReference1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(Enter1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(search, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jReference1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(Enter1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(search, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jBarcode1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(Enter2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + getAccessibleContext().setAccessibleName("By product"); + }// </editor-fold>//GEN-END:initComponents + + private void m_jReference1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jReference1ActionPerformed + this.assignProductByReference(); + }//GEN-LAST:event_m_jReference1ActionPerformed + + private void searchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchActionPerformed + + assignProduct(JProductFinder.showMessage(this, m_dlSales, JProductFinder.PRODUCT_NORMAL)); + +}//GEN-LAST:event_searchActionPerformed + + private void Enter2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Enter2ActionPerformed + this.assignProductByCode(); + }//GEN-LAST:event_Enter2ActionPerformed + + private void Enter1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Enter1ActionPerformed + this.assignProductByReference(); + }//GEN-LAST:event_Enter1ActionPerformed + + private void m_jBarcode1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBarcode1ActionPerformed + this.assignProductByCode(); + }//GEN-LAST:event_m_jBarcode1ActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton Enter1; + private javax.swing.JButton Enter2; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JTextField m_jBarcode1; + private javax.swing.JTextField m_jReference1; + private javax.swing.JTextField m_jSearch; + private javax.swing.JButton search; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/panels/ComboItemLocal.java b/src/main/java/com/unicenta/pos/panels/ComboItemLocal.java new file mode 100644 index 0000000..593745d --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/ComboItemLocal.java @@ -0,0 +1,73 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.data.loader.IKeyed; +import com.unicenta.pos.forms.AppLocal; + +/** + * + * @author adrianromero + * Created on February 12, 2007, 10:49 PM + * + */ +public class ComboItemLocal implements IKeyed { + + /** + * + */ + protected Integer m_iKey; + + /** + * + */ + protected String m_sKeyValue; + + /** + * + * @param iKey + * @param sKeyValue + */ + public ComboItemLocal(Integer iKey, String sKeyValue) { + m_iKey = iKey; + m_sKeyValue = sKeyValue; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return m_iKey; + } + + /** + * + * @return + */ + public Object getValue() { + return m_sKeyValue; + } + @Override + public String toString() { + return AppLocal.getIntString(m_sKeyValue); + } +} diff --git a/src/main/java/com/unicenta/pos/panels/EnumerationIter.java b/src/main/java/com/unicenta/pos/panels/EnumerationIter.java new file mode 100644 index 0000000..067a589 --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/EnumerationIter.java @@ -0,0 +1,49 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-130 + +package com.unicenta.pos.panels; + +import java.util.Enumeration; +import java.util.Iterator; + +/** + * + * @author adrianromero + */ +public class EnumerationIter implements Enumeration { + + private Iterator i; + + /** + * + * @param i + */ + public EnumerationIter(Iterator i) { + this.i = i; + } + @Override + public boolean hasMoreElements() { + return i.hasNext(); + } + @Override + public Object nextElement() { + return i.next(); + } +} diff --git a/src/main/java/com/unicenta/pos/panels/JPanelCloseMoney.form b/src/main/java/com/unicenta/pos/panels/JPanelCloseMoney.form new file mode 100644 index 0000000..c10bdba --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JPanelCloseMoney.form @@ -0,0 +1,613 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,54,0,0,4,35"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel11"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.sequence" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="10" y="11" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jSequence"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="145" y="12" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.StartDate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="10" y="50" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jMinDate"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="145" y="50" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.EndDate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="355" y="50" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jMaxDate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="515" y="50" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.sales" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="355" y="137" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jCash"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="515" y="306" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.cash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="355" y="305" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jCount"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="515" y="96" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jLinesRemoved"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="513" y="360" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.Tickets" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="355" y="95" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSeparator" name="jSeparator1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="353" y="347" width="312" height="10"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="m_jScrollTableTicket"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="horizontalScrollBarPolicy" type="int" value="31"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[350, 140]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[325, 150]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JPanelCloseMoney_m_jScrollTableTicket"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="10" y="95" width="-1" height="-1"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="m_jTicketTable"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="0" rowCount="0"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="intercellSpacing" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 1]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + <Property name="showVerticalLines" type="boolean" value="false"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel9"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.linevoids" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="353" y="359" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jNoCashSales"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="513" y="402" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.nocashsales" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="353" y="401" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jSalesTotal"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="515" y="264" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.total" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="355" y="263" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel12"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.taxes" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="355" y="221" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jSalesTaxes"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="515" y="222" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JScrollPane" name="m_jScrollSales"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="horizontalScrollBarPolicy" type="int" value="31"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[325, 150]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="10" y="250" width="-1" height="-1"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="m_jsalestable"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="intercellSpacing" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 1]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + <Property name="showVerticalLines" type="boolean" value="false"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JTextField" name="m_jSales"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="515" y="138" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="m_jSalesSubtotal"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="515" y="180" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.totalnet" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="355" y="179" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="m_jCloseCash"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/calculator.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.closecash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.btn.closecash" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="iconTextGap" type="int" value="2"/> + <Property name="inheritsPopupMenu" type="boolean" value="true"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jCloseCashActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="170" y="450" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="m_jPrintCash"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/printer.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.printcash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.btn.partialcash" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="iconTextGap" type="int" value="2"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jPrintCashActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="10" y="450" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JComboBox" name="jCBCloseCash"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.closecashactions" replaceFormat="AppLocal.getIntString("tooltip.closecashactions")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCBCloseCashActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="510" y="450" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/panels/JPanelCloseMoney.java b/src/main/java/com/unicenta/pos/panels/JPanelCloseMoney.java new file mode 100644 index 0000000..6c5102a --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JPanelCloseMoney.java @@ -0,0 +1,797 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.gui.TableRendererBasic; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.data.loader.Session; +import com.unicenta.data.loader.StaticSentence; +import com.unicenta.format.Formats; +import com.unicenta.plugins.Application; +import com.unicenta.pos.forms.*; +import com.unicenta.pos.printer.TicketParser; +import com.unicenta.pos.printer.TicketPrinterException; +import com.unicenta.pos.scripting.ScriptEngine; +import com.unicenta.pos.scripting.ScriptException; +import com.unicenta.pos.scripting.ScriptFactory; +import lombok.extern.slf4j.Slf4j; + +import java.awt.*; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.UUID; +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; + +/** + * + * @author adrianromero + */ +@Slf4j +public class JPanelCloseMoney extends JPanel implements JPanelView, BeanFactoryApp { + + private AppView m_App; + private DataLogicSystem m_dlSystem; + + private PaymentsModel m_PaymentsToClose = null; + + private TicketParser m_TTP; + private final DateFormat df= new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); + + private Session s; + private Connection con; + private Statement stmt; + private Integer result; + private Integer dresult; + private String SQL; + private ResultSet rs; + + private AppUser m_User; + + private final ComboBoxValModel m_ReasonModel; + + /** Creates new form JPanelCloseMoney */ + public JPanelCloseMoney() { + initComponents(); + + m_ReasonModel = new ComboBoxValModel(); + m_ReasonModel.add(AppLocal.getIntString("cboption.preview")); + m_ReasonModel.add(AppLocal.getIntString("cboption.reprint")); + jCBCloseCash.setModel(m_ReasonModel); + } + + /** + * + * @param app + * @throws BeanFactoryException + */ + @Override + public void init(AppView app) throws BeanFactoryException { + + m_App = app; + m_dlSystem = (DataLogicSystem) m_App.getBean("com.unicenta.pos.forms.DataLogicSystem"); + m_TTP = new TicketParser(m_App.getDeviceTicket(), m_dlSystem); + + m_jTicketTable.setDefaultRenderer(Object.class, new TableRendererBasic( + new Formats[] {new FormatsPayment(), Formats.CURRENCY})); + m_jTicketTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + m_jScrollTableTicket.getVerticalScrollBar().setPreferredSize(new Dimension(25,25)); + m_jTicketTable.getTableHeader().setReorderingAllowed(false); + m_jTicketTable.setRowHeight(25); + m_jTicketTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + m_jsalestable.setDefaultRenderer(Object.class, new TableRendererBasic( + new Formats[] {Formats.STRING, Formats.CURRENCY, Formats.CURRENCY, Formats.CURRENCY})); + m_jsalestable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + m_jScrollSales.getVerticalScrollBar().setPreferredSize(new Dimension(25,25)); + m_jsalestable.getTableHeader().setReorderingAllowed(false); + m_jsalestable.setRowHeight(25); + m_jsalestable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + } + + /** + * + * @return + */ + @Override + public Object getBean() { + return this; + } + + /** + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + /** + * @return + */ + + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.CloseTPV"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + loadData(); + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + + return true; + } + + private void loadData() throws BasicException { + + // Reset + m_jSequence.setText(null); + m_jMinDate.setText(null); + m_jMaxDate.setText(null); + m_jPrintCash.setEnabled(false); + m_jCloseCash.setEnabled(false); + + + m_jCount.setText(null); + m_jCash.setText(null); + + m_jSales.setText(null); + m_jSalesSubtotal.setText(null); + m_jSalesTaxes.setText(null); + m_jSalesTotal.setText(null); + + m_jTicketTable.setModel(new DefaultTableModel()); + m_jsalestable.setModel(new DefaultTableModel()); + + // LoadData + m_PaymentsToClose = PaymentsModel.loadInstance(m_App); + + // Populate Data + m_jSequence.setText(m_PaymentsToClose.printSequence()); + m_jMinDate.setText(m_PaymentsToClose.printDateStart()); + m_jMaxDate.setText(m_PaymentsToClose.printDateEnd()); + + if (m_PaymentsToClose.getPayments() != 0 + || m_PaymentsToClose.getSales() != 0) { + + m_jPrintCash.setEnabled(true); + m_jCloseCash.setEnabled(true); + + + m_jCount.setText(m_PaymentsToClose.printPayments()); + m_jCash.setText(m_PaymentsToClose.printPaymentsTotal()); + + m_jSales.setText(m_PaymentsToClose.printSales()); + m_jSalesSubtotal.setText(m_PaymentsToClose.printSalesBase()); + m_jSalesTaxes.setText(m_PaymentsToClose.printSalesTaxes()); + m_jSalesTotal.setText(m_PaymentsToClose.printSalesTotal()); + } + + m_jTicketTable.setModel(m_PaymentsToClose.getPaymentsModel()); + + TableColumnModel jColumns = m_jTicketTable.getColumnModel(); + jColumns.getColumn(0).setPreferredWidth(200); + jColumns.getColumn(0).setResizable(false); + jColumns.getColumn(1).setPreferredWidth(100); + jColumns.getColumn(1).setResizable(false); + + m_jsalestable.setModel(m_PaymentsToClose.getSalesModel()); + + jColumns = m_jsalestable.getColumnModel(); + jColumns.getColumn(0).setPreferredWidth(100); + jColumns.getColumn(0).setResizable(false); + jColumns.getColumn(1).setPreferredWidth(100); + jColumns.getColumn(1).setResizable(false); + jColumns.getColumn(2).setPreferredWidth(100); + jColumns.getColumn(2).setResizable(false); + +// read number of no cash drawer activations + try{ + result=0; + s=m_App.getSession(); + con=s.getConnection(); + String sdbmanager = m_dlSystem.getDBVersion(); + + if ("PostgreSQL".equals(sdbmanager) || "SQLite".equals(sdbmanager)) { + SQL = "SELECT * " + + "FROM draweropened " + + "WHERE TICKETID = 'No Sale' AND OPENDATE > " + "'" + m_PaymentsToClose.printDateStart() + "'"; + } else { + SQL = "SELECT * " + + "FROM draweropened " + + "WHERE TICKETID = 'No Sale' AND OPENDATE > {fn TIMESTAMP('" + m_PaymentsToClose.getDateStartDerby() + "')}"; + } + + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + while (rs.next()){ + result ++; + } + rs=null; + +// Get Ticket DELETES & Line Voids + dresult=0; + if ("PostgreSQL".equals(sdbmanager) || "SQLite".equals(sdbmanager)) { + SQL = "SELECT * " + + "FROM lineremoved " + + "WHERE REMOVEDDATE > " + "'" + m_PaymentsToClose.printDateStart() + "'"; + } else { + SQL = "SELECT * " + + "FROM lineremoved " + + "WHERE REMOVEDDATE > {fn TIMESTAMP('" + m_PaymentsToClose.getDateStartDerby() + "')}"; + } + log.debug("close-cash sql -> {}",SQL); + + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + while (rs.next()){ + dresult ++; + } + rs=null; + con=null; + s=null; + } + catch (SQLException e){ + log.error("Got a problem here! Something to with dresult "); + log.error(e.getMessage()); + } + + m_jLinesRemoved.setText(dresult.toString()); + m_jNoCashSales.setText(result.toString()); + } + + private void CloseCash() { + + int res = JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.wannaclosecash"), + AppLocal.getIntString("message.title"), + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + + if (res == JOptionPane.YES_OPTION) { + + Date dNow = new Date(); + + try { + + if (m_App.getActiveCashDateEnd() == null) { + new StaticSentence(m_App.getSession() + , "UPDATE closedcash SET DATEEND = ?, NOSALES = ? WHERE HOST = ? AND MONEY = ?" + , new SerializerWriteBasic(new Datas[] { + Datas.TIMESTAMP, + Datas.INT, + Datas.STRING, + Datas.STRING})) + .exec(new Object[] {dNow, result, + m_App.getProperties().getHost(), + m_App.getActiveCashIndex()}); + } + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, + AppLocal.getIntString("message.cannotclosecash"), e); + msg.show(this); + } + + try { + // Create NEW CloshCash Sequence + m_App.setActiveCash(UUID.randomUUID().toString(), + m_App.getActiveCashSequence() + 1, dNow, null); + + // Create CURRENT CloseCash Sequence + m_dlSystem.execInsertCash( + new Object[] {m_App.getActiveCashIndex(), + m_App.getProperties().getHost(), + m_App.getActiveCashSequence(), + m_App.getActiveCashDateStart(), + m_App.getActiveCashDateEnd(),0}); + + m_dlSystem.execDrawerOpened( + new Object[] {m_App.getAppUserView().getUser().getName(),"Close Cash"}); + + // Set ENDDATE CloseCash Date + m_PaymentsToClose.setDateEnd(dNow); + + // print report + printPayments("Printer.CloseCash"); + + // Close Cash Message + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.closecashok"), + AppLocal.getIntString("message.title"), + JOptionPane.INFORMATION_MESSAGE); + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, + AppLocal.getIntString("message.cannotclosecash"), e); + msg.show(this); + } + + try { + loadData(); + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, + AppLocal.getIntString("label.noticketstoclose"), e); + msg.show(this); + } + } + } + + private void printPayments(String report) { + + String sresource = m_dlSystem.getResourceAsXML(report); + if (sresource == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotprintticket")); + msg.show(this); + } else { + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); + script.put("payments", m_PaymentsToClose); + script.put("nosales",result.toString()); + m_TTP.printTicket(script.eval(sresource).toString()); + } catch (ScriptException | TicketPrinterException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotprintticket"), e); + msg.show(this); + } + } + } + + private class FormatsPayment extends Formats { + @Override + protected String formatValueInt(Object value) { + return AppLocal.getIntString("transpayment." + (String) value); + } + @Override + protected Object parseValueInt(String value) throws ParseException { + return value; + } + @Override + public int getAlignment() { + return javax.swing.SwingConstants.LEFT; + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLabel11 = new javax.swing.JLabel(); + m_jSequence = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + m_jMinDate = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + m_jMaxDate = new javax.swing.JTextField(); + jLabel5 = new javax.swing.JLabel(); + m_jCash = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + m_jCount = new javax.swing.JTextField(); + m_jLinesRemoved = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + jSeparator1 = new javax.swing.JSeparator(); + m_jScrollTableTicket = new javax.swing.JScrollPane(); + m_jTicketTable = new javax.swing.JTable(); + jLabel9 = new javax.swing.JLabel(); + m_jNoCashSales = new javax.swing.JTextField(); + jLabel8 = new javax.swing.JLabel(); + m_jSalesTotal = new javax.swing.JTextField(); + jLabel7 = new javax.swing.JLabel(); + jLabel12 = new javax.swing.JLabel(); + m_jSalesTaxes = new javax.swing.JTextField(); + m_jScrollSales = new javax.swing.JScrollPane(); + m_jsalestable = new javax.swing.JTable(); + m_jSales = new javax.swing.JTextField(); + m_jSalesSubtotal = new javax.swing.JTextField(); + jLabel6 = new javax.swing.JLabel(); + m_jCloseCash = new javax.swing.JButton(); + m_jPrintCash = new javax.swing.JButton(); + jCBCloseCash = new javax.swing.JComboBox<>(); + + setLayout(new java.awt.BorderLayout()); + + jPanel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jLabel11.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel11.setText(AppLocal.getIntString("label.sequence")); // NOI18N + jLabel11.setPreferredSize(new java.awt.Dimension(125, 30)); + jPanel1.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 11, -1, -1)); + + m_jSequence.setEditable(false); + m_jSequence.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSequence.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jSequence.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(m_jSequence, new org.netbeans.lib.awtextra.AbsoluteConstraints(145, 12, -1, -1)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLabel2.setText(AppLocal.getIntString("label.StartDate")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(125, 30)); + jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, -1, -1)); + + m_jMinDate.setEditable(false); + m_jMinDate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jMinDate.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jMinDate.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(m_jMinDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(145, 50, -1, -1)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLabel3.setText(AppLocal.getIntString("label.EndDate")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(125, 30)); + jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(355, 50, -1, -1)); + + m_jMaxDate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jMaxDate.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jMaxDate.setEnabled(false); + m_jMaxDate.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(m_jMaxDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(515, 50, -1, -1)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.sales")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(355, 137, -1, -1)); + + m_jCash.setEditable(false); + m_jCash.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCash.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jCash.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(m_jCash, new org.netbeans.lib.awtextra.AbsoluteConstraints(515, 306, -1, -1)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.cash")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(355, 305, -1, -1)); + + m_jCount.setEditable(false); + m_jCount.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCount.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jCount.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(m_jCount, new org.netbeans.lib.awtextra.AbsoluteConstraints(515, 96, -1, -1)); + + m_jLinesRemoved.setEditable(false); + m_jLinesRemoved.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jLinesRemoved.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jLinesRemoved.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(m_jLinesRemoved, new org.netbeans.lib.awtextra.AbsoluteConstraints(513, 360, -1, -1)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.Tickets")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(355, 95, -1, -1)); + jPanel1.add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(353, 347, 312, 10)); + + m_jScrollTableTicket.setBorder(null); + m_jScrollTableTicket.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + m_jScrollTableTicket.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jScrollTableTicket.setMinimumSize(new java.awt.Dimension(350, 140)); + m_jScrollTableTicket.setPreferredSize(new java.awt.Dimension(325, 150)); + + m_jTicketTable.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jTicketTable.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + + } + )); + m_jTicketTable.setFocusable(false); + m_jTicketTable.setIntercellSpacing(new java.awt.Dimension(0, 1)); + m_jTicketTable.setRequestFocusEnabled(false); + m_jTicketTable.setShowVerticalLines(false); + m_jScrollTableTicket.setViewportView(m_jTicketTable); + + jPanel1.add(m_jScrollTableTicket, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 95, -1, -1)); + + jLabel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLabel9.setText(bundle.getString("label.linevoids")); // NOI18N + jLabel9.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(353, 359, -1, -1)); + + m_jNoCashSales.setEditable(false); + m_jNoCashSales.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jNoCashSales.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jNoCashSales.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(m_jNoCashSales, new org.netbeans.lib.awtextra.AbsoluteConstraints(513, 402, -1, -1)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLabel8.setText(bundle.getString("label.nocashsales")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(353, 401, -1, -1)); + + m_jSalesTotal.setEditable(false); + m_jSalesTotal.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSalesTotal.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jSalesTotal.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(m_jSalesTotal, new org.netbeans.lib.awtextra.AbsoluteConstraints(515, 264, -1, -1)); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.total")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(355, 263, -1, -1)); + + jLabel12.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel12.setText(AppLocal.getIntString("label.taxes")); // NOI18N + jLabel12.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(355, 221, -1, -1)); + + m_jSalesTaxes.setEditable(false); + m_jSalesTaxes.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSalesTaxes.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jSalesTaxes.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(m_jSalesTaxes, new org.netbeans.lib.awtextra.AbsoluteConstraints(515, 222, -1, -1)); + + m_jScrollSales.setBorder(null); + m_jScrollSales.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + m_jScrollSales.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jScrollSales.setPreferredSize(new java.awt.Dimension(325, 150)); + + m_jsalestable.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jsalestable.setFocusable(false); + m_jsalestable.setIntercellSpacing(new java.awt.Dimension(0, 1)); + m_jsalestable.setRequestFocusEnabled(false); + m_jsalestable.setShowVerticalLines(false); + m_jScrollSales.setViewportView(m_jsalestable); + + jPanel1.add(m_jScrollSales, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 250, -1, -1)); + + m_jSales.setEditable(false); + m_jSales.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSales.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jSales.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(m_jSales, new org.netbeans.lib.awtextra.AbsoluteConstraints(515, 138, -1, -1)); + + m_jSalesSubtotal.setEditable(false); + m_jSalesSubtotal.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSalesSubtotal.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jSalesSubtotal.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(m_jSalesSubtotal, new org.netbeans.lib.awtextra.AbsoluteConstraints(515, 180, -1, -1)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.totalnet")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(150, 30)); + jPanel1.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(355, 179, -1, -1)); + + m_jCloseCash.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jCloseCash.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/calculator.png"))); // NOI18N + m_jCloseCash.setText(AppLocal.getIntString("button.closecash")); // NOI18N + m_jCloseCash.setToolTipText(bundle.getString("tooltip.btn.closecash")); // NOI18N + m_jCloseCash.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + m_jCloseCash.setIconTextGap(2); + m_jCloseCash.setInheritsPopupMenu(true); + m_jCloseCash.setMaximumSize(new java.awt.Dimension(85, 33)); + m_jCloseCash.setMinimumSize(new java.awt.Dimension(85, 33)); + m_jCloseCash.setPreferredSize(new java.awt.Dimension(150, 45)); + m_jCloseCash.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jCloseCashActionPerformed(evt); + } + }); + jPanel1.add(m_jCloseCash, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 450, -1, -1)); + + m_jPrintCash.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jPrintCash.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/printer.png"))); // NOI18N + m_jPrintCash.setText(AppLocal.getIntString("button.printcash")); // NOI18N + m_jPrintCash.setToolTipText(bundle.getString("tooltip.btn.partialcash")); // NOI18N + m_jPrintCash.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + m_jPrintCash.setIconTextGap(2); + m_jPrintCash.setMaximumSize(new java.awt.Dimension(85, 33)); + m_jPrintCash.setMinimumSize(new java.awt.Dimension(85, 33)); + m_jPrintCash.setPreferredSize(new java.awt.Dimension(150, 45)); + m_jPrintCash.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jPrintCashActionPerformed(evt); + } + }); + jPanel1.add(m_jPrintCash, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 450, -1, -1)); + + jCBCloseCash.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jCBCloseCash.setToolTipText(AppLocal.getIntString("tooltip.closecashactions")); // NOI18N + jCBCloseCash.setPreferredSize(new java.awt.Dimension(150, 45)); + jCBCloseCash.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jCBCloseCashActionPerformed(evt); + } + }); + jPanel1.add(jCBCloseCash, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 450, -1, -1)); + + add(jPanel1, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + private void m_jCloseCashActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jCloseCashActionPerformed + + int res = JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.wannaclosecash"), + AppLocal.getIntString("message.title"), + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + + if (res == JOptionPane.YES_OPTION) { + + try { + //Fire cash.closed event + ScriptEngine scriptEngine = ScriptFactory.getScriptEngine(ScriptFactory.BEANSHELL); + DataLogicSystem dlSystem = (DataLogicSystem) m_App.getBean("com.unicenta.pos.forms.DataLogicSystem"); + String script = dlSystem.getResourceAsXML("cash.close"); + scriptEngine.eval(script); + } + catch (Exception e) { + log.error("Error firing cash close event {}", e.getMessage()); + } + + Date dNow = new Date(); + + try { + + if (m_App.getActiveCashDateEnd() == null) { + StaticSentence staticSentence = new StaticSentence( + m_App.getSession(), + "UPDATE closedcash SET DATEEND = ?, NOSALES = ? WHERE HOST = ? AND MONEY = ?", + new SerializerWriteBasic(Datas.TIMESTAMP, Datas.INT, Datas.STRING, Datas.STRING)); + + staticSentence.exec(dNow, result, m_App.getProperties().getHost(), m_App.getActiveCashIndex()); + } + } catch (Exception e) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotclosecash"), e); + msg.show(this); + } + + try { + // Creamos una nueva caja + m_App.setActiveCash(UUID.randomUUID().toString(), + m_App.getActiveCashSequence() + 1, dNow, null); + + // creamos la caja activa + m_dlSystem.execInsertCash( + new Object[] {m_App.getActiveCashIndex(), + m_App.getProperties().getHost(), + m_App.getActiveCashSequence(), + m_App.getActiveCashDateStart(), + m_App.getActiveCashDateEnd(),0}); + + m_dlSystem.execDrawerOpened( + new Object[] {m_App.getAppUserView().getUser().getName(),"Close Cash"}); + + // ponemos la fecha de fin + m_PaymentsToClose.setDateEnd(dNow); + + // print report + printPayments("Printer.CloseCash"); + + // Mostramos el mensaje + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.closecashok"), + AppLocal.getIntString("message.title"), + JOptionPane.INFORMATION_MESSAGE); + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, + AppLocal.getIntString("message.cannotclosecash"), e); + msg.show(this); + } + + if (m_App.getProperties().getProperty("payment.gateway").equals("PaymentSense")) { + new Application().paymentSenseEOD(getActiveWindow()); + } + + try { + loadData(); + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, + AppLocal.getIntString("label.noticketstoclose"), e); + msg.show(this); + } + + } + }//GEN-LAST:event_m_jCloseCashActionPerformed + + Window getActiveWindow() { + for (Window window : Window.getWindows()) { + if (window.isActive()) { + return window; + } + } + return null; + } + private void m_jPrintCashActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jPrintCashActionPerformed + + printPayments("Printer.PartialCash"); + + }//GEN-LAST:event_m_jPrintCashActionPerformed + + private void jCBCloseCashActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBCloseCashActionPerformed + if(jCBCloseCash.getSelectedIndex() == 0){ + printPayments("Printer.CloseCash.Preview"); + } + if(jCBCloseCash.getSelectedIndex() == 1) { + m_App.getAppUserView().showTask("com.unicenta.pos.panels.JPanelCloseMoneyReprint"); + } + }//GEN-LAST:event_jCBCloseCashActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox<String> jCBCloseCash; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JPanel jPanel1; + private javax.swing.JSeparator jSeparator1; + private javax.swing.JTextField m_jCash; + private javax.swing.JButton m_jCloseCash; + private javax.swing.JTextField m_jCount; + private javax.swing.JTextField m_jLinesRemoved; + private javax.swing.JTextField m_jMaxDate; + private javax.swing.JTextField m_jMinDate; + private javax.swing.JTextField m_jNoCashSales; + private javax.swing.JButton m_jPrintCash; + private javax.swing.JTextField m_jSales; + private javax.swing.JTextField m_jSalesSubtotal; + private javax.swing.JTextField m_jSalesTaxes; + private javax.swing.JTextField m_jSalesTotal; + private javax.swing.JScrollPane m_jScrollSales; + private javax.swing.JScrollPane m_jScrollTableTicket; + private javax.swing.JTextField m_jSequence; + private javax.swing.JTable m_jTicketTable; + private javax.swing.JTable m_jsalestable; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/panels/JPanelCloseMoneyReprint.form b/src/main/java/com/unicenta/pos/panels/JPanelCloseMoneyReprint.form new file mode 100644 index 0000000..5146b7a --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JPanelCloseMoneyReprint.form @@ -0,0 +1,597 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-12,0,0,2,-70"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jScrollSales" alignment="0" max="-2" attributes="0"/> + <Component id="m_jScrollTableTicket" alignment="0" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="m_jMaxDate" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel5" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jSales" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel1" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jCount" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel6" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jSalesSubtotal" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel12" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jSalesTaxes" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel7" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jSalesTotal" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="103" alignment="1" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel4" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jCash" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel9" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jLinesRemoved" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel8" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jNoCashSales" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jMinDate" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel11" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jSequence" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="webBtnFindSequence" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="141" max="-2" attributes="0"/> + <Component id="m_jPrint" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="2" attributes="0"> + <Component id="webBtnFindSequence" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jSequence" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jLabel11" alignment="2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jMaxDate" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jMinDate" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCount" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jSales" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jSalesSubtotal" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jSalesTaxes" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jSalesTotal" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jCash" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jLinesRemoved" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel8" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="m_jNoCashSales" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" attributes="0"> + <Component id="m_jScrollTableTicket" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jScrollSales" min="-2" max="-2" attributes="1"/> + </Group> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="m_jPrint" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="15" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel11"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.sequence" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jSequence"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.button.WebButton" name="webBtnFindSequence"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/search32.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="webBtnFindSequenceActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.StartDate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jMinDate"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.EndDate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jMaxDate"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="m_jScrollTableTicket"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="horizontalScrollBarPolicy" type="int" value="31"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[350, 140]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[350, 150]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JPanelCloseMoney_m_jScrollTableTicket"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="m_jTicketTable"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="0" rowCount="0"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="intercellSpacing" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 1]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + <Property name="showVerticalLines" type="boolean" value="false"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="m_jScrollSales"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="horizontalScrollBarPolicy" type="int" value="31"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[350, 150]"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="m_jsalestable"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="intercellSpacing" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 1]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + <Property name="showVerticalLines" type="boolean" value="false"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.Tickets" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jCount"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.sales" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jSales"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.totalnet" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jSalesSubtotal"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel12"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.taxes" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jSalesTaxes"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.total" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jSalesTotal"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.Money" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jCash"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel9"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.linevoids" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jLinesRemoved"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.nocashsales" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jNoCashSales"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="m_jPrint"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/printer.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.print" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.btn.closecash" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="iconTextGap" type="int" value="2"/> + <Property name="inheritsPopupMenu" type="boolean" value="true"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jPrintActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/panels/JPanelCloseMoneyReprint.java b/src/main/java/com/unicenta/pos/panels/JPanelCloseMoneyReprint.java new file mode 100644 index 0000000..70c55d9 --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JPanelCloseMoneyReprint.java @@ -0,0 +1,690 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.gui.TableRendererBasic; +import com.unicenta.data.loader.Session; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.*; +import com.unicenta.pos.printer.TicketParser; +import com.unicenta.pos.printer.TicketPrinterException; +import com.unicenta.pos.scripting.ScriptEngine; +import com.unicenta.pos.scripting.ScriptException; +import com.unicenta.pos.scripting.ScriptFactory; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; +import java.awt.*; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; + +/** + * + * @author JG uniCenta + */ +@Slf4j +public class JPanelCloseMoneyReprint extends JPanel implements JPanelView, BeanFactoryApp { + private AppView m_App; + private DataLogicSystem m_dlSystem; + + private PaymentsReprintModel m_PaymentsClosed = null; + + private TicketParser m_TTP; + private final DateFormat df= new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); + + private Session s; + private Connection con; + private Statement stmt; + private Integer result; + private Integer dresult; + private String SQL; + private ResultSet rs; + + private AppUser m_User; + + /** Creates new form JPanelCloseMoneyReprint */ + public JPanelCloseMoneyReprint() { + initComponents(); + } + + /** + * + * @param app + * @throws BeanFactoryException + */ + @Override + public void init(AppView app) throws BeanFactoryException { + + m_App = app; + m_dlSystem = (DataLogicSystem) m_App.getBean("com.unicenta.pos.forms.DataLogicSystem"); + m_TTP = new TicketParser(m_App.getDeviceTicket(), m_dlSystem); + + m_jTicketTable.setDefaultRenderer(Object.class, new TableRendererBasic( + new Formats[] {new FormatsPayment(), Formats.CURRENCY})); + m_jTicketTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + m_jScrollTableTicket.getVerticalScrollBar().setPreferredSize(new Dimension(25,25)); + m_jTicketTable.getTableHeader().setReorderingAllowed(false); + m_jTicketTable.setRowHeight(25); + m_jTicketTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + m_jsalestable.setDefaultRenderer(Object.class, new TableRendererBasic( + new Formats[] {Formats.STRING, Formats.CURRENCY, Formats.CURRENCY, Formats.CURRENCY})); + m_jsalestable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + m_jScrollSales.getVerticalScrollBar().setPreferredSize(new Dimension(25,25)); + m_jsalestable.getTableHeader().setReorderingAllowed(false); + m_jsalestable.setRowHeight(25); + m_jsalestable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + m_jPrint.setEnabled(false); + + } + + /** + * + * @return + */ + @Override + public Object getBean() { + return this; + } + + /** + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.CloseTPV"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { +// loadData(); + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + return true; + } + + public String getInputSequence() { + return m_jSequence.getText(); + } + + private void loadData() throws BasicException { + + m_jSequence.setText(null); + m_jMinDate.setText(null); + m_jMaxDate.setText(null); + + m_jCount.setText(null); + m_jCash.setText(null); + + m_jSales.setText(null); + m_jSalesSubtotal.setText(null); + m_jSalesTaxes.setText(null); + m_jSalesTotal.setText(null); + + m_jTicketTable.setModel(new DefaultTableModel()); + m_jsalestable.setModel(new DefaultTableModel()); + + m_PaymentsClosed = PaymentsReprintModel.loadInstance(m_App); + + if (m_PaymentsClosed.getPayments() > 0 + || m_PaymentsClosed.getSales() > 0) { + + m_jSequence.setText(m_PaymentsClosed.printSequence()); + m_jMinDate.setText(m_PaymentsClosed.reformDateStart()); + m_jMaxDate.setText(m_PaymentsClosed.reformDateEnd()); + + m_jPrint.setEnabled(true); + + m_jCount.setText(m_PaymentsClosed.printPayments()); + m_jCash.setText(m_PaymentsClosed.printPaymentsTotal()); + + m_jSales.setText(m_PaymentsClosed.printSales()); + m_jSalesSubtotal.setText(m_PaymentsClosed.printSalesBase()); + m_jSalesTaxes.setText(m_PaymentsClosed.printSalesTaxes()); + m_jSalesTotal.setText(m_PaymentsClosed.printSalesTotal()); + + m_jTicketTable.setModel(m_PaymentsClosed.getPaymentsReprintModel()); + + TableColumnModel jColumns = m_jTicketTable.getColumnModel(); + jColumns.getColumn(0).setPreferredWidth(225); + jColumns.getColumn(0).setResizable(false); + jColumns.getColumn(1).setPreferredWidth(100); + jColumns.getColumn(1).setResizable(false); + + m_jsalestable.setModel(m_PaymentsClosed.getSalesModel()); + + jColumns = m_jsalestable.getColumnModel(); + jColumns.getColumn(0).setPreferredWidth(125); + jColumns.getColumn(0).setResizable(false); + jColumns.getColumn(1).setPreferredWidth(100); + jColumns.getColumn(1).setResizable(false); + jColumns.getColumn(2).setPreferredWidth(100); + jColumns.getColumn(2).setResizable(false); + + try{ + result=0; + s=m_App.getSession(); + con=s.getConnection(); + String sdbmanager = m_dlSystem.getDBVersion(); + + if ("PostgreSQL".equals(sdbmanager)) { + SQL = "SELECT * " + + "FROM draweropened " + + "WHERE TICKETID = 'No Sale' AND OPENDATE > " + "'" + m_PaymentsClosed.printDateStart() + "'"; + } else { + SQL = "SELECT * " + + "FROM draweropened " + + "WHERE TICKETID = 'No Sale' AND DATE(OPENDATE) = " + "'" + m_PaymentsClosed.printDateStart() + "'"; + } + + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + while (rs.next()){ + result ++; + } + + rs=null; + dresult=0; + if ("PostgreSQL".equals(sdbmanager)) { + SQL = "SELECT * " + + "FROM lineremoved " + + "WHERE TICKETID = 'Void' AND REMOVEDDATE > " + "'" + m_PaymentsClosed.printDateStart() + "'"; + } else { + SQL = "SELECT * " + + "FROM lineremoved " + + "WHERE TICKETID = 'Void' AND DATE(REMOVEDDATE) = " + "'" + m_PaymentsClosed.printDateStart() + "'"; + } + + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + while (rs.next()){ + dresult ++; + } + rs=null; + con=null; + s=null; + } + + catch (SQLException e){} + + m_jLinesRemoved.setText(dresult.toString()); + m_jNoCashSales.setText(result.toString()); + } + } + + private void printPayments(String report) { + + String sresource = m_dlSystem.getResourceAsXML(report); + if (sresource == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotprintticket")); + msg.show(this); + } else { + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); + script.put("payments", m_PaymentsClosed); + script.put("nosales",result.toString()); + m_TTP.printTicket(script.eval(sresource).toString()); + } catch (ScriptException | TicketPrinterException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotprintticket"), e); + msg.show(this); + } + } + } + + private class FormatsPayment extends Formats { + @Override + protected String formatValueInt(Object value) { + return AppLocal.getIntString("transpayment." + (String) value); + } + @Override + protected Object parseValueInt(String value) throws ParseException { + return value; + } + @Override + public int getAlignment() { + return javax.swing.SwingConstants.LEFT; + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jLabel11 = new javax.swing.JLabel(); + m_jSequence = new javax.swing.JTextField(); + webBtnFindSequence = new com.alee.laf.button.WebButton(); + jLabel2 = new javax.swing.JLabel(); + m_jMinDate = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + m_jMaxDate = new javax.swing.JTextField(); + m_jScrollTableTicket = new javax.swing.JScrollPane(); + m_jTicketTable = new javax.swing.JTable(); + m_jScrollSales = new javax.swing.JScrollPane(); + m_jsalestable = new javax.swing.JTable(); + jLabel1 = new javax.swing.JLabel(); + m_jCount = new javax.swing.JTextField(); + jLabel5 = new javax.swing.JLabel(); + m_jSales = new javax.swing.JTextField(); + jLabel6 = new javax.swing.JLabel(); + m_jSalesSubtotal = new javax.swing.JTextField(); + jLabel12 = new javax.swing.JLabel(); + m_jSalesTaxes = new javax.swing.JTextField(); + jLabel7 = new javax.swing.JLabel(); + m_jSalesTotal = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + m_jCash = new javax.swing.JTextField(); + jLabel9 = new javax.swing.JLabel(); + m_jLinesRemoved = new javax.swing.JTextField(); + jLabel8 = new javax.swing.JLabel(); + m_jNoCashSales = new javax.swing.JTextField(); + m_jPrint = new javax.swing.JButton(); + + setLayout(new java.awt.BorderLayout()); + + jPanel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + + jLabel11.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel11.setText(AppLocal.getIntString("label.sequence")); // NOI18N + jLabel11.setPreferredSize(new java.awt.Dimension(125, 30)); + + m_jSequence.setEditable(false); + m_jSequence.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSequence.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jSequence.setPreferredSize(new java.awt.Dimension(150, 30)); + + webBtnFindSequence.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/search32.png"))); // NOI18N + webBtnFindSequence.setToolTipText(""); + webBtnFindSequence.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + webBtnFindSequence.setPreferredSize(new java.awt.Dimension(80, 45)); + webBtnFindSequence.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + webBtnFindSequenceActionPerformed(evt); + } + }); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLabel2.setText(AppLocal.getIntString("label.StartDate")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(125, 30)); + + m_jMinDate.setEditable(false); + m_jMinDate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jMinDate.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jMinDate.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLabel3.setText(AppLocal.getIntString("label.EndDate")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jMaxDate.setEditable(false); + m_jMaxDate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jMaxDate.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jMaxDate.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jScrollTableTicket.setBorder(null); + m_jScrollTableTicket.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + m_jScrollTableTicket.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jScrollTableTicket.setMinimumSize(new java.awt.Dimension(350, 140)); + m_jScrollTableTicket.setPreferredSize(new java.awt.Dimension(350, 150)); + + m_jTicketTable.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jTicketTable.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + + }, + new String [] { + + } + )); + m_jTicketTable.setFocusable(false); + m_jTicketTable.setIntercellSpacing(new java.awt.Dimension(0, 1)); + m_jTicketTable.setRequestFocusEnabled(false); + m_jTicketTable.setShowVerticalLines(false); + m_jScrollTableTicket.setViewportView(m_jTicketTable); + + m_jScrollSales.setBorder(null); + m_jScrollSales.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + m_jScrollSales.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jScrollSales.setPreferredSize(new java.awt.Dimension(350, 150)); + + m_jsalestable.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jsalestable.setFocusable(false); + m_jsalestable.setIntercellSpacing(new java.awt.Dimension(0, 1)); + m_jsalestable.setRequestFocusEnabled(false); + m_jsalestable.setShowVerticalLines(false); + m_jScrollSales.setViewportView(m_jsalestable); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.Tickets")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jCount.setEditable(false); + m_jCount.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCount.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jCount.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.sales")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jSales.setEditable(false); + m_jSales.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSales.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jSales.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.totalnet")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jSalesSubtotal.setEditable(false); + m_jSalesSubtotal.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSalesSubtotal.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jSalesSubtotal.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel12.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel12.setText(AppLocal.getIntString("label.taxes")); // NOI18N + jLabel12.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jSalesTaxes.setEditable(false); + m_jSalesTaxes.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSalesTaxes.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jSalesTaxes.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.total")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jSalesTotal.setEditable(false); + m_jSalesTotal.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSalesTotal.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jSalesTotal.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.Money")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jCash.setEditable(false); + m_jCash.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCash.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jCash.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLabel9.setText(bundle.getString("label.linevoids")); // NOI18N + jLabel9.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jLinesRemoved.setEditable(false); + m_jLinesRemoved.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jLinesRemoved.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jLinesRemoved.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jLabel8.setText(bundle.getString("label.nocashsales")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jNoCashSales.setEditable(false); + m_jNoCashSales.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jNoCashSales.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + m_jNoCashSales.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jPrint.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/printer.png"))); // NOI18N + m_jPrint.setText(AppLocal.getIntString("button.print")); // NOI18N + m_jPrint.setToolTipText(bundle.getString("tooltip.btn.closecash")); // NOI18N + m_jPrint.setIconTextGap(2); + m_jPrint.setInheritsPopupMenu(true); + m_jPrint.setMaximumSize(new java.awt.Dimension(85, 33)); + m_jPrint.setMinimumSize(new java.awt.Dimension(85, 33)); + m_jPrint.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jPrint.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jPrintActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jScrollSales, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jScrollTableTicket, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(m_jMaxDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jSales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jSalesSubtotal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jSalesTaxes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jSalesTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jCash, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jLinesRemoved, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jNoCashSales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jMinDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jSequence, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(webBtnFindSequence, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(141, 141, 141) + .addComponent(m_jPrint, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(webBtnFindSequence, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSequence, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jMaxDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jMinDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(18, 18, 18) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jSales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSalesSubtotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSalesTaxes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jSalesTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jCash, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jLinesRemoved, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jNoCashSales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(m_jScrollTableTicket, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jScrollSales, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(18, 18, 18) + .addComponent(m_jPrint, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(15, Short.MAX_VALUE)) + ); + + add(jPanel1, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + private void m_jPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jPrintActionPerformed + printPayments("Printer.CloseCash"); + }//GEN-LAST:event_m_jPrintActionPerformed + + private void webBtnFindSequenceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_webBtnFindSequenceActionPerformed + try { + m_jPrint.setEnabled(false); + + loadData(); + + if (m_jCount.getText() != null) { + m_jPrint.setEnabled(true); + } else { + m_jPrint.setEnabled(false); + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("Nope"), + AppLocal.getIntString("message.title"), + JOptionPane.OK_OPTION); + } + repaint(); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + + }//GEN-LAST:event_webBtnFindSequenceActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JPanel jPanel1; + private javax.swing.JTextField m_jCash; + private javax.swing.JTextField m_jCount; + private javax.swing.JTextField m_jLinesRemoved; + private javax.swing.JTextField m_jMaxDate; + private javax.swing.JTextField m_jMinDate; + private javax.swing.JTextField m_jNoCashSales; + private javax.swing.JButton m_jPrint; + private javax.swing.JTextField m_jSales; + private javax.swing.JTextField m_jSalesSubtotal; + private javax.swing.JTextField m_jSalesTaxes; + private javax.swing.JTextField m_jSalesTotal; + private javax.swing.JScrollPane m_jScrollSales; + private javax.swing.JScrollPane m_jScrollTableTicket; + private javax.swing.JTextField m_jSequence; + private javax.swing.JTable m_jTicketTable; + private javax.swing.JTable m_jsalestable; + private com.alee.laf.button.WebButton webBtnFindSequence; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/panels/JPanelPayments.java b/src/main/java/com/unicenta/pos/panels/JPanelPayments.java new file mode 100644 index 0000000..488470b --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JPanelPayments.java @@ -0,0 +1,87 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; + +/** + * + * @author adrianromero + */ +public class JPanelPayments extends JPanelTable { + + private PaymentsEditor jeditor; + private DataLogicSales m_dlSales = null; + + /** Creates a new instance of JPanelPayments */ + public JPanelPayments() { + } + + /** + * + */ + @Override + protected void init() { + m_dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + jeditor = new PaymentsEditor(app, dirty); + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return null; + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(null + , m_dlSales.getPaymentMovementInsert() + , m_dlSales.getPaymentMovementDelete()); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Payments"); + } +} diff --git a/src/main/java/com/unicenta/pos/panels/JPanelPrinter.form b/src/main/java/com/unicenta/pos/panels/JPanelPrinter.form new file mode 100644 index 0000000..3f00d53 --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JPanelPrinter.form @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jDisplay"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JTabbedPane" name="m_jPrinters"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/panels/JPanelPrinter.java b/src/main/java/com/unicenta/pos/panels/JPanelPrinter.java new file mode 100644 index 0000000..256166b --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JPanelPrinter.java @@ -0,0 +1,129 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.basic.BasicException; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.JPanelView; +import com.unicenta.pos.printer.DeviceFiscalPrinter; +import com.unicenta.pos.printer.DevicePrinter; +import java.util.List; +import javax.swing.JComponent; +import javax.swing.JPanel; + +/** + * + * @author adrianromero + */ +public class JPanelPrinter extends JPanel implements JPanelView { + + /** Creates new form JPrinter + * @param oApp */ + public JPanelPrinter(AppView oApp) { + + initComponents(); + + + if (oApp.getDeviceTicket().getDeviceDisplay().getDisplayComponent() != null) { + m_jDisplay.add(oApp.getDeviceTicket().getDeviceDisplay().getDisplayComponent()); + } + + List<DevicePrinter> aprinters = oApp.getDeviceTicket().getDevicePrinterAll(); + for (int i = 0; i < aprinters.size(); i++) { + DevicePrinter printer = aprinters.get(i); + if (printer.getPrinterComponent() != null) { + m_jPrinters.add(printer.getPrinterName(), printer.getPrinterComponent()); + } + } + + DeviceFiscalPrinter fp = oApp.getDeviceTicket().getFiscalPrinter(); + if (fp.getFiscalComponent() != null) { + m_jPrinters.add(fp.getFiscalName(), fp.getFiscalComponent()); + } + } + + /** + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Printer"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + return true; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jDisplay = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + m_jPrinters = new javax.swing.JTabbedPane(); + + setLayout(new java.awt.BorderLayout()); + add(m_jDisplay, java.awt.BorderLayout.NORTH); + + jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel1.setLayout(new java.awt.BorderLayout()); + + m_jPrinters.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel1.add(m_jPrinters, java.awt.BorderLayout.CENTER); + + add(jPanel1, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel m_jDisplay; + private javax.swing.JTabbedPane m_jPrinters; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/panels/JPanelTable.form b/src/main/java/com/unicenta/pos/panels/JPanelTable.form new file mode 100644 index 0000000..f2727ff --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JPanelTable.form @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="container"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="toolbar"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/panels/JPanelTable.java b/src/main/java/com/unicenta/pos/panels/JPanelTable.java new file mode 100644 index 0000000..4c79f3d --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JPanelTable.java @@ -0,0 +1,274 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.*; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.*; +import com.unicenta.pos.customers.CustomerInfoGlobal; +import com.unicenta.pos.forms.*; +import java.awt.BorderLayout; +import java.awt.Component; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; + +/** + * + * @author adrianromero + */ +public abstract class JPanelTable extends JPanel implements JPanelView, BeanFactoryApp { + + /** + * + */ + protected BrowsableEditableData bd; + + /** + * + */ + protected DirtyManager dirty; + + /** + * + */ + protected AppView app; + + /** Creates new form JPanelTableEditor */ + public JPanelTable() { + + initComponents(); + } + + /** + * + * @param app + * @throws BeanFactoryException + */ + @Override + public void init(AppView app) throws BeanFactoryException { + + this.app = app; + dirty = new DirtyManager(); + bd = null; + init(); + } + + /** + * + * @return + */ + @Override + public Object getBean() { + return this; + } + + /** + * + */ + protected void startNavigation() { + + if (bd == null) { + + // init browsable editable data + bd = new BrowsableEditableData(getListProvider(), getSaveProvider(), getEditor(), dirty); + + // Add the filter panel + Component c = getFilter(); + if (c != null) { + c.applyComponentOrientation(getComponentOrientation()); + add(c, BorderLayout.NORTH); + } + + // Add the editor + c = getEditor().getComponent(); + if (c != null) { + c.applyComponentOrientation(getComponentOrientation()); + container.add(c, BorderLayout.CENTER); + } + + // el panel este + ListCellRenderer cr = getListCellRenderer(); + if (cr != null) { + JListNavigator nl = new JListNavigator(bd); + nl.applyComponentOrientation(getComponentOrientation()); + if (cr != null) { + nl.setCellRenderer(cr); + } + container.add(nl, java.awt.BorderLayout.LINE_START); + } + + // add toolbar extras + c = getToolbarExtras(); + if (c != null) { + c.applyComponentOrientation(getComponentOrientation()); + toolbar.add(c); + } + + // La Toolbar + c = new JLabelDirty(dirty); + c.applyComponentOrientation(getComponentOrientation()); + toolbar.add(c); + c = new JCounter(bd); + c.applyComponentOrientation(getComponentOrientation()); + toolbar.add(c); + c = new JNavigator(bd, getVectorer(), getComparatorCreator()); + c.applyComponentOrientation(getComponentOrientation()); + toolbar.add(c); + c = new JSaver(bd); + c.applyComponentOrientation(getComponentOrientation()); + toolbar.add(c); + } + } + + /** + * + * @return + */ + public Component getToolbarExtras() { + return null; + } + + /** + * + * @return + */ + public Component getFilter() { + return null; + } + + /** + * + */ + protected abstract void init(); + + /** + * + * @return + */ + public abstract EditorRecord getEditor(); + + /** + * + * @return + */ + public abstract ListProvider getListProvider(); + + /** + * + * @return + */ + public abstract SaveProvider getSaveProvider(); + + /** + * + * @return + */ + public Vectorer getVectorer() { + return null; + } + + /** + * + * @return + */ + public ComparatorCreator getComparatorCreator() { + return null; + } + + /** + * + * @return + */ + public ListCellRenderer getListCellRenderer() { + return null; + } + + /** + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + startNavigation(); + bd.actionLoad(); + + //HS insert new customer 20.03.2014 + if (CustomerInfoGlobal.getInstance()!=null){ + bd.actionInsert(); + } + + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + + try { + return bd.actionClosingForm(this); + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.CannotMove"), eD); + msg.show(this); + return false; + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + container = new javax.swing.JPanel(); + toolbar = new javax.swing.JPanel(); + + setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + setLayout(new java.awt.BorderLayout()); + + container.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + container.setLayout(new java.awt.BorderLayout()); + container.add(toolbar, java.awt.BorderLayout.NORTH); + + add(container, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel container; + private javax.swing.JPanel toolbar; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/panels/JPanelTable2.java b/src/main/java/com/unicenta/pos/panels/JPanelTable2.java new file mode 100644 index 0000000..c7cd34a --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JPanelTable2.java @@ -0,0 +1,94 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.model.Row; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.SaveProvider; +import javax.swing.ListCellRenderer; + +/** + * + * @author adrianromero + */ +public abstract class JPanelTable2 extends JPanelTable { + + /** + * + */ + protected Row row; + + /** + * + */ + protected ListProvider lpr; + + /** + * + */ + protected SaveProvider spr; + + /** + * + * @return + */ + @Override + public final ListProvider getListProvider() { + return lpr; + } + + /** + * + * @return + */ + @Override + public final SaveProvider getSaveProvider() { + return spr; + } + + /** + * + * @return + */ + @Override + public final Vectorer getVectorer() { + return row.getVectorer(); + } + + /** + * + * @return + */ + @Override + public final ComparatorCreator getComparatorCreator() { + return row.getComparatorCreator(); + } + + /** + * + * @return + */ + @Override + public final ListCellRenderer getListCellRenderer() { + return row.getListCellRenderer(); + } +} diff --git a/src/main/java/com/unicenta/pos/panels/JProductFinder.form b/src/main/java/com/unicenta/pos/panels/JProductFinder.form new file mode 100644 index 0000000..6e6a4d6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JProductFinder.form @@ -0,0 +1,280 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="form.productslist" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[750, 600]"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,122,0,0,2,-10"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="West"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jProductSelect"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jButton3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.executefilter" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Execute Filter"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton3ActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 140]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="West"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 147]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="jListProducts"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="selectionMode" type="int" value="0"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jListProductsMouseClicked"/> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="jListProductsValueChanged"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[290, 300]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jKeysActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Last"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="2"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="jcmdCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[103, 44]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[103, 44]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jcmdOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[103, 44]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[103, 44]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel6"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jImageViewerProduct" pref="280" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="32767" attributes="0"/> + <Component id="jImageViewerProduct" min="-2" pref="222" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="com.unicenta.data.gui.JImageViewerProduct" name="jImageViewerProduct"> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/panels/JProductFinder.java b/src/main/java/com/unicenta/pos/panels/JProductFinder.java new file mode 100644 index 0000000..c835669 --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JProductFinder.java @@ -0,0 +1,372 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.ticket.ProductFilterSales; +import com.unicenta.pos.ticket.ProductInfoExt; +import com.unicenta.pos.ticket.ProductRenderer; +import java.awt.*; +import javax.swing.JFrame; + +/** + * + * @author JG uniCenta + */ +public class JProductFinder extends javax.swing.JDialog { + + private ProductInfoExt m_ReturnProduct; + private ListProvider lpr; + public final static int PRODUCT_ALL = 0; + public final static int PRODUCT_NORMAL = 1; + public final static int PRODUCT_AUXILIAR = 2; + public final static int PRODUCT_BUNDLE = 3; + private Object dlSales; + + private JProductFinder(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + + private JProductFinder(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + private ProductInfoExt init(DataLogicSales dlSales, int productsType) { + + initComponents(); + + jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); + jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(35, 35)); + + ProductFilterSales jproductfilter = new ProductFilterSales(dlSales, m_jKeys); + jproductfilter.activate(); + m_jProductSelect.add(jproductfilter, BorderLayout.CENTER); + switch (productsType) { + case PRODUCT_NORMAL: + lpr = new ListProviderCreator(dlSales.getProductListNormal(), jproductfilter); + break; + case PRODUCT_AUXILIAR: + lpr = new ListProviderCreator(dlSales.getProductListAuxiliar(), jproductfilter); + break; + default: // PRODUCT_ALL + lpr = new ListProviderCreator(dlSales.getProductList(), jproductfilter); + break; + + } + jListProducts.setCellRenderer(new ProductRenderer()); + + + getRootPane().setDefaultButton(jcmdOK); + m_ReturnProduct = null; + + setVisible(true); + + return m_ReturnProduct; + + + } + + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window)parent; + } else { + return getWindow(parent.getParent()); + } + } + + /** + * + * @param parent + * @param dlSales + * @return + */ + public static ProductInfoExt showMessage(Component parent, DataLogicSales dlSales) { + return showMessage(parent, dlSales, PRODUCT_ALL); + } + + /** + * + * @param parent + * @param dlSales + * @param productsType + * @return + */ + public static ProductInfoExt showMessage(Component parent, DataLogicSales dlSales, int productsType) { + + Window window = getWindow(parent); + + JProductFinder myMsg; + if (window instanceof Frame) { + myMsg = new JProductFinder((Frame) window, true); + } else { + myMsg = new JProductFinder((Dialog) window, true); + } + return myMsg.init(dlSales, productsType); + } + + private static class MyListData extends javax.swing.AbstractListModel { + + private final java.util.List m_data; + + public MyListData(java.util.List data) { + m_data = data; + } + + @Override + public Object getElementAt(int index) { + return m_data.get(index); + } + + @Override + public int getSize() { + return m_data.size(); + } + } + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel2 = new javax.swing.JPanel(); + m_jProductSelect = new javax.swing.JPanel(); + jPanel3 = new javax.swing.JPanel(); + jButton3 = new javax.swing.JButton(); + jPanel5 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jListProducts = new javax.swing.JList(); + jPanel4 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel1 = new javax.swing.JPanel(); + jcmdCancel = new javax.swing.JButton(); + jcmdOK = new javax.swing.JButton(); + jPanel6 = new javax.swing.JPanel(); + jImageViewerProduct = new com.unicenta.data.gui.JImageViewerProduct(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("form.productslist")); // NOI18N + setPreferredSize(new java.awt.Dimension(750, 600)); + + jPanel2.setPreferredSize(new java.awt.Dimension(450, 0)); + jPanel2.setLayout(new java.awt.BorderLayout()); + + m_jProductSelect.setLayout(new java.awt.BorderLayout()); + + jButton3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jButton3.setText(AppLocal.getIntString("button.executefilter")); // NOI18N + jButton3.setToolTipText("Execute Filter"); + jButton3.setPreferredSize(new java.awt.Dimension(110, 45)); + jButton3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton3ActionPerformed(evt); + } + }); + jPanel3.add(jButton3); + + m_jProductSelect.add(jPanel3, java.awt.BorderLayout.SOUTH); + + jPanel2.add(m_jProductSelect, java.awt.BorderLayout.NORTH); + + jPanel5.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel5.setPreferredSize(new java.awt.Dimension(450, 140)); + jPanel5.setLayout(new java.awt.BorderLayout()); + + jScrollPane1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jScrollPane1.setPreferredSize(new java.awt.Dimension(400, 147)); + + jListProducts.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jListProducts.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + jListProducts.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jListProductsMouseClicked(evt); + } + }); + jListProducts.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + jListProductsValueChanged(evt); + } + }); + jScrollPane1.setViewportView(jListProducts); + + jPanel5.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + jPanel2.add(jPanel5, java.awt.BorderLayout.WEST); + + getContentPane().add(jPanel2, java.awt.BorderLayout.WEST); + + jPanel4.setPreferredSize(new java.awt.Dimension(300, 0)); + jPanel4.setLayout(new java.awt.BorderLayout()); + + m_jKeys.setPreferredSize(new java.awt.Dimension(290, 300)); + m_jKeys.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jKeysActionPerformed(evt); + } + }); + jPanel4.add(m_jKeys, java.awt.BorderLayout.NORTH); + + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N + jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdCancel.setMaximumSize(new java.awt.Dimension(103, 44)); + jcmdCancel.setMinimumSize(new java.awt.Dimension(103, 44)); + jcmdCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel1.add(jcmdCancel); + + jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + jcmdOK.setEnabled(false); + jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdOK.setMaximumSize(new java.awt.Dimension(103, 44)); + jcmdOK.setMinimumSize(new java.awt.Dimension(103, 44)); + jcmdOK.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel1.add(jcmdOK); + + jPanel4.add(jPanel1, java.awt.BorderLayout.PAGE_END); + + javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); + jPanel6.setLayout(jPanel6Layout); + jPanel6Layout.setHorizontalGroup( + jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jImageViewerProduct, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE) + .addContainerGap()) + ); + jPanel6Layout.setVerticalGroup( + jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jImageViewerProduct, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + jPanel4.add(jPanel6, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel4, java.awt.BorderLayout.EAST); + + setSize(new java.awt.Dimension(758, 634)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void jListProductsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListProductsMouseClicked + + m_ReturnProduct = (ProductInfoExt) jListProducts.getSelectedValue(); + + if (m_ReturnProduct != null) { + m_ReturnProduct = (ProductInfoExt) jListProducts.getSelectedValue(); + + if (m_ReturnProduct != null) { + jImageViewerProduct.setImage(m_ReturnProduct.getImage()); + } + } + + }//GEN-LAST:event_jListProductsMouseClicked + + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + m_ReturnProduct = (ProductInfoExt) jListProducts.getSelectedValue(); + dispose(); + + }//GEN-LAST:event_jcmdOKActionPerformed + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + m_ReturnProduct=null; + dispose(); + + }//GEN-LAST:event_jcmdCancelActionPerformed + + private void jListProductsValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListProductsValueChanged + + m_ReturnProduct = (ProductInfoExt) jListProducts.getSelectedValue(); + + if (m_ReturnProduct != null) { + m_ReturnProduct = (ProductInfoExt) jListProducts.getSelectedValue(); + + if (m_ReturnProduct != null) { + jImageViewerProduct.setImage(m_ReturnProduct.getImage()); + } + } + + jcmdOK.setEnabled(jListProducts.getSelectedValue() != null); + + }//GEN-LAST:event_jListProductsValueChanged + + private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed + + try { + jListProducts.setModel(new MyListData(lpr.loadData())); + if (jListProducts.getModel().getSize() > 0) { + jListProducts.setSelectedIndex(0); + } + } catch (BasicException e) { + } + + }//GEN-LAST:event_jButton3ActionPerformed + + private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_m_jKeysActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton3; + private com.unicenta.data.gui.JImageViewerProduct jImageViewerProduct; + private javax.swing.JList jListProducts; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JPanel m_jProductSelect; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/panels/JTextFieldLimit.java b/src/main/java/com/unicenta/pos/panels/JTextFieldLimit.java new file mode 100644 index 0000000..fd0507f --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JTextFieldLimit.java @@ -0,0 +1,22 @@ +package com.unicenta.pos.panels; + +import javax.swing.text.AttributeSet; +import javax.swing.text.BadLocationException; +import javax.swing.text.PlainDocument; + +public class JTextFieldLimit extends PlainDocument { + private int limit; + + JTextFieldLimit(int limit) { + super(); + this.limit = limit; + } + + public void insertString(int offset, String str, AttributeSet attr ) throws BadLocationException { + if (str == null) return; + + if ((getLength() + str.length()) <= limit) { + super.insertString(offset, str, attr); + } + } +} diff --git a/src/main/java/com/unicenta/pos/panels/JTicketsFinder.form b/src/main/java/com/unicenta/pos/panels/JTicketsFinder.form new file mode 100644 index 0000000..dc1ed2d --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JTicketsFinder.form @@ -0,0 +1,642 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="form.tickettitle" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[568, 600]"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,122,0,0,2,-10"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="First"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel7"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 210]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" max="-2" attributes="0"> + <Component id="jLabel6" alignment="0" pref="115" max="32767" attributes="0"/> + <Component id="labelCustomer" alignment="0" max="32767" attributes="0"/> + <Component id="jLabel4" alignment="0" max="32767" attributes="0"/> + <Component id="jLabel3" alignment="0" max="32767" attributes="0"/> + <Component id="jLabel1" alignment="0" max="32767" attributes="0"/> + <Component id="jLabel7" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="1" max="-2" attributes="0"> + <Component id="jtxtCustomer" alignment="0" max="32767" attributes="0"/> + <Component id="jTxtStartDate" alignment="0" max="32767" attributes="0"/> + <Component id="jTxtEndDate" alignment="0" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="btnDateEnd" min="-2" max="-2" attributes="0"/> + <Component id="btnDateStart" min="-2" max="-2" attributes="0"/> + <Component id="btnCustomer" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" attributes="0"> + <Component id="jcboMoney" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jtxtMoney" min="-2" pref="131" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jtxtTicketID" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jComboBoxTicket" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jcboUser" min="-2" pref="150" max="-2" attributes="0"/> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="103" alignment="0" groupAlignment="1" attributes="0"> + <Component id="jComboBoxTicket" max="-2" attributes="0"/> + <Component id="jtxtTicketID" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="btnDateStart" min="-2" max="-2" attributes="0"/> + <Component id="jTxtStartDate" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="2" attributes="0"> + <Component id="jLabel4" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jTxtEndDate" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="btnDateEnd" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="2" attributes="0"> + <Component id="labelCustomer" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jtxtCustomer" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="btnCustomer" alignment="2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jcboUser" alignment="3" max="-2" attributes="0"/> + <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="2" attributes="0"> + <Component id="jtxtMoney" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="103" alignment="1" groupAlignment="3" attributes="0"> + <Component id="jcboMoney" alignment="3" max="32767" attributes="0"/> + <Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace min="-2" pref="19" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.ticketid" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.user" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.totalcash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorCurrency" name="jtxtMoney"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jcboUser"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[220, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcboUserActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jcboMoney"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorIntegerPositive" name="jtxtTicketID"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="labelCustomer"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.customer" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.StartDate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.EndDate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTxtStartDate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTxtEndDate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="btnDateStart"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/date.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Open Calendar"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnDateStartActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="btnDateEnd"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/date.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Open Calendar"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnDateEndActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="jtxtCustomer"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="btnCustomer"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/customer_sml.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Open Customers"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCustomerActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboBoxTicket"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel6"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jbtnReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.clean" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Clear Filter"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnResetActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jbtnExecute"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.executefilter" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Execute Filter"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnExecuteActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="jListTickets"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jListTicketsMouseClicked"/> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="jListTicketsValueChanged"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 250]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[290, 300]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jKeysActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="0" y="0" width="300" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jPanel8"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="0" y="536" width="300" height="-1"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jcmdCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jcmdOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[103, 44]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[103, 44]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLblTicketCount"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="cc" red="33" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Century Gothic" size="18" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="ff" green="cc" red="33" type="rgb"/> + </LineBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 50]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="10" y="306" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLblReturnCount"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.ticketsfound" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="ff" green="cc" red="0" type="rgb"/> + </LineBorder> + </Border> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 50]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="90" y="306" width="200" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/panels/JTicketsFinder.java b/src/main/java/com/unicenta/pos/panels/JTicketsFinder.java new file mode 100644 index 0000000..9801b08 --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/JTicketsFinder.java @@ -0,0 +1,820 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.basic.BasicException; +import com.unicenta.beans.JCalendarDialog; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.ListQBFModelNumber; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.user.EditorCreator; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.format.Formats; +import com.unicenta.pos.customers.DataLogicCustomers; +import com.unicenta.pos.customers.JCustomerFinder; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.inventory.TaxCategoryInfo; +import com.unicenta.pos.ticket.FindTicketsInfo; +import com.unicenta.pos.ticket.FindTicketsRenderer; +import java.awt.*; +import java.time.LocalTime; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JFrame; + +/** + * + * @author Mikel irurita + */ +public class JTicketsFinder extends javax.swing.JDialog implements EditorCreator { + + private ListProvider listProvider; + private SentenceList m_sentcat; + private ComboBoxValModel m_CategoryModel; + private DataLogicSales dlSales; + private DataLogicCustomers dlCustomers; + private FindTicketsInfo selectedTicket; + + /** Creates new form JTicketsFinder */ + private JTicketsFinder(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + + /** Creates new form JTicketsFinder */ + private JTicketsFinder(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + /** + * + * @param parent + * @param dlSales + * @param dlCustomers + * @return + */ + public static JTicketsFinder getReceiptFinder(Component parent, DataLogicSales dlSales, DataLogicCustomers dlCustomers) { + Window window = getWindow(parent); + + JTicketsFinder myMsg; + if (window instanceof Frame) { + myMsg = new JTicketsFinder((Frame) window, true); + } else { + myMsg = new JTicketsFinder((Dialog) window, true); + } + myMsg.init(dlSales, dlCustomers); + myMsg.applyComponentOrientation(parent.getComponentOrientation()); + return myMsg; + } + + /** + * + * @return + */ + public FindTicketsInfo getSelectedCustomer() { + return selectedTicket; + } + + private void init(DataLogicSales dlSales, DataLogicCustomers dlCustomers) { + + this.dlSales = dlSales; + this.dlCustomers = dlCustomers; + + initComponents(); + + jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); + + jtxtTicketID.addEditorKeys(m_jKeys); + jtxtMoney.addEditorKeys(m_jKeys); + + listProvider = new ListProviderCreator(dlSales.getTicketsList(), this); + + jListTickets.setCellRenderer(new FindTicketsRenderer()); + + getRootPane().setDefaultButton(jcmdOK); + + initCombos(); + + defaultValues(); + + selectedTicket = null; + + } + + /** + * + */ + public void executeSearch() { + + jLblTicketCount.setVisible(false); + jLblReturnCount.setVisible(false); + jLblTicketCount.setText(null); + + try { + MyListData myListData = new MyListData(listProvider.loadData()); + jListTickets.setModel(myListData); + if (jListTickets.getModel().getSize() > 0) { + String count = String.valueOf(jListTickets.getModel().getSize()); + jLblTicketCount.setVisible(true); + jLblReturnCount.setVisible(true); + jListTickets.setSelectedIndex(0); + jLblTicketCount.setText(count); + } + } catch (BasicException e) { + System.err.println("Search Error: "+e); + } + } + + private void initCombos() { + String[] values = new String[] {AppLocal.getIntString("label.sales"), + AppLocal.getIntString("label.refunds"), AppLocal.getIntString("label.all")}; + jComboBoxTicket.setModel(new DefaultComboBoxModel(values)); + + jcboMoney.setModel(ListQBFModelNumber.getMandatoryNumber()); + + m_sentcat = dlSales.getUserList(); + m_CategoryModel = new ComboBoxValModel(); + + List catlist=null; + + try { + catlist = m_sentcat.list(); + } catch (BasicException ex) { + ex.getMessage(); + } + + catlist.add(0, null); + + m_CategoryModel = new ComboBoxValModel(catlist); + jcboUser.setModel(m_CategoryModel); + } + + private void defaultValues() { + + jListTickets.setModel(new MyListData(new ArrayList())); + jcboUser.setSelectedItem(null); + jtxtTicketID.reset(); + jtxtTicketID.activate(); + jTxtStartDate.setText(null); + jTxtEndDate.setText(null); + jtxtCustomer.setText(null); + jComboBoxTicket.setSelectedIndex(0); + jcboUser.setSelectedItem(null); + + jcboMoney.setSelectedItem( ((ListQBFModelNumber)jcboMoney.getModel()).getElementAt(0) ); + jcboMoney.revalidate(); + jcboMoney.repaint(); + jtxtMoney.reset(); + jTxtStartDate.setText(null); + jTxtEndDate.setText(null); + jtxtCustomer.setText(null); + jtxtCardNumber.setText(null); + + jLblTicketCount.setVisible(false); + jLblReturnCount.setVisible(false); + jLblTicketCount.setText(null); + + Date startOfToday = Date.from(ZonedDateTime.now().with(LocalTime.MIN).toInstant()); + jTxtStartDate.setText(Formats.TIMESTAMP.formatValue(startOfToday)); + + repaint(); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + /* + This is where you build your search criteria + */ + + + Object[] afilter = new Object[16]; + + if (jtxtTicketID.getText() == null || jtxtTicketID.getText().equals("")) { + afilter[0] = QBFCompareEnum.COMP_NONE; + afilter[1] = null; + } else { + afilter[0] = QBFCompareEnum.COMP_EQUALS; + afilter[1] = jtxtTicketID.getValueInteger(); + } + + switch (jComboBoxTicket.getSelectedIndex()) { + case 2: + afilter[2] = QBFCompareEnum.COMP_DISTINCT; + afilter[3] = 2; + break; + case 0: + afilter[2] = QBFCompareEnum.COMP_EQUALS; + afilter[3] = 0; + break; + case 1: + afilter[2] = QBFCompareEnum.COMP_EQUALS; + afilter[3] = 1; + break; + default: + break; + } + + afilter[5] = jtxtMoney.getDoubleValue(); + afilter[4] = afilter[5] == null ? QBFCompareEnum.COMP_NONE : jcboMoney.getSelectedItem(); + + Object startdate = Formats.TIMESTAMP.parseValue(jTxtStartDate.getText()); + Object enddate = Formats.TIMESTAMP.parseValue(jTxtEndDate.getText()); + + afilter[6] = (startdate == null) ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_GREATEROREQUALS; + afilter[7] = startdate; + afilter[8] = (enddate == null) ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_LESS; + afilter[9] = enddate; + + if (jcboUser.getSelectedItem() == null) { + afilter[10] = QBFCompareEnum.COMP_NONE; + afilter[11] = null; + } else { + afilter[10] = QBFCompareEnum.COMP_EQUALS; + afilter[11] = ((TaxCategoryInfo)jcboUser.getSelectedItem()).getName(); + } + + if (jtxtCustomer.getText() == null || jtxtCustomer.getText().equals("")) { + afilter[12] = QBFCompareEnum.COMP_NONE; + afilter[13] = null; + } else { + afilter[12] = QBFCompareEnum.COMP_RE; + afilter[13] = "%" + jtxtCustomer.getText() + "%"; + } + + if (jtxtCardNumber.getText() == null || jtxtCardNumber.getText().equals("")) { + afilter[14] = QBFCompareEnum.COMP_NONE; + afilter[15] = null; + } else { + afilter[14] = QBFCompareEnum.COMP_EQUALS; + afilter[15] = jtxtCardNumber.getText(); + } + + return afilter; + + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window) parent; + } else { + return getWindow(parent.getParent()); + } + } + + + private static class MyListData extends javax.swing.AbstractListModel { + + private final java.util.List m_data; + + public MyListData(java.util.List data) { + m_data = data; + } + + @Override + public Object getElementAt(int index) { + return m_data.get(index); + } + + @Override + public int getSize() { + return m_data.size(); + } + } + /** + * + * @param d + */ + public void setStartDate(Date d) { + Date startOfDay = Date.from(ZonedDateTime.now().with(LocalTime.MIN).toInstant()); + jTxtStartDate.setText(Formats.TIMESTAMP.formatValue(startOfDay)); + } + public void setEndDate(Date d) { + Date endOfDay = Date.from(ZonedDateTime.now().with(LocalTime.MAX).toInstant()); + jTxtEndDate.setText(Formats.TIMESTAMP.formatValue(endOfDay)); + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel3 = new javax.swing.JPanel(); + jPanel5 = new javax.swing.JPanel(); + jPanel7 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + jLabel7 = new javax.swing.JLabel(); + jtxtMoney = new com.unicenta.editor.JEditorCurrency(); + jcboUser = new javax.swing.JComboBox(); + jcboMoney = new javax.swing.JComboBox(); + jtxtTicketID = new com.unicenta.editor.JEditorIntegerPositive(); + labelCustomer = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jTxtStartDate = new javax.swing.JTextField(); + jTxtEndDate = new javax.swing.JTextField(); + btnDateStart = new javax.swing.JButton(); + btnDateEnd = new javax.swing.JButton(); + jtxtCustomer = new javax.swing.JTextField(); + btnCustomer = new javax.swing.JButton(); + jComboBoxTicket = new javax.swing.JComboBox(); + jtxtCardNumber = new javax.swing.JTextField(4); + jLabelCardNumber = new javax.swing.JLabel(); + jPanel6 = new javax.swing.JPanel(); + jbtnReset = new javax.swing.JButton(); + jbtnExecute = new javax.swing.JButton(); + jPanel4 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jListTickets = new javax.swing.JList(); + jPanel2 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel8 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jcmdCancel = new javax.swing.JButton(); + jcmdOK = new javax.swing.JButton(); + jLblTicketCount = new javax.swing.JLabel(); + jLblReturnCount = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("form.tickettitle")); // NOI18N + setPreferredSize(new java.awt.Dimension(568, 600)); + + jPanel3.setLayout(new java.awt.BorderLayout()); + + jPanel5.setLayout(new java.awt.BorderLayout()); + + jPanel7.setPreferredSize(new java.awt.Dimension(0, 250)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.ticketid")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.user")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.totalcash")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(100, 30)); + + jtxtMoney.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtMoney.setPreferredSize(new java.awt.Dimension(150, 30)); + + jcboUser.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboUser.setPreferredSize(new java.awt.Dimension(220, 30)); + jcboUser.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcboUserActionPerformed(evt); + } + }); + + jcboMoney.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jcboMoney.setPreferredSize(new java.awt.Dimension(150, 30)); + + jtxtTicketID.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jtxtTicketID.setPreferredSize(new java.awt.Dimension(150, 30)); + + labelCustomer.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + labelCustomer.setText(AppLocal.getIntString("label.customer")); // NOI18N + labelCustomer.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.StartDate")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.EndDate")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(100, 30)); + + jTxtStartDate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jTxtStartDate.setPreferredSize(new java.awt.Dimension(150, 30)); + + jTxtEndDate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jTxtEndDate.setPreferredSize(new java.awt.Dimension(150, 30)); + + btnDateStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/date.png"))); // NOI18N + btnDateStart.setToolTipText("Open Calendar"); + btnDateStart.setPreferredSize(new java.awt.Dimension(100, 30)); + btnDateStart.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnDateStartActionPerformed(evt); + } + }); + + btnDateEnd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/date.png"))); // NOI18N + btnDateEnd.setToolTipText("Open Calendar"); + btnDateEnd.setPreferredSize(new java.awt.Dimension(100, 30)); + btnDateEnd.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnDateEndActionPerformed(evt); + } + }); + + jtxtCustomer.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jtxtCustomer.setPreferredSize(new java.awt.Dimension(150, 30)); + + btnCustomer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer_sml.png"))); // NOI18N + btnCustomer.setToolTipText("Open Customers"); + btnCustomer.setFocusPainted(false); + btnCustomer.setFocusable(false); + btnCustomer.setMargin(new java.awt.Insets(8, 14, 8, 14)); + btnCustomer.setPreferredSize(new java.awt.Dimension(100, 30)); + btnCustomer.setRequestFocusEnabled(false); + btnCustomer.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCustomerActionPerformed(evt); + } + }); + + jComboBoxTicket.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jComboBoxTicket.setPreferredSize(new java.awt.Dimension(150, 30)); + + jtxtCardNumber.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jtxtCardNumber.setPreferredSize(new java.awt.Dimension(150, 30)); + jtxtCardNumber.setDocument(new JTextFieldLimit(4)); + + jLabelCardNumber.setText("CC number (last 4)"); + + javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); + jPanel7.setLayout(jPanel7Layout); + jPanel7Layout.setHorizontalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE) + .addComponent(labelCustomer, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(jLabelCardNumber)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jtxtCustomer, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jTxtStartDate, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jTxtEndDate, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jtxtCardNumber, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(btnDateEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(btnDateStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(btnCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel7Layout.createSequentialGroup() + .addComponent(jcboMoney, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jtxtMoney, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel7Layout.createSequentialGroup() + .addComponent(jtxtTicketID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jComboBoxTicket, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jcboUser, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(25, Short.MAX_VALUE)) + ); + jPanel7Layout.setVerticalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jComboBoxTicket, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtTicketID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(btnDateStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTxtStartDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTxtEndDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(btnDateEnd, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(labelCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(btnCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jtxtCardNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabelCardNumber)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jcboUser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jtxtMoney, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jcboMoney, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(19, 19, 19)) + ); + + jPanel5.add(jPanel7, java.awt.BorderLayout.CENTER); + + jbtnReset.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jbtnReset.setText(AppLocal.getIntString("button.clean")); // NOI18N + jbtnReset.setToolTipText("Clear Filter"); + jbtnReset.setPreferredSize(new java.awt.Dimension(110, 45)); + jbtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnResetActionPerformed(evt); + } + }); + jPanel6.add(jbtnReset); + + jbtnExecute.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnExecute.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jbtnExecute.setText(AppLocal.getIntString("button.executefilter")); // NOI18N + jbtnExecute.setToolTipText("Execute Filter"); + jbtnExecute.setFocusPainted(false); + jbtnExecute.setFocusable(false); + jbtnExecute.setPreferredSize(new java.awt.Dimension(110, 45)); + jbtnExecute.setRequestFocusEnabled(false); + jbtnExecute.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnExecuteActionPerformed(evt); + } + }); + jPanel6.add(jbtnExecute); + + jPanel5.add(jPanel6, java.awt.BorderLayout.SOUTH); + + jPanel3.add(jPanel5, java.awt.BorderLayout.PAGE_START); + + jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel4.setLayout(new java.awt.BorderLayout()); + + jListTickets.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jListTickets.setFocusable(false); + jListTickets.setRequestFocusEnabled(false); + jListTickets.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jListTicketsMouseClicked(evt); + } + }); + jListTickets.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + jListTicketsValueChanged(evt); + } + }); + jScrollPane1.setViewportView(jListTickets); + + jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + jPanel3.add(jPanel4, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER); + + jPanel2.setPreferredSize(new java.awt.Dimension(300, 250)); + jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + m_jKeys.setPreferredSize(new java.awt.Dimension(290, 300)); + m_jKeys.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jKeysActionPerformed(evt); + } + }); + jPanel2.add(m_jKeys, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 300, -1)); + + jPanel8.setLayout(new java.awt.BorderLayout()); + + jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N + jcmdCancel.setFocusPainted(false); + jcmdCancel.setFocusable(false); + jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdCancel.setRequestFocusEnabled(false); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel1.add(jcmdCancel); + + jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + jcmdOK.setEnabled(false); + jcmdOK.setFocusPainted(false); + jcmdOK.setFocusable(false); + jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdOK.setMaximumSize(new java.awt.Dimension(103, 44)); + jcmdOK.setMinimumSize(new java.awt.Dimension(103, 44)); + jcmdOK.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdOK.setRequestFocusEnabled(false); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel1.add(jcmdOK); + + jPanel8.add(jPanel1, java.awt.BorderLayout.LINE_END); + + jPanel2.add(jPanel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 536, 300, -1)); + + jLblTicketCount.setBackground(new java.awt.Color(51, 204, 255)); + jLblTicketCount.setFont(new java.awt.Font("Century Gothic", 0, 18)); // NOI18N + jLblTicketCount.setForeground(new java.awt.Color(255, 255, 255)); + jLblTicketCount.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLblTicketCount.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(51, 204, 255))); + jLblTicketCount.setOpaque(true); + jLblTicketCount.setPreferredSize(new java.awt.Dimension(80, 50)); + jPanel2.add(jLblTicketCount, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 306, -1, -1)); + + jLblReturnCount.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLblReturnCount.setText(bundle.getString("label.ticketsfound")); // NOI18N + jLblReturnCount.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 204, 255))); + jLblReturnCount.setPreferredSize(new java.awt.Dimension(80, 50)); + jPanel2.add(jLblReturnCount, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 306, 200, -1)); + + getContentPane().add(jPanel2, java.awt.BorderLayout.LINE_END); + + setSize(new java.awt.Dimension(758, 634)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + selectedTicket = (FindTicketsInfo) jListTickets.getSelectedValue(); + dispose(); + + }//GEN-LAST:event_jcmdOKActionPerformed + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_jcmdCancelActionPerformed + + private void jbtnExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnExecuteActionPerformed + + executeSearch(); + + jLblTicketCount.setVisible(true); + jLblReturnCount.setVisible(true); + jLblReturnCount.setText(" Tickets found"); + + }//GEN-LAST:event_jbtnExecuteActionPerformed + + private void jListTicketsValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListTicketsValueChanged + + jcmdOK.setEnabled(jListTickets.getSelectedValue() != null); + + }//GEN-LAST:event_jListTicketsValueChanged + + private void jListTicketsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListTicketsMouseClicked + + if (evt.getClickCount() == 2) { + selectedTicket = (FindTicketsInfo) jListTickets.getSelectedValue(); + dispose(); + } + + }//GEN-LAST:event_jListTicketsMouseClicked + + private void jbtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnResetActionPerformed + + defaultValues(); + }//GEN-LAST:event_jbtnResetActionPerformed + + private void btnDateStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDateStartActionPerformed + + jLblTicketCount.setVisible(false); + jLblReturnCount.setVisible(false); + + Date date; + try { + date = (Date) Formats.TIMESTAMP.parseValue(jTxtStartDate.getText()); + } catch (BasicException e) { + date = null; + } + date = JCalendarDialog.showCalendarTimeHours(this, date); + if (date != null) { + jTxtStartDate.setText(Formats.TIMESTAMP.formatValue(date)); + } + }//GEN-LAST:event_btnDateStartActionPerformed + + private void btnDateEndActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDateEndActionPerformed + jLblTicketCount.setVisible(false); + jLblReturnCount.setVisible(false); + + Date date; + try { + date = (Date) Formats.TIMESTAMP.parseValue(jTxtEndDate.getText()); + } catch (BasicException e) { + date = null; + } + date = JCalendarDialog.showCalendarTimeHours(this, date); + if (date != null) { + jTxtEndDate.setText(Formats.TIMESTAMP.formatValue(date)); + } + }//GEN-LAST:event_btnDateEndActionPerformed + + private void btnCustomerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCustomerActionPerformed + jLblTicketCount.setVisible(false); + jLblReturnCount.setVisible(false); + + JCustomerFinder finder = JCustomerFinder.getCustomerFinder(this, dlCustomers); + finder.search(null); + finder.setVisible(true); + + try { + jtxtCustomer.setText(finder.getSelectedCustomer() == null + ? null + : dlSales.loadCustomerExt(finder.getSelectedCustomer().getId()).toString()); + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), e); + msg.show(this); + } + + }//GEN-LAST:event_btnCustomerActionPerformed + + private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed + + }//GEN-LAST:event_m_jKeysActionPerformed + + private void jcboUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboUserActionPerformed + + }//GEN-LAST:event_jcboUserActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCustomer; + private javax.swing.JButton btnDateEnd; + private javax.swing.JButton btnDateStart; + private javax.swing.JComboBox jComboBoxTicket; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabelCardNumber; + private javax.swing.JLabel jLblReturnCount; + private javax.swing.JLabel jLblTicketCount; + private javax.swing.JList jListTickets; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JPanel jPanel7; + private javax.swing.JPanel jPanel8; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextField jTxtEndDate; + private javax.swing.JTextField jTxtStartDate; + private javax.swing.JButton jbtnExecute; + private javax.swing.JButton jbtnReset; + private javax.swing.JComboBox jcboMoney; + private javax.swing.JComboBox jcboUser; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + private javax.swing.JTextField jtxtCardNumber; + private javax.swing.JTextField jtxtCustomer; + private com.unicenta.editor.JEditorCurrency jtxtMoney; + private com.unicenta.editor.JEditorIntegerPositive jtxtTicketID; + private javax.swing.JLabel labelCustomer; + private com.unicenta.editor.JEditorKeys m_jKeys; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/panels/PaymentsEditor.form b/src/main/java/com/unicenta/pos/panels/PaymentsEditor.form new file mode 100644 index 0000000..1004c2d --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/PaymentsEditor.form @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,2,-100"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel5" min="-2" max="-2" attributes="1"/> + <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="1"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="m_jNotes" alignment="0" pref="234" max="32767" attributes="0"/> + <Component id="m_jreason" alignment="0" min="-2" max="-2" attributes="1"/> + <Component id="jTotal" alignment="0" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jreason" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jTotal" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="m_jNotes" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.paymentreason" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jreason"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.paymenttotal" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorCurrency" name="jTotal"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="PaymentsEditor_jTotal"/> + </AuxValues> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jNotes"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[132, 100]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + <Events> + <EventHandler event="propertyChange" listener="java.beans.PropertyChangeListener" parameters="java.beans.PropertyChangeEvent" handler="m_jKeysPropertyChange"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/panels/PaymentsEditor.java b/src/main/java/com/unicenta/pos/panels/PaymentsEditor.java new file mode 100644 index 0000000..98be6f4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/PaymentsEditor.java @@ -0,0 +1,357 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import java.awt.Component; +import java.util.Date; +import java.util.UUID; + + +/** + * + * @author adrianromero + */ +public final class PaymentsEditor extends javax.swing.JPanel implements EditorRecord { + + private final ComboBoxValModel m_ReasonModel; + + private String m_sId; + private String m_sPaymentId; + private Date datenew; + + private final AppView m_App; + private String m_sNotes; + + /** Creates new form JPanelPayments + * @param oApp + * @param dirty */ + public PaymentsEditor(AppView oApp, DirtyManager dirty) { + + m_App = oApp; + + initComponents(); + + m_ReasonModel = new ComboBoxValModel(); + m_ReasonModel.add(new PaymentReasonPositive("cashin", AppLocal.getIntString("transpayment.cashin"))); + m_ReasonModel.add(new PaymentReasonNegative("cashout", AppLocal.getIntString("transpayment.cashout"))); + m_jreason.setModel(m_ReasonModel); + + jTotal.addEditorKeys(m_jKeys); + + m_jreason.addActionListener(dirty); + jTotal.addPropertyChangeListener("Text", dirty); + m_jNotes.addPropertyChangeListener("Text", dirty); + m_jNotes.addEditorKeys(m_jKeys); + + writeValueEOF(); + } + + /** + * + */ + @Override + public void writeValueEOF() { + m_sId = null; + m_sPaymentId = null; + datenew = null; + setReasonTotal(null, null); + m_jreason.setEnabled(false); + jTotal.setEnabled(false); +// JG Added July 2011 + m_sNotes = null; + m_jNotes.setEnabled(false); + + } + + /** + * + */ + @Override + public void writeValueInsert() { + + m_sId = null; + m_sPaymentId = null; + datenew = null; + setReasonTotal("cashin", null); + m_jreason.setEnabled(true); + jTotal.setEnabled(true); + jTotal.activate(); +// JG Added July 2011 + m_sNotes = null; + m_jNotes.setEnabled(true); + m_jNotes.setText(m_sNotes); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + Object[] payment = (Object[]) value; + m_sId = (String) payment[0]; + datenew = (Date) payment[2]; + m_sPaymentId = (String) payment[3]; + setReasonTotal(payment[4], payment[5]); + m_jreason.setEnabled(false); + jTotal.setEnabled(false); +// JG Added July 2011 + m_sNotes = (String) payment[6]; + m_jNotes.setEnabled(false); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + Object[] payment = (Object[]) value; + m_sId = (String) payment[0]; + datenew = (Date) payment[2]; + m_sPaymentId = (String) payment[3]; + setReasonTotal(payment[4], payment[5]); + m_jreason.setEnabled(false); + jTotal.setEnabled(false); + jTotal.activate(); +// JG Added July 2011 + m_sNotes = (String) payment[6]; + m_jNotes.setEnabled(false); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { +//JG Modified Array + 1 - July 2011 + Object[] payment = new Object[7]; + payment[0] = m_sId == null ? UUID.randomUUID().toString() : m_sId; + payment[1] = m_App.getActiveCashIndex(); + payment[2] = datenew == null ? new Date() : datenew; + payment[3] = m_sPaymentId == null ? UUID.randomUUID().toString() : m_sPaymentId; + payment[4] = m_ReasonModel.getSelectedKey(); + PaymentReason reason = (PaymentReason) m_ReasonModel.getSelectedItem(); + Double dtotal = jTotal.getDoubleValue(); + payment[5] = reason == null ? dtotal : reason.addSignum(dtotal); +// JG Added July 2011 + String snotes = ""; + m_sNotes = m_jNotes.getText(); + payment[6] = m_sNotes == null ? snotes : m_sNotes; + return payment; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + */ + @Override + public void refresh() { + } + + private void setReasonTotal(Object reasonfield, Object totalfield) { + + m_ReasonModel.setSelectedKey(reasonfield); + + PaymentReason reason = (PaymentReason) m_ReasonModel.getSelectedItem(); + + if (reason == null) { + jTotal.setDoubleValue((Double) totalfield); + } else { + jTotal.setDoubleValue(reason.positivize((Double) totalfield)); + } + } + + private static abstract class PaymentReason implements IKeyed { + private String m_sKey; + private String m_sText; + + public PaymentReason(String key, String text) { + m_sKey = key; + m_sText = text; + } + @Override + public Object getKey() { + return m_sKey; + } + public abstract Double positivize(Double d); + public abstract Double addSignum(Double d); + + @Override + public String toString() { + return m_sText; + } + } + private static class PaymentReasonPositive extends PaymentReason { + public PaymentReasonPositive(String key, String text) { + super(key, text); + } + @Override + public Double positivize(Double d) { + return d; + } + @Override + public Double addSignum(Double d) { + if (d == null) { + return null; + } else if (d.doubleValue() < 0.0) { + return new Double(-d.doubleValue()); + } else { + return d; + } + } + } + private static class PaymentReasonNegative extends PaymentReason { + public PaymentReasonNegative(String key, String text) { + super(key, text); + } + @Override + public Double positivize(Double d) { + return d == null ? null : new Double(-d.doubleValue()); + } + @Override + public Double addSignum(Double d) { + if (d == null) { + return null; + } else if (d.doubleValue() > 0.0) { + return new Double(-d.doubleValue()); + } else { + return d; + } + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel3 = new javax.swing.JPanel(); + jLabel5 = new javax.swing.JLabel(); + m_jreason = new javax.swing.JComboBox(); + jLabel3 = new javax.swing.JLabel(); + jTotal = new com.unicenta.editor.JEditorCurrency(); + m_jNotes = new com.unicenta.editor.JEditorString(); + jPanel2 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + + setLayout(new java.awt.BorderLayout()); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.paymentreason")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jreason.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jreason.setFocusable(false); + m_jreason.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.paymenttotal")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(110, 30)); + + jTotal.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTotal.setPreferredSize(new java.awt.Dimension(200, 30)); + + m_jNotes.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jNotes.setPreferredSize(new java.awt.Dimension(132, 100)); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(m_jNotes, javax.swing.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE) + .addComponent(m_jreason, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTotal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jreason, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(m_jNotes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + add(jPanel3, java.awt.BorderLayout.CENTER); + + jPanel2.setLayout(new java.awt.BorderLayout()); + + m_jKeys.addPropertyChangeListener(new java.beans.PropertyChangeListener() { + public void propertyChange(java.beans.PropertyChangeEvent evt) { + m_jKeysPropertyChange(evt); + } + }); + jPanel2.add(m_jKeys, java.awt.BorderLayout.NORTH); + + add(jPanel2, java.awt.BorderLayout.LINE_END); + }// </editor-fold>//GEN-END:initComponents + + private void m_jKeysPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_m_jKeysPropertyChange + + }//GEN-LAST:event_m_jKeysPropertyChange + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel5; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private com.unicenta.editor.JEditorCurrency jTotal; + private com.unicenta.editor.JEditorKeys m_jKeys; + private com.unicenta.editor.JEditorString m_jNotes; + private javax.swing.JComboBox m_jreason; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/panels/PaymentsModel.java b/src/main/java/com/unicenta/pos/panels/PaymentsModel.java new file mode 100644 index 0000000..bf8e9ce --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/PaymentsModel.java @@ -0,0 +1,1106 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.*; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.util.StringUtils; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import javax.swing.table.AbstractTableModel; + +/** + * + * @authors adrianromero, jackgerrard, janarnagel + * + */ +public class PaymentsModel { + + private String m_sHost; + private String m_sUser; + private int m_iSeq; + private Date m_dDateStart; + private Date m_dDateEnd; + private Date rDate; + private Date m_dPrintDate; + + + private Integer m_iPayments; + private Double m_dPaymentsTotal; + private java.util.List<PaymentsLine> m_lpayments; + +// JG 9 Nov 12 + private Integer m_iCategorySalesRows; + private Double m_dCategorySalesTotalUnits; + private Double m_dCategorySalesTotal; + private java.util.List<CategorySalesLine> m_lcategorysales; +// end + + // by janar153 @ 01.12.2013 + private Integer m_iProductSalesRows; + private Double m_dProductSalesTotalUnits; + private Double m_dProductSalesTotal; + private java.util.List<ProductSalesLine> m_lproductsales; + // end + + // added by janar153 @ 29.12.2013 + private java.util.List<RemovedProductLines> m_lremovedlines; + + private java.util.List<DrawerOpenedLines> m_ldraweropenedlines; + + private final static String[] PAYMENTHEADERS = {"label.Payment", "label.Money"}; + + private Integer m_iSales; + private Double m_dSalesBase; + private Double m_dSalesTaxes; + private Double m_dSalesTaxNet; + private java.util.List<SalesLine> m_lsales; + + private final static String[] SALEHEADERS = {"label.taxcategory", "label.totaltax", "label.totalnet"}; + + private PaymentsModel() { + } + + /** + * + * @return + */ + public static PaymentsModel emptyInstance() { + + PaymentsModel p = new PaymentsModel(); + + p.m_iPayments = 0; + p.m_dPaymentsTotal = 0.0; +// JG 16 May 2013 use diamond inference + p.m_lpayments = new ArrayList<>(); + +// JG 9 Nov 12 + p.m_iCategorySalesRows = 0; + p.m_dCategorySalesTotalUnits = 0.0; + p.m_dCategorySalesTotal = 0.0; + p.m_lcategorysales = new ArrayList<>(); +// end + p.m_iSales = null; + p.m_dSalesBase = null; + p.m_dSalesTaxes = null; + p.m_dSalesTaxNet = null; + +// JG 16 May 2013 use diamond inference + + // by janar153 @ 01.12.2013 + p.m_iProductSalesRows = 0; + p.m_dProductSalesTotalUnits = 0.0; + p.m_dProductSalesTotal = 0.0; + p.m_lproductsales = new ArrayList<>(); + p.m_lremovedlines = new ArrayList<>(); + + p.m_lsales = new ArrayList<>(); + + return p; + } + + /** + * + * @param app + * @return + * @throws BasicException + */ + public static PaymentsModel loadInstance(AppView app) throws BasicException { + + PaymentsModel p = new PaymentsModel(); + + // Propiedades globales + p.m_sHost = app.getProperties().getHost(); + p.m_sUser = app.getAppUserView().getUser().getName(); + p.m_iSeq = app.getActiveCashSequence(); + p.m_dDateStart = app.getActiveCashDateStart(); + p.m_dDateEnd = null; + + + +// JG 9 Nov 12 + // Product category Sales + Object[] valcategorysales = (Object []) new StaticSentence(app.getSession() + , "SELECT COUNT(*), " + + "SUM(ticketlines.UNITS), " + + "SUM((ticketlines.PRICE + ticketlines.PRICE * taxes.RATE ) * ticketlines.UNITS) " + + "FROM ticketlines, tickets, receipts, taxes " + + "WHERE ticketlines.TICKET = tickets.ID AND tickets.ID = receipts.ID " + + "AND ticketlines.TAXID = taxes.ID " + + "AND ticketlines.PRODUCT IS NOT NULL " + + "AND receipts.MONEY = ? " + + "GROUP BY receipts.MONEY" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[] {Datas.INT, Datas.DOUBLE, Datas.DOUBLE})) + .find(app.getActiveCashIndex()); + + if (valcategorysales == null) { + p.m_iCategorySalesRows = 0; + p.m_dCategorySalesTotalUnits = 0.0; + p.m_dCategorySalesTotal = 0.0; + } else { + p.m_iCategorySalesRows = (Integer) valcategorysales[0]; + p.m_dCategorySalesTotalUnits = (Double) valcategorysales[1]; + p.m_dCategorySalesTotal= (Double) valcategorysales[2]; + } + + List categorys = new StaticSentence(app.getSession() + , "SELECT a.NAME, sum(c.UNITS), sum(c.UNITS * (c.PRICE + (c.PRICE * d.RATE))) " + + "FROM categories as a " + + "LEFT JOIN products as b on a.id = b.CATEGORY " + + "LEFT JOIN ticketlines as c on b.id = c.PRODUCT " + + "LEFT JOIN taxes as d on c.TAXID = d.ID " + + "LEFT JOIN receipts as e on c.TICKET = e.ID " + + "WHERE e.MONEY = ? " + + "GROUP BY a.NAME" + , SerializerWriteString.INSTANCE + , new SerializerReadClass(PaymentsModel.CategorySalesLine.class)) + .list(app.getActiveCashIndex()); + + if (categorys == null) { + p.m_lcategorysales = new ArrayList(); + } else { + p.m_lcategorysales = categorys; + } +// end + + // Payments + Object[] valtickets = (Object []) new StaticSentence(app.getSession() + , "SELECT COUNT(*), SUM(payments.TOTAL) " + + "FROM payments, receipts " + + "WHERE payments.RECEIPT = receipts.ID AND receipts.MONEY = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[] {Datas.INT, Datas.DOUBLE})) + .find(app.getActiveCashIndex()); + + if (valtickets == null) { + p.m_iPayments = 0; + p.m_dPaymentsTotal = 0.0; + } else { + p.m_iPayments = (Integer) valtickets[0]; + p.m_dPaymentsTotal = (Double) valtickets[1]; + } + + List l = new StaticSentence(app.getSession(), + "SELECT payments.PAYMENT, SUM(payments.TOTAL), payments.NOTES " + + "FROM payments, receipts " + + "WHERE payments.RECEIPT = receipts.ID AND receipts.MONEY = ? " + + "GROUP BY payments.PAYMENT, payments.NOTES" + , SerializerWriteString.INSTANCE + , new SerializerReadClass(PaymentsModel.PaymentsLine.class)) + .list(app.getActiveCashIndex()); + + if (l == null) { + p.m_lpayments = new ArrayList(); + } else { + p.m_lpayments = l; + } + + // Sales + Object[] recsales = (Object []) new StaticSentence(app.getSession(), + "SELECT COUNT(DISTINCT receipts.ID), SUM(ticketlines.UNITS * ticketlines.PRICE) " + + "FROM receipts, ticketlines " + + "WHERE receipts.ID = ticketlines.TICKET AND receipts.MONEY = ?", + SerializerWriteString.INSTANCE, + new SerializerReadBasic(new Datas[] {Datas.INT, Datas.DOUBLE})) + .find(app.getActiveCashIndex()); + + if (recsales == null) { + p.m_iSales = null; + p.m_dSalesBase = null; + } else { + p.m_iSales = (Integer) recsales[0]; + p.m_dSalesBase = (Double) recsales[1]; + } + + // Taxes + Object[] rectaxes = (Object []) new StaticSentence(app.getSession(), + "SELECT SUM(taxlines.AMOUNT), SUM(taxlines.BASE) " + + "FROM receipts, taxlines " + + "WHERE receipts.ID = taxlines.RECEIPT AND receipts.MONEY = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[] {Datas.DOUBLE, Datas.DOUBLE})) + .find(app.getActiveCashIndex()); + + if (rectaxes == null) { + p.m_dSalesTaxes = null; + p.m_dSalesTaxNet = null; + } else { + p.m_dSalesTaxes = (Double) rectaxes[0]; + p.m_dSalesTaxNet = (Double) rectaxes[1]; + } + + // JG June 2014 Added .BASE for array + List<SalesLine> asales = new StaticSentence(app.getSession(), + "SELECT taxcategories.NAME, SUM(taxlines.AMOUNT), SUM(taxlines.BASE), SUM(taxlines.BASE + taxlines.AMOUNT) " + + "FROM receipts, taxlines, taxes, taxcategories " + + "WHERE receipts.ID = taxlines.RECEIPT AND taxlines.TAXID = taxes.ID AND taxes.CATEGORY = taxcategories.ID " + + "AND receipts.MONEY = ?" + + "GROUP BY taxcategories.NAME" + , SerializerWriteString.INSTANCE + , new SerializerReadClass(PaymentsModel.SalesLine.class)) + .list(app.getActiveCashIndex()); + + if (asales == null) { + p.m_lsales = new ArrayList<>(); + } else { + p.m_lsales = asales; + } + + // added by janar153 @ 29.12.2013 + // removed lines list + SimpleDateFormat ndf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String startDateFormatted = ndf.format(app.getActiveCashDateStart()); + List removedLines = new StaticSentence(app.getSession() + , "SELECT lineremoved.NAME, lineremoved.TICKETID, lineremoved.PRODUCTNAME, SUM(lineremoved.UNITS) AS TOTAL_UNITS " + + "FROM lineremoved " + + "WHERE lineremoved.REMOVEDDATE > ? " + + "GROUP BY lineremoved.NAME, lineremoved.TICKETID, lineremoved.PRODUCTNAME" + , SerializerWriteString.INSTANCE + , new SerializerReadClass(PaymentsModel.RemovedProductLines.class)) //new SerializerReadBasic(new Datas[] {Datas.STRING, Datas.DOUBLE})) + .list(startDateFormatted); + + if (removedLines == null) { + p.m_lremovedlines = new ArrayList(); + } else { + p.m_lremovedlines = removedLines; + } + +/** + * JG Dec 14 + * Open Drawer List +*/ + + List drawerOpenedLines = new StaticSentence(app.getSession() + , "SELECT OPENDATE, NAME, TICKETID " + + "FROM draweropened " + + "WHERE TICKETID = 'No Sale' AND OPENDATE > ? " + + "GROUP BY NAME, OPENDATE, TICKETID" + , SerializerWriteString.INSTANCE + , new SerializerReadClass(PaymentsModel.DrawerOpenedLines.class)) //new SerializerReadBasic(new Datas[] {Datas.STRING, Datas.DOUBLE})) + .list(startDateFormatted); + + if (drawerOpenedLines == null) { + p.m_ldraweropenedlines = new ArrayList(); + } else { + p.m_ldraweropenedlines = drawerOpenedLines; + } + + // by janar153 @ 01.12.2013 + // Product Sales + Object[] valproductsales = (Object []) new StaticSentence(app.getSession() + , "SELECT COUNT(*), SUM(ticketlines.UNITS), " + + "SUM((ticketlines.PRICE + ticketlines.PRICE * taxes.RATE ) * ticketlines.UNITS) " + + "FROM ticketlines, tickets, receipts, taxes " + + "WHERE ticketlines.TICKET = tickets.ID " + + "AND tickets.ID = receipts.ID " + + "AND ticketlines.TAXID = taxes.ID " + + "AND ticketlines.PRODUCT IS NOT NULL " + + "AND receipts.MONEY = ? " + + "GROUP BY receipts.MONEY" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[] {Datas.INT, Datas.DOUBLE, Datas.DOUBLE})) + .find(app.getActiveCashIndex()); + + if (valproductsales == null) { + p.m_iProductSalesRows = 0; + p.m_dProductSalesTotalUnits = 0.0; + p.m_dProductSalesTotal = 0.0; + } else { + p.m_iProductSalesRows = (Integer) valproductsales[0]; + p.m_dProductSalesTotalUnits = (Double) valproductsales[1]; + p.m_dProductSalesTotal= (Double) valproductsales[2]; + } + + List products = new StaticSentence(app.getSession() + , "SELECT products.NAME, SUM(ticketlines.UNITS), ticketlines.PRICE, taxes.RATE " + + "FROM ticketlines, tickets, receipts, products, taxes " + + "WHERE ticketlines.PRODUCT = products.ID " + + "AND ticketlines.TICKET = tickets.ID " + + "AND tickets.ID = receipts.ID " + + "AND ticketlines.TAXID = taxes.ID " + + "AND receipts.MONEY = ? " + + "GROUP BY products.NAME, ticketlines.PRICE, taxes.RATE" + , SerializerWriteString.INSTANCE + , new SerializerReadClass(PaymentsModel.ProductSalesLine.class)) + .list(app.getActiveCashIndex()); + + if (products == null) { + p.m_lproductsales = new ArrayList(); + } else { + p.m_lproductsales = products; + } + + return p; + } + + /** + * + * @return + */ + public int getPayments() { + return m_iPayments; + } + + /** + * + * @return + */ + public double getTotal() { + return m_dPaymentsTotal; + } + + /** + * + * @return + */ + public String getHost() { + return m_sHost; + } + /** + * + * @return + */ + public String getUser() { + return m_sUser; + } + + /** + * + * @return + */ + public int getSequence() { + return m_iSeq; + } + + public String getPrintDate() { + Date m_dPrintDate = new Date(); + return Formats.TIMESTAMP.formatValue(m_dPrintDate); + } + /** + * + * @return + */ + public Date getDateStart() { + return m_dDateStart; + } + + /** + * + * @param dValue + */ + public void setDateEnd(Date dValue) { + m_dDateEnd = dValue; + } + + /** + * + * @return + */ + public Date getDateEnd() { + return m_dDateEnd; + } + + /** + * + * @return + */ + public String getDateStartDerby(){ + SimpleDateFormat ndf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return ndf.format(m_dDateStart); + } + + /** + * + * @return + */ + public String printHost() { +// return m_sHost; + return StringUtils.encodeXML(m_sHost); + } + + /** + * + * @return + */ + public String printUser() { + return StringUtils.encodeXML(m_sUser); + } + + /** + * + * @return + */ + public String printSequence() { + return Formats.INT.formatValue(m_iSeq); + } + + public String printDate() { + Date m_dPrintDate = new Date(); + return Formats.TIMESTAMP.formatValue(m_dPrintDate); + } + + + /** + * + * @return + */ + public String printDateStart() { + return Formats.TIMESTAMP.formatValue(m_dDateStart); + } + + /** + * + * @return + */ + public String printDateEnd() { + return Formats.TIMESTAMP.formatValue(m_dDateEnd); + } + + /** + * + * @return + */ + public String printPayments() { + return Formats.INT.formatValue(m_iPayments); + } + + /** + * + * @return + */ + public String printPaymentsTotal() { + return Formats.CURRENCY.formatValue(m_dPaymentsTotal); + } + + /** + * + * @return + */ + public List<PaymentsLine> getPaymentLines() { + return m_lpayments; + } + + /** + * + * @return + */ + public int getSales() { + return m_iSales == null ? 0 : m_iSales; + } + + /** + * + * @return + */ + public String printSales() { + return Formats.INT.formatValue(m_iSales); + } + + /** + * + * @return + */ + public String printSalesBase() { + return Formats.CURRENCY.formatValue(m_dSalesBase); + } + + /** + * + * @return + */ + public String printSalesTaxes() { + return Formats.CURRENCY.formatValue(m_dSalesTaxes); + } + + /** + * + * @return + */ + public String printSalesTotal() { + return Formats.CURRENCY.formatValue((m_dSalesBase == null || m_dSalesTaxes == null) + ? null + : m_dSalesBase + m_dSalesTaxes); + } + + /** + * + * @return + */ + public List<SalesLine> getSaleLines() { + return m_lsales; + } + +// JG 9 Nov 12 + + /** + * + * @return + */ + public double getCategorySalesRows() { + return m_iCategorySalesRows; + } + + /** + * + * @return + */ + public String printCategorySalesRows() { + return Formats.INT.formatValue(m_iCategorySalesRows); + } + + /** + * + * @return + */ + public double getCategorySalesTotalUnits() { + return m_dCategorySalesTotalUnits; + } + + /** + * + * @return + */ + public String printCategorySalesTotalUnits() { + return Formats.DOUBLE.formatValue(m_dCategorySalesTotalUnits); + } + + /** + * + * @return + */ + public double getCategorySalesTotal() { + return m_dCategorySalesTotal; + } + + /** + * + * @return + */ + public String printCategorySalesTotal() { + return Formats.CURRENCY.formatValue(m_dCategorySalesTotal); + } + + /** + * + * @return + */ + public List<CategorySalesLine> getCategorySalesLines() { + return m_lcategorysales; + } +// end + + // by janar153 @ 01.12.2013 + + /** + * + * @return + */ + public double getProductSalesRows() { + return m_iProductSalesRows; + } + + /** + * + * @return + */ + public String printProductSalesRows() { + return Formats.INT.formatValue(m_iProductSalesRows); + } + + /** + * + * @return + */ + public double getProductSalesTotalUnits() { + return m_dProductSalesTotalUnits; + } + + /** + * + * @return + */ + public String printProductSalesTotalUnits() { + return Formats.DOUBLE.formatValue(m_dProductSalesTotalUnits); + } + + /** + * + * @return + */ + public double getProductSalesTotal() { + return m_dProductSalesTotal; + } + + /** + * + * @return + */ + public String printProductSalesTotal() { + return Formats.CURRENCY.formatValue(m_dProductSalesTotal); + } + + /** + * + * @return + */ + public List<ProductSalesLine> getProductSalesLines() { + return m_lproductsales; + } + // end + + /** + * janar153 @ 29.12.2013 + * @return + */ + public List<RemovedProductLines> getRemovedProductLines() { + return m_lremovedlines; + } + + /** + * JG Dec 14 + * @return + */ + public List<DrawerOpenedLines> getDrawerOpenedLines() { + return m_ldraweropenedlines; + } + + /** + * + * @return + */ + public AbstractTableModel getPaymentsModel() { + return new AbstractTableModel() { + @Override + public String getColumnName(int column) { + return AppLocal.getIntString(PAYMENTHEADERS[column]); + } + @Override + public int getRowCount() { + return m_lpayments.size(); + } + @Override + public int getColumnCount() { + return PAYMENTHEADERS.length; + } + @Override + public Object getValueAt(int row, int column) { + PaymentsLine l = m_lpayments.get(row); + switch (column) { + case 0: return l.getType(); + case 1: return l.getValue(); + default: return null; + } + } + }; + } + +// JG 9 Nov 12 + // Products category sales class + + /** + * + */ + public static class CategorySalesLine implements SerializableRead { + + private String m_CategoryName; + private Double m_CategoryUnits; + private Double m_CategorySum; + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_CategoryName = dr.getString(1); + m_CategoryUnits = dr.getDouble(2); + m_CategorySum = dr.getDouble(3); + } + + /** + * + * @return + */ + public String printCategoryName() { + return m_CategoryName; + } + + /** + * + * @return + */ + public String printCategoryUnits() { + return Formats.DOUBLE.formatValue(m_CategoryUnits); + } + + /** + * + * @return + */ + public Double getCategoryUnits() { + return m_CategoryUnits; + } + + /** + * + * @return + */ + public String printCategorySum() { + return Formats.CURRENCY.formatValue(m_CategorySum); + } + + /** + * + * @return + */ + public Double getCategorySum() { + return m_CategorySum; + } + } +// end + + /** + * janar153 @ 29.12.2013 + */ + public static class RemovedProductLines implements SerializableRead { + + private String m_Name; + private String m_TicketId; + private String m_ProductName; + private Double m_TotalUnits; + + @Override + public void readValues(DataRead dr) throws BasicException { + m_Name = dr.getString(1); + m_TicketId = dr.getString(2); + m_ProductName = dr.getString(3); + m_TotalUnits = dr.getDouble(4); + } + + public String printWorkerName() { + return StringUtils.encodeXML(m_Name); + } + + public String printTicketId() { + return StringUtils.encodeXML(m_TicketId); + } + + public String printProductName() { + return StringUtils.encodeXML(m_ProductName); + } + + public String printTotalUnits() { + return Formats.DOUBLE.formatValue(m_TotalUnits); + } + + } + + /** + * JG Dec 14 + */ + public static class DrawerOpenedLines implements SerializableRead { + + private String m_DrawerOpened; + private String m_Name; + private String m_TicketId; + + @Override + public void readValues(DataRead dr) throws BasicException { + m_DrawerOpened = dr.getString(1); + m_Name = dr.getString(2); + m_TicketId = dr.getString(3); + } + + public String printDrawerOpened() { + return StringUtils.encodeXML(m_DrawerOpened); + } + + public String printUserName() { + return StringUtils.encodeXML(m_Name); + } + + public String printTicketId() { + return StringUtils.encodeXML(m_TicketId); + } + } + + public static class ProductSalesLine implements SerializableRead { + + private String m_ProductName; + private Double m_ProductUnits; + private Double m_ProductPrice; + private Double m_TaxRate; + private Double m_ProductPriceTax; + private Double m_ProductPriceNet; //JG 7 June 2014 + + @Override + public void readValues(DataRead dr) throws BasicException { + m_ProductName = dr.getString(1); + m_ProductUnits = dr.getDouble(2); + m_ProductPrice = dr.getDouble(3); + m_TaxRate = dr.getDouble(4); + + m_ProductPriceTax = m_ProductPrice + m_ProductPrice*m_TaxRate; + m_ProductPriceNet = m_ProductPrice * m_TaxRate; + } + + public String printProductName() { + return StringUtils.encodeXML(m_ProductName); + } + + public String printProductUnits() { + return Formats.DOUBLE.formatValue(m_ProductUnits); + } + + public Double getProductUnits() { + return m_ProductUnits; + } + + public String printProductPrice() { + return Formats.CURRENCY.formatValue(m_ProductPrice); + } + + public Double getProductPrice() { + return m_ProductPrice; + } + + public String printTaxRate() { + return Formats.PERCENT.formatValue(m_TaxRate); + } + + public Double getTaxRate() { + return m_TaxRate; + } + + public String printProductPriceTax() { + return Formats.CURRENCY.formatValue(m_ProductPriceTax); + } + + public String printProductSubValue() { + return Formats.CURRENCY.formatValue(m_ProductPriceTax*m_ProductUnits); + } + + /** + * JG 4 Jun 2014 + * @return + */ + public String printProductPriceNet() { + return Formats.CURRENCY.formatValue(m_ProductPrice*m_ProductUnits); + } + + } + + public static class SalesLine implements SerializableRead { + + private String m_SalesTaxName; + private Double m_SalesTaxes; + private Double m_SalesTaxNet; //JG June 2014 + private Double m_SalesTaxGross; //JG June 2014 + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_SalesTaxName = dr.getString(1); + m_SalesTaxes = dr.getDouble(2); + m_SalesTaxNet = dr.getDouble(3); //JG June 2014 + m_SalesTaxGross = dr.getDouble(4); //JG June 2014 + } + + /** + * + * @return + */ + public String printTaxName() { + return m_SalesTaxName; + } + + /** + * + * @return + */ + public String printTaxes() { + return Formats.CURRENCY.formatValue(m_SalesTaxes); + } + + /** + * JG June 2014 + * @return + */ + public String printTaxNet() { + return Formats.CURRENCY.formatValue(m_SalesTaxNet); + } + + /** + * JG June 2014 + * @return + */ + public String printTaxGross() { + return Formats.CURRENCY.formatValue(m_SalesTaxes + m_SalesTaxNet); + } + + + /** + * + * @return + */ + public String getTaxName() { + return m_SalesTaxName; + } + + /** + * + * @return + */ + public Double getTaxes() { + return m_SalesTaxes; + } + + /** + * JG June 2014 + * @return + */ + public Double getTaxNet() { + return m_SalesTaxNet; + } + + /** + * JG June 2014 + * @return + */ + public Double getTaxGross() { + return m_SalesTaxGross; + } + + + + } + + /** + * + * @return + */ + public AbstractTableModel getSalesModel() { + return new AbstractTableModel() { + @Override + public String getColumnName(int column) { + return AppLocal.getIntString(SALEHEADERS[column]); + } + @Override + public int getRowCount() { + return m_lsales.size(); + } + @Override + public int getColumnCount() { + return SALEHEADERS.length; + } + @Override + public Object getValueAt(int row, int column) { + SalesLine l = m_lsales.get(row); + switch (column) { + case 0: return l.getTaxName(); + case 1: return l.getTaxes(); + case 2: return l.getTaxNet(); //JG June 2014 + default: return null; + } + } + }; + } + + /** + * + */ + public static class PaymentsLine implements SerializableRead { + + private String m_PaymentType; + private Double m_PaymentValue; +// JG 1 Oct 13 - Add Payment Reason for Partial Cash - thanks Shaun Cains + private String s_PaymentReason; + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_PaymentType = dr.getString(1); + m_PaymentValue = dr.getDouble(2); + s_PaymentReason=dr.getString(3) == null ? "": dr.getString(3); + } + + /** + * + * @return + */ + public String printType() { + return AppLocal.getIntString("transpayment." + m_PaymentType); + } + + /** + * + * @return + */ + public String getType() { + return m_PaymentType; + } + + /** + * + * @return + */ + public String printValue() { + return Formats.CURRENCY.formatValue(m_PaymentValue); + } + + /** + * + * @return + */ + public Double getValue() { + return m_PaymentValue; + } + + /** + * + * @return + */ + public String printReason() { + return s_PaymentReason; + } + + /** + * + * @return + */ + public String getReason() { + return s_PaymentReason; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/panels/PaymentsReprintModel.java b/src/main/java/com/unicenta/pos/panels/PaymentsReprintModel.java new file mode 100644 index 0000000..5fef018 --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/PaymentsReprintModel.java @@ -0,0 +1,1097 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.*; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.util.StringUtils; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import javax.swing.table.AbstractTableModel; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * October 2018 + * + * @authors JG + */ +@Slf4j +public class PaymentsReprintModel { + + private String m_sHost; + private String m_sUser; + private int m_iSeq; + + private String m_dDateStart; + private String m_dDateEnd; + private Date rDate; + private Date m_dPrintDate; + + + private Integer m_iPayments; + private Double m_dPaymentsTotal; + private java.util.List<PaymentsLine> m_lpayments; + + private Integer m_iCategorySalesRows; + private Double m_dCategorySalesTotalUnits; + private Double m_dCategorySalesTotal; + private java.util.List<CategorySalesLine> m_lcategorysales; + + private Integer m_iProductSalesRows; + private Double m_dProductSalesTotalUnits; + private Double m_dProductSalesTotal; + private java.util.List<ProductSalesLine> m_lproductsales; + + private java.util.List<RemovedProductLines> m_lremovedlines; + + private java.util.List<DrawerOpenedLines> m_ldraweropenedlines; + + private final static String[] PAYMENTHEADERS = {"label.Payment", "label.Money"}; + + private Integer m_iSales; + private Double m_dSalesBase; + private Double m_dSalesTaxes; + private Double m_dSalesTaxNet; + private java.util.List<SalesLine> m_lsales; + + private final static String[] SALEHEADERS = {"label.taxcategory", "label.totaltax", "label.totalnet"}; + + private PaymentsReprintModel() { + } + + /** + * @return + */ + public static PaymentsReprintModel emptyInstance() { + + PaymentsReprintModel p = new PaymentsReprintModel(); + + p.m_iPayments = 0; + p.m_dPaymentsTotal = 0.0; + p.m_lpayments = new ArrayList<>(); + + p.m_iCategorySalesRows = 0; + p.m_dCategorySalesTotalUnits = 0.0; + p.m_dCategorySalesTotal = 0.0; + p.m_lcategorysales = new ArrayList<>(); + + p.m_iSales = 0; + p.m_dSalesBase = 0.0; + p.m_dSalesTaxes = 0.0; + p.m_dSalesTaxNet = 0.0; + + p.m_iProductSalesRows = 0; + p.m_dProductSalesTotalUnits = 0.0; + p.m_dProductSalesTotal = 0.0; + p.m_lproductsales = new ArrayList<>(); + p.m_lremovedlines = new ArrayList<>(); + + p.m_lsales = new ArrayList<>(); + + return p; + } + + /** + * @param app + * @return + * @throws BasicException + */ + public static PaymentsReprintModel loadInstance(AppView app) throws BasicException { + + PaymentsReprintModel p = new PaymentsReprintModel(); + + p.m_sUser = app.getAppUserView().getUser().getName(); + p.m_sHost = app.getProperties().getHost(); + + JFrame frame = new JFrame("Sequence"); + String sequence = JOptionPane.showInputDialog(frame, + AppLocal.getIntString("message.ccentersequence"), + JOptionPane.INFORMATION_MESSAGE); + if (sequence != null) { + int isequence = Integer.parseInt(sequence); + p.m_iSeq = isequence; + } else { + app.getAppUserView().showTask("com.unicenta.pos.panels.JPanelCloseMoneyReprint"); + } + + Object[] ccash; + ccash = (Object[]) new StaticSentence(app.getSession(), + "SELECT money, host, hostsequence, datestart, dateend, nosales " + + "FROM closedcash " + + "where hostsequence = ? and dateend is not null " + + "AND host = " + "'" + app.getProperties().getHost() + "'" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[]{ + Datas.STRING, Datas.STRING, Datas.INT, Datas.STRING, Datas.STRING, Datas.INT})) + .find(sequence); + + if (ccash == null) { + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.ccsequencenotfound"), + "", + JOptionPane.WARNING_MESSAGE); + } else { + p.m_dDateStart = ccash[3].toString(); + p.m_dDateEnd = ccash[4].toString(); + + // Product category Sales + Object[] valcategorysales = (Object[]) new StaticSentence(app.getSession() + , "SELECT COUNT(*), " + + "SUM(ticketlines.UNITS), " + + "SUM((ticketlines.PRICE + ticketlines.PRICE * taxes.RATE ) * ticketlines.UNITS) " + + "FROM ticketlines, tickets, receipts, taxes " + + "WHERE ticketlines.TICKET = tickets.ID " + + "AND tickets.ID = receipts.ID " + + "AND ticketlines.TAXID = taxes.ID " + + "AND ticketlines.PRODUCT IS NOT NULL " + + "AND receipts.MONEY = ? " + + "GROUP BY receipts.MONEY" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[]{Datas.INT, Datas.DOUBLE, Datas.DOUBLE})) + .find(ccash[0]); + + if (valcategorysales == null) { + p.m_iCategorySalesRows = 0; + p.m_dCategorySalesTotalUnits = 0.0; + p.m_dCategorySalesTotal = 0.0; + } else { + p.m_iCategorySalesRows = (Integer) valcategorysales[0]; + p.m_dCategorySalesTotalUnits = (Double) valcategorysales[1]; + p.m_dCategorySalesTotal = (Double) valcategorysales[2]; + } + + List categorys = new StaticSentence(app.getSession() + , "SELECT a.NAME, sum(c.UNITS), sum(c.UNITS * (c.PRICE + (c.PRICE * d.RATE))) " + + "FROM categories as a " + + "LEFT JOIN products as b on a.id = b.CATEGORY " + + "LEFT JOIN ticketlines as c on b.id = c.PRODUCT " + + "LEFT JOIN taxes as d on c.TAXID = d.ID " + + "LEFT JOIN receipts as e on c.TICKET = e.ID " + + "WHERE e.MONEY = ? " + + "GROUP BY a.NAME" + , SerializerWriteString.INSTANCE + , new SerializerReadClass(PaymentsReprintModel.CategorySalesLine.class)) + .list(ccash[0]); + + if (categorys == null) { + p.m_lcategorysales = new ArrayList(); + } else { + p.m_lcategorysales = categorys; + } + + // Payments + Object[] valtickets = (Object[]) new StaticSentence(app.getSession() + , "SELECT COUNT(*), SUM(payments.TOTAL) " + + "FROM payments, receipts " + + "WHERE payments.RECEIPT = receipts.ID AND receipts.MONEY = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[]{Datas.INT, Datas.DOUBLE})) + .find(ccash[0]); + + if (valtickets == null) { + p.m_iPayments = 0; + p.m_dPaymentsTotal = 0.0; + } else { + p.m_iPayments = (Integer) valtickets[0]; + p.m_dPaymentsTotal = (Double) valtickets[1]; + } + + List l = new StaticSentence(app.getSession(), + "SELECT payments.PAYMENT, SUM(payments.TOTAL), payments.NOTES " + + "FROM payments, receipts " + + "WHERE payments.RECEIPT = receipts.ID AND receipts.MONEY = ? " + + "GROUP BY payments.PAYMENT, payments.NOTES" + , SerializerWriteString.INSTANCE + , new SerializerReadClass(PaymentsReprintModel.PaymentsLine.class)) + .list(ccash[0]); + + if (l == null) { + p.m_lpayments = new ArrayList(); + } else { + p.m_lpayments = l; + } + + // Sales + Object[] recsales = (Object[]) new StaticSentence(app.getSession(), + "SELECT COUNT(DISTINCT receipts.ID), SUM(ticketlines.UNITS * ticketlines.PRICE) " + + "FROM receipts, ticketlines " + + "WHERE receipts.ID = ticketlines.TICKET AND receipts.MONEY = ?" + , SerializerWriteString.INSTANCE, + new SerializerReadBasic(new Datas[]{Datas.INT, Datas.DOUBLE})) + .find(ccash[0]); + + if (recsales == null) { + p.m_iSales = null; + p.m_dSalesBase = null; + } else { + p.m_iSales = (Integer) recsales[0]; + p.m_dSalesBase = (Double) recsales[1]; + } + + // Taxes + Object[] rectaxes = (Object[]) new StaticSentence(app.getSession(), + "SELECT SUM(taxlines.AMOUNT), SUM(taxlines.BASE) " + + "FROM receipts, taxlines " + + "WHERE receipts.ID = taxlines.RECEIPT AND receipts.MONEY = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[]{ + Datas.DOUBLE, Datas.DOUBLE})) + .find(ccash[0]); + + if (rectaxes == null) { + p.m_dSalesTaxes = null; + p.m_dSalesTaxNet = null; + } else { + p.m_dSalesTaxes = (Double) rectaxes[0]; + p.m_dSalesTaxNet = (Double) rectaxes[1]; + } + + List<SalesLine> asales = new StaticSentence(app.getSession(), + "SELECT taxcategories.NAME, SUM(taxlines.AMOUNT), SUM(taxlines.BASE), " + + "SUM(taxlines.BASE + taxlines.AMOUNT) " + + "FROM receipts, taxlines, taxes, taxcategories " + + "WHERE receipts.ID = taxlines.RECEIPT AND taxlines.TAXID = taxes.ID AND taxes.CATEGORY = taxcategories.ID " + + "AND receipts.MONEY = ? " + + "GROUP BY taxcategories.NAME" + , SerializerWriteString.INSTANCE + , new SerializerReadClass(PaymentsReprintModel.SalesLine.class)) + .list(ccash[0]); + + if (asales == null) { + p.m_lsales = new ArrayList<>(); + } else { + p.m_lsales = asales; + } + + List removedLines = new StaticSentence(app.getSession() + , "SELECT lineremoved.NAME, lineremoved.TICKETID, lineremoved.PRODUCTNAME, " + + "SUM(lineremoved.UNITS) AS TOTAL_UNITS " + + "FROM lineremoved " + + "WHERE lineremoved.REMOVEDDATE > " + "'" + p.m_dDateStart + "'" + " " + + "GROUP BY lineremoved.NAME, lineremoved.TICKETID, lineremoved.PRODUCTNAME" + , SerializerWriteString.INSTANCE + , new SerializerReadClass(PaymentsReprintModel.RemovedProductLines.class)) + .list(p.m_dDateStart); + + if (removedLines == null) { + p.m_lremovedlines = new ArrayList(); + } else { + p.m_lremovedlines = removedLines; + } + + List drawerOpenedLines = new StaticSentence(app.getSession() + , "SELECT OPENDATE, NAME, TICKETID " + + "FROM draweropened " + + "WHERE TICKETID = 'No Sale' AND OPENDATE > ? " + + "GROUP BY NAME, OPENDATE, TICKETID" + , SerializerWriteString.INSTANCE + , new SerializerReadClass(PaymentsReprintModel.DrawerOpenedLines.class)) + .list(p.m_dDateStart); + + if (drawerOpenedLines == null) { + p.m_ldraweropenedlines = new ArrayList(); + } else { + p.m_ldraweropenedlines = drawerOpenedLines; + } + + // Product Sales + Object[] valproductsales = (Object[]) new StaticSentence(app.getSession() + , "SELECT COUNT(*), SUM(ticketlines.UNITS), " + + "SUM((ticketlines.PRICE + ticketlines.PRICE * taxes.RATE ) * ticketlines.UNITS) " + + "FROM ticketlines, tickets, receipts, taxes " + + "WHERE ticketlines.TICKET = tickets.ID " + + "AND tickets.ID = receipts.ID " + + "AND ticketlines.TAXID = taxes.ID " + + "AND ticketlines.PRODUCT IS NOT NULL " + + "AND receipts.MONEY = ? " + + "GROUP BY receipts.MONEY" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[]{Datas.INT, Datas.DOUBLE, Datas.DOUBLE})) + .find(ccash[0]); + + if (valproductsales == null) { + p.m_iProductSalesRows = 0; + p.m_dProductSalesTotalUnits = 0.0; + p.m_dProductSalesTotal = 0.0; + } else { + p.m_iProductSalesRows = (Integer) valproductsales[0]; + p.m_dProductSalesTotalUnits = (Double) valproductsales[1]; + p.m_dProductSalesTotal = (Double) valproductsales[2]; + } + + List products = new StaticSentence(app.getSession() + , "SELECT products.NAME, SUM(ticketlines.UNITS), ticketlines.PRICE, taxes.RATE " + + "FROM ticketlines, tickets, receipts, products, taxes " + + "WHERE ticketlines.PRODUCT = products.ID " + + "AND ticketlines.TICKET = tickets.ID " + + "AND tickets.ID = receipts.ID " + + "AND ticketlines.TAXID = taxes.ID " + + "AND receipts.MONEY = ? " + + "GROUP BY products.NAME, ticketlines.PRICE, taxes.RATE" + , SerializerWriteString.INSTANCE + , new SerializerReadClass(PaymentsReprintModel.ProductSalesLine.class)) + .list(ccash[0]); + + if (products == null) { + p.m_lproductsales = new ArrayList(); + } else { + p.m_lproductsales = products; + } + + return p; + } + + return null; + } + + /** + * @return + */ + public int getPayments() { + return m_iPayments; + } + + /** + * @return + */ + public double getTotal() { + return m_dPaymentsTotal; + } + + /** + * @return + */ + public String getHost() { + return m_sHost; + } + + /** + * @return + */ + public String getUser() { + return m_sUser; + } + + /** + * @return + */ + public int getSequence() { + return m_iSeq; + } + + public String getPrintDate() { + Date m_dPrintDate = new Date(); + return Formats.TIMESTAMP.formatValue(m_dPrintDate); + } + + /** + * @return + */ + public String getDateStart() { + return m_dDateStart; + } + + /** + * @param dValue + */ + public void setDateEnd(String dValue) { + m_dDateEnd = dValue; + } + + /** + * @return + */ + public String getDateEnd() { + return m_dDateEnd; + } + + /** + * @return + */ + public String getDateStartDerby() { + SimpleDateFormat ndf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return ndf.format(m_dDateStart); + } + + /** + * @return + */ + public String printHost() { + return StringUtils.encodeXML(m_sHost); + } + + /** + * @return + */ + public String printUser() { + return StringUtils.encodeXML(m_sUser); + } + + /** + * @return + */ + public String printSequence() { + return Formats.INT.formatValue(m_iSeq); + } + + public String printDate() { + Date m_dPrintDate = new Date(); + return Formats.TIMESTAMP.formatValue(m_dPrintDate); + } + + + /** + * @return + */ + public String printDateStart() { +// return Formats.TIMESTAMP.formatValue(m_dDateStart); + return m_dDateStart; + } + + public String reformDateStart() { + + SimpleDateFormat sdfIn = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + SimpleDateFormat sdfOut = new SimpleDateFormat("dd MMM yyyy HH:mm:ss"); + String input = m_dDateStart; + Date date = null; + try { + date = sdfIn.parse(input); + } catch (ParseException ex) { + log.error(ex.getMessage()); + } + +// System.out.println(sdfOut.format(date)); + m_dDateStart = sdfOut.format(date); + + return m_dDateStart; + } + + public String reformDateEnd() { + + SimpleDateFormat sdfIn = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + SimpleDateFormat sdfOut = new SimpleDateFormat("dd MMM yyyy HH:mm:ss"); + String input = m_dDateEnd; + Date date = null; + try { + date = sdfIn.parse(input); + } catch (ParseException ex) { + log.error(ex.getMessage()); + } + +// System.out.println(sdfOut.format(date)); + m_dDateEnd = sdfOut.format(date); + + return m_dDateEnd; + } + + /** + * @return + */ + public String printDateEnd() { +// return Formats.TIMESTAMP.formatValue(m_dDateEnd); + return m_dDateEnd; + } + + /** + * @return + */ + public String printPayments() { + return Formats.INT.formatValue(m_iPayments); + } + + /** + * @return + */ + public String printPaymentsTotal() { + return Formats.CURRENCY.formatValue(m_dPaymentsTotal); + } + + /** + * @return + */ + public List<PaymentsLine> getPaymentLines() { + return m_lpayments; + } + + /** + * @return + */ + public int getSales() { + return m_iSales == null ? 0 : m_iSales; + } + + /** + * @return + */ + public String printSales() { + return Formats.INT.formatValue(m_iSales); + } + + /** + * @return + */ + public String printSalesBase() { + return Formats.CURRENCY.formatValue(m_dSalesBase); + } + + /** + * @return + */ + public String printSalesTaxes() { + return Formats.CURRENCY.formatValue(m_dSalesTaxes); + } + + /** + * @return + */ + public String printSalesTotal() { + return Formats.CURRENCY.formatValue((m_dSalesBase == null || m_dSalesTaxes == null) + ? null + : m_dSalesBase + m_dSalesTaxes); + } + + /** + * @return + */ + public List<SalesLine> getSaleLines() { + return m_lsales; + } + + /** + * @return + */ + public double getCategorySalesRows() { + return m_iCategorySalesRows; + } + + /** + * @return + */ + public String printCategorySalesRows() { + return Formats.INT.formatValue(m_iCategorySalesRows); + } + + /** + * @return + */ + public double getCategorySalesTotalUnits() { + return m_dCategorySalesTotalUnits; + } + + /** + * @return + */ + public String printCategorySalesTotalUnits() { + return Formats.DOUBLE.formatValue(m_dCategorySalesTotalUnits); + } + + /** + * @return + */ + public double getCategorySalesTotal() { + return m_dCategorySalesTotal; + } + + /** + * @return + */ + public String printCategorySalesTotal() { + return Formats.CURRENCY.formatValue(m_dCategorySalesTotal); + } + + /** + * @return + */ + public List<CategorySalesLine> getCategorySalesLines() { + return m_lcategorysales; + } + + + /** + * @return + */ + public double getProductSalesRows() { + return m_iProductSalesRows; + } + + /** + * @return + */ + public String printProductSalesRows() { + return Formats.INT.formatValue(m_iProductSalesRows); + } + + /** + * @return + */ + public double getProductSalesTotalUnits() { + return m_dProductSalesTotalUnits; + } + + /** + * @return + */ + public String printProductSalesTotalUnits() { + return Formats.DOUBLE.formatValue(m_dProductSalesTotalUnits); + } + + /** + * @return + */ + public double getProductSalesTotal() { + return m_dProductSalesTotal; + } + + /** + * @return + */ + public String printProductSalesTotal() { + return Formats.CURRENCY.formatValue(m_dProductSalesTotal); + } + + /** + * @return + */ + public List<ProductSalesLine> getProductSalesLines() { + return m_lproductsales; + } + + /** + * @return + */ + public List<RemovedProductLines> getRemovedProductLines() { + return m_lremovedlines; + } + + /** + * JG Dec 14 + * + * @return + */ + public List<DrawerOpenedLines> getDrawerOpenedLines() { + return m_ldraweropenedlines; + } + + /** + * @return + */ + public AbstractTableModel getPaymentsReprintModel() { + return new AbstractTableModel() { + @Override + public String getColumnName(int column) { + return AppLocal.getIntString(PAYMENTHEADERS[column]); + } + + @Override + public int getRowCount() { + return m_lpayments.size(); + } + + @Override + public int getColumnCount() { + return PAYMENTHEADERS.length; + } + + @Override + public Object getValueAt(int row, int column) { + PaymentsLine l = m_lpayments.get(row); + switch (column) { + case 0: + return l.getType(); + case 1: + return l.getValue(); + default: + return null; + } + } + }; + } + + public static class CategorySalesLine implements SerializableRead { + + private String m_CategoryName; + private Double m_CategoryUnits; + private Double m_CategorySum; + + /** + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_CategoryName = dr.getString(1); + m_CategoryUnits = dr.getDouble(2); + m_CategorySum = dr.getDouble(3); + } + + /** + * @return + */ + public String printCategoryName() { + return m_CategoryName; + } + + /** + * @return + */ + public String printCategoryUnits() { + return Formats.DOUBLE.formatValue(m_CategoryUnits); + } + + /** + * @return + */ + public Double getCategoryUnits() { + return m_CategoryUnits; + } + + /** + * @return + */ + public String printCategorySum() { + return Formats.CURRENCY.formatValue(m_CategorySum); + } + + /** + * @return + */ + public Double getCategorySum() { + return m_CategorySum; + } + } + + public static class RemovedProductLines implements SerializableRead { + + private String m_Name; + private String m_TicketId; + private String m_ProductName; + private Double m_TotalUnits; + + @Override + public void readValues(DataRead dr) throws BasicException { + m_Name = dr.getString(1); + m_TicketId = dr.getString(2); + m_ProductName = dr.getString(3); + m_TotalUnits = dr.getDouble(4); + } + + public String printWorkerName() { + return StringUtils.encodeXML(m_Name); + } + + public String printTicketId() { + return StringUtils.encodeXML(m_TicketId); + } + + public String printProductName() { + return StringUtils.encodeXML(m_ProductName); + } + + public String printTotalUnits() { + return Formats.DOUBLE.formatValue(m_TotalUnits); + } + + } + + /** + * JG Dec 14 + */ + public static class DrawerOpenedLines implements SerializableRead { + + private String m_DrawerOpened; + private String m_Name; + private String m_TicketId; + + @Override + public void readValues(DataRead dr) throws BasicException { + m_DrawerOpened = dr.getString(1); + m_Name = dr.getString(2); + m_TicketId = dr.getString(3); + } + + public String printDrawerOpened() { + return StringUtils.encodeXML(m_DrawerOpened); + } + + public String printUserName() { + return StringUtils.encodeXML(m_Name); + } + + public String printTicketId() { + return StringUtils.encodeXML(m_TicketId); + } + } + + public static class ProductSalesLine implements SerializableRead { + + private String m_ProductName; + private Double m_ProductUnits; + private Double m_ProductPrice; + private Double m_TaxRate; + private Double m_ProductPriceTax; + private Double m_ProductPriceNet; + + @Override + public void readValues(DataRead dr) throws BasicException { + m_ProductName = dr.getString(1); + m_ProductUnits = dr.getDouble(2); + m_ProductPrice = dr.getDouble(3); + m_TaxRate = dr.getDouble(4); + + m_ProductPriceTax = m_ProductPrice + m_ProductPrice * m_TaxRate; + m_ProductPriceNet = m_ProductPrice * m_TaxRate; + } + + public String printProductName() { + return StringUtils.encodeXML(m_ProductName); + } + + public String printProductUnits() { + return Formats.DOUBLE.formatValue(m_ProductUnits); + } + + public Double getProductUnits() { + return m_ProductUnits; + } + + public String printProductPrice() { + return Formats.CURRENCY.formatValue(m_ProductPrice); + } + + public Double getProductPrice() { + return m_ProductPrice; + } + + public String printTaxRate() { + return Formats.PERCENT.formatValue(m_TaxRate); + } + + public Double getTaxRate() { + return m_TaxRate; + } + + public String printProductPriceTax() { + return Formats.CURRENCY.formatValue(m_ProductPriceTax); + } + + public String printProductSubValue() { + return Formats.CURRENCY.formatValue(m_ProductPriceTax * m_ProductUnits); + } + + /** + * JG 4 Jun 2014 + * + * @return + */ + public String printProductPriceNet() { + return Formats.CURRENCY.formatValue(m_ProductPrice * m_ProductUnits); + } + + } + + public static class SalesLine implements SerializableRead { + + private String m_SalesTaxName; + private Double m_SalesTaxes; + private Double m_SalesTaxNet; + private Double m_SalesTaxGross; + + /** + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_SalesTaxName = dr.getString(1); + m_SalesTaxes = dr.getDouble(2); + m_SalesTaxNet = dr.getDouble(3); + m_SalesTaxGross = dr.getDouble(4); + } + + /** + * @return + */ + public String printTaxName() { + return m_SalesTaxName; + } + + /** + * @return + */ + public String printTaxes() { + return Formats.CURRENCY.formatValue(m_SalesTaxes); + } + + /** + * @return + */ + public String printTaxNet() { + return Formats.CURRENCY.formatValue(m_SalesTaxNet); + } + + /** + * @return + */ + public String printTaxGross() { + return Formats.CURRENCY.formatValue(m_SalesTaxes + m_SalesTaxNet); + } + + + /** + * @return + */ + public String getTaxName() { + return m_SalesTaxName; + } + + /** + * @return + */ + public Double getTaxes() { + return m_SalesTaxes; + } + + /** + * @return + */ + public Double getTaxNet() { + return m_SalesTaxNet; + } + + /** + * JG June 2014 + * + * @return + */ + public Double getTaxGross() { + return m_SalesTaxGross; + } + + + } + + /** + * @return + */ + public AbstractTableModel getSalesModel() { + return new AbstractTableModel() { + @Override + public String getColumnName(int column) { + return AppLocal.getIntString(SALEHEADERS[column]); + } + + @Override + public int getRowCount() { + return m_lsales.size(); + } + + @Override + public int getColumnCount() { + return SALEHEADERS.length; + } + + @Override + public Object getValueAt(int row, int column) { + SalesLine l = m_lsales.get(row); + switch (column) { + case 0: + return l.getTaxName(); + case 1: + return l.getTaxes(); + case 2: + return l.getTaxNet(); + default: + return null; + } + } + }; + } + + /** + * + */ + public static class PaymentsLine implements SerializableRead { + + private String m_PaymentType; + private Double m_PaymentValue; + private String s_PaymentReason; + + /** + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_PaymentType = dr.getString(1); + m_PaymentValue = dr.getDouble(2); + s_PaymentReason = dr.getString(3) == null ? "" : dr.getString(3); + } + + /** + * @return + */ + public String printType() { + return AppLocal.getIntString("transpayment." + m_PaymentType); + } + + /** + * @return + */ + public String getType() { + return m_PaymentType; + } + + /** + * @return + */ + public String printValue() { + return Formats.CURRENCY.formatValue(m_PaymentValue); + } + + /** + * @return + */ + public Double getValue() { + return m_PaymentValue; + } + + /** + * @return + */ + public String printReason() { + return s_PaymentReason; + } + + /** + * @return + */ + public String getReason() { + return s_PaymentReason; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/panels/Printer.PartialCash.xml b/src/main/java/com/unicenta/pos/panels/Printer.PartialCash.xml new file mode 100644 index 0000000..f579936 --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/Printer.PartialCash.xml @@ -0,0 +1,186 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> +<output> + <ticket> + <image>Printer.Ticket.Logo</image> + <line></line> + <line></line> + <line size="1"> + <text align ="center" length="42" bold="true">Partial Cash Report</text> + </line> + <line></line> + <line> + <text bold="true">Sales report</text> + </line> + <line> + <text align ="left" length="12">Name</text> + <text align ="right" length="14">Price+Tax</text> + <text align ="right" length="1"></text> + <text align ="right" length="5">Unit</text> + <text align ="right" length="10">Total</text> + </line> + <line> + <text>------------------------------------------</text> + </line> + #foreach ($line in $payments.getProductSalesLines()) + <line> + <text align ="left" length="12">${line.printProductName()}</text> + <text align ="right" length="10">${line.printProductPriceTax()}</text> + <text align ="right" length="5">${line.printTaxRate()}</text> + <text align ="right" length="5">${line.printProductUnits()}</text> + <text align ="right" length="10">${line.printProductSubValue()}</text> + </line> + #end + <line> + <text>------------------------------------------</text> + </line> + <line> + <text align ="left" length="32">Ticket rows:</text> + <text align ="right" length="10">${payments.printProductSalesRows()}</text> + </line> + <line></line> + <line size="1"> + <text align ="left" length="22" bold="true">Total</text> + <text align ="right" length="10" bold="true">${payments.printProductSalesTotalUnits()}</text> + <text align ="right" length="10" bold="true">${payments.printProductSalesTotal()}</text> + </line> + <line></line> + <line> + <text bold="true">Payments Report</text> + </line> + <line> + <text align ="right" length="42">Total</text> + </line> + <line> + <text>------------------------------------------</text> + </line> + #foreach ($line in $payments.getPaymentLines()) + <line> + <text align ="left" length="32">${line.printType()}</text> + <text align ="right" length="10">${line.printValue()}</text> + </line> + #end + <line> + <text>------------------------------------------</text> + </line> + <line> + <text align ="left" length="32">Payments:</text> + <text align ="right" length="10">${payments.printPayments()}</text> + </line> + <line></line> + <line size="1"> + <text align ="left" length="32" bold="true">Total</text> + <text align ="right" length="10" bold="true">${payments.printPaymentsTotal()}</text> + </line> + <line></line> + <line> + <text bold="true">Taxes Report</text> + </line> + <line> + <text align ="right" length="42">Total</text> + </line> + <line> + <text>------------------------------------------</text> + </line> + #foreach ($line in $payments.getSaleLines()) + <line> + <text align ="left" length="32">${line.printTaxName()}</text> + <text align ="right" length="10">${line.printTaxes()}</text> + </line> + #end + <line> + <text>------------------------------------------</text> + </line> +<!-- JG 9 Nov 12 for Categories --> + <line></line> + <line> + <text bold="true">Product Category Sales</text> + </line> + <line> + <text align ="left" length="22">Name</text> + <text align ="right" length="10">Qty</text> + <text align ="right" length="10">Total</text> + </line> + <line> + <text>------------------------------------------</text> + </line> + #foreach ($line in $payments.getCategorySalesLines()) + <line> + <text align ="left" length="22">${line.printCategoryName()}</text> + <text align ="right" length="10">${line.printCategoryUnits()}</text> + <text align ="right" length="10">${line.printCategorySum()}</text> + </line> + #end + <line> + <text>------------------------------------------</text> + </line> + <line> + <text align ="left" length="22">Ticket Lines:</text> + <text align ="right" length="10">${payments.printCategorySalesRows()}</text> + </line> + <line></line> + <line size="1"> + <text align ="left" length="22" bold="true">Total</text> + <text align ="right" length="10" bold="true">${payments.printCategorySalesTotalUnits()}</text> + <text align ="right" length="10" bold="true">${payments.printCategorySalesTotal()}</text> + </line> + <line> + <text>------------------------------------------</text> + </line> + <line></line> +<!-- end --> + <line> + <text align ="left" length="32">Receipts:</text> + <text align ="right" length="10">${payments.printSales()}</text> + </line> + <line></line> + <line size="1"> + <text align ="left" length="32" bold="true">Subtotal</text> + <text align ="right" length="10" bold="true">${payments.printSalesBase()}</text> + </line> + <line size="1"> + <text align ="left" length="32" bold="true">Taxes</text> + <text align ="right" length="10" bold="true">${payments.printSalesTaxes()}</text> + </line> + <line size="1"> + <text align ="left" length="32" bold="true">Total</text> + <text align ="right" length="10" bold="true">${payments.printSalesTotal()}</text> + </line> + <line></line> + <line> + <text length="18">Machine:</text> + <text>${payments.printHost()}</text> + </line> + <line> + <text length="18">Sequence:</text> + <text>${payments.printSequence()}</text> + </line> + <line> + <text length="18">Start Date:</text> + <text>${payments.printDateStart()}</text> + </line> + <line> + <text length="18">End Date:</text> + <text>${payments.printDateEnd()}</text> + </line> + </ticket> +</output> diff --git a/src/main/java/com/unicenta/pos/panels/SQLColumn.java b/src/main/java/com/unicenta/pos/panels/SQLColumn.java new file mode 100644 index 0000000..2e88873 --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/SQLColumn.java @@ -0,0 +1,75 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-130 + +package com.unicenta.pos.panels; + +import java.util.Enumeration; +import javax.swing.tree.TreeNode; + +/** + * + * @author adrianromero + */ +public class SQLColumn implements TreeNode { + + private SQLTable m_table; + private String m_sName; + + /** Creates a new instance of SQLColumn + * @param t + * @param name */ + public SQLColumn(SQLTable t, String name) { + m_table = t; + m_sName = name; + } + @Override + public String toString() { + return m_sName; + } + + @Override + public Enumeration children(){ + return null; + } + @Override + public boolean getAllowsChildren() { + return false; + } + @Override + public TreeNode getChildAt(int childIndex) { + throw new ArrayIndexOutOfBoundsException(); + } + @Override + public int getChildCount() { + return 0; + } + @Override + public int getIndex(TreeNode node){ + throw new ArrayIndexOutOfBoundsException(); + } + @Override + public TreeNode getParent() { + return m_table; + } + @Override + public boolean isLeaf() { + return true; + } +} diff --git a/src/main/java/com/unicenta/pos/panels/SQLDatabase.java b/src/main/java/com/unicenta/pos/panels/SQLDatabase.java new file mode 100644 index 0000000..8355f0f --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/SQLDatabase.java @@ -0,0 +1,97 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import javax.swing.tree.TreeNode; + +/** + * + * @author adrianromero + */ +public class SQLDatabase implements TreeNode { + + private ArrayList m_aTables; + private HashMap m_mTables; + private String m_sName; + + /** Creates a new instance of SQLDatabase + * @param name */ + public SQLDatabase(String name) { + m_sName = name; + m_aTables = new ArrayList(); + m_mTables = new HashMap(); + } + @Override + public String toString() { + return m_sName; + } + + /** + * + * @param sTable + */ + public void addTable(String sTable) { + SQLTable t = new SQLTable(this, sTable); + m_aTables.add(t); + m_mTables.put(sTable, t); + } + + /** + * + * @param sTable + * @return + */ + public SQLTable getTable(String sTable) { + return (SQLTable) m_mTables.get(sTable); + } + + @Override + public Enumeration children(){ + return new EnumerationIter(m_aTables.iterator()); + } + @Override + public boolean getAllowsChildren() { + return true; + } + @Override + public TreeNode getChildAt(int childIndex) { + return (TreeNode) m_aTables.get(childIndex); + } + @Override + public int getChildCount() { + return m_aTables.size(); + } + @Override + public int getIndex(TreeNode node){ + return m_aTables.indexOf(node); + } + @Override + public TreeNode getParent() { + return null; + } + @Override + public boolean isLeaf() { +// JG 16 May 2013 use isEmpty + return m_aTables.isEmpty(); + } +} diff --git a/src/main/java/com/unicenta/pos/panels/SQLTable.java b/src/main/java/com/unicenta/pos/panels/SQLTable.java new file mode 100644 index 0000000..f27fee8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/SQLTable.java @@ -0,0 +1,111 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import java.util.ArrayList; +import java.util.Enumeration; +import javax.swing.tree.TreeNode; + +/** + * + * @author adrianromero + */ +public class SQLTable implements TreeNode { + + private SQLDatabase m_db; + private String m_sName; + + private ArrayList m_aColumns; + + /** Creates a new instance of SQLTable + * @param db + * @param name */ + public SQLTable(SQLDatabase db, String name) { + m_db = db; + m_sName = name; + m_aColumns = new ArrayList(); + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + + /** + * + * @param name + */ + public void addColumn(String name) { + SQLColumn c = new SQLColumn(this, name); + m_aColumns.add(c); + } + + @Override + public String toString() { + return m_sName; + } + + @Override + public Enumeration children(){ + return new EnumerationIter(m_aColumns.iterator()); + } + @Override + public boolean getAllowsChildren() { + return true; + } + @Override + public TreeNode getChildAt(int childIndex) { + return (TreeNode) m_aColumns.get(childIndex); + } + @Override + public int getChildCount() { + return m_aColumns.size(); + } + @Override + public int getIndex(TreeNode node){ + return m_aColumns.indexOf(node); + } + @Override + public TreeNode getParent() { + return m_db; + } + @Override + public boolean isLeaf() { +// JG 16 May 2013 use isEmpty instead of size. + return m_aColumns.isEmpty(); + } +// public Enumeration children(){ +// } +// public boolean getAllowsChildren() { +// } +// public TreeNode getChildAt(int childIndex) { +// } +// public int getChildCount() { +// } +// public int getIndex(TreeNode node){ +// } +// public TreeNode getParent() { +// } +// public boolean isLeaf() { +// } +} diff --git a/src/main/java/com/unicenta/pos/panels/SQLTableModel.java b/src/main/java/com/unicenta/pos/panels/SQLTableModel.java new file mode 100644 index 0000000..c7059d6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/panels/SQLTableModel.java @@ -0,0 +1,153 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.panels; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataField; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.Datas; +import java.sql.Types; +import java.util.ArrayList; +import java.util.List; +import javax.swing.table.AbstractTableModel; + +/** + * + * @author adrianromero + */ +public class SQLTableModel extends AbstractTableModel { + + private List m_aRows; + + private DataField[] m_df; + private Datas[] m_classes; + + /** Creates a new instance of SQLTableModel + * @param df */ + public SQLTableModel(DataField[] df) { + m_aRows = new ArrayList(); + + m_df = df; + m_classes = new Datas[df.length]; + for (int i = 0; i < df.length; i++) { + switch (df[i].Type) { + case Types.INTEGER: + case Types.BIGINT: + case Types.SMALLINT: + case Types.TINYINT: + m_classes[i] = Datas.INT; + break; + case Types.BIT: + case Types.BOOLEAN: + m_classes[i] = Datas.BOOLEAN; + break; + case Types.DECIMAL: + case Types.DOUBLE: + case Types.FLOAT: + case Types.REAL: + case Types.NUMERIC: + m_classes[i] = Datas.DOUBLE; + break; + case Types.CHAR: + case Types.VARCHAR: + case Types.LONGVARCHAR: + case Types.CLOB: + m_classes[i] = Datas.STRING; + break; + case Types.DATE: + case Types.TIME: + case Types.TIMESTAMP: + m_classes[i] = Datas.TIMESTAMP; + break; + case Types.BINARY: + case Types.VARBINARY: + case Types.LONGVARBINARY: + case Types.BLOB: + m_classes[i] = Datas.BYTES; + break; + case Types.ARRAY: + case Types.DATALINK: + case Types.DISTINCT: + case Types.JAVA_OBJECT: + case Types.NULL: + case Types.OTHER: + case Types.REF: + case Types.STRUCT: + default: + m_classes[i] = Datas.OBJECT; + break; + } + } + } + + /** + * + * @param dr + * @throws BasicException + */ + public void addRow(DataRead dr) throws BasicException { + + Object[] m_values = new Object[m_classes.length]; + for (int i = 0; i < m_classes.length; i++) { + m_values[i] = m_classes[i].getValue(dr, i + 1); + } + m_aRows.add(m_values); + } + + /** + * + * @param row + * @return + */ + public String getColumnString(int row) { + Object [] rowvalues = (Object[]) m_aRows.get(row); +// JG 16 May 2013 use StringBuilder instead of StringBuilder + StringBuilder s = new StringBuilder(); + for(int i = 0; i < rowvalues.length; i++) { + if (i > 0) { + s.append(", "); + } + s.append(m_classes[i].toString(rowvalues[i])); + } + return s.toString(); + } + + @Override + public Class getColumnClass(int columnIndex) { + return m_classes[columnIndex].getClassValue(); + } + @Override + public String getColumnName(int columnIndex) { + return m_df[columnIndex].Name; + } + @Override + public int getRowCount() { + return m_aRows.size(); + } + @Override + public int getColumnCount() { + return m_df.length; + } + @Override + public Object getValueAt(int row, int column) { + Object [] rowvalues = (Object[]) m_aRows.get(row); + return rowvalues[column]; + } +} diff --git a/src/main/java/com/unicenta/pos/payment/ConfigPaymentPanelEmpty.form b/src/main/java/com/unicenta/pos/payment/ConfigPaymentPanelEmpty.form new file mode 100644 index 0000000..99f1a79 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/ConfigPaymentPanelEmpty.form @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[650, 75]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="650" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="150" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/ConfigPaymentPanelEmpty.java b/src/main/java/com/unicenta/pos/payment/ConfigPaymentPanelEmpty.java new file mode 100644 index 0000000..ac5780b --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/ConfigPaymentPanelEmpty.java @@ -0,0 +1,92 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.pos.forms.AppConfig; +import javax.swing.JPanel; + +/** + * + * @author Mikel Irurita + */ +public class ConfigPaymentPanelEmpty extends javax.swing.JPanel implements PaymentConfiguration { + + /** Creates new form ConfigPaymentPanelGeneric */ + public ConfigPaymentPanelEmpty() { + initComponents(); + } + + /** + * + * @return + */ + @Override + public JPanel getComponent() { + return this; + } + + /** + * + * @param config + */ + @Override + public void loadProperties(AppConfig config) { + + } + + /** + * + * @param config + */ + @Override + public void saveProperties(AppConfig config) { + + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + setBackground(new java.awt.Color(255, 255, 255)); + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setPreferredSize(new java.awt.Dimension(650, 75)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 650, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 150, Short.MAX_VALUE) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/payment/ConfigPaymentPanelGeneric.form b/src/main/java/com/unicenta/pos/payment/ConfigPaymentPanelGeneric.form new file mode 100644 index 0000000..acf4b71 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/ConfigPaymentPanelGeneric.form @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 90]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="jLabel2" max="32767" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jtxtCommerceID" min="-2" max="-2" attributes="0"/> + <Component id="jtxtCommercePwd" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace pref="30" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jtxtCommerceID" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jtxtCommercePwd" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.commerceid" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jtxtCommerceID"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.commercepwd" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JPasswordField" name="jtxtCommercePwd"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/ConfigPaymentPanelGeneric.java b/src/main/java/com/unicenta/pos/payment/ConfigPaymentPanelGeneric.java new file mode 100644 index 0000000..0540918 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/ConfigPaymentPanelGeneric.java @@ -0,0 +1,143 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.AltEncrypter; +import javax.swing.JPanel; + +/** + * + * @author Mikel Irurita + */ +public class ConfigPaymentPanelGeneric extends javax.swing.JPanel implements PaymentConfiguration { + + /** Creates new form ConfigPaymentPanelGeneric */ + public ConfigPaymentPanelGeneric() { + initComponents(); + } + + /** + * + * @return + */ + @Override + public JPanel getComponent() { + return this; + } + + /** + * + * @param config + */ + @Override + public void loadProperties(AppConfig config) { + String sCommerceID = config.getProperty("payment.commerceid"); + String sCommercePass = config.getProperty("payment.commercepassword"); + + if (sCommerceID != null && sCommercePass != null && sCommercePass.startsWith("crypt:")) { + jtxtCommerceID.setText(config.getProperty("payment.commerceid")); + AltEncrypter cypher = new AltEncrypter("cypherkey" + config.getProperty("payment.commerceid")); + jtxtCommercePwd.setText(cypher.decrypt(config.getProperty("payment.commercepassword").substring(6))); + } + } + + /** + * + * @param config + */ + @Override + public void saveProperties(AppConfig config) { + config.setProperty("payment.commerceid", jtxtCommerceID.getText()); + AltEncrypter cypher = new AltEncrypter("cypherkey" + jtxtCommerceID.getText()); + config.setProperty("payment.commercepassword", "crypt:" + cypher.encrypt(new String(jtxtCommercePwd.getPassword()))); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jtxtCommerceID = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + jtxtCommercePwd = new javax.swing.JPasswordField(); + + setBackground(new java.awt.Color(255, 255, 255)); + setPreferredSize(new java.awt.Dimension(400, 90)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.commerceid")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(150, 30)); + + jtxtCommerceID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtCommerceID.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.commercepwd")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(150, 30)); + + jtxtCommercePwd.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtCommercePwd.setPreferredSize(new java.awt.Dimension(200, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtxtCommerceID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtCommercePwd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(30, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtCommerceID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jtxtCommercePwd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JTextField jtxtCommerceID; + private javax.swing.JPasswordField jtxtCommercePwd; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentBank.form b/src/main/java/com/unicenta/pos/payment/JPaymentBank.form new file mode 100644 index 0000000..14ad2fd --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentBank.form @@ -0,0 +1,140 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,49,0,0,2,99"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + </Component> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="com.unicenta.editor.JEditorCurrencyPositive" name="m_jTendered"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.InputCash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="10" y="4" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="m_jMoneyEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="ff" red="cc" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="120" y="4" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentBank.java b/src/main/java/com/unicenta/pos/payment/JPaymentBank.java new file mode 100644 index 0000000..a11fbbe --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentBank.java @@ -0,0 +1,185 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; +import com.unicenta.format.Formats; +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.RoundUtils; +import java.awt.Component; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/** + * + * @author JG uniCenta + */ +public class JPaymentBank extends javax.swing.JPanel implements JPaymentInterface { + + private JPaymentNotifier m_notifier; + + private double m_dPaid; + private double m_dTotal; + + /** Creates new form JPaymentCash + * @param notifier */ + public JPaymentBank(JPaymentNotifier notifier) { + + m_notifier = notifier; + + initComponents(); + + m_jTendered.addPropertyChangeListener("Edition", new RecalculateState()); + m_jTendered.addEditorKeys(m_jKeys); + + + + } + + /** + * + * @param customerext + * @param dTotal + * @param transID + */ + @Override + public void activate(CustomerInfoExt customerext, double dTotal, String transID) { + + m_dTotal = dTotal; + + + m_jTendered.reset(); + m_jTendered.activate(); + + printState(); + + } + + /** + * + * @return + */ + @Override + public PaymentInfo executePayment() { + return new PaymentInfoTicket(m_dPaid, "bank"); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + private void printState() { + + Double value = m_jTendered.getDoubleValue(); + if (value == null) { + m_dPaid = m_dTotal; + } else { + m_dPaid = value; + } + + m_jMoneyEuros.setText(Formats.CURRENCY.formatValue(new Double(m_dPaid))); + + int iCompare = RoundUtils.compare(m_dPaid, m_dTotal); + + // if iCompare > 0 then the payment is not valid + m_notifier.setStatus(m_dPaid > 0.0 && iCompare <= 0, iCompare == 0); + } + + private class RecalculateState implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + printState(); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel2 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel3 = new javax.swing.JPanel(); + m_jTendered = new com.unicenta.editor.JEditorCurrencyPositive(); + jPanel4 = new javax.swing.JPanel(); + jLabel8 = new javax.swing.JLabel(); + m_jMoneyEuros = new javax.swing.JLabel(); + + setLayout(new java.awt.BorderLayout()); + + jPanel2.setLayout(new java.awt.BorderLayout()); + + jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS)); + jPanel1.add(m_jKeys); + + jPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel3.setLayout(new java.awt.BorderLayout()); + + m_jTendered.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + jPanel3.add(m_jTendered, java.awt.BorderLayout.CENTER); + + jPanel1.add(jPanel3); + + jPanel2.add(jPanel1, java.awt.BorderLayout.NORTH); + + add(jPanel2, java.awt.BorderLayout.EAST); + + jPanel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel4.setLayout(null); + + jLabel8.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.InputCash")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(100, 30)); + jPanel4.add(jLabel8); + jLabel8.setBounds(10, 4, 100, 30); + + m_jMoneyEuros.setBackground(new java.awt.Color(204, 255, 51)); + m_jMoneyEuros.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + m_jMoneyEuros.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jMoneyEuros.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jMoneyEuros.setOpaque(true); + m_jMoneyEuros.setPreferredSize(new java.awt.Dimension(180, 30)); + jPanel4.add(m_jMoneyEuros); + m_jMoneyEuros.setBounds(120, 4, 180, 30); + + add(jPanel4, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel8; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JLabel m_jMoneyEuros; + private com.unicenta.editor.JEditorCurrencyPositive m_jTendered; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentCashPos.form b/src/main/java/com/unicenta/pos/payment/JPaymentCashPos.form new file mode 100644 index 0000000..a09fcb7 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentCashPos.form @@ -0,0 +1,230 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 400]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-112,0,0,2,-18"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 70]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="m_jChangeEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JPaymentCashPos_m_jChangeEuros"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="120" y="36" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.ChangeCash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="10" y="36" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.InputCash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="10" y="4" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="m_jMoneyEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="120" y="4" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel6"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 10]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="0"/> + </Layout> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + </Component> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="com.unicenta.editor.JEditorCurrencyPositive" name="m_jTendered"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="1"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentCashPos.java b/src/main/java/com/unicenta/pos/payment/JPaymentCashPos.java new file mode 100644 index 0000000..c1d31aa --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentCashPos.java @@ -0,0 +1,336 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.format.Formats; +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSystem; +import com.unicenta.pos.scripting.ScriptEngine; +import com.unicenta.pos.scripting.ScriptException; +import com.unicenta.pos.scripting.ScriptFactory; +import com.unicenta.pos.util.RoundUtils; +import com.unicenta.pos.util.ThumbNailBuilder; +import java.awt.Component; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.File; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.SwingConstants; + +/** + * + * @author adrianromero + */ +public class JPaymentCashPos extends javax.swing.JPanel implements JPaymentInterface { + + private final JPaymentNotifier m_notifier; + + private double m_dPaid; + private double m_dTotal; + private final Boolean priceWith00; + + /** Creates new form JPaymentCash + * @param notifier + * @param dlSystem */ + public JPaymentCashPos(JPaymentNotifier notifier, DataLogicSystem dlSystem) { + + m_notifier = notifier; + + initComponents(); + + m_jTendered.addPropertyChangeListener("Edition", new RecalculateState()); + m_jTendered.addEditorKeys(m_jKeys); + +// added JDL 11.05.13 + AppConfig m_config = new AppConfig(new File((System.getProperty("user.home")), AppLocal.APP_ID + ".properties")); + m_config.load(); + priceWith00 =("true".equals(m_config.getProperty("till.pricewith00"))); + if (priceWith00) { + // use '00' instead of '.' + m_jKeys.dotIs00(true); + } +// m_config=null; + + String code = dlSystem.getResourceAsXML("payment.cash"); + if (code != null) { + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.BEANSHELL); + script.put("payment", new ScriptPaymentCash(dlSystem)); + script.eval(code); + } catch (ScriptException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.cannotexecute"), e); + msg.show(this); + } + } + + } + + /** + * + * @param customerext + * @param dTotal + * @param transID + */ + @Override + public void activate(CustomerInfoExt customerext, double dTotal, String transID) { + + + m_dTotal = dTotal; + + m_jTendered.reset(); + m_jTendered.activate(); + + printState(); + } + + /** + * + * @return + */ + @Override + public PaymentInfo executePayment() { + if (m_dPaid - m_dTotal >= 0.0) { + // pago completo + return new PaymentInfoCash(m_dTotal, m_dPaid); + } else { + // pago parcial + return new PaymentInfoCash(m_dPaid, m_dPaid); + } + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + private void printState() { + + Double value = m_jTendered.getDoubleValue(); + if (value == null || value == 0.0) { + m_dPaid = m_dTotal; + } else { + m_dPaid = value; + + } + + int iCompare = RoundUtils.compare(m_dPaid, m_dTotal); + + m_jMoneyEuros.setText(Formats.CURRENCY.formatValue(m_dPaid)); + m_jChangeEuros.setText(iCompare > 0 + ? Formats.CURRENCY.formatValue(m_dPaid - m_dTotal) + : null); + + m_notifier.setStatus(m_dPaid > 0.0, iCompare >= 0); + } + + private class RecalculateState implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + printState(); + } + } + + /** + * + */ + public class ScriptPaymentCash { + + private final DataLogicSystem dlSystem; + private final ThumbNailBuilder tnbbutton; + private final AppConfig m_config; + + /** + * + * @param dlSystem + */ + public ScriptPaymentCash(DataLogicSystem dlSystem) { +//added 19.04.13 JDL + AppConfig m_config = new AppConfig(new File((System.getProperty("user.home")), AppLocal.APP_ID + ".properties")); + m_config.load(); + this.m_config = m_config; + + this.dlSystem = dlSystem; + tnbbutton = new ThumbNailBuilder(64, 50, "com/unicenta/images/cash.png"); + } + + /** + * + * @param image + * @param amount + */ + public void addButton(String image, double amount) { + JButton btn = new JButton(); +//added 19.04.13 JDL removal of text on payment buttons if required. + try { + if ((m_config.getProperty("payments.textoverlay")).equals("false")){ + btn.setIcon(new ImageIcon(tnbbutton.getThumbNailText(dlSystem.getResourceAsImage(image),""))); + } else { + btn.setIcon(new ImageIcon(tnbbutton.getThumbNailText(dlSystem.getResourceAsImage(image), Formats.CURRENCY.formatValue(amount)))); + } + } catch (Exception e){ + btn.setIcon(new ImageIcon(tnbbutton.getThumbNailText(dlSystem.getResourceAsImage(image), Formats.CURRENCY.formatValue(amount)))); + } + + btn.setFocusPainted(false); + btn.setFocusable(false); + btn.setRequestFocusEnabled(false); + btn.setHorizontalTextPosition(SwingConstants.CENTER); + btn.setVerticalTextPosition(SwingConstants.BOTTOM); + btn.setMargin(new Insets(2, 2, 2, 2)); + btn.addActionListener(new AddAmount(amount)); + jPanel6.add(btn); + } + } + + + + private class AddAmount implements ActionListener { + private final double amount; + public AddAmount(double amount) { + this.amount = amount; + } + @Override + public void actionPerformed(ActionEvent e) { + Double tendered = m_jTendered.getDoubleValue(); + + if (tendered == null) { + m_jTendered.setDoubleValue(amount); + } else { + m_jTendered.setDoubleValue(tendered + amount); + + } + + printState(); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel5 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + m_jChangeEuros = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + jLabel8 = new javax.swing.JLabel(); + m_jMoneyEuros = new javax.swing.JLabel(); + jPanel6 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel3 = new javax.swing.JPanel(); + m_jTendered = new com.unicenta.editor.JEditorCurrencyPositive(); + + setPreferredSize(new java.awt.Dimension(700, 400)); + setLayout(new java.awt.BorderLayout()); + + jPanel5.setLayout(new java.awt.BorderLayout()); + + jPanel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel4.setPreferredSize(new java.awt.Dimension(450, 70)); + jPanel4.setLayout(null); + + m_jChangeEuros.setBackground(new java.awt.Color(255, 255, 255)); + m_jChangeEuros.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + m_jChangeEuros.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jChangeEuros.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jChangeEuros.setOpaque(true); + m_jChangeEuros.setPreferredSize(new java.awt.Dimension(180, 30)); + jPanel4.add(m_jChangeEuros); + m_jChangeEuros.setBounds(120, 36, 180, 30); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.ChangeCash")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(100, 30)); + jPanel4.add(jLabel6); + jLabel6.setBounds(10, 36, 100, 30); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.InputCash")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(100, 30)); + jPanel4.add(jLabel8); + jLabel8.setBounds(10, 4, 100, 30); + + m_jMoneyEuros.setBackground(new java.awt.Color(255, 255, 255)); + m_jMoneyEuros.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + m_jMoneyEuros.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jMoneyEuros.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jMoneyEuros.setOpaque(true); + m_jMoneyEuros.setPreferredSize(new java.awt.Dimension(180, 30)); + jPanel4.add(m_jMoneyEuros); + m_jMoneyEuros.setBounds(120, 4, 180, 30); + + jPanel5.add(jPanel4, java.awt.BorderLayout.NORTH); + + jPanel6.setPreferredSize(new java.awt.Dimension(450, 10)); + jPanel6.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); + jPanel5.add(jPanel6, java.awt.BorderLayout.CENTER); + + add(jPanel5, java.awt.BorderLayout.CENTER); + + jPanel2.setLayout(new java.awt.BorderLayout()); + + jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS)); + jPanel1.add(m_jKeys); + + jPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel3.setLayout(new java.awt.BorderLayout()); + + m_jTendered.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + jPanel3.add(m_jTendered, java.awt.BorderLayout.CENTER); + + jPanel1.add(jPanel3); + + jPanel2.add(jPanel1, java.awt.BorderLayout.NORTH); + + add(jPanel2, java.awt.BorderLayout.LINE_END); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel8; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JLabel m_jChangeEuros; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JLabel m_jMoneyEuros; + private com.unicenta.editor.JEditorCurrencyPositive m_jTendered; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentCheque.form b/src/main/java/com/unicenta/pos/payment/JPaymentCheque.form new file mode 100644 index 0000000..3e5a15d --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentCheque.form @@ -0,0 +1,138 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,49,0,0,2,-118"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + </Component> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="com.unicenta.editor.JEditorCurrencyPositive" name="m_jTendered"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="16" style="1"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.InputCash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="10" y="4" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="m_jMoneyEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="ff" red="cc" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="120" y="4" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentCheque.java b/src/main/java/com/unicenta/pos/payment/JPaymentCheque.java new file mode 100644 index 0000000..4291425 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentCheque.java @@ -0,0 +1,198 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; +import com.unicenta.format.Formats; +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.RoundUtils; +import java.awt.Component; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.File; + +/** + * + * @author JG uniCenta + */ +public class JPaymentCheque extends javax.swing.JPanel implements JPaymentInterface { + + private JPaymentNotifier m_notifier; + + private double m_dPaid; + private double m_dTotal; + private Boolean priceWith00; + + /** Creates new form JPaymentCash + * @param notifier */ + public JPaymentCheque(JPaymentNotifier notifier) { + + m_notifier = notifier; + + initComponents(); + + m_jTendered.addPropertyChangeListener("Edition", new RecalculateState()); + m_jTendered.addEditorKeys(m_jKeys); + + /* added JDL 11.05.13 + AppConfig m_config = new AppConfig(new File((System.getProperty("user.home")), AppLocal.APP_ID + ".properties")); + m_config.load(); + priceWith00 =("true".equals(m_config.getProperty("till.pricewith00"))); + if (priceWith00) { + // use '00' instead of '.' + m_jKeys.dotIs00(true); + } + m_config=null; +*/ + + + } + + /** + * + * @param customerext + * @param dTotal + * @param transID + */ + @Override + public void activate(CustomerInfoExt customerext, double dTotal, String transID) { + + m_dTotal = dTotal; + + + m_jTendered.reset(); + m_jTendered.activate(); + + printState(); + + } + + /** + * + * @return + */ + @Override + public PaymentInfo executePayment() { + return new PaymentInfoTicket(m_dPaid, "cheque"); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + private void printState() { + + Double value = m_jTendered.getDoubleValue(); + if (value == null) { + m_dPaid = m_dTotal; + } else { + m_dPaid = value; + } + + m_jMoneyEuros.setText(Formats.CURRENCY.formatValue(new Double(m_dPaid))); + + int iCompare = RoundUtils.compare(m_dPaid, m_dTotal); + + // if iCompare > 0 then the payment is not valid + m_notifier.setStatus(m_dPaid > 0.0 && iCompare <= 0, iCompare == 0); + } + + private class RecalculateState implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + printState(); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel2 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel3 = new javax.swing.JPanel(); + m_jTendered = new com.unicenta.editor.JEditorCurrencyPositive(); + jPanel4 = new javax.swing.JPanel(); + jLabel8 = new javax.swing.JLabel(); + m_jMoneyEuros = new javax.swing.JLabel(); + + setLayout(new java.awt.BorderLayout()); + + jPanel2.setLayout(new java.awt.BorderLayout()); + + jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS)); + jPanel1.add(m_jKeys); + + jPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + jPanel3.setLayout(new java.awt.BorderLayout()); + + m_jTendered.setFont(new java.awt.Font("Arial", 1, 16)); // NOI18N + jPanel3.add(m_jTendered, java.awt.BorderLayout.CENTER); + + jPanel1.add(jPanel3); + + jPanel2.add(jPanel1, java.awt.BorderLayout.NORTH); + + add(jPanel2, java.awt.BorderLayout.EAST); + + jPanel4.setLayout(null); + + jLabel8.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.InputCash")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(100, 30)); + jPanel4.add(jLabel8); + jLabel8.setBounds(10, 4, 100, 30); + + m_jMoneyEuros.setBackground(new java.awt.Color(204, 255, 51)); + m_jMoneyEuros.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + m_jMoneyEuros.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jMoneyEuros.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jMoneyEuros.setOpaque(true); + m_jMoneyEuros.setPreferredSize(new java.awt.Dimension(180, 30)); + jPanel4.add(m_jMoneyEuros); + m_jMoneyEuros.setBounds(120, 4, 180, 30); + + add(jPanel4, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel8; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JLabel m_jMoneyEuros; + private com.unicenta.editor.JEditorCurrencyPositive m_jTendered; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentDebt.form b/src/main/java/com/unicenta/pos/payment/JPaymentDebt.form new file mode 100644 index 0000000..2bbfb35 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentDebt.form @@ -0,0 +1,412 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,103,0,0,2,104"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="txtCurdebt" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="txtMaxdebt" max="32767" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel12" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jScrollPane1" max="32767" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jName" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel8" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jMoneyEuros" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0"> + <Component id="jlblMessage" alignment="0" pref="0" max="32767" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="txtCurdate" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace pref="30" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel8" min="-2" max="-2" attributes="0"/> + <Component id="m_jMoneyEuros" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel12" min="-2" max="-2" attributes="0"/> + <Component id="jScrollPane1" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="txtMaxdebt" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="txtCurdebt" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="txtCurdate" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jlblMessage" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.debt" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jMoneyEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="ff" red="cc" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.name" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel12"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.notes" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.maxdebt" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtMaxdebt"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.curdebt" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtCurdebt"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.curdate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtCurdate"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 30]"/> + </Property> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="m_jNotes"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="f0" green="f0" red="f0" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[170, 80]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JPaymentDebt_m_jNotes"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JTextArea" name="jlblMessage"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="0" red="cc" type="rgb"/> + </Property> + <Property name="lineWrap" type="boolean" value="true"/> + <Property name="wrapStyleWord" type="boolean" value="true"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo"> + <EtchetBorder/> + </Border> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[275, 60]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel6"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Last"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jKeysActionPerformed"/> + </Events> + </Component> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="40" max="-2" attributes="0"/> + <Component id="m_jTendered" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="50" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jTendered" min="-2" max="-2" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorCurrencyPositive" name="m_jTendered"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentDebt.java b/src/main/java/com/unicenta/pos/payment/JPaymentDebt.java new file mode 100644 index 0000000..d3f6281 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentDebt.java @@ -0,0 +1,400 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +package com.unicenta.pos.payment; + +import com.unicenta.format.Formats; +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.RoundUtils; +import java.awt.Component; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/** + * + * @author adrianromero + */ +public class JPaymentDebt extends javax.swing.JPanel implements JPaymentInterface { + + private JPaymentNotifier notifier; + private CustomerInfoExt customerext; + private double m_dPaid; + private double m_dTotal; + + /** Creates new form JPaymentDebt + * @param notifier */ + public JPaymentDebt(JPaymentNotifier notifier) { + + this.notifier = notifier; + + initComponents(); + + m_jTendered.addPropertyChangeListener("Edition", new RecalculateState()); + m_jTendered.addEditorKeys(m_jKeys); + + } + + /** + * + * @param customerext + * @param dTotal + * @param transID + */ + @Override + public void activate(CustomerInfoExt customerext, double dTotal, String transID) { + + this.customerext = customerext; + m_dTotal = dTotal; + + m_jTendered.reset(); + + if (customerext == null) { + m_jName.setText(null); + m_jNotes.setText(null); + txtMaxdebt.setText(null); + txtCurdate.setText(null); + txtCurdebt.setText(null); + + m_jKeys.setEnabled(false); + m_jTendered.setEnabled(false); + + + } else { + m_jName.setText(customerext.getName()); + m_jNotes.setText(customerext.getNotes()); + txtMaxdebt.setText(Formats.CURRENCY.formatValue(RoundUtils.getValue(customerext.getMaxdebt()))); + txtCurdate.setText(Formats.DATE.formatValue(customerext.getCurdate())); + txtCurdebt.setText(Formats.CURRENCY.formatValue(RoundUtils.getValue(customerext.getAccdebt()))); + + if (RoundUtils.compare(RoundUtils.getValue(customerext.getAccdebt()), RoundUtils.getValue(customerext.getMaxdebt())) >= 0) { + m_jKeys.setEnabled(false); + m_jTendered.setEnabled(false); + } else { + m_jKeys.setEnabled(true); + m_jTendered.setEnabled(true); + m_jTendered.activate(); + } + } + + printState(); + + } + + /** + * + * @return + */ + @Override + public PaymentInfo executePayment() { + return new PaymentInfoTicket(m_dPaid, "debt"); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + private void printState() { + + if (customerext == null) { + m_jMoneyEuros.setText(null); + jlblMessage.setText(AppLocal.getIntString("message.nocustomernodebt")); + notifier.setStatus(false, false); + } else { + Double value = m_jTendered.getDoubleValue(); + if (value == null || value == 0.0) { + m_dPaid = m_dTotal; + } else { + m_dPaid = value; + } + + m_jMoneyEuros.setText(Formats.CURRENCY.formatValue(m_dPaid)); + + +// if (RoundUtils.compare(RoundUtils.getValue(customerext.getAccdebt()) + m_dPaid, +// RoundUtils.getValue(customerext.getMaxdebt())) >= 0) { + if ((customerext.getAccdebt() + RoundUtils.round(m_dPaid)) - (customerext.getMaxdebt()) > 0) { + jlblMessage.setText(AppLocal.getIntString("message.customerdebtexceded")); + notifier.setStatus(false, false); + } else { + jlblMessage.setText(null); + int iCompare = RoundUtils.compare(m_dPaid, m_dTotal); + // if iCompare > 0 then the payment is not valid + notifier.setStatus(m_dPaid > 0.0 && iCompare <= 0, iCompare == 0); + } + } + } + + private class RecalculateState implements PropertyChangeListener { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + printState(); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel5 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + jLabel8 = new javax.swing.JLabel(); + m_jMoneyEuros = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + jLabel12 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + txtMaxdebt = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + txtCurdebt = new javax.swing.JTextField(); + jLabel6 = new javax.swing.JLabel(); + txtCurdate = new javax.swing.JTextField(); + jScrollPane1 = new javax.swing.JScrollPane(); + m_jNotes = new javax.swing.JTextArea(); + jlblMessage = new javax.swing.JTextArea(); + jPanel6 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel3 = new javax.swing.JPanel(); + m_jTendered = new com.unicenta.editor.JEditorCurrencyPositive(); + + setLayout(new java.awt.BorderLayout()); + + jPanel5.setLayout(new java.awt.BorderLayout()); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.debt")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jMoneyEuros.setBackground(new java.awt.Color(204, 255, 51)); + m_jMoneyEuros.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + m_jMoneyEuros.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jMoneyEuros.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jMoneyEuros.setOpaque(true); + m_jMoneyEuros.setPreferredSize(new java.awt.Dimension(170, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.name")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jName.setEditable(false); + m_jName.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(170, 30)); + + jLabel12.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel12.setText(AppLocal.getIntString("label.notes")); // NOI18N + jLabel12.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.maxdebt")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(100, 30)); + + txtMaxdebt.setEditable(false); + txtMaxdebt.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + txtMaxdebt.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + txtMaxdebt.setPreferredSize(new java.awt.Dimension(170, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.curdebt")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(100, 30)); + + txtCurdebt.setEditable(false); + txtCurdebt.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + txtCurdebt.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + txtCurdebt.setPreferredSize(new java.awt.Dimension(170, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.curdate")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(100, 30)); + + txtCurdate.setEditable(false); + txtCurdate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + txtCurdate.setHorizontalAlignment(javax.swing.JTextField.CENTER); + txtCurdate.setPreferredSize(new java.awt.Dimension(170, 30)); + + m_jNotes.setEditable(false); + m_jNotes.setBackground(new java.awt.Color(240, 240, 240)); + m_jNotes.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jNotes.setBorder(null); + m_jNotes.setEnabled(false); + m_jNotes.setPreferredSize(new java.awt.Dimension(170, 80)); + jScrollPane1.setViewportView(m_jNotes); + + jlblMessage.setEditable(false); + jlblMessage.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jlblMessage.setForeground(new java.awt.Color(204, 0, 102)); + jlblMessage.setLineWrap(true); + jlblMessage.setWrapStyleWord(true); + jlblMessage.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + jlblMessage.setFocusable(false); + jlblMessage.setPreferredSize(new java.awt.Dimension(275, 60)); + jlblMessage.setRequestFocusEnabled(false); + + javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(txtCurdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(txtMaxdebt, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup() + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jMoneyEuros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jlblMessage, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel4Layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(txtCurdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap(30, Short.MAX_VALUE)) + ); + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jMoneyEuros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtMaxdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtCurdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtCurdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jlblMessage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + jPanel5.add(jPanel4, java.awt.BorderLayout.CENTER); + + jPanel6.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + jPanel5.add(jPanel6, java.awt.BorderLayout.PAGE_END); + + add(jPanel5, java.awt.BorderLayout.CENTER); + + jPanel2.setLayout(new java.awt.BorderLayout()); + + jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS)); + + m_jKeys.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jKeysActionPerformed(evt); + } + }); + jPanel1.add(m_jKeys); + + jPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + + m_jTendered.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTendered.setPreferredSize(new java.awt.Dimension(200, 30)); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGap(40, 40, 40) + .addComponent(m_jTendered, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(50, Short.MAX_VALUE)) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jTendered, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + + jPanel1.add(jPanel3); + + jPanel2.add(jPanel1, java.awt.BorderLayout.NORTH); + + add(jPanel2, java.awt.BorderLayout.EAST); + }// </editor-fold>//GEN-END:initComponents + + private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_m_jKeysActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel8; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTextArea jlblMessage; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JLabel m_jMoneyEuros; + private javax.swing.JTextField m_jName; + private javax.swing.JTextArea m_jNotes; + private com.unicenta.editor.JEditorCurrencyPositive m_jTendered; + private javax.swing.JTextField txtCurdate; + private javax.swing.JTextField txtCurdebt; + private javax.swing.JTextField txtMaxdebt; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentFree.form b/src/main/java/com/unicenta/pos/payment/JPaymentFree.form new file mode 100644 index 0000000..3436b5d --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentFree.form @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="148" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="165" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="126" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="131" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="36" style="1"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="message.paymentfree" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentFree.java b/src/main/java/com/unicenta/pos/payment/JPaymentFree.java new file mode 100644 index 0000000..f737f94 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentFree.java @@ -0,0 +1,113 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; + +/** + * + * @author JG uniCenta + */ +public class JPaymentFree extends javax.swing.JPanel implements JPaymentInterface { + + private double m_dTotal; + private JPaymentNotifier m_notifier; + + /** Creates new form JPaymentFree + * @param notifier */ + public JPaymentFree(JPaymentNotifier notifier) { + m_notifier = notifier; + initComponents(); + } + + /** + * + * @param customerext + * @param dTotal + * @param transID + */ + @Override + public void activate(CustomerInfoExt customerext, double dTotal, String transID) { + + m_dTotal = dTotal; + + // m_jTotal.setText(Formats.CURRENCY.formatValue(new Double(m_dTotal))); + + m_notifier.setStatus(true, true); + } + + /** + * + * @return + */ + @Override + public PaymentInfo executePayment() { + return new PaymentInfoFree(m_dTotal); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + + jLabel1.setFont(new java.awt.Font("Arial", 1, 36)); // NOI18N + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setText(AppLocal.getIntString("message.paymentfree")); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(148, 148, 148) + .addComponent(jLabel1) + .addContainerGap(165, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(126, 126, 126) + .addComponent(jLabel1) + .addContainerGap(131, Short.MAX_VALUE)) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentInterface.java b/src/main/java/com/unicenta/pos/payment/JPaymentInterface.java new file mode 100644 index 0000000..036b262 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentInterface.java @@ -0,0 +1,34 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.pos.customers.CustomerInfoExt; +import java.awt.Component; + +/** + * + * @author Adrian + */ +public interface JPaymentInterface { + + public void activate(CustomerInfoExt customerext, double dTotal, String transactionID); + public PaymentInfo executePayment(); + public Component getComponent(); +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentMagcard.form b/src/main/java/com/unicenta/pos/payment/JPaymentMagcard.form new file mode 100644 index 0000000..bdb9e9a --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentMagcard.form @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 50]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,50,0,0,1,-12"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[290, 35]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 45]"/> + </Property> + </Properties> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jlblMessage" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jlblMessage" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jlblMessage"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentMagcard.java b/src/main/java/com/unicenta/pos/payment/JPaymentMagcard.java new file mode 100644 index 0000000..f723090 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentMagcard.java @@ -0,0 +1,162 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import java.awt.BorderLayout; +import java.awt.Component; + +/** + * + * @author adrianromero + */ +public class JPaymentMagcard extends javax.swing.JPanel implements JPaymentInterface { + + private PaymentPanel m_cardpanel; + private final PaymentGateway m_paymentgateway; + private final JPaymentNotifier m_notifier; + private String transaction; + + /** Creates new form JPaymentMagcard + * @param app + * @param notifier */ + public JPaymentMagcard(AppView app, JPaymentNotifier notifier) { + + initComponents(); + + m_notifier = notifier; + + m_paymentgateway = PaymentGatewayFac.getPaymentGateway(app.getProperties()); + + if (m_paymentgateway == null) { + jlblMessage.setText(AppLocal.getIntString("message.nopaymentgateway")); + } else { + // Se van a poder efectuar pagos con tarjeta + m_cardpanel = PaymentPanelFac.getPaymentPanel(app.getProperties().getProperty("payment.magcardreader"), notifier); + add(m_cardpanel.getComponent(), BorderLayout.CENTER); + jlblMessage.setText(null); + // jlblMessage.setText(AppLocal.getIntString("message.nocardreader")); + } + } + + /** + * + * @param customerext + * @param dTotal + * @param transID + */ + @Override + public void activate(CustomerInfoExt customerext, double dTotal, String transID) { + this.transaction = transID; + + if (m_cardpanel == null) { + jlblMessage.setText(AppLocal.getIntString("message.nopaymentgateway")); + m_notifier.setStatus(false, false); + } else { + jlblMessage.setText(null); + m_cardpanel.activate(transaction, dTotal); + } + } + + /** + * + * @return + */ + @Override + public PaymentInfo executePayment() { + + jlblMessage.setText(null); + + PaymentInfoMagcard payinfo = m_cardpanel.getPaymentInfoMagcard(); + + m_paymentgateway.execute(payinfo); + if (payinfo.isPaymentOK()) { + return payinfo; + } else { + jlblMessage.setText(payinfo.getMessage()); + return null; + } + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @param transid + */ + public void setTransaction(String transid){ + transaction = transid; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jlblMessage = new javax.swing.JLabel(); + + setMinimumSize(new java.awt.Dimension(300, 40)); + setPreferredSize(new java.awt.Dimension(500, 50)); + + jPanel1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel1.setMinimumSize(new java.awt.Dimension(290, 35)); + jPanel1.setPreferredSize(new java.awt.Dimension(500, 45)); + + jlblMessage.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + jlblMessage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jlblMessage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jlblMessage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + + add(jPanel1); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JLabel jlblMessage; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentNotifier.java b/src/main/java/com/unicenta/pos/payment/JPaymentNotifier.java new file mode 100644 index 0000000..b3ea141 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentNotifier.java @@ -0,0 +1,38 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + + +package com.unicenta.pos.payment; + +/** + * + * @author adrian + */ +public interface JPaymentNotifier { + +// public void setOKEnabled(boolean bValue); +// public void setAddEnabled(boolean bValue); + + /** + * + * @param isPositive + * @param isComplete + */ + public void setStatus(boolean isPositive, boolean isComplete); +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentPaper.form b/src/main/java/com/unicenta/pos/payment/JPaymentPaper.form new file mode 100644 index 0000000..c937600 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentPaper.form @@ -0,0 +1,254 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,127,0,0,2,88"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="webLblCustomer" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="webLblcustomerName" max="32767" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="10" pref="10" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jMoneyEuros" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jVoucher" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace min="120" pref="120" max="-2" attributes="0"/> + <Component id="voucherID" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jVoucher" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <Component id="m_jMoneyEuros" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="webLblCustomer" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="webLblcustomerName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="voucherID" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="197" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="m_jVoucher"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.voucher" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jVoucher"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jVoucherActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.voucherValue" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jMoneyEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="ff" red="cc" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.label.WebLabel" name="webLblCustomer"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.customer" replaceFormat="AppLocal.getIntString("label.customer")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="1"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.label.WebLabel" name="webLblcustomerName"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.customer" replaceFormat="AppLocal.getIntString("label.customer")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.label.WebLabel" name="voucherID"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.customer" replaceFormat="AppLocal.getIntString("label.customer")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel11"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel12"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + </Component> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="com.unicenta.editor.JEditorCurrencyPositive" name="m_jTendered"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentPaper.java b/src/main/java/com/unicenta/pos/payment/JPaymentPaper.java new file mode 100644 index 0000000..683ce91 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentPaper.java @@ -0,0 +1,348 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2016 uniCenta and part works Openbravo, S.L. +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.format.Formats; +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.customers.DataLogicCustomers; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.util.RoundUtils; +import com.unicenta.pos.voucher.VoucherInfo; +//import com.unicenta.pos.voucher.VoucherInfo; +import java.awt.Component; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public class JPaymentPaper extends javax.swing.JPanel implements JPaymentInterface { + + private final JPaymentNotifier m_notifier; + + private DataLogicSales dlSales; + private DataLogicCustomers dlCustomers; + private ComboBoxValModel m_VoucherModel; + private SentenceList m_sentvouch; + private VoucherInfo m_voucherInfo; + + private double m_dTicket; + private double m_dTotal; + + private final String m_sPaper; // "paperin", "paperout" + private String m_sVoucher; + + /** Creates new form JPaymentTicket + * @param app + * @param notifier + * @param sPaper */ + public JPaymentPaper(AppView app, JPaymentNotifier notifier, String sPaper) { + + m_notifier = notifier; + m_sPaper = sPaper; + m_dTotal=0.0; + + init(app); + + m_jTendered.addPropertyChangeListener("Edition", new RecalculateState()); +// m_jTendered.addEditorKeys(m_jKeys); + + } + private void init(AppView app) { + + try { + dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + dlCustomers = (DataLogicCustomers) app.getBean("com.unicenta.pos.customers.DataLogicCustomers"); + m_sentvouch = dlSales.getVoucherList(); + + initComponents(); + + m_VoucherModel = new ComboBoxValModel(); + List a = m_sentvouch.list(); + a.add(0, null); + + m_VoucherModel = new ComboBoxValModel(a); + m_jVoucher.setModel(m_VoucherModel); + + webLblcustomerName.setText(null); + + } catch (BasicException ex) { + } + } + + /** + * + * @param customerext + * @param dTotal + * @param transID + */ + @Override + public void activate(CustomerInfoExt customerext, double dTotal,String transID) { + + m_dTotal = dTotal; + + m_jTendered.reset(); +// m_jTendered.activate(); + + m_jKeys.setEnabled(false); + m_jTendered.setEnabled(false); + + printState(); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + */ + @Override + public PaymentInfo executePayment() { +/* try { + String id = m_VoucherModel.getSelectedKey().toString(); + VoucherInfo m_voucherInfo = dlCustomers.getVoucherInfo(id); + + } catch (BasicException ex) { + } + if (m_dTicket>m_dTotal){ + return new VoucherPaymentInfo(m_dTotal, m_sPaper,m_voucherInfo.getVoucherNumber()); + }else{ + return new VoucherPaymentInfo(m_dTicket, m_sPaper,m_voucherInfo.getVoucherNumber()); + } +*/ + try { + String id = m_VoucherModel.getSelectedKey().toString(); + VoucherInfo m_voucherInfo1 = dlCustomers.getVoucherInfo(id); + m_sVoucher = m_voucherInfo1.getVoucherNumber(); + } catch (BasicException ex) { + } + return new PaymentInfoTicket(m_dTicket, m_sPaper, m_sVoucher); + + } + + private void printState() { + + Double value = m_jTendered.getDoubleValue(); + if (value == null) { + m_dTicket = 0.0; + } else { + m_dTicket = value; + } + + m_jMoneyEuros.setText(Formats.CURRENCY.formatValue(m_dTicket)); + + int iCompare = RoundUtils.compare(m_dTicket, m_dTotal); + + // it is allowed to pay more + m_notifier.setStatus(m_dTicket > 0.0, iCompare >= 0); + } + + private class RecalculateState implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + printState(); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel4 = new javax.swing.JPanel(); + jLabel5 = new javax.swing.JLabel(); + m_jVoucher = new javax.swing.JComboBox(); + jLabel1 = new javax.swing.JLabel(); + m_jMoneyEuros = new javax.swing.JLabel(); + webLblCustomer = new com.alee.laf.label.WebLabel(); + webLblcustomerName = new com.alee.laf.label.WebLabel(); + voucherID = new com.alee.laf.label.WebLabel(); + jPanel11 = new javax.swing.JPanel(); + jPanel12 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel1 = new javax.swing.JPanel(); + m_jTendered = new com.unicenta.editor.JEditorCurrencyPositive(); + + setLayout(new java.awt.BorderLayout()); + + jLabel5.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + jLabel5.setLabelFor(m_jVoucher); + jLabel5.setText(AppLocal.getIntString("label.voucher")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jVoucher.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jVoucher.setPreferredSize(new java.awt.Dimension(180, 30)); + m_jVoucher.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jVoucherActionPerformed(evt); + } + }); + + jLabel1.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.voucherValue")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jMoneyEuros.setBackground(new java.awt.Color(204, 255, 51)); + m_jMoneyEuros.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + m_jMoneyEuros.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jMoneyEuros.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jMoneyEuros.setOpaque(true); + m_jMoneyEuros.setPreferredSize(new java.awt.Dimension(180, 30)); + + webLblCustomer.setText(AppLocal.getIntString("label.customer")); // NOI18N + webLblCustomer.setToolTipText(""); + webLblCustomer.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + webLblCustomer.setPreferredSize(new java.awt.Dimension(100, 30)); + + webLblcustomerName.setText(AppLocal.getIntString("label.customer")); // NOI18N + webLblcustomerName.setToolTipText(""); + webLblcustomerName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + webLblcustomerName.setPreferredSize(new java.awt.Dimension(100, 30)); + + voucherID.setText(AppLocal.getIntString("label.customer")); // NOI18N + voucherID.setToolTipText(""); + voucherID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + voucherID.setPreferredSize(new java.awt.Dimension(100, 30)); + + javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addComponent(webLblCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(webLblcustomerName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(jPanel4Layout.createSequentialGroup() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addGap(10, 10, 10) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jMoneyEuros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jVoucher, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(jPanel4Layout.createSequentialGroup() + .addGap(120, 120, 120) + .addComponent(voucherID, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jVoucher, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jMoneyEuros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(webLblCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webLblcustomerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(voucherID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(197, 197, 197)) + ); + + add(jPanel4, java.awt.BorderLayout.CENTER); + + jPanel11.setLayout(new java.awt.BorderLayout()); + + jPanel12.setLayout(new javax.swing.BoxLayout(jPanel12, javax.swing.BoxLayout.Y_AXIS)); + jPanel12.add(m_jKeys); + + jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel1.setLayout(new java.awt.BorderLayout()); + + m_jTendered.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jTendered.setPreferredSize(new java.awt.Dimension(130, 30)); + jPanel1.add(m_jTendered, java.awt.BorderLayout.CENTER); + + jPanel12.add(jPanel1); + + jPanel11.add(jPanel12, java.awt.BorderLayout.NORTH); + + add(jPanel11, java.awt.BorderLayout.EAST); + }// </editor-fold>//GEN-END:initComponents + + private void m_jVoucherActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jVoucherActionPerformed + + if (m_VoucherModel.getSelectedKey()!=null){ + try { + + String id = m_VoucherModel.getSelectedKey().toString(); + VoucherInfo m_voucherInfo = dlCustomers.getVoucherInfo(id); + + if (m_voucherInfo != null){ + m_jTendered.setDoubleValue(m_voucherInfo.getAmount()); + m_jMoneyEuros.setText(Formats.CURRENCY.formatValue(m_voucherInfo.getAmount())); + + webLblcustomerName.setText(m_voucherInfo.getCustomerName()); + + printState(); + } + } catch (BasicException ex) { +// ex.printStackTrace(); + } + + } + }//GEN-LAST:event_m_jVoucherActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel5; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel11; + private javax.swing.JPanel jPanel12; + private javax.swing.JPanel jPanel4; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JLabel m_jMoneyEuros; + private com.unicenta.editor.JEditorCurrencyPositive m_jTendered; + private javax.swing.JComboBox m_jVoucher; + private com.alee.laf.label.WebLabel voucherID; + private com.alee.laf.label.WebLabel webLblCustomer; + private com.alee.laf.label.WebLabel webLblcustomerName; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentRefund.form b/src/main/java/com/unicenta/pos/payment/JPaymentRefund.form new file mode 100644 index 0000000..24fda90 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentRefund.form @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace pref="35" max="32767" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="35" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="131" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="155" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="30" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="message.paymentcashneg" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentRefund.java b/src/main/java/com/unicenta/pos/payment/JPaymentRefund.java new file mode 100644 index 0000000..e6c5a5f --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentRefund.java @@ -0,0 +1,115 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; + +/** + * + * @author JG uniCenta + */ +public class JPaymentRefund extends javax.swing.JPanel implements JPaymentInterface { + + private JPaymentNotifier m_notifier; + private double m_dTotal; + + private String m_sName; + + /** Creates new form JPaymentChequeRefund + * @param notifier + * @param sName */ + public JPaymentRefund(JPaymentNotifier notifier, String sName) { + + m_notifier = notifier; + m_sName = sName; + + initComponents(); + } + + /** + * + * @param customerext + * @param dTotal + * @param transID + */ + @Override + public void activate(CustomerInfoExt customerext, double dTotal, String transID) { + m_dTotal = dTotal; + + m_notifier.setStatus(true, true); + } + + /** + * + * @return + */ + @Override + public PaymentInfo executePayment() { + return new PaymentInfoTicket(m_dTotal, m_sName); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 30)); // NOI18N + jLabel1.setText(AppLocal.getIntString("message.paymentcashneg")); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap(35, Short.MAX_VALUE) + .addComponent(jLabel1) + .addContainerGap(35, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(131, 131, 131) + .addComponent(jLabel1) + .addContainerGap(155, Short.MAX_VALUE)) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentSelect.form b/src/main/java/com/unicenta/pos/payment/JPaymentSelect.form new file mode 100644 index 0000000..efc0368 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentSelect.form @@ -0,0 +1,379 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="payment.title" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[750, 127]"/> + </Property> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-15,0,0,2,-10"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="-2" pref="5" max="-2" attributes="0"/> + <Component id="m_jLblTotalEuros1" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jTotalEuros" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel6" min="-2" max="-2" attributes="0"/> + <Group type="102" attributes="0"> + <Component id="m_jLblRemainingEuros" min="-2" pref="120" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jRemaininglEuros" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="m_jButtonAdd" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jButtonRemove" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="4" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jButtonRemove" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="m_jButtonAdd" alignment="1" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Component id="jPanel6" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jLblTotalEuros1" min="-2" max="-2" attributes="0"/> + <Component id="m_jRemaininglEuros" min="-2" max="-2" attributes="0"/> + <Component id="m_jLblRemainingEuros" min="-2" max="-2" attributes="0"/> + <Component id="m_jTotalEuros" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="m_jLblTotalEuros1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.totalcash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jTotalEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="24" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="99" green="8a" id="Button.darkShadow" palette="3" red="7a" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jLblRemainingEuros"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="24" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.remainingcash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[120, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jRemaininglEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="24" style="1"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="99" green="8a" id="Button.darkShadow" palette="3" red="7a" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Container class="javax.swing.JPanel" name="jPanel6"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="verticalGap" type="int" value="0"/> + </Layout> + </Container> + <Component class="javax.swing.JButton" name="m_jButtonRemove"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/btnminus.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Delete Part Payment"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonRemoveActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jButtonAdd"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/btnplus.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Add Part Payment"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonAddActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="nextFocusableComponent" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="m_jTabPayment"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JTabbedPane" name="m_jTabPayment"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + <Property name="tabPlacement" type="int" value="2"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="m_jTabPaymentStateChanged"/> + <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="m_jTabPaymentKeyPressed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jButtonCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jButtonOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 44]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JToggleButton" name="m_jButtonPrint"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/printer24_off.png"/> + </Property> + <Property name="selected" type="boolean" value="true"/> + <Property name="toolTipText" type="java.lang.String" value="Print Receipt"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + <Property name="selectedIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/printer24.png"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonPrintActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Before"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jlblPrinterStatus"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="24" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.printerstatusOn" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentSelect.java b/src/main/java/com/unicenta/pos/payment/JPaymentSelect.java new file mode 100644 index 0000000..d90ee7c --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentSelect.java @@ -0,0 +1,787 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.format.Formats; +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.customers.DataLogicCustomers; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.forms.DataLogicSystem; + +import java.awt.*; +import java.awt.event.KeyEvent; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.swing.JFrame; +import javax.swing.SwingWorker; + +/** + * + * @author adrianromero + */ +public abstract class JPaymentSelect extends javax.swing.JDialog + implements JPaymentNotifier { + + private PaymentInfoList m_aPaymentInfo; + private boolean printselected; + + private boolean accepted; + + private AppView app; + private double m_dTotal; + private CustomerInfoExt customerext; + private DataLogicSystem dlSystem; + private DataLogicCustomers dlCustomers ; + DataLogicSales dlSales; + + // JG 16 May 12 use diamond inference + private Map<String, JPaymentInterface> payments = new HashMap<>(); + private String m_sTransactionID; + private static PaymentInfo returnPayment = null; + + public static PaymentInfo getReturnPayment() { + return returnPayment; + } + + public static void setReturnPayment(PaymentInfo returnPayment) { + JPaymentSelect.returnPayment = returnPayment; + } + + + /** + * Creates new form JPaymentSelect + * + * @param parent + * @param modal + * @param o + */ + protected JPaymentSelect(java.awt.Frame parent, boolean modal, ComponentOrientation o) { + super(parent, modal); + initComponents(); + this.applyComponentOrientation(o); + getRootPane().setDefaultButton(m_jButtonOK); + + } + + /** Creates new form JPaymentSelect + * @param parent + * @param modal + * @param o */ + protected JPaymentSelect(java.awt.Dialog parent, boolean modal, ComponentOrientation o) { + super(parent, modal); + initComponents(); + + m_jButtonPrint.setVisible(true); + this.applyComponentOrientation(o); + if (printselected) { + jlblPrinterStatus.setText("Printer ON"); + } else { + jlblPrinterStatus.setText("Printer OFF"); + } + } + + public void init(AppView app) { + this.app = app; + dlSystem = (DataLogicSystem) app.getBean("com.unicenta.pos.forms.DataLogicSystem"); + dlCustomers= (DataLogicCustomers) app.getBean("com.unicenta.pos.customers.DataLogicCustomers"); + dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + printselected = false; + if (printselected) { + jlblPrinterStatus.setText("Printer ON"); + } else { + jlblPrinterStatus.setText("Printer OFF"); + } + + } + + public void setPrintSelected(boolean value) { + printselected = value; + } + + public boolean isPrintSelected() { + return printselected; + } + + public List<PaymentInfo> getSelectedPayments() { + return m_aPaymentInfo.getPayments(); + } + + public boolean showDialog(double total, CustomerInfoExt customerext,double deposit) { + m_aPaymentInfo = new PaymentInfoList(); + accepted = false; + total -= deposit; + m_dTotal = total; + + this.customerext = customerext; + m_jButtonPrint.setVisible(true); + m_jButtonPrint.setSelected(printselected); + m_jTotalEuros.setText(Formats.CURRENCY.formatValue(m_dTotal)); + + addTabs(); + + // gets the print button state + printselected = m_jButtonPrint.isSelected(); + + // remove all tabs + m_jTabPayment.removeAll(); + + return accepted; + } + + public boolean showDialog(double total, CustomerInfoExt customerext) { + + m_aPaymentInfo = new PaymentInfoList(); + accepted = false; + + m_dTotal = total; + + this.customerext = customerext; + + setPrintSelected(!Boolean.parseBoolean(app.getProperties().getProperty("till.receiptprintoff"))); + m_jButtonPrint.setSelected(printselected); + m_jTotalEuros.setText(Formats.CURRENCY.formatValue(m_dTotal)); + + if (printselected) { + jlblPrinterStatus.setText("Printer ON"); + } else { + jlblPrinterStatus.setText("Printer OFF"); + } + +// N. Deppe 08/11/2018 +// Fix issue where dialog keeps moving lower and lower on the screen +// Get the size of the screen, and center the dialog in the window + Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize(); + Dimension thisDim = this.getSize(); + int x = (screenDim.width - thisDim.width) / 2; + int y = (screenDim.height - thisDim.height) / 2; + this.setLocation(x, y); + + addTabs(); + + if (m_jTabPayment.getTabCount() == 0) { + // No payment panels available + m_aPaymentInfo.add(getDefaultPayment(total)); + accepted = true; + } else { + getRootPane().setDefaultButton(m_jButtonOK); + printState(); + setVisible(true); + } + + // gets the print button state + printselected = m_jButtonPrint.isSelected(); + + // remove all tabs + m_jTabPayment.removeAll(); + + return accepted; + } + + protected abstract void addTabs(); + protected abstract void setStatusPanel(boolean isPositive, boolean isComplete); + protected abstract PaymentInfo getDefaultPayment(double total); + + protected void setOKEnabled(boolean value) { + m_jButtonOK.setEnabled(value); + } + + protected void setAddEnabled(boolean value) { + m_jButtonAdd.setEnabled(value); + } + + protected void addTabPayment(JPaymentCreator jpay) { + if (app.getAppUserView().getUser().hasPermission(jpay.getKey())) { + + JPaymentInterface jpayinterface = payments.get(jpay.getKey()); + if (jpayinterface == null) { + jpayinterface = jpay.createJPayment(); + payments.put(jpay.getKey(), jpayinterface); + } + + jpayinterface.getComponent().applyComponentOrientation(getComponentOrientation()); + m_jTabPayment.addTab( + AppLocal.getIntString(jpay.getLabelKey()), + new javax.swing.ImageIcon(getClass().getResource(jpay.getIconKey())), + jpayinterface.getComponent()); + } + } + + + public interface JPaymentCreator { + public JPaymentInterface createJPayment(); + public String getKey(); + public String getLabelKey(); + public String getIconKey(); + } + + public class JPaymentCashCreator implements JPaymentCreator { + @Override + public JPaymentInterface createJPayment() { + return new JPaymentCashPos(JPaymentSelect.this, dlSystem); + } + @Override + public String getKey() { + return "payment.cash"; } + @Override + public String getLabelKey() { + return "tab.cash"; } + @Override + public String getIconKey() { + return "/com/unicenta/images/cash.png"; } + } + + public class JPaymentChequeCreator implements JPaymentCreator { + @Override + public JPaymentInterface createJPayment() { + return new JPaymentCheque(JPaymentSelect.this); + } + @Override + public String getKey() { + return "payment.cheque"; } + @Override + public String getLabelKey() { + return "tab.cheque"; } + @Override + public String getIconKey() { + return "/com/unicenta/images/cheque.png"; } + } + + public class JPaymentVoucherCreator implements JPaymentCreator { + @Override + public JPaymentInterface createJPayment() { + return new JPaymentVoucher(app, JPaymentSelect.this, "voucherin"); + } + @Override + public String getKey() { + return "payment.voucher"; } + @Override + public String getLabelKey() { + return "tab.voucher"; } + @Override + public String getIconKey() { + return "/com/unicenta/images/voucher.png"; } + } + + public class JPaymentMagcardCreator implements JPaymentCreator { + @Override + public JPaymentInterface createJPayment() { + return new JPaymentMagcard(app, JPaymentSelect.this); + } + @Override + public String getKey() { + return "payment.magcard"; } + @Override + public String getLabelKey() { + return "tab.magcard"; } + @Override + public String getIconKey() { + return "/com/unicenta/images/ccard.png"; } + } + + + + public class JPaymentFreeCreator implements JPaymentCreator { + @Override + public JPaymentInterface createJPayment() { + return new JPaymentFree(JPaymentSelect.this); + } + @Override + public String getKey() { + return "payment.free"; + } + @Override + public String getLabelKey() { + return "tab.free"; + } + @Override + public String getIconKey() { + return "/com/unicenta/images/wallet.png"; + } + } + + public class JPaymentDebtCreator implements JPaymentCreator { + @Override + public JPaymentInterface createJPayment() { + return new JPaymentDebt(JPaymentSelect.this); + } + @Override + public String getKey() { + return "payment.debt"; + } + @Override + public String getLabelKey() { + return "tab.debt"; + } + @Override + public String getIconKey() { + return "/com/unicenta/images/customer.png"; + } + } + + public class JPaymentCashRefundCreator implements JPaymentCreator { + @Override + public JPaymentInterface createJPayment() { + return new JPaymentRefund(JPaymentSelect.this, "cashrefund"); + } + @Override + public String getKey() { + return "refund.cash"; + } + @Override + public String getLabelKey() { + return "tab.cashrefund"; + } + @Override + public String getIconKey() { + return "/com/unicenta/images/cash.png"; + } + } + + public class JPaymentChequeRefundCreator implements JPaymentCreator { + @Override + public JPaymentInterface createJPayment() { + return new JPaymentRefund(JPaymentSelect.this, "chequerefund"); + } + @Override + public String getKey() { + return "refund.cheque"; + } + @Override + public String getLabelKey() { + return "tab.chequerefund"; + } + @Override + public String getIconKey() { + return "/com/unicenta/images/cheque.png"; + } + } + + public class JPaymentVoucherRefundCreator implements JPaymentCreator { + @Override + public JPaymentInterface createJPayment() { + return new JPaymentRefund(JPaymentSelect.this, "voucherout"); + } + @Override + public String getKey() { + return "refund.voucher"; + } + @Override + public String getLabelKey() { + return "tab.voucher"; + } + @Override + public String getIconKey() { + return "/com/unicenta/images/voucher.png"; + } + } + + public class JPaymentMagcardRefundCreator implements JPaymentCreator { + @Override + public JPaymentInterface createJPayment() { + return new JPaymentMagcard(app, JPaymentSelect.this); + } + @Override + public String getKey() { + return "refund.magcard"; + } + @Override + public String getLabelKey() { + return "tab.magcard"; + } + @Override + public String getIconKey() { + return "/com/unicenta/images/ccard.png"; + } + } + + public class JPaymentBankCreator implements JPaymentCreator { + @Override + public JPaymentInterface createJPayment() { + return new JPaymentBank(JPaymentSelect.this); + } + @Override + public String getKey() { + return "payment.bank"; + } + @Override + public String getLabelKey() { + return "tab.bank"; + } + @Override + public String getIconKey() { + return "/com/unicenta/images/bank.png"; + } + } + + public class JPaymentSlipCreator implements JPaymentCreator { + @Override + public JPaymentInterface createJPayment() { + return new JPaymentSlip(JPaymentSelect.this); + } + @Override + public String getKey() { + return "payment.slip"; + } + @Override + public String getLabelKey() { + return "tab.slip"; + } + @Override + public String getIconKey() { + return "/com/unicenta/images/slip.png"; + } + } + + private void printState() { + + m_jRemaininglEuros.setText(Formats.CURRENCY.formatValue( + m_dTotal - m_aPaymentInfo.getTotal())); + m_jButtonRemove.setEnabled(!m_aPaymentInfo.isEmpty()); + m_jTabPayment.setSelectedIndex(0); + ((JPaymentInterface) m_jTabPayment.getSelectedComponent()) + .activate(customerext, + m_dTotal - m_aPaymentInfo.getTotal() + , m_sTransactionID); + } + + protected static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window)parent; + } else { + return getWindow(parent.getParent()); + } + } + + @Override + public void setStatus(boolean isPositive, boolean isComplete) { + + setStatusPanel(isPositive, isComplete); + } + + public void setTransactionID(String tID){ + this.m_sTransactionID = tID; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel4 = new javax.swing.JPanel(); + m_jLblTotalEuros1 = new javax.swing.JLabel(); + m_jTotalEuros = new javax.swing.JLabel(); + m_jLblRemainingEuros = new javax.swing.JLabel(); + m_jRemaininglEuros = new javax.swing.JLabel(); + jPanel6 = new javax.swing.JPanel(); + m_jButtonRemove = new javax.swing.JButton(); + m_jButtonAdd = new javax.swing.JButton(); + jPanel3 = new javax.swing.JPanel(); + m_jTabPayment = new javax.swing.JTabbedPane(); + jPanel5 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + m_jButtonCancel = new javax.swing.JButton(); + m_jButtonOK = new javax.swing.JButton(); + m_jButtonPrint = new javax.swing.JToggleButton(); + jlblPrinterStatus = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("payment.title")); // NOI18N + setPreferredSize(new java.awt.Dimension(750, 127)); + setResizable(false); + + jPanel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + + m_jLblTotalEuros1.setFont(new java.awt.Font("Arial", 0, 24)); // NOI18N + m_jLblTotalEuros1.setText(AppLocal.getIntString("label.totalcash")); // NOI18N + m_jLblTotalEuros1.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jTotalEuros.setFont(new java.awt.Font("Arial", 0, 24)); // NOI18N + m_jTotalEuros.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + m_jTotalEuros.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jTotalEuros.setOpaque(true); + m_jTotalEuros.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jTotalEuros.setRequestFocusEnabled(false); + + m_jLblRemainingEuros.setFont(new java.awt.Font("Arial", 0, 24)); // NOI18N + m_jLblRemainingEuros.setText(AppLocal.getIntString("label.remainingcash")); // NOI18N + m_jLblRemainingEuros.setPreferredSize(new java.awt.Dimension(120, 30)); + + m_jRemaininglEuros.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N + m_jRemaininglEuros.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + m_jRemaininglEuros.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jRemaininglEuros.setOpaque(true); + m_jRemaininglEuros.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jRemaininglEuros.setRequestFocusEnabled(false); + + jPanel6.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 0)); + + m_jButtonRemove.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btnminus.png"))); // NOI18N + m_jButtonRemove.setToolTipText("Delete Part Payment"); + m_jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jButtonRemove.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonRemoveActionPerformed(evt); + } + }); + + m_jButtonAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btnplus.png"))); // NOI18N + m_jButtonAdd.setToolTipText("Add Part Payment"); + m_jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jButtonAdd.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonAddActionPerformed(evt); + } + }); + + org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel4Layout.createSequentialGroup() + .add(5, 5, 5) + .add(m_jLblTotalEuros1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(m_jTotalEuros, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(jPanel4Layout.createSequentialGroup() + .add(m_jLblRemainingEuros, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 120, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(m_jRemaininglEuros, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + .add(18, 18, 18) + .add(m_jButtonAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(m_jButtonRemove, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(4, 4, 4)) + ); + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup() + .add(0, 0, Short.MAX_VALUE) + .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(org.jdesktop.layout.GroupLayout.TRAILING, m_jButtonRemove, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(org.jdesktop.layout.GroupLayout.TRAILING, m_jButtonAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup() + .add(5, 5, 5) + .add(jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(m_jLblTotalEuros1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(m_jRemaininglEuros, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(m_jLblRemainingEuros, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(m_jTotalEuros, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + getContentPane().add(jPanel4, java.awt.BorderLayout.NORTH); + + jPanel3.setNextFocusableComponent(m_jTabPayment); + jPanel3.setLayout(new java.awt.BorderLayout()); + + m_jTabPayment.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + m_jTabPayment.setTabPlacement(javax.swing.JTabbedPane.LEFT); + m_jTabPayment.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTabPayment.setRequestFocusEnabled(false); + m_jTabPayment.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + m_jTabPaymentStateChanged(evt); + } + }); + m_jTabPayment.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + m_jTabPaymentKeyPressed(evt); + } + }); + jPanel3.add(m_jTabPayment, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER); + + jPanel5.setLayout(new java.awt.BorderLayout()); + + m_jButtonCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + m_jButtonCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N + m_jButtonCancel.setFocusPainted(false); + m_jButtonCancel.setFocusable(false); + m_jButtonCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jButtonCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonCancelActionPerformed(evt); + } + }); + jPanel2.add(m_jButtonCancel); + + m_jButtonOK.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jButtonOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + m_jButtonOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + m_jButtonOK.setFocusPainted(false); + m_jButtonOK.setFocusable(false); + m_jButtonOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonOK.setMaximumSize(new java.awt.Dimension(100, 44)); + m_jButtonOK.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jButtonOK.setRequestFocusEnabled(false); + m_jButtonOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonOKActionPerformed(evt); + } + }); + jPanel2.add(m_jButtonOK); + + jPanel5.add(jPanel2, java.awt.BorderLayout.LINE_END); + + m_jButtonPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/printer24_off.png"))); // NOI18N + m_jButtonPrint.setSelected(true); + m_jButtonPrint.setToolTipText("Print Receipt"); + m_jButtonPrint.setFocusPainted(false); + m_jButtonPrint.setFocusable(false); + m_jButtonPrint.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonPrint.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jButtonPrint.setRequestFocusEnabled(false); + m_jButtonPrint.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/printer24.png"))); // NOI18N + m_jButtonPrint.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonPrintActionPerformed(evt); + } + }); + jPanel5.add(m_jButtonPrint, java.awt.BorderLayout.LINE_START); + + jlblPrinterStatus.setFont(new java.awt.Font("Arial", 0, 24)); // NOI18N + jlblPrinterStatus.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jlblPrinterStatus.setText(bundle.getString("label.printerstatusOn")); // NOI18N + jPanel5.add(jlblPrinterStatus, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel5, java.awt.BorderLayout.SOUTH); + + setSize(new java.awt.Dimension(758, 497)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void m_jButtonRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonRemoveActionPerformed + + m_aPaymentInfo.removeLast(); + printState(); + + }//GEN-LAST:event_m_jButtonRemoveActionPerformed + + private void m_jButtonAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonAddActionPerformed + + PaymentInfo returnPayment = ( + (JPaymentInterface) m_jTabPayment.getSelectedComponent()) + .executePayment(); + if (returnPayment != null) { + m_aPaymentInfo.add(returnPayment); + printState(); + } + + }//GEN-LAST:event_m_jButtonAddActionPerformed + + private void m_jTabPaymentStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_m_jTabPaymentStateChanged + + if (m_jTabPayment.getSelectedComponent() != null) { + ((JPaymentInterface) m_jTabPayment.getSelectedComponent()) + .activate(customerext + , m_dTotal - m_aPaymentInfo.getTotal() + , m_sTransactionID); + m_jRemaininglEuros.setText( + Formats.CURRENCY.formatValue( + m_dTotal - m_aPaymentInfo.getTotal())); + } + + }//GEN-LAST:event_m_jTabPaymentStateChanged + + private void m_jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonOKActionPerformed + + SwingWorker worker = new SwingWorker() { + @Override + protected Object doInBackground() throws Exception { + m_jButtonOK.setEnabled(false); + setReturnPayment(((JPaymentInterface) m_jTabPayment.getSelectedComponent()).executePayment()); + return null; + } + + @Override + public void done() { + m_jButtonOK.setEnabled(true); + m_jButtonCancel.setEnabled(true); + if (returnPayment != null) { + m_aPaymentInfo.add(returnPayment); + accepted = true; + dispose(); + } + } + }; + + worker.execute(); + }//GEN-LAST:event_m_jButtonOKActionPerformed + + private void m_jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_m_jButtonCancelActionPerformed + + private void m_jButtonPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonPrintActionPerformed + if (!m_jButtonPrint.isSelected()) { + jlblPrinterStatus.setText("Printer OFF"); + } else { + jlblPrinterStatus.setText("Printer ON"); + } + }//GEN-LAST:event_m_jButtonPrintActionPerformed + + private void m_jTabPaymentKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_m_jTabPaymentKeyPressed + + if( evt.getKeyCode() == KeyEvent.VK_F1 ) { + + } else if ( evt.getKeyCode() == KeyEvent.VK_F2 ) { + + } + }//GEN-LAST:event_m_jTabPaymentKeyPressed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JLabel jlblPrinterStatus; + private javax.swing.JButton m_jButtonAdd; + private javax.swing.JButton m_jButtonCancel; + private javax.swing.JButton m_jButtonOK; + private javax.swing.JToggleButton m_jButtonPrint; + private javax.swing.JButton m_jButtonRemove; + private javax.swing.JLabel m_jLblRemainingEuros; + private javax.swing.JLabel m_jLblTotalEuros1; + private javax.swing.JLabel m_jRemaininglEuros; + private javax.swing.JTabbedPane m_jTabPayment; + private javax.swing.JLabel m_jTotalEuros; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentSelectCustomer.java b/src/main/java/com/unicenta/pos/payment/JPaymentSelectCustomer.java new file mode 100644 index 0000000..4c718db --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentSelectCustomer.java @@ -0,0 +1,97 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import java.awt.*; + +/** + * + * @author adrianromero + */ +public class JPaymentSelectCustomer extends JPaymentSelect { + + /** Creates new form JPaymentSelect + * @param parent + * @param modal + * @param o */ + protected JPaymentSelectCustomer(java.awt.Frame parent, boolean modal, ComponentOrientation o) { + super(parent, modal, o); + } + /** Creates new form JPaymentSelect + * @param parent + * @param modal + * @param o */ + protected JPaymentSelectCustomer(java.awt.Dialog parent, boolean modal, ComponentOrientation o) { + super(parent, modal, o); + } + + /** + * + * @param parent + * @return + */ + public static JPaymentSelect getDialog(Component parent) { + + Window window = getWindow(parent); + + if (window instanceof Frame) { + return new JPaymentSelectCustomer((Frame) window, true, parent.getComponentOrientation()); + } else { + return new JPaymentSelectCustomer((Dialog) window, true, parent.getComponentOrientation()); + } + } + + /** + * + */ + @Override + protected void addTabs() { +// Bank Payment Receipt - Thanks Steve Clough! August 2011 + addTabPayment(new JPaymentSelect.JPaymentCashCreator()); + addTabPayment(new JPaymentSelect.JPaymentChequeCreator()); + addTabPayment(new JPaymentSelect.JPaymentVoucherCreator()); + addTabPayment(new JPaymentSelect.JPaymentBankCreator()); + addTabPayment(new JPaymentSelect.JPaymentMagcardCreator()); + addTabPayment(new JPaymentSelect.JPaymentSlipCreator()); + } + + /** + * + * @param isPositive + * @param isComplete + */ + @Override + protected void setStatusPanel(boolean isPositive, boolean isComplete) { + + setAddEnabled(isPositive && !isComplete); + setOKEnabled(isPositive); + } + + /** + * + * @param total + * @return + */ + @Override + protected PaymentInfo getDefaultPayment(double total) { +// return new PaymentInfoCash_original(total, total); + return new PaymentInfoCash(total, total); + } +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentSelectReceipt.java b/src/main/java/com/unicenta/pos/payment/JPaymentSelectReceipt.java new file mode 100644 index 0000000..78a49d6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentSelectReceipt.java @@ -0,0 +1,100 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import java.awt.*; + +/** + * + * @author adrianromero + */ +public class JPaymentSelectReceipt extends JPaymentSelect { + + /** Creates new form JPaymentSelect + * @param parent + * @param modal + * @param o */ + protected JPaymentSelectReceipt(java.awt.Frame parent, boolean modal, ComponentOrientation o) { + super(parent, modal, o); + } + /** Creates new form JPaymentSelect + * @param parent + * @param o + * @param modal */ + protected JPaymentSelectReceipt(java.awt.Dialog parent, boolean modal, ComponentOrientation o) { + super(parent, modal, o); + } + + /** + * + * @param parent + * @return + */ + public static JPaymentSelect getDialog(Component parent) { + + Window window = getWindow(parent); + + if (window instanceof Frame) { + return new JPaymentSelectReceipt((Frame) window, true, parent.getComponentOrientation()); + } else { + return new JPaymentSelectReceipt((Dialog) window, true, parent.getComponentOrientation()); + } + } + + /** + * + */ + @Override + protected void addTabs() { + + addTabPayment(new JPaymentSelect.JPaymentCashCreator()); + addTabPayment(new JPaymentSelect.JPaymentChequeCreator()); + addTabPayment(new JPaymentSelect.JPaymentVoucherCreator()); + addTabPayment(new JPaymentSelect.JPaymentMagcardCreator()); + addTabPayment(new JPaymentSelect.JPaymentFreeCreator()); + addTabPayment(new JPaymentSelect.JPaymentDebtCreator()); +// JG Added 1 Dec 13 + addTabPayment(new JPaymentSelect.JPaymentBankCreator()); + addTabPayment(new JPaymentSelect.JPaymentSlipCreator()); + } + + /** + * + * @param isPositive + * @param isComplete + */ + @Override + protected void setStatusPanel(boolean isPositive, boolean isComplete) { + + setAddEnabled(isPositive && !isComplete); + setOKEnabled(isComplete); + } + + /** + * + * @param total + * @return + */ + @Override + protected PaymentInfo getDefaultPayment(double total) { +// return new PaymentInfoCash_original(total, total); + return new PaymentInfoCash(total, total); + } +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentSelectRefund.java b/src/main/java/com/unicenta/pos/payment/JPaymentSelectRefund.java new file mode 100644 index 0000000..dc9e367 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentSelectRefund.java @@ -0,0 +1,95 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import java.awt.*; + +/** + * + * @author adrianromero + */ +public class JPaymentSelectRefund extends JPaymentSelect { + + /** Creates new form JPaymentSelect + * @param parent + * @param modal + * @param o */ + protected JPaymentSelectRefund(java.awt.Frame parent, boolean modal, ComponentOrientation o) { + super(parent, modal, o); + } + /** Creates new form JPaymentSelect + * @param parent + * @param modal + * @param o */ + protected JPaymentSelectRefund(java.awt.Dialog parent, boolean modal, ComponentOrientation o) { + super(parent, modal, o); + } + + /** + * + * @param parent + * @return + */ + public static JPaymentSelect getDialog(Component parent) { + + Window window = getWindow(parent); + + if (window instanceof Frame) { + return new JPaymentSelectRefund((Frame) window, true, parent.getComponentOrientation()); + } else { + return new JPaymentSelectRefund((Dialog) window, true, parent.getComponentOrientation()); + } + } + + /** + * + */ + @Override + protected void addTabs() { + + addTabPayment(new JPaymentSelect.JPaymentCashRefundCreator()); + addTabPayment(new JPaymentSelect.JPaymentChequeRefundCreator()); + addTabPayment(new JPaymentSelect.JPaymentVoucherRefundCreator()); + addTabPayment(new JPaymentSelect.JPaymentMagcardRefundCreator()); +// setHeaderVisible(false); + } + + /** + * + * @param isPositive + * @param isComplete + */ + @Override + protected void setStatusPanel(boolean isPositive, boolean isComplete) { + + setAddEnabled(isPositive && !isComplete); + setOKEnabled(isComplete); + } + + /** + * + * @param total + * @return + */ + @Override + protected PaymentInfo getDefaultPayment(double total) { + return new PaymentInfoTicket(total, "cashrefund"); + } +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentSlip.form b/src/main/java/com/unicenta/pos/payment/JPaymentSlip.form new file mode 100644 index 0000000..14ad2fd --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentSlip.form @@ -0,0 +1,140 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,49,0,0,2,99"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + </Component> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="com.unicenta.editor.JEditorCurrencyPositive" name="m_jTendered"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.InputCash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="10" y="4" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="m_jMoneyEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="ff" red="cc" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="120" y="4" width="-1" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentSlip.java b/src/main/java/com/unicenta/pos/payment/JPaymentSlip.java new file mode 100644 index 0000000..ddf9c07 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentSlip.java @@ -0,0 +1,180 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; +import com.unicenta.format.Formats; +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.RoundUtils; +import java.awt.Component; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/** + * + * @author JG uniCenta + */ +public class JPaymentSlip extends javax.swing.JPanel implements JPaymentInterface { + + private final JPaymentNotifier m_notifier; + + private double m_dPaid; + private double m_dTotal; + + /** Creates new form JPaymentCash + * @param notifier */ + public JPaymentSlip(JPaymentNotifier notifier) { + + m_notifier = notifier; + + initComponents(); + + m_jTendered.addPropertyChangeListener("Edition", new RecalculateState()); + m_jTendered.addEditorKeys(m_jKeys); + + } + + /** + * + * @param customerext + * @param dTotal + * @param transID + */ + @Override + public void activate(CustomerInfoExt customerext, double dTotal, String transID) { + + m_dTotal = dTotal; + m_jTendered.reset(); + m_jTendered.activate(); + + printState(); + + } + + /** + * + * @return + */ + @Override + public PaymentInfo executePayment() { + return new PaymentInfoTicket(m_dPaid, "slip"); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + private void printState() { + + Double value = m_jTendered.getDoubleValue(); + if (value == null) { + m_dPaid = m_dTotal; + } else { + m_dPaid = value; + } + + m_jMoneyEuros.setText(Formats.CURRENCY.formatValue(m_dPaid)); + + int iCompare = RoundUtils.compare(m_dPaid, m_dTotal); + + m_notifier.setStatus(m_dPaid > 0.0 && iCompare <= 0, iCompare == 0); + } + + private class RecalculateState implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + printState(); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel2 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel3 = new javax.swing.JPanel(); + m_jTendered = new com.unicenta.editor.JEditorCurrencyPositive(); + jPanel4 = new javax.swing.JPanel(); + jLabel8 = new javax.swing.JLabel(); + m_jMoneyEuros = new javax.swing.JLabel(); + + setLayout(new java.awt.BorderLayout()); + + jPanel2.setLayout(new java.awt.BorderLayout()); + + jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS)); + jPanel1.add(m_jKeys); + + jPanel3.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel3.setLayout(new java.awt.BorderLayout()); + + m_jTendered.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + jPanel3.add(m_jTendered, java.awt.BorderLayout.CENTER); + + jPanel1.add(jPanel3); + + jPanel2.add(jPanel1, java.awt.BorderLayout.NORTH); + + add(jPanel2, java.awt.BorderLayout.EAST); + + jPanel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel4.setLayout(null); + + jLabel8.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.InputCash")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(100, 30)); + jPanel4.add(jLabel8); + jLabel8.setBounds(10, 4, 100, 30); + + m_jMoneyEuros.setBackground(new java.awt.Color(204, 255, 51)); + m_jMoneyEuros.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + m_jMoneyEuros.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jMoneyEuros.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jMoneyEuros.setOpaque(true); + m_jMoneyEuros.setPreferredSize(new java.awt.Dimension(180, 30)); + jPanel4.add(m_jMoneyEuros); + m_jMoneyEuros.setBounds(120, 4, 180, 30); + + add(jPanel4, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel8; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JLabel m_jMoneyEuros; + private com.unicenta.editor.JEditorCurrencyPositive m_jTendered; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentVoucher.form b/src/main/java/com/unicenta/pos/payment/JPaymentVoucher.form new file mode 100644 index 0000000..5188710 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentVoucher.form @@ -0,0 +1,292 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-101,0,0,2,88"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="10" pref="10" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jMoneyEuros" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jVoucher" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="webLblCustomer" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="webLblcustomerName" max="32767" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="voucherStatus" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jVoucher" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + <Component id="voucherStatus" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <Component id="m_jMoneyEuros" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="webLblCustomer" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="webLblcustomerName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" pref="33" max="-2" attributes="0"/> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="m_jVoucher"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.voucher" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jVoucher"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jVoucherActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.voucherValue" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jMoneyEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="ff" red="cc" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.label.WebLabel" name="webLblCustomer"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.customer" replaceFormat="AppLocal.getIntString("label.customer")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.label.WebLabel" name="webLblcustomerName"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.customer" replaceFormat="AppLocal.getIntString("label.customer")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.label.WebLabel" name="voucherStatus"> + <Properties> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.voucherStatus" replaceFormat="AppLocal.getIntString("label.voucherStatus")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="m_jVoucher"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.voucherStatus" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="text" type="java.lang.String" value="jButton1"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel11"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel12"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + </Component> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="com.unicenta.editor.JEditorCurrencyPositive" name="m_jTendered"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/JPaymentVoucher.java b/src/main/java/com/unicenta/pos/payment/JPaymentVoucher.java new file mode 100644 index 0000000..ff1895e --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/JPaymentVoucher.java @@ -0,0 +1,391 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta and part works Openbravo, S.L. +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.format.Formats; +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.customers.DataLogicCustomers; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.util.RoundUtils; +import com.unicenta.pos.voucher.VoucherInfo; +import lombok.extern.slf4j.Slf4j; + +import java.awt.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.List; + +/** + * @author JG uniCenta + */ +@Slf4j +public class JPaymentVoucher extends javax.swing.JPanel implements JPaymentInterface { + + private final JPaymentNotifier m_notifier; + + private DataLogicSales dlSales; + private DataLogicCustomers dlCustomers; + private ComboBoxValModel m_VoucherModel; + private SentenceList m_sentvouch; + private VoucherInfo m_voucherInfo; + + private double m_dTicket; + private double m_dTotal; + + private final String m_sVoucher; // "voucherin", "voucherout" + private String m_sVoucher1; + + /** + * Creates new form JPaymentTicket + * + * @param app + * @param notifier + * @param sVoucher + */ + public JPaymentVoucher(AppView app, JPaymentNotifier notifier, String sVoucher) { + + m_notifier = notifier; + m_sVoucher = sVoucher; + m_dTotal = 0.0; + + init(app); + + m_jTendered.addPropertyChangeListener("Edition", new RecalculateState()); + + } + + private void init(AppView app) { + + dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + dlCustomers = (DataLogicCustomers) app.getBean("com.unicenta.pos.customers.DataLogicCustomers"); + initComponents(); + + webLblcustomerName.setText(null); + } + + /** + * @param customerext + * @param dTotal + * @param transID + */ + @Override + public void activate(CustomerInfoExt customerext, double dTotal, String transID) { + + m_dTotal = dTotal; + + m_jTendered.reset(); + + m_jKeys.setEnabled(false); + m_jTendered.setEnabled(false); + m_VoucherModel = new ComboBoxValModel(); + m_sentvouch = dlSales.getVoucherList(); + List a = null; + try { + a = m_sentvouch.list(); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + m_VoucherModel = new ComboBoxValModel(a); + m_jVoucher.setModel(m_VoucherModel); + + printState(); + } + + /** + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * @return + */ + @Override + public PaymentInfo executePayment() { + + try { + String id = m_VoucherModel.getSelectedKey().toString(); + VoucherInfo m_voucherInfo1 = dlCustomers.getVoucherInfo(id); + m_sVoucher1 = m_voucherInfo1.getVoucherNumber(); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + return new PaymentInfoTicket(m_dTicket, m_sVoucher, m_sVoucher1); + + } + + public void confirmVoucher() { + List a = null; + try { + a = m_sentvouch.list(); + +// a.forEach(System.out::println); + a.remove(m_jVoucher.getSelectedIndex()); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + + m_VoucherModel = new ComboBoxValModel(a); + m_jVoucher.setModel(m_VoucherModel); + } + + private void printState() { + + Double value = m_jTendered.getDoubleValue(); + if (value == null) { + m_dTicket = 0.0; + } else { + m_dTicket = value; + } + + m_jMoneyEuros.setText(Formats.CURRENCY.formatValue(m_dTicket)); + + int iCompare = RoundUtils.compare(m_dTicket, m_dTotal); + + m_notifier.setStatus(m_dTicket > 0.0, iCompare >= 0); + + } + + private class RecalculateState implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + printState(); + } + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel4 = new javax.swing.JPanel(); + jLabel5 = new javax.swing.JLabel(); + m_jVoucher = new javax.swing.JComboBox(); + jLabel1 = new javax.swing.JLabel(); + m_jMoneyEuros = new javax.swing.JLabel(); + webLblCustomer = new com.alee.laf.label.WebLabel(); + webLblcustomerName = new com.alee.laf.label.WebLabel(); + voucherStatus = new com.alee.laf.label.WebLabel(); + jLabel6 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); + jPanel11 = new javax.swing.JPanel(); + jPanel12 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel1 = new javax.swing.JPanel(); + m_jTendered = new com.unicenta.editor.JEditorCurrencyPositive(); + + setLayout(new java.awt.BorderLayout()); + + jLabel5.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + jLabel5.setLabelFor(m_jVoucher); + jLabel5.setText(AppLocal.getIntString("label.voucher")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jVoucher.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jVoucher.setPreferredSize(new java.awt.Dimension(180, 30)); + m_jVoucher.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jVoucherActionPerformed(evt); + } + }); + + jLabel1.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.voucherValue")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jMoneyEuros.setBackground(new java.awt.Color(204, 255, 51)); + m_jMoneyEuros.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + m_jMoneyEuros.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jMoneyEuros.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jMoneyEuros.setOpaque(true); + m_jMoneyEuros.setPreferredSize(new java.awt.Dimension(180, 30)); + + webLblCustomer.setText(AppLocal.getIntString("label.customer")); // NOI18N + webLblCustomer.setToolTipText(""); + webLblCustomer.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + webLblCustomer.setPreferredSize(new java.awt.Dimension(100, 30)); + + webLblcustomerName.setText(AppLocal.getIntString("label.customer")); // NOI18N + webLblcustomerName.setToolTipText(""); + webLblcustomerName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + webLblcustomerName.setPreferredSize(new java.awt.Dimension(100, 30)); + + voucherStatus.setText(AppLocal.getIntString("label.voucherStatus")); // NOI18N + voucherStatus.setToolTipText(""); + voucherStatus.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + voucherStatus.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + jLabel6.setLabelFor(m_jVoucher); + jLabel6.setText(AppLocal.getIntString("label.voucherStatus")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(100, 30)); + + jButton1.setText("jButton1"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addGap(10, 10, 10) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jMoneyEuros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jVoucher, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jButton1))) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(webLblCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(webLblcustomerName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(voucherStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) + ); + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jVoucher, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(voucherStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jMoneyEuros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(webLblCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webLblcustomerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(33, 33, 33) + .addComponent(jButton1) + .addContainerGap()) + ); + + add(jPanel4, java.awt.BorderLayout.CENTER); + + jPanel11.setLayout(new java.awt.BorderLayout()); + + jPanel12.setLayout(new javax.swing.BoxLayout(jPanel12, javax.swing.BoxLayout.Y_AXIS)); + jPanel12.add(m_jKeys); + + jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel1.setLayout(new java.awt.BorderLayout()); + + m_jTendered.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jTendered.setPreferredSize(new java.awt.Dimension(130, 30)); + jPanel1.add(m_jTendered, java.awt.BorderLayout.CENTER); + + jPanel12.add(jPanel1); + + jPanel11.add(jPanel12, java.awt.BorderLayout.NORTH); + + add(jPanel11, java.awt.BorderLayout.EAST); + }// </editor-fold>//GEN-END:initComponents + + private void m_jVoucherActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jVoucherActionPerformed + + m_jMoneyEuros.setText(null); + + if (m_VoucherModel.getSelectedKey() != null) { + try { + String id = m_VoucherModel.getSelectedKey().toString(); + VoucherInfo m_voucherInfo = dlCustomers.getVoucherInfo(id); + + if (m_voucherInfo != null) { + m_jTendered.setDoubleValue(m_voucherInfo.getAmount()); + m_jMoneyEuros.setText(Formats.CURRENCY.formatValue(m_voucherInfo.getAmount())); + webLblcustomerName.setText(m_voucherInfo.getCustomerName()); + + if ("A".equals(m_voucherInfo.getStatus())) { + voucherStatus.setText("Available"); + } else if ("D".equals(m_voucherInfo.getStatus())) { + voucherStatus.setText("Redeemed"); + } + + printState(); + + } else { + voucherStatus.setText("Error"); + webLblcustomerName.setText(""); + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + + } + }//GEN-LAST:event_m_jVoucherActionPerformed + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + + }//GEN-LAST:event_jButton1ActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel11; + private javax.swing.JPanel jPanel12; + private javax.swing.JPanel jPanel4; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JLabel m_jMoneyEuros; + private com.unicenta.editor.JEditorCurrencyPositive m_jTendered; + private javax.swing.JComboBox m_jVoucher; + private com.alee.laf.label.WebLabel voucherStatus; + private com.alee.laf.label.WebLabel webLblCustomer; + private com.alee.laf.label.WebLabel webLblcustomerName; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/payment/MagCardReader.java b/src/main/java/com/unicenta/pos/payment/MagCardReader.java new file mode 100644 index 0000000..61fe648 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/MagCardReader.java @@ -0,0 +1,40 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +public interface MagCardReader { + + public String getReaderName(); + + public void reset(); + public void appendChar(char c); + public boolean isComplete(); + + public String getHolderName(); + public String getCardNumber(); + public String getExpirationDate(); + + public String getTrack1(); + public String getTrack2(); + public String getTrack3(); + + public String getEncryptedCardData(); + public String getEncryptionKey(); +} diff --git a/src/main/java/com/unicenta/pos/payment/MagCardReaderFac.java b/src/main/java/com/unicenta/pos/payment/MagCardReaderFac.java new file mode 100644 index 0000000..de83896 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/MagCardReaderFac.java @@ -0,0 +1,43 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +/** + * + * @author adrianromero + */ +public class MagCardReaderFac { + + /** Creates a new instance of MagCarReaderFac */ + private MagCardReaderFac() { + } + + public static MagCardReader getMagCardReader(String sReader) { +// JG 16 May 12 use switch + switch (sReader) { + case "Intelligent": + return new MagCardReaderIntelligent(); + case "Generic": + return new MagCardReaderGeneric(); + default: + return null; + } + } +} diff --git a/src/main/java/com/unicenta/pos/payment/MagCardReaderGeneric.java b/src/main/java/com/unicenta/pos/payment/MagCardReaderGeneric.java new file mode 100644 index 0000000..20488eb --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/MagCardReaderGeneric.java @@ -0,0 +1,242 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.pos.util.LuhnAlgorithm; +import com.unicenta.pos.util.StringUtils; +import java.util.ArrayList; +import java.util.List; + +public class MagCardReaderGeneric implements MagCardReader { + + private String m_sHolderName; + private String m_sCardNumber; + private String m_sExpirationDate; + private StringBuffer track1; + private StringBuffer track2; + private StringBuffer track3; + private static final int READING_STARTSENTINEL1 = 0; + private static final int READING_STARTSENTINEL2 = 1; + private static final int READING_STARTSENTINEL3 = 2; + private static final int READING_CARDTYPE = 3; + private static final int READING_TRACK1 = 4; + private static final int READING_TRACK2 = 5; + private static final int READING_TRACK3 = 6; + private static final int READING_END = 7; + private int m_iAutomState; + private List m_aTrack1; + private List m_aTrack2; + private List m_aTrack3; + private StringBuffer m_sField; + private char m_cCardType; + + private String m_encryptedCardData; + private String m_encryptionKey; + + /** + * Creates a new instance of GenericMagCardReader + */ + public MagCardReaderGeneric() { + reset(); + } + + public String getReaderName() { + return "Generic magnetic card reader"; + } + + public void reset() { + m_aTrack1 = null; + m_aTrack2 = null; + m_aTrack3 = null; + m_sField = null; + m_cCardType = ' '; + + m_sHolderName = null; + m_sCardNumber = null; + m_sExpirationDate = null; + + + m_encryptedCardData = null; + m_encryptionKey = null; + + + m_iAutomState = READING_STARTSENTINEL1; + } + + public void appendChar(char c) { + // Mastercard + // %B1111222233334444^PUBLIC/JOHN?;1111222233334444=99121010000000000000? + // *---------------- ----------- ----*** + // Visa + // %B1111222233334444^PUBLIC/JOHN^9912101xxxxxxxxxxxxx?;1111222233334444=9912101xxxxxxxxxxxxx? + // *---------------- ----------- ---- *** + + if (c == '%') { // && READING_STARTSENTINEL1; + track1 = new StringBuffer(); + track2 = new StringBuffer(); + track3 = new StringBuffer(); + m_aTrack1 = new ArrayList(); + m_aTrack2 = null; + m_aTrack3 = null; + m_sField = new StringBuffer(); + m_cCardType = ' '; + m_sHolderName = null; + m_sCardNumber = null; + m_sExpirationDate = null; + m_iAutomState = READING_CARDTYPE; + } else if (m_iAutomState == READING_CARDTYPE) { + m_cCardType = c; + m_iAutomState = READING_TRACK1; + } else if (c == ';' && m_iAutomState == READING_STARTSENTINEL2) { + m_aTrack2 = new ArrayList(); + m_sField = new StringBuffer(); + m_iAutomState = READING_TRACK2; + } else if (c == ';' && m_iAutomState == READING_STARTSENTINEL3) { + m_aTrack3 = new ArrayList(); + m_sField = new StringBuffer(); + m_iAutomState = READING_TRACK3; + + } else if (c == '^' && m_iAutomState == READING_TRACK1) { + m_aTrack1.add(m_sField.toString()); + m_sField = new StringBuffer(); + } else if (c == '=' && m_iAutomState == READING_TRACK2) { + m_aTrack2.add(m_sField.toString()); + m_sField = new StringBuffer(); + } else if (c == '=' && m_iAutomState == READING_TRACK3) { + m_aTrack3.add(m_sField.toString()); + m_sField = new StringBuffer(); + + } else if (c == '?' && m_iAutomState == READING_TRACK1) { + m_aTrack1.add(m_sField.toString()); + m_sField = null; + m_iAutomState = READING_STARTSENTINEL2; + } else if (c == '?' && m_iAutomState == READING_TRACK2) { + m_aTrack2.add(m_sField.toString()); + m_sField = null; + m_iAutomState = READING_STARTSENTINEL3; + checkTracks(); // aqui ya chequeamos los paramentros que leemos... + } else if (c == '?' && m_iAutomState == READING_TRACK3) { + m_aTrack3.add(m_sField.toString()); + m_sField = null; + m_iAutomState = READING_END; + + } else if (m_iAutomState == READING_TRACK1 || m_iAutomState == READING_TRACK2 || m_iAutomState == READING_TRACK3) { + m_sField.append(c); + } + + + if (m_iAutomState == READING_CARDTYPE || m_iAutomState == READING_TRACK1 || m_iAutomState == READING_STARTSENTINEL2) { + track1.append(c); + } else if (m_iAutomState == READING_TRACK2 || m_iAutomState == READING_STARTSENTINEL3) { + track2.append(c); + } else if (m_iAutomState == READING_TRACK3 || m_iAutomState == READING_END) { + track3.append(c); + } + } + + private void checkTracks() { + + // Test del tipo de tarjeta + if (m_cCardType != 'B') { + return; + } + + // Lectura de los valores + String sCardNumber1 = (m_aTrack1 == null || m_aTrack1.size() < 1) ? null : (String) m_aTrack1.get(0); + String sCardNumber2 = (m_aTrack2 == null || m_aTrack2.size() < 1) ? null : (String) m_aTrack2.get(0); + String sHolderName = (m_aTrack1 == null || m_aTrack1.size() < 2) ? null : (String) m_aTrack1.get(1); + String sExpDate1 = (m_aTrack1 == null || m_aTrack1.size() < 3) ? null : ((String) m_aTrack1.get(2)).substring(0, 4); + String sExpDate2 = (m_aTrack2 == null || m_aTrack2.size() < 2) ? null : ((String) m_aTrack2.get(1)).substring(0, 4); + + // Test del numero de tarjeta + if (!checkCardNumber(sCardNumber1) || (sCardNumber2 != null && !sCardNumber1.equals(sCardNumber2))) { + return; + } + // Test del nombre del propietario + if (sHolderName == null) { + return; + } + // Test de la fecha de expiracion + if ((sExpDate1 != null || !checkExpDate(sExpDate2)) && (!checkExpDate(sExpDate1) || !sExpDate1.equals(sExpDate2))) { + return; + } + + m_sCardNumber = sCardNumber1; + m_sHolderName = formatHolderName(sHolderName); + String yymm = sExpDate1 == null ? sExpDate2 : sExpDate1; + m_sExpirationDate = yymm.substring(2, 4) + yymm.substring(0, 2); //MMYY format + } + + private boolean checkCardNumber(String sNumber) { + return LuhnAlgorithm.checkCC(sNumber); + } + + private boolean checkExpDate(String sDate) { + return ( sDate.length()==4 && StringUtils.isNumber(sDate.trim()) ); + } + + private String formatHolderName(String sName) { + + int iPos = sName.indexOf('/'); + if (iPos >= 0) { + return sName.substring(iPos + 1).trim() + ' ' + sName.substring(0, iPos); + } else { + return sName.trim(); + } + } + + public boolean isComplete() { + return m_sCardNumber != null; + } + + public String getHolderName() { + return m_sHolderName; + } + + public String getCardNumber() { + return m_sCardNumber; + } + + public String getExpirationDate() { + return m_sExpirationDate; + } + + public String getTrack1() { + return track1 == null ? null : track1.toString(); + } + + public String getTrack2() { + return track2 == null ? null : track2.toString(); + } + + public String getTrack3() { + return track3 == null ? null : track3.toString(); + } + + + public String getEncryptedCardData() { + return "".equals(m_encryptedCardData) ? null : m_encryptedCardData; + +} + + public String getEncryptionKey() { + return "".equals(m_encryptionKey) ? null : m_encryptionKey; + } +} diff --git a/src/main/java/com/unicenta/pos/payment/MagCardReaderIntelligent.java b/src/main/java/com/unicenta/pos/payment/MagCardReaderIntelligent.java new file mode 100644 index 0000000..6505f4d --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/MagCardReaderIntelligent.java @@ -0,0 +1,137 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +public final class MagCardReaderIntelligent implements MagCardReader { + + private String m_sHolderName; + private String m_sCardNumber; + private String m_sExpirationDate; + + private StringBuffer m_sField; + + private static final int READING_HOLDER = 0; + private static final int READING_NUMBER = 1; + private static final int READING_DATE = 2; + private static final int READING_FINISHED = 3; + private int m_iAutomState; + + /** Creates a new instance of BasicMagCardReader */ + public MagCardReaderIntelligent() { + reset(); + } + + public String getReaderName() { + return "Basic magnetic card reader"; + } + + public void reset() { + m_sHolderName = null; + m_sCardNumber = null; + m_sExpirationDate = null; + m_sField = new StringBuffer(); + m_iAutomState = READING_HOLDER; + } + + public void appendChar(char c) { + + switch (m_iAutomState) { + case READING_HOLDER: + case READING_FINISHED: + if (c == 0x0009) { + m_sHolderName = m_sField.toString(); + m_sField = new StringBuffer(); + m_iAutomState = READING_NUMBER; + } else if (c == 0x000A) { + m_sHolderName = null; + m_sCardNumber = null; + m_sExpirationDate = null; + m_sField = new StringBuffer(); + m_iAutomState = READING_HOLDER; + } else { + m_sField.append(c); + m_iAutomState = READING_HOLDER; + } + break; + case READING_NUMBER: + if (c == 0x0009) { + m_sCardNumber = m_sField.toString(); + m_sField = new StringBuffer(); + m_iAutomState = READING_DATE; + } else if (c == 0x000A) { + m_sHolderName = null; + m_sCardNumber = null; + m_sExpirationDate = null; + m_sField = new StringBuffer(); + m_iAutomState = READING_HOLDER; + } else { + m_sField.append(c); + } + break; + case READING_DATE: + if (c == 0x0009) { + m_sHolderName = m_sCardNumber; + m_sCardNumber = m_sExpirationDate; + m_sExpirationDate = null; + m_sField = new StringBuffer(); + } else if (c == 0x000A) { + m_sExpirationDate = m_sField.toString(); + m_sField = new StringBuffer(); + m_iAutomState = READING_FINISHED; + } else { + m_sField.append(c); + } + break; + } + } + + public boolean isComplete() { + return m_iAutomState == READING_FINISHED; + } + + public String getHolderName() { + return m_sHolderName; + } + public String getCardNumber() { + return m_sCardNumber; + } + public String getExpirationDate() { + return m_sExpirationDate; + } + public String getTrack1() { + return null; + } + public String getTrack2() { + return null; + } + public String getTrack3() { + return null; + } + + @Override + public String getEncryptedCardData() { + return null; + } + + @Override + public String getEncryptionKey() { + return null; + } +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentConfiguration.java b/src/main/java/com/unicenta/pos/payment/PaymentConfiguration.java new file mode 100644 index 0000000..e3a11bc --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentConfiguration.java @@ -0,0 +1,49 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.pos.forms.AppConfig; +import javax.swing.JPanel; + +/** + * + * @author Mikel Irurita + */ +public interface PaymentConfiguration { + + /** + * + * @return + */ + public JPanel getComponent(); + + /** + * + * @param config + */ + public void loadProperties(AppConfig config); + + /** + * + * @param config + */ + public void saveProperties(AppConfig config); + +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentException.java b/src/main/java/com/unicenta/pos/payment/PaymentException.java new file mode 100644 index 0000000..ad3725e --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentException.java @@ -0,0 +1,42 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +/** + * + * @author JG uniCenta + */ +public class PaymentException extends java.lang.Exception { + + /** + * Creates a new instance of <code>PaymentException</code> without detail message. + */ + public PaymentException() { + } + + + /** + * Constructs an instance of <code>PaymentException</code> with the specified detail message. + * @param msg the detail message. + */ + public PaymentException(String msg) { + super(msg); + } +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentGateway.java b/src/main/java/com/unicenta/pos/payment/PaymentGateway.java new file mode 100644 index 0000000..a1b38e2 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentGateway.java @@ -0,0 +1,33 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +/** + * + * @author JG uniCenta + */ +public interface PaymentGateway { + + /** + * + * @param payinfo + */ + public void execute(PaymentInfoMagcard payinfo); +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentGatewayExt.java b/src/main/java/com/unicenta/pos/payment/PaymentGatewayExt.java new file mode 100644 index 0000000..c5cf565 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentGatewayExt.java @@ -0,0 +1,40 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +/** + * + * @author JG uniCenta + */ +public class PaymentGatewayExt implements PaymentGateway { + + /** Creates a new instance of PaymentGatewayExt */ + public PaymentGatewayExt() { + } + + /** + * + * @param payinfo + */ + @Override + public void execute(PaymentInfoMagcard payinfo) { + payinfo.paymentOK("OK", payinfo.getTransactionID() , ""); + } +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentGatewayFac.java b/src/main/java/com/unicenta/pos/payment/PaymentGatewayFac.java new file mode 100644 index 0000000..0ef0c94 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentGatewayFac.java @@ -0,0 +1,46 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.pos.forms.AppProperties; + + +/** + * Creates a new instance of PaymentGatewayFac + */ +public class PaymentGatewayFac { + + /** Creates a new instance of PaymentGatewayFac */ + private PaymentGatewayFac() { + } + + public static PaymentGateway getPaymentGateway(AppProperties props) { + + String sReader = props.getProperty("payment.gateway"); + switch (sReader) { + case "external": + return new PaymentGatewayExt(); + case "PaymentSense": + return new PaymentGatewayPaymentSense(); + default: + return null; + } + } +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java b/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java new file mode 100644 index 0000000..055a4bd --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentGatewayPaymentSense.java @@ -0,0 +1,86 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.plugins.Application; +import com.unicenta.plugins.common.AppContext; +import com.unicenta.pos.util.RoundUtils; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import java.awt.*; + +@Slf4j +public class PaymentGatewayPaymentSense implements PaymentGateway { + + /** Creates a new instance of PaymentGatewayExt */ + public PaymentGatewayPaymentSense() { + } + + Window getPaymentWindow() { + for (Window window : Window.getWindows()) { + if (window.isActive()) { + return window; + } + } + return null; + } + + /** + * + * @param payinfo + */ + @Override + public void execute(PaymentInfoMagcard payinfo) { + + int timer = 0; + int timeout = 180; + + new Application().paymentSenseTransaction(RoundUtils.round(payinfo.getTotal()), getPaymentWindow()); + + while (AppContext.getIsProcessing() == null || AppContext.getIsProcessing()) { + try { + log.info("uniCenta-oPos: waiting for payment to complete ...."); + Thread.sleep(1000); + timer += 1; + if (timer > timeout) break; + } catch (InterruptedException e) { + log.error(e.getMessage()); + } + } + + if (AppContext.getPaymentResult() == null) { + payinfo.paymentError("Transaction Error! Please try again", "No Response"); + } + if (AppContext.getPaymentResult().getTransactionResult().equals("SUCCESSFUL")){ + payinfo.setCardName(AppContext.getPaymentResult().getCardSchemeName()); + payinfo.setVerification(AppContext.getPaymentResult().getPaymentMethod()); + payinfo.setChipAndPin(true); + payinfo.paymentOK( + AppContext.getPaymentResult().getAuthCode(), + AppContext.getPaymentResult().getTransactionId(), + AppContext.getPaymentResult().getTransactionResult() + ); + } + else { + payinfo.paymentError("Transaction Error! Please try again", AppContext.getPaymentResult().getTransactionResult()); + } + } +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentInfo.java b/src/main/java/com/unicenta/pos/payment/PaymentInfo.java new file mode 100644 index 0000000..a5594a5 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentInfo.java @@ -0,0 +1,39 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.format.Formats; + +public abstract class PaymentInfo { + + public abstract String getName(); + public abstract double getTotal(); + public abstract PaymentInfo copyPayment(); + public abstract String getTransactionID(); + public abstract double getPaid(); + public abstract double getChange(); + public abstract double getTendered(); + public abstract String getCardName(); + public abstract String getVoucher(); + + public String printTotal() { + return Formats.CURRENCY.formatValue(getTotal()); + } +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentInfoCash.java b/src/main/java/com/unicenta/pos/payment/PaymentInfoCash.java new file mode 100644 index 0000000..88e67f1 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentInfoCash.java @@ -0,0 +1,133 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.format.Formats; + +public class PaymentInfoCash extends PaymentInfo { + + private double prePayAmount = 0.0; + private double m_dPaid; + private double m_dTotal; + private double m_dTendered; + private String m_dCardName =null; +// private double m_dTip; + + /** + * Creates a new instance of PaymentInfoCash + * @param dTotal + * @param dPaid + * @param dTendered + */ + public PaymentInfoCash(double dTotal, double dPaid, double dTendered) { + m_dTotal = dTotal; + m_dPaid = dPaid; + m_dTendered = dTendered; + } + + /** + * Creates a new instance of PaymentInfoCash + * @param dTotal + * @param dPaid + * @param dTendered + * @param prePayAmount + */ + public PaymentInfoCash(double dTotal, double dPaid, double dTendered, double prePayAmount) { + this(dTotal, dTendered, dPaid); + this.prePayAmount = prePayAmount; + } + + /** Creates a new instance of PaymentInfoCash + * @param dTotal + * @param dPaid */ + public PaymentInfoCash(double dTotal, double dPaid) { + m_dTotal = dTotal; + m_dPaid = dPaid; + } + + @Override + public PaymentInfo copyPayment() { + return new PaymentInfoCash(m_dTotal, m_dPaid, m_dTendered, prePayAmount); +// return new PaymentInfoCash(m_dTotal, m_dPaid, prePayAmount); + } + + @Override + public String getTransactionID() { + return "no ID"; + } + + @Override + public String getName() { + return "cash"; + } + @Override + public double getTotal() { + return m_dTotal; + } +// public double getTip() { +// return m_dTip; +// } + @Override + public double getPaid() { + return m_dPaid; + } + + @Override + public double getTendered() { + return m_dTendered; + } + + @Override + public double getChange(){ + return m_dPaid - m_dTotal; + } + + @Override + public String getCardName() { + return m_dCardName; + } + + public boolean hasPrePay() { + if (prePayAmount > 0) { + return true; + } + return false; + } + + public double getPrePaid() { + return prePayAmount; + } + + public String printTendered() { + return Formats.CURRENCY.formatValue(m_dTendered); + } + public String printPaid() { + return Formats.CURRENCY.formatValue(m_dPaid); + } + public String printChange() { + return Formats.CURRENCY.formatValue(m_dPaid - m_dTotal); + } + + @Override + public String getVoucher() { + return null; + } + +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentInfoCash_original.java b/src/main/java/com/unicenta/pos/payment/PaymentInfoCash_original.java new file mode 100644 index 0000000..9703cf8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentInfoCash_original.java @@ -0,0 +1,98 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.format.Formats; + +/** + * + * @author JG uniCenta + */ +public class PaymentInfoCash_original extends PaymentInfo { + + private final double m_dPaid; + private final double m_dTotal; + private double m_dTendered; + private final String m_dCardName =null; +// private double m_dTip; + + /** Creates a new instance of PaymentInfoCash + * @param dTotal + * @param dPaid */ + public PaymentInfoCash_original(double dTotal, double dPaid) { + m_dTotal = dTotal; + m_dPaid = dPaid; + } + + @Override + public PaymentInfo copyPayment(){ + return new PaymentInfoCash_original(m_dTotal, m_dPaid); + } + + @Override + public String getTransactionID(){ + return "no ID"; + } + + @Override + public String getName() { + return "cash"; + } + @Override + public double getTotal() { + return m_dTotal; + } +/** public double getTip() { + return m_dTip; + } + * @return +*/ + @Override + public double getPaid() { + return m_dPaid; + } + + @Override + public double getTendered() { + return m_dTendered; + } + + @Override + public double getChange(){ + return m_dPaid - m_dTotal; + } + + @Override + public String getCardName() { + return m_dCardName; + } + public String printPaid() { + return Formats.CURRENCY.formatValue(m_dPaid); + } + public String printChange() { + return Formats.CURRENCY.formatValue(m_dPaid - m_dTotal); + } + + @Override + public String getVoucher() { + return null; + } + +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentInfoFree.java b/src/main/java/com/unicenta/pos/payment/PaymentInfoFree.java new file mode 100644 index 0000000..0187587 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentInfoFree.java @@ -0,0 +1,86 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +public class PaymentInfoFree extends PaymentInfo { + + private double m_dTotal; + private double m_dTendered; + private String m_dCardName =null; +// private double m_dTip; + + /** Creates a new instance of PaymentInfoFree + * @param dTotal */ + public PaymentInfoFree(double dTotal) { + m_dTotal = dTotal; + } + + public PaymentInfo copyPayment(){ + return new PaymentInfoFree(m_dTotal); + } + public String getTransactionID(){ + return "no ID"; + } + public String getName() { + return "free"; + } + public double getTotal() { + return m_dTotal; + } + public double getPaid() { + return (0.0); + } + +/** + * + public double getTip() { + return m_dTip; + } +*/ + + public double getChange(){ + return (0.00); + } + public double getTendered() { + return m_dTendered; + } + public String getCardName() { + return m_dCardName; + } + +/** + public boolean getIsProcessed() { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void setIsProcessed(boolean value) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public String getReturnMessage() { + throw new UnsupportedOperationException("Not supported yet."); + } +*/ + + public String getVoucher() { + return null; + } + +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentInfoList.java b/src/main/java/com/unicenta/pos/payment/PaymentInfoList.java new file mode 100644 index 0000000..46a633c --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentInfoList.java @@ -0,0 +1,62 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import java.util.Iterator; +import java.util.LinkedList; + +public class PaymentInfoList { + + private LinkedList<PaymentInfo> m_apayment; + + /** Creates a new instance of PaymentInfoComposed */ + public PaymentInfoList() { +// JG 16 May 12 use diamond inference + m_apayment = new LinkedList<>(); + } + + public double getTotal() { + + double dTotal = 0.0; + Iterator i = m_apayment.iterator(); + while (i.hasNext()) { + PaymentInfo p = (PaymentInfo) i.next(); + dTotal += p.getTotal(); + } + + return dTotal; + } + + public boolean isEmpty() { + return m_apayment.isEmpty(); + } + + public void add(PaymentInfo p) { + m_apayment.addLast(p); + } + + public void removeLast() { + m_apayment.removeLast(); + } + + public LinkedList<PaymentInfo> getPayments() { + return m_apayment; + } +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentInfoMagcard.java b/src/main/java/com/unicenta/pos/payment/PaymentInfoMagcard.java new file mode 100644 index 0000000..29f9898 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentInfoMagcard.java @@ -0,0 +1,310 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +public class PaymentInfoMagcard extends PaymentInfo { + + protected double m_dTotal; + protected double m_dTip; + protected String m_sHolderName; + protected String m_sCardNumber; + protected String m_sExpirationDate; + protected String track1; + protected String track2; + protected String track3; + protected String m_sTransactionID; + protected String m_sAuthorization; + protected String m_sErrorMessage; + protected String m_sReturnMessage; + //JG Jan 2018 + protected String encryptedTrack; + protected String encryptionKey; + protected String m_dCardName =null; + + protected Boolean chipAndPin = Boolean.FALSE; + protected String verification; + protected String lastFourDigits; + + /** + * Creates a new instance of PaymentInfoMagcard + * @param sHolderName + * @param sCardNumber + * @param sExpirationDate + * @param track1 + * @param track2 + * @param track3 + * @param encryptedCard + * @param encryptKey + * @param sTransactionID + * @param dTotal + */ + public PaymentInfoMagcard(String sHolderName, String sCardNumber, + String sExpirationDate, String track1, String track2, String track3, String encryptedCard, String encryptKey, + String sTransactionID, double dTotal) { + m_sHolderName = sHolderName; + m_sCardNumber = sCardNumber; + m_sExpirationDate = sExpirationDate; + this.track1 = track1; + this.track2 = track2; + this.track3 = track3; + encryptedTrack = encryptedCard; + encryptionKey = encryptKey; + m_sTransactionID = sTransactionID; + m_dTotal = dTotal; + + + m_sAuthorization = null; + m_sErrorMessage = null; + m_sReturnMessage = null; + } + + /** + * Creates a new instance of PaymentInfoMagcard + * @param sHolderName + * @param sCardNumber + * @param sExpirationDate + * @param sTransactionID + * @param dTotal + */ + public PaymentInfoMagcard(String sHolderName, String sCardNumber, + String sExpirationDate, String sTransactionID, double dTotal) { + this(sHolderName, sCardNumber, sExpirationDate, + null, null, null, null, null, sTransactionID, dTotal); + } + + @Override + public PaymentInfo copyPayment() { + PaymentInfoMagcard p = new PaymentInfoMagcard(m_sHolderName, + m_sCardNumber, m_sExpirationDate, track1, track2, + track3, encryptedTrack, encryptionKey, m_sTransactionID, m_dTotal); + p.m_sAuthorization = m_sAuthorization; + p.m_sErrorMessage = m_sErrorMessage; + return p; + } + + public String getName() { +// return "magcard"; + return "ccard"; + } + + @Override + public double getTotal() { + return m_dTotal; + } + + public double getTip() { + return m_dTip; + } + + public boolean isPaymentOK() { + return m_sAuthorization != null; + } + + public String getHolderName() { + return m_sHolderName; + } + + @Override + public String getCardName() { + if (chipAndPin){ + return m_dCardName; + } + return getCardType(m_sCardNumber); + } + + public String getCardNumber() { + return m_sCardNumber; + } + + public String getExpirationDate() { + return m_sExpirationDate; + } + + @Override + public String getTransactionID() { + return m_sTransactionID; + } + + /** + * Get tracks of magnetic card. Framing characters: - start sentinel (SS) - + * end sentinel (ES) - LRC + * + * @return tracks of the magnetic card + */ + public String getEncryptedCardData() { + return encryptedTrack; + } + + public String getEncryptionKey() { + return encryptionKey; + } + + /** @param sCardNumber + * @return + */ + public String getCardType(String sCardNumber){ + String c = "UNKNOWN"; + + if (sCardNumber.startsWith("4")) { + c = "VISA"; + } else if (sCardNumber.startsWith("6")) { + c = "DISC"; + } else if (sCardNumber.startsWith("5")) { + c = "MAST"; + } else if (sCardNumber.startsWith("34") || sCardNumber.startsWith("37")) { + c = "AMEX"; + } else if (sCardNumber.startsWith("3528") || sCardNumber.startsWith("3589")) { + c = "JCB"; + } else if (sCardNumber.startsWith("3")) { + c = "DINE"; + } + m_sCardNumber = c; + return c; + } + + public String getTrack1(boolean framingChar) { + return (framingChar) + ? track1 + : track1.substring(1, track1.length() - 2); + } + + public String getTrack2(boolean framingChar) { + return (framingChar) + ? track2 + : track2.substring(1, track2.length() - 2); + } + + public String getTrack3(boolean framingChar) { + return (framingChar) + ? track3 + : track3.substring(1, track3.length() - 2); + } + + public String getAuthorization() { + return m_sAuthorization; + } + + public String getMessage() { + return m_sErrorMessage; + } + + public void paymentError(String sMessage, String moreInfo) { + m_sAuthorization = null; + m_sErrorMessage = sMessage + "\n" + moreInfo; + } + + public void setReturnMessage(String returnMessage) { + m_sReturnMessage = returnMessage; + } + + public String getReturnMessage() { + return m_sReturnMessage; + } + + public void paymentOK(String sAuthorization, String sTransactionId, String sReturnMessage) { + m_sAuthorization = sAuthorization; + m_sTransactionID = sTransactionId; + m_sReturnMessage = sReturnMessage; + m_sErrorMessage = null; + } + + public String printCardNumber() { + System.out.println(m_sCardNumber); + if (m_sCardNumber.length() > 4) { + return m_sCardNumber.substring(0, m_sCardNumber.length() - 4).replaceAll("\\.", "*") + + m_sCardNumber.substring(m_sCardNumber.length() - 4); + } else { + return "****"; + } + } + + public String printExpirationDate() { + return m_sExpirationDate; + } + + public String printAuthorization() { + return m_sAuthorization; + } + + public String printTransactionID() { + return m_sTransactionID; + } + + public boolean getIsProcessed() { + throw new UnsupportedOperationException("Not supported yet."); + } + + + public void setIsProcessed(boolean value) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public double getPaid() { + return (0.0); + } + + @Override + public double getChange(){ + return 0.00; + } + + @Override + public double getTendered() { + return 0.00; + } + + @Override + public String getVoucher() { + return null; + } + + public void setCardName(String m_dCardName){ + this.m_dCardName = m_dCardName; + } + + public Boolean isChipAndPin() { + return chipAndPin; + } + + public void setChipAndPin(Boolean chipAndPin) { + this.chipAndPin = chipAndPin; + } + + public String printVerification() { + return verification; + } + + public void setVerification(String verification) { + this.verification = verification; + } + + public String getLastFourDigits() { + return lastFourDigits; + } + + public String printLastFourDigits() { + return lastFourDigits; + } + + public void setLastFourDigits(String lastFourDigits) { + this.lastFourDigits = lastFourDigits; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/payment/PaymentInfoMagcardRefund.java b/src/main/java/com/unicenta/pos/payment/PaymentInfoMagcardRefund.java new file mode 100644 index 0000000..0f8af93 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentInfoMagcardRefund.java @@ -0,0 +1,53 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +public class PaymentInfoMagcardRefund extends PaymentInfoMagcard { + +/** + * Creates a new instance of PaymentInfoMagcardRefund + */ + public PaymentInfoMagcardRefund(String sHolderName, String sCardNumber, String sExpirationDate, String track1, String track2, + String track3, String encryptCard, String encryptKey, String sTransactionID, double dTotal) { + super(sHolderName, sCardNumber, sExpirationDate, track1, track2, track3, encryptCard, encryptKey, sTransactionID, dTotal); + } + + /** + * Creates a new instance of PaymentInfoMagcard + */ + public PaymentInfoMagcardRefund(String sHolderName, String sCardNumber, String sExpirationDate, String sTransactionID, String encryptedCard, String encryptionKey, double dTotal) { + super(sHolderName, sCardNumber, sExpirationDate, sTransactionID, dTotal); + } + + @Override + public PaymentInfo copyPayment() { + PaymentInfoMagcard p = new PaymentInfoMagcardRefund(m_sHolderName, m_sCardNumber, m_sExpirationDate, + track1, track2, track3, encryptedTrack, encryptionKey, m_sTransactionID, m_dTotal); + p.m_sAuthorization = m_sAuthorization; + p.m_sErrorMessage = m_sErrorMessage; + return p; + } + + @Override + public String getName() { +// return "magcardrefund"; + return "ccardrefund"; + } +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentInfoTicket.java b/src/main/java/com/unicenta/pos/payment/PaymentInfoTicket.java new file mode 100644 index 0000000..624b3f6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentInfoTicket.java @@ -0,0 +1,154 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.SerializableRead; +import com.unicenta.format.Formats; + +public class PaymentInfoTicket extends PaymentInfo implements SerializableRead { + + private static final long serialVersionUID = 8865238639097L; + private double m_dTicket; + private String m_sName; + private String m_transactionID; + private double m_dTendered; + private double m_change; + private String m_dCardName =null; + private double m_dTip; + private boolean m_isProcessed; + private String m_returnMessage; + private String m_sVoucher; + private String sVoucher; + private String m_sVoucherNumber; + + /** Creates a new instance of PaymentInfoTicket + * @param dTicket + * @param sName */ + +// call by Cheque, Bank , Slip + public PaymentInfoTicket(double dTicket, String sName) { + m_sName = sName; + m_dTicket = dTicket; + } + + public PaymentInfoTicket(double dTicket, String sName, String transactionID, String sVoucher) { + m_sName = sName; + m_dTicket = dTicket; + m_transactionID = transactionID; + m_sVoucher = sVoucher; + } + +// call by Voucher + public PaymentInfoTicket(double dTicket, String sName, String sVoucher) { + m_sName = sName; + m_dTicket = dTicket; + m_sVoucher = sVoucher; + m_sVoucherNumber = sVoucher; + } + + public PaymentInfoTicket() { + m_sName = null; + m_dTicket = 0.0; + m_transactionID = null; + m_dTendered = 0.00; + } + + @Override + public void readValues(DataRead dr) throws BasicException { + m_sName = dr.getString(1); + m_dTicket = dr.getDouble(2); + m_transactionID = dr.getString(3); + if (dr.getDouble(4) != null) { + m_dTendered = dr.getDouble(4); + } + m_dCardName = dr.getString(5); + } + + @Override + public PaymentInfo copyPayment(){ + return new PaymentInfoTicket(m_dTicket, m_sName); + } + @Override + public String getName() { + return m_sName; + } + @Override + public double getTotal() { + return m_dTicket; + } + @Override + public String getTransactionID(){ + return m_transactionID; + } + + @Override + public double getPaid() { + return (0.0); + } + + @Override + public double getChange(){ + return m_dTendered - m_dTicket; + } + + @Override + public double getTendered() { + return (0.0); + } + + @Override + public String getCardName() { + return m_dCardName; + } + + public String printPaid() { + return Formats.CURRENCY.formatValue(m_dTicket); + } + + + public String printVoucherTotal() { + return Formats.CURRENCY.formatValue(-m_dTicket); + } + + public String printChange() { + return Formats.CURRENCY.formatValue(m_dTendered - m_dTicket); + } + + public String printTendered() { + return Formats.CURRENCY.formatValue(m_dTendered); + } + + + @Override + public String getVoucher() { + return m_sVoucher; + } + public String printVoucher() { + return m_sVoucher; + } + public String getVoucherNumber() { + return m_sVoucherNumber; + } + public String printVoucherNumber() { + return m_sVoucherNumber; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/payment/PaymentPanel.java b/src/main/java/com/unicenta/pos/payment/PaymentPanel.java new file mode 100644 index 0000000..bf97a25 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentPanel.java @@ -0,0 +1,29 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import javax.swing.JComponent; + +public interface PaymentPanel { + + public void activate(String sTransaction, double dTotal); + public JComponent getComponent(); + public PaymentInfoMagcard getPaymentInfoMagcard(); +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentPanelBasic.form b/src/main/java/com/unicenta/pos/payment/PaymentPanelBasic.form new file mode 100644 index 0000000..a69b60a --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentPanelBasic.form @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,124,0,0,1,-94"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/PaymentPanelBasic.java b/src/main/java/com/unicenta/pos/payment/PaymentPanelBasic.java new file mode 100644 index 0000000..ef4adba --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentPanelBasic.java @@ -0,0 +1,102 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.pos.forms.AppLocal; +import javax.swing.JComponent; + +public class PaymentPanelBasic extends javax.swing.JPanel implements PaymentPanel { + + private double m_dTotal; + private String m_sTransactionID; + private JPaymentNotifier m_notifier; + + /** + * Creates new form PaymentPanelSimple + */ + public PaymentPanelBasic(JPaymentNotifier notifier) { + + m_notifier = notifier; + initComponents(); + } + + public JComponent getComponent() { + return this; + } + + public void activate(String sTransaction, double dTotal) { + + m_sTransactionID = sTransaction; + m_dTotal = dTotal; + + jLabel1.setText( + m_dTotal > 0.0 + ? AppLocal.getIntString("message.paymentgatewayext") + : AppLocal.getIntString("message.paymentgatewayextrefund")); + + m_notifier.setStatus(true, true); + } + + public PaymentInfoMagcard getPaymentInfoMagcard() { + + if (m_dTotal > 0.0) { + return new PaymentInfoMagcard( + "", + "", + "", + null, + null, + null, + null, + null, + m_sTransactionID, + m_dTotal); + } else { + return new PaymentInfoMagcardRefund( + "", + "", + "", + null, + null, + null, + null, + null, + m_sTransactionID, + m_dTotal); + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents + private void initComponents() { + jLabel1 = new javax.swing.JLabel(); + + add(jLabel1); + + } + // </editor-fold>//GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentPanelEMV.java b/src/main/java/com/unicenta/pos/payment/PaymentPanelEMV.java new file mode 100644 index 0000000..f5ff07c --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentPanelEMV.java @@ -0,0 +1,108 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.pos.forms.AppLocal; + +import javax.swing.*; + +public class PaymentPanelEMV extends javax.swing.JPanel implements PaymentPanel { + + private double m_dTotal; + private String m_sTransactionID; + private final JPaymentNotifier m_notifier; + + /** + * Creates new form PaymentPanelSimple + * @param notifier + */ + public PaymentPanelEMV(JPaymentNotifier notifier) { + + m_notifier = notifier; + initComponents(); + } + + @Override + public JComponent getComponent() { + return this; + } + + @Override + public void activate(String sTransaction, double dTotal) { + + m_sTransactionID = sTransaction; + m_dTotal = dTotal; + + jLabel1.setText( + m_dTotal > 0.0 + //TODO: Needs to be done for all locals i.e. message.paymentgatewayemv + ? AppLocal.getIntString("message.paymentgatewayemv") + : AppLocal.getIntString("message.paymentgatewayemvrefund")); + + m_notifier.setStatus(true, true); + } + + @Override + public PaymentInfoMagcard getPaymentInfoMagcard() { + + if (m_dTotal > 0.0) { + return new PaymentInfoMagcard( + "", + "", + "", + null, + null, + null, + null, + null, + m_sTransactionID, + m_dTotal); + } else { + return new PaymentInfoMagcardRefund( + "", + "", + "", + null, + null, + null, + null, + null, + m_sTransactionID, + m_dTotal); + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents + private void initComponents() { + jLabel1 = new javax.swing.JLabel(); + + add(jLabel1); + + } + // </editor-fold>//GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + // End of variables declaration//GEN-END:variables +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/payment/PaymentPanelFac.java b/src/main/java/com/unicenta/pos/payment/PaymentPanelFac.java new file mode 100644 index 0000000..820add7 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentPanelFac.java @@ -0,0 +1,47 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +/** + * + * @author adrianromero + */ +public class PaymentPanelFac { + + /** Creates a new instance of PaymentPanelFac */ + private PaymentPanelFac() { + } + + public static PaymentPanel getPaymentPanel(String sReader, JPaymentNotifier notifier) { +// JG 16 May 12 use switch + switch (sReader) { + case "Intelligent": + return new PaymentPanelMagCard(new MagCardReaderIntelligent(), notifier); + case "Generic": + return new PaymentPanelMagCard(new MagCardReaderGeneric(), notifier); + case "Keyboard": + return new PaymentPanelType(notifier); + case "EMV": + return new PaymentPanelEMV(notifier); + default: + return new PaymentPanelBasic(notifier); + } + } +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentPanelMagCard.form b/src/main/java/com/unicenta/pos/payment/PaymentPanelMagCard.form new file mode 100644 index 0000000..081b86b --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentPanelMagCard.form @@ -0,0 +1,267 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-52,0,0,1,-7"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="message.paymentgatewayswipe" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[263, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="m_jKeyFactory" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + <Component id="jLabel7" min="-2" max="-2" attributes="0"/> + <Component id="jLabel8" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jExpirationDate" alignment="0" min="-2" pref="70" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="m_jHolderName" min="-2" max="-2" attributes="0"/> + <Component id="m_jCardNumber" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jReset" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace min="-2" pref="22" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jKeyFactory" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jReset" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel8" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="m_jHolderName" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + <Component id="m_jCardNumber" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jExpirationDate" min="-2" max="-2" attributes="0"/> + <Component id="jLabel7" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace min="-2" pref="17" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="jReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="11" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.reset" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jResetActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JTextArea" name="m_jKeyFactory"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1, 1]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.cardnumber" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.cardexpdate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jExpirationDate"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jCardNumber"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.cardholder" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jHolderName"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="1" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/PaymentPanelMagCard.java b/src/main/java/com/unicenta/pos/payment/PaymentPanelMagCard.java new file mode 100644 index 0000000..984238a --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentPanelMagCard.java @@ -0,0 +1,518 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.HeadlessException; +import java.awt.Insets; +import java.io.File; +import javax.swing.*; + +import jpos.JposException; +import jpos.MSR; +import jpos.MSRControl113; +import jpos.events.DataEvent; +import jpos.events.DataListener; +import jpos.events.ErrorEvent; +import jpos.events.ErrorListener; + +public class PaymentPanelMagCard extends javax.swing.JPanel implements PaymentPanel, + DataListener, ErrorListener { + + private JPaymentNotifier m_notifier; + private MagCardReader m_cardreader; + private String track1 = null; + private String track2 = null; + private String track3 = null; + private String m_sTransactionID; + private double m_dTotal; + // --------------------MagTeck variables----------------------------// + String track1DataTextField = null; + String track2DataTextField = null; + String track3DataTextField = null; + String additionalSecurityInformationTextField = null; + String track1DataEncryptedTextField = null; + String track2DataEncryptedTextField = null; + String track3DataEncryptedTextField = null; + //JButton clearButton = new JButton("Clear"); + String infoLine = ""; + String title = ""; + String resultValue = ""; + boolean enabled = false; + boolean openDevice = false; + boolean init = true; + String logicalDeviceName = "MagTekMSR_Encrypted"; + String encryptedCardData = null; + String encryptionKey = null; + boolean isMercury; + MSRControl113 msr = null; + //----------------------------------------------------------------------// + + /** + * Creates new form JMagCardReader + */ + // public PaymentPanelMagCard(String sReader, JPaymentNotifier notifier) { + public PaymentPanelMagCard(MagCardReader cardreader, JPaymentNotifier notifier) { + m_notifier = notifier; + m_cardreader = cardreader; + + initComponents(); + + + AppConfig config = new AppConfig(new File(new File(System.getProperty("user.home")), AppLocal.APP_ID + ".properties")); + config.load(); + + String payProcessor = config.getProperty("payment.gateway"); + if ("MercuryPay".equals(payProcessor)) { + isMercury = true; + } else { + isMercury = false; + } + + if (m_cardreader != null) { + // They will be able to pay by card + m_jKeyFactory.addKeyListener(new KeyBarsListener()); + jReset.setEnabled(true); + } else { + jReset.setEnabled(false); + } + //---------------------------------------------------// + + msr = new MSR(); + msr.addDataListener(this); + msr.addErrorListener(this); + if (isMercury) { + processMSRSession(); + } + } + + private void processMSRSession() { + + + if ((this.logicalDeviceName != null) && (!"".equals(this.logicalDeviceName))) { + if (this.openDevice) { + try { + msr.close(); + } catch (JposException localJposException1) { + JOptionPane.showMessageDialog(this, "Error Occured " + localJposException1.getMessage()); + } + } + try { + msr.open(this.logicalDeviceName); + this.openDevice = true; + } catch (JposException localJposException2) { + JOptionPane.showMessageDialog(this, "Error Occured " + localJposException2.getMessage()); + } + //Clear the field data. + clear(); + + try { + this.msr.claim(1000); + } catch (JposException localJposException3) { + JOptionPane.showMessageDialog(this, "Error Occured " + localJposException3.getMessage()); + } + try { + this.msr.setDataEventEnabled(true); + } catch (JposException localJposException5) { + JOptionPane.showMessageDialog(this, "Error Occured " + localJposException5.getMessage()); + } + try { + this.msr.setDeviceEnabled(true); + this.enabled = true; + } catch (JposException localJposException4) { + this.enabled = false; + JOptionPane.showMessageDialog(this, "Error Occured " + localJposException4.getMessage()); + } + } + } + + public void clear() { + this.track1DataTextField = ""; + this.track2DataTextField = ""; + this.track3DataTextField = ""; + this.additionalSecurityInformationTextField = ""; + this.track1DataEncryptedTextField = ""; + this.track2DataEncryptedTextField = ""; + this.track3DataEncryptedTextField = ""; + } + + @Override + public void dataOccurred(DataEvent paramDataEvent) { + String str = ""; + byte[] arrayOfByte = new byte[0]; + try { + arrayOfByte = this.msr.getTrack1Data(); + str = new String(arrayOfByte); + if (str.length() == 0) { + str = ""; + } + this.track1DataTextField = str; + + arrayOfByte = this.msr.getTrack2Data(); + str = new String(arrayOfByte); + if (str.length() == 0) { + str = ""; + } + this.track2DataTextField = str; + + arrayOfByte = this.msr.getTrack3Data(); + str = new String(arrayOfByte); + if (str.length() == 0) { + str = ""; + } + this.track3DataTextField = str; + + arrayOfByte = this.msr.getAdditionalSecurityInformation(); + str = new String(arrayOfByte); + if (str.length() == 0) { + str = ""; + } + this.additionalSecurityInformationTextField = str; + + arrayOfByte = this.msr.getTrack1EncryptedData(); + str = new String(arrayOfByte); + if (str.length() == 0) { + str = ""; + } + this.track1DataEncryptedTextField = str; + + arrayOfByte = this.msr.getTrack2EncryptedData(); + str = new String(arrayOfByte); + if (str.length() == 0) { + str = ""; + } + this.track2DataEncryptedTextField = str; + + arrayOfByte = this.msr.getTrack3EncryptedData(); + str = new String(arrayOfByte); + if (str.length() == 0) { + str = ""; + } + this.track3DataEncryptedTextField = str; + this.msr.setDataEventEnabled(true); + + encryptedCardData = track2DataEncryptedTextField; + encryptionKey = additionalSecurityInformationTextField; + + char[] cData = ("%" + track1DataTextField + "?;" + track2DataTextField + "?").toCharArray(); + + if (cData.length > 0) { + for (int i = 0; i < cData.length; i++) { + stateTransition(cData[i]); + } + } + } catch (JposException localJposException) { + processJposException(localJposException, ""); + } + } + + @Override + public void errorOccurred(ErrorEvent paramErrorEvent) { + String str1 = Integer.toString(paramErrorEvent.getErrorCode()); + String str2 = Integer.toString(paramErrorEvent.getErrorCodeExtended()); + String str3 = Integer.toString(paramErrorEvent.getErrorLocus()); + String str4 = Integer.toString(paramErrorEvent.getErrorResponse()); + + JOptionPane.showMessageDialog(this, "ErrorEvent: EC=" + str1 + ", ECE=" + str2 + ", EL=" + str3 + ", ER=" + str4, this.title, 0); + } + + private void processJposException(JposException paramJposException, String paramString) { + JOptionPane.showMessageDialog(this, "Exception...message = " + paramJposException.getMessage() + " with errorCode = " + paramJposException.getErrorCode() + ", errorCodeExtended = " + paramJposException.getErrorCodeExtended(), this.title, 0); + + } + + class XmlDialog extends JDialog { + + JScrollPane jScrollPane = new JScrollPane(); + JTextArea jTextArea = new JTextArea(); + GridBagLayout gridBagLayout1 = new GridBagLayout(); + + public XmlDialog(String arg2) throws HeadlessException { + try { + jaInit(); + String str = ""; + this.jTextArea.append(str); + } catch (Exception localException) { + localException.printStackTrace(); + } + + } + + private void jaInit() throws Exception { + getContentPane().setLayout(this.gridBagLayout1); + + this.jTextArea.setColumns(16); + this.jTextArea.setRows(18); + + getContentPane().add(this.jScrollPane, new GridBagConstraints(0, 0, 2, 1, 1.0D, 1.0D, 10, 1, new Insets(15, 17, 0, 15), 364, 213)); + + this.jScrollPane.getViewport().add(this.jTextArea, null); + } + } + //--------------------------------------------------------------// + + @Override + public JComponent getComponent() { + return this; + } + + @Override + public void activate(String sTransaction, double dTotal) { + m_sTransactionID = sTransaction; + m_dTotal = dTotal; + resetState(); + m_jKeyFactory.setText(null); + java.awt.EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + m_jKeyFactory.requestFocus(); + } + }); + } + + private void resetState() { + + m_notifier.setStatus(false, false); + + m_jHolderName.setText(null); + m_jCardNumber.setText(null); + m_jExpirationDate.setText(null); + track1 = null; + track2 = null; + track3 = null; + + if (m_cardreader != null) { + // Se van a poder efectuar pagos con tarjeta + m_cardreader.reset(); + } + //clear(); + } + + @Override + public PaymentInfoMagcard getPaymentInfoMagcard() { + + if (m_dTotal > 0.0) { + return new PaymentInfoMagcard( + m_jHolderName.getText(), + m_jCardNumber.getText(), + m_jExpirationDate.getText(), + track1, + track2, + track3, + encryptedCardData, + encryptionKey, + m_sTransactionID, + m_dTotal); + } else { + return new PaymentInfoMagcardRefund( + m_jHolderName.getText(), + m_jCardNumber.getText(), + m_jExpirationDate.getText(), + track1, + track2, + track3, + encryptedCardData, + encryptionKey, + m_sTransactionID, + m_dTotal); + } + } + + private void stateTransition(char cTrans) { + + m_cardreader.appendChar(cTrans); + + if (m_cardreader.isComplete()) { + m_jHolderName.setText(m_cardreader.getHolderName()); + m_jCardNumber.setText(m_cardreader.getCardNumber()); + m_jExpirationDate.setText(m_cardreader.getExpirationDate()); + track1 = m_cardreader.getTrack1(); + track2 = m_cardreader.getTrack2(); + track3 = m_cardreader.getTrack3(); + m_notifier.setStatus(true, true); + + m_jKeyFactory.addKeyListener(new KeyBarsListener()); + jReset.setEnabled(true); + + } else { + m_jHolderName.setText(null); + m_jCardNumber.setText(null); + m_jExpirationDate.setText(null); + track1 = null; + track3 = null; + track3 = null; + m_notifier.setStatus(false, false); + } + } + + private class KeyBarsListener extends java.awt.event.KeyAdapter { + + @Override + public void keyTyped(java.awt.event.KeyEvent e) { + m_jKeyFactory.setText(null); + stateTransition(e.getKeyChar()); + } + } + + /** + * + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel2 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jPanel1 = new javax.swing.JPanel(); + jReset = new javax.swing.JButton(); + m_jKeyFactory = new javax.swing.JTextArea(); + jLabel6 = new javax.swing.JLabel(); + jLabel7 = new javax.swing.JLabel(); + m_jExpirationDate = new javax.swing.JLabel(); + m_jCardNumber = new javax.swing.JLabel(); + jLabel8 = new javax.swing.JLabel(); + m_jHolderName = new javax.swing.JLabel(); + + setLayout(new java.awt.BorderLayout()); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setText(AppLocal.getIntString("message.paymentgatewayswipe")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(263, 30)); + jPanel2.add(jLabel1); + + add(jPanel2, java.awt.BorderLayout.NORTH); + + jReset.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + jReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jReset.setText(AppLocal.getIntString("button.reset")); // NOI18N + jReset.setFocusPainted(false); + jReset.setFocusable(false); + jReset.setPreferredSize(new java.awt.Dimension(100, 45)); + jReset.setRequestFocusEnabled(false); + jReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jResetActionPerformed(evt); + } + }); + + m_jKeyFactory.setPreferredSize(new java.awt.Dimension(1, 1)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.cardnumber")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.cardexpdate")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jExpirationDate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jExpirationDate.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jExpirationDate.setOpaque(true); + m_jExpirationDate.setPreferredSize(new java.awt.Dimension(180, 30)); + + m_jCardNumber.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCardNumber.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jCardNumber.setOpaque(true); + m_jCardNumber.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.cardholder")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jHolderName.setBackground(java.awt.Color.white); + m_jHolderName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jHolderName.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jHolderName.setOpaque(true); + m_jHolderName.setPreferredSize(new java.awt.Dimension(200, 30)); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(m_jKeyFactory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jExpirationDate, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(m_jHolderName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCardNumber, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(jReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(22, 22, 22)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jKeyFactory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jHolderName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCardNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jExpirationDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGap(17, 17, 17)) + ); + + add(jPanel1, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + private void jResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jResetActionPerformed + + resetState(); + + }//GEN-LAST:event_jResetActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JButton jReset; + private javax.swing.JLabel m_jCardNumber; + private javax.swing.JLabel m_jExpirationDate; + private javax.swing.JLabel m_jHolderName; + private javax.swing.JTextArea m_jKeyFactory; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/payment/PaymentPanelType.form b/src/main/java/com/unicenta/pos/payment/PaymentPanelType.form new file mode 100644 index 0000000..b7ac3c6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentPanelType.form @@ -0,0 +1,232 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,89,0,0,2,-18"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jKeysActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 105]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel7" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jExpirationDate" min="-2" pref="90" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" pref="61" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel8" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jHolderName" min="-2" pref="200" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCardNumber" min="-2" pref="200" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel8" min="-2" max="-2" attributes="0"/> + <Component id="m_jHolderName" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + <Component id="m_jCardNumber" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jExpirationDate" min="-2" max="-2" attributes="0"/> + <Component id="jLabel7" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace pref="177" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorStringNumber" name="m_jCardNumber"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorStringNumber" name="m_jExpirationDate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jHolderName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.cardholder" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.cardnumber" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.cardexpdate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="MMYY"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[350, 45]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="message.paymentgatewaytype" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/payment/PaymentPanelType.java b/src/main/java/com/unicenta/pos/payment/PaymentPanelType.java new file mode 100644 index 0000000..4dca2da --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/PaymentPanelType.java @@ -0,0 +1,273 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.LuhnAlgorithm; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import javax.swing.JComponent; + +/** + * + * @author adrianromero + */ +public class PaymentPanelType extends javax.swing.JPanel implements PaymentPanel { + + private double m_dTotal; + private String m_sTransactionID; + private JPaymentNotifier m_notifier; + + /** + * Creates new form JPaymentCash + */ + public PaymentPanelType(JPaymentNotifier notifier) { + + m_notifier = notifier; + + initComponents(); + + m_jHolderName.addPropertyChangeListener("Edition", new RecalculateName()); + m_jCardNumber.addPropertyChangeListener("Edition", new RecalculateName()); + m_jExpirationDate.addPropertyChangeListener("Edition", new RecalculateName()); + + + m_jHolderName.addEditorKeys(m_jKeys); + m_jCardNumber.addEditorKeys(m_jKeys); + m_jExpirationDate.addEditorKeys(m_jKeys); + + } + + public JComponent getComponent() { + return this; + } + + public void activate(String sTransaction, double dTotal) { + + m_sTransactionID = sTransaction; + m_dTotal = dTotal; + + resetState(); + + m_jHolderName.activate(); + } + + private void resetState() { + + m_notifier.setStatus(false, false); + + m_jHolderName.setText(null); + m_jCardNumber.setText(null); + m_jExpirationDate.setText(null); + } + + public PaymentInfoMagcard getPaymentInfoMagcard() { + + if (m_dTotal > 0.0) { + return new PaymentInfoMagcard( + m_jHolderName.getText(), + m_jCardNumber.getText(), + m_jExpirationDate.getText(), + null, + null, + null, + null, + null, + m_sTransactionID, + m_dTotal); + } else { + return new PaymentInfoMagcardRefund( + m_jHolderName.getText(), + m_jCardNumber.getText(), + m_jExpirationDate.getText(), + null, + null, + null, + null, + null, + m_sTransactionID, + m_dTotal); + } + } + + private class RecalculateName implements PropertyChangeListener { + + public void propertyChange(PropertyChangeEvent evt) { + boolean isvalid = isValidHolder() && isValidCardNumber() && isValidExpirationDate(); + m_notifier.setStatus(isvalid, isvalid); + } + } + + private boolean isValidHolder() { + return !(m_jHolderName.getText() == null || m_jHolderName.getText().equals("")); + } + + private boolean isValidCardNumber() { + return (LuhnAlgorithm.checkCC(m_jCardNumber.getText()) && m_jCardNumber.getText().length() > 13 && m_jCardNumber.getText().length() < 20); + } + + private boolean isValidExpirationDate() { + return !(m_jExpirationDate.getText() == null || m_jExpirationDate.getText().length() != 4); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel2 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel4 = new javax.swing.JPanel(); + m_jCardNumber = new com.unicenta.editor.JEditorStringNumber(); + m_jExpirationDate = new com.unicenta.editor.JEditorStringNumber(); + m_jHolderName = new com.unicenta.editor.JEditorString(); + jLabel8 = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + jLabel7 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jPanel5 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + + setLayout(new java.awt.BorderLayout()); + + jPanel2.setLayout(new java.awt.BorderLayout()); + + jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS)); + + m_jKeys.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jKeysActionPerformed(evt); + } + }); + jPanel1.add(m_jKeys); + + jPanel2.add(jPanel1, java.awt.BorderLayout.NORTH); + + add(jPanel2, java.awt.BorderLayout.EAST); + + jPanel4.setPreferredSize(new java.awt.Dimension(400, 105)); + + m_jCardNumber.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCardNumber.setMinimumSize(new java.awt.Dimension(100, 30)); + m_jCardNumber.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jExpirationDate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jExpirationDate.setMinimumSize(new java.awt.Dimension(100, 30)); + m_jExpirationDate.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jHolderName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jHolderName.setMinimumSize(new java.awt.Dimension(100, 30)); + m_jHolderName.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.cardholder")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.cardnumber")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.cardexpdate")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText("MMYY"); + jLabel2.setPreferredSize(new java.awt.Dimension(150, 30)); + + javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jExpirationDate, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jHolderName, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel4Layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCardNumber, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jHolderName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCardNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jExpirationDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(177, Short.MAX_VALUE)) + ); + + add(jPanel4, java.awt.BorderLayout.CENTER); + + jPanel5.setPreferredSize(new java.awt.Dimension(350, 45)); + + jLabel1.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + jLabel1.setText(AppLocal.getIntString("message.paymentgatewaytype")); // NOI18N + jPanel5.add(jLabel1); + + add(jPanel5, java.awt.BorderLayout.NORTH); + }// </editor-fold>//GEN-END:initComponents + + private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_m_jKeysActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private com.unicenta.editor.JEditorStringNumber m_jCardNumber; + private com.unicenta.editor.JEditorStringNumber m_jExpirationDate; + private com.unicenta.editor.JEditorString m_jHolderName; + private com.unicenta.editor.JEditorKeys m_jKeys; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/payment/VoucherPaymentInfo.java b/src/main/java/com/unicenta/pos/payment/VoucherPaymentInfo.java new file mode 100644 index 0000000..25a0bbe --- /dev/null +++ b/src/main/java/com/unicenta/pos/payment/VoucherPaymentInfo.java @@ -0,0 +1,112 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.payment; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.SerializableRead; +import com.unicenta.format.Formats; + + +public class VoucherPaymentInfo extends PaymentInfo implements SerializableRead { + + private static final long serialVersionUID = 8865238639097L; + private double m_dTicket; + private String m_sName; + private String m_sVoucher; + + public VoucherPaymentInfo(double dTicket, String sName, String sVoucher) { + m_dTicket = dTicket; + m_sName = sName; + m_sVoucher = sVoucher; + } + + public VoucherPaymentInfo() { + m_dTicket = 0.0; + m_sName = null; + m_sVoucher = null; + } + + @Override + public void readValues(DataRead dr) throws BasicException { + m_sName = dr.getString(1); + m_dTicket = dr.getDouble(2); + m_sVoucher = dr.getString(3); + } + + @Override + public PaymentInfo copyPayment(){ + return new VoucherPaymentInfo(m_dTicket, m_sName, m_sVoucher); + } + + @Override + public String getName() { + return m_sName; + } + + @Override + public double getTotal() { + return m_dTicket; + } + + @Override + public String getTransactionID(){ + return null; + } + + public String printPaid() { + return Formats.CURRENCY.formatValue(m_dTicket); + } + + public String printVoucherTotal() { + return Formats.CURRENCY.formatValue(-m_dTicket); + } + + + @Override + public double getPaid() { + return m_dTicket; + } + + @Override + public double getChange() { + return 0; + } + + + @Override + public String getVoucher() { + return m_sVoucher; + } + + public String getCardType() { + return null; + } + + @Override + public double getTendered() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public String getCardName() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } +} diff --git a/src/main/java/com/unicenta/pos/printer/BaseAnimator.java b/src/main/java/com/unicenta/pos/printer/BaseAnimator.java new file mode 100644 index 0000000..cfd4d3f --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/BaseAnimator.java @@ -0,0 +1,83 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer; + +/** + * + * @author adrianromero + */ +public abstract class BaseAnimator implements DisplayAnimator { + + /** + * + */ + protected String baseLine1; + + /** + * + */ + protected String baseLine2; + + /** + * + */ + protected String currentLine1; + + /** + * + */ + protected String currentLine2; + + /** + * + */ + public BaseAnimator() { + baseLine1 = null; + baseLine2 = null; + } + + /** + * + * @param line1 + * @param line2 + */ + public BaseAnimator(String line1, String line2) { + baseLine1 = line1; + baseLine2 = line2; + } + + /** + * + * @return + */ + @Override + public String getLine1() { + return currentLine1; + } + + /** + * + * @return + */ + @Override + public String getLine2() { + return currentLine2; + } +} diff --git a/src/main/java/com/unicenta/pos/printer/BlinkAnimator.java b/src/main/java/com/unicenta/pos/printer/BlinkAnimator.java new file mode 100644 index 0000000..5a8faf4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/BlinkAnimator.java @@ -0,0 +1,54 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + + +package com.unicenta.pos.printer; + +/** + * + * @author adrianromero + */ +public class BlinkAnimator extends BaseAnimator { + + /** + * + * @param line1 + * @param line2 + */ + public BlinkAnimator(String line1, String line2) { + baseLine1 = DeviceTicket.alignLeft(line1, 20); + baseLine2 = DeviceTicket.alignLeft(line2, 20); + } + + /** + * + * @param i + */ + @Override + public void setTiming(int i) { + + if ((i % 10) < 5) { + currentLine1 = ""; + currentLine2 = ""; + } else { + currentLine1 = baseLine1; + currentLine2 = baseLine2; + } + } +} diff --git a/src/main/java/com/unicenta/pos/printer/CurtainAnimator.java b/src/main/java/com/unicenta/pos/printer/CurtainAnimator.java new file mode 100644 index 0000000..59789bc --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/CurtainAnimator.java @@ -0,0 +1,56 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + + +package com.unicenta.pos.printer; + +/** + * + * @author adrianromero + */ +public class CurtainAnimator extends BaseAnimator { + + /** + * + * @param line1 + * @param line2 + */ + public CurtainAnimator(String line1, String line2) { + baseLine1 = DeviceTicket.alignLeft(line1, 20); + baseLine2 = DeviceTicket.alignLeft(line2, 20); + } + + /** + * + * @param i + */ + @Override + public void setTiming(int i) { + + int j = i / 2; + + if (j < 10) { + currentLine1 = DeviceTicket.alignCenter(baseLine1.substring(10 - j, 10 + j), 20); + currentLine2 = DeviceTicket.alignCenter(baseLine2.substring(10 - j, 10 + j), 20); + } else { + currentLine1 = baseLine1; + currentLine2 = baseLine2; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/printer/DeviceDisplay.java b/src/main/java/com/unicenta/pos/printer/DeviceDisplay.java new file mode 100644 index 0000000..099a1bc --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/DeviceDisplay.java @@ -0,0 +1,71 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer; + +import javax.swing.JComponent; + +/** + * + * @author JG uniCenta + */ +public interface DeviceDisplay { + + // INTERFAZ DESCRIPCION + + /** + * + * @return + */ + public String getDisplayName(); + + /** + * + * @return + */ + public String getDisplayDescription(); + + /** + * + * @return + */ + public JComponent getDisplayComponent(); + + // INTERFAZ VISOR + + /** + * + * @param animation + * @param sLine1 + * @param sLine2 + */ + public void writeVisor(int animation, String sLine1, String sLine2); + + /** + * + * @param sLine1 + * @param sLine2 + */ + public void writeVisor(String sLine1, String sLine2); + + /** + * + */ + public void clearVisor(); +} diff --git a/src/main/java/com/unicenta/pos/printer/DeviceDisplayBase.java b/src/main/java/com/unicenta/pos/printer/DeviceDisplayBase.java new file mode 100644 index 0000000..e66d059 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/DeviceDisplayBase.java @@ -0,0 +1,146 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * + * @author adrianromero + */ +public class DeviceDisplayBase { + + /** + * + */ + public static final int ANIMATION_NULL = 0; + + /** + * + */ + public static final int ANIMATION_FLYER = 1; + + /** + * + */ + public static final int ANIMATION_SCROLL = 2; + + /** + * + */ + public static final int ANIMATION_BLINK = 3; + + /** + * + */ + public static final int ANIMATION_CURTAIN = 4; + + private DeviceDisplayImpl impl; + private DisplayAnimator anim; + private javax.swing.Timer m_tTimeTimer; + private int counter = 0; + + /** Creates a new instance of DeviceDisplayBase + * @param impl */ + public DeviceDisplayBase(DeviceDisplayImpl impl) { + this.impl = impl; + anim = new NullAnimator("", ""); + m_tTimeTimer = new javax.swing.Timer(50, new PrintTimeAction()); + } + + /** + * + * @param animation + * @param sLine1 + * @param sLine2 + */ + public void writeVisor(int animation, String sLine1, String sLine2) { + + m_tTimeTimer.stop(); + switch (animation) { + case ANIMATION_FLYER: + anim = new FlyerAnimator(sLine1, sLine2); + break; + case ANIMATION_SCROLL: + anim = new ScrollAnimator(sLine1, sLine2); + break; + case ANIMATION_BLINK: + anim = new BlinkAnimator(sLine1, sLine2); + break; + case ANIMATION_CURTAIN: + anim = new CurtainAnimator(sLine1, sLine2); + break; + default: // ANIMATION_NULL + anim = new NullAnimator(sLine1, sLine2); + break; + } + + counter = 0; + anim.setTiming(counter); + impl.repaintLines(); + + if (animation != ANIMATION_NULL) { + counter = 0; + m_tTimeTimer.start(); + } + } + + /** + * + * @param sLine1 + * @param sLine2 + */ + public void writeVisor(String sLine1, String sLine2) { + writeVisor(ANIMATION_NULL, sLine1, sLine2); + } + + /** + * + */ + public void clearVisor() { + writeVisor(ANIMATION_NULL, "", ""); + } + + /** + * + * @return + */ + public String getLine1() { + return anim.getLine1(); + } + + /** + * + * @return + */ + public String getLine2() { + return anim.getLine2(); + } + + private class PrintTimeAction implements ActionListener { + @Override + public void actionPerformed(ActionEvent evt) { + counter ++; + anim.setTiming(counter); + impl.repaintLines(); + } + } +} diff --git a/src/main/java/com/unicenta/pos/printer/DeviceDisplayImpl.java b/src/main/java/com/unicenta/pos/printer/DeviceDisplayImpl.java new file mode 100644 index 0000000..a6db684 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/DeviceDisplayImpl.java @@ -0,0 +1,32 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer; + +/** + * + * @author JG uniCenta + */ +public interface DeviceDisplayImpl { + + /** + * + */ + public void repaintLines(); +} diff --git a/src/main/java/com/unicenta/pos/printer/DeviceDisplayNull.java b/src/main/java/com/unicenta/pos/printer/DeviceDisplayNull.java new file mode 100644 index 0000000..0712bf3 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/DeviceDisplayNull.java @@ -0,0 +1,97 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer; + +import com.unicenta.pos.forms.AppLocal; + +/** + * + * @author JG uniCenta + */ +public class DeviceDisplayNull implements DeviceDisplay { + + private String m_sName; + private String m_sDescription; + + /** Creates a new instance of DeviceDisplayNull */ + public DeviceDisplayNull() { + this(null); + } + + /** Creates a new instance of DeviceDisplayNull + * @param desc */ + public DeviceDisplayNull(String desc) { + m_sName = AppLocal.getIntString("display.null"); + m_sDescription = desc; + } + + /** + * + * @return + */ + @Override + public String getDisplayName() { + return m_sName; + } + + /** + * + * @return + */ + @Override + public String getDisplayDescription() { + return m_sDescription; + } + + /** + * + * @return + */ + @Override + public javax.swing.JComponent getDisplayComponent() { + return null; + } + + /** + * + */ + @Override + public void clearVisor() { + } + + /** + * + * @param sLine1 + * @param sLine2 + */ + @Override + public void writeVisor(String sLine1, String sLine2) { + } + + /** + * + * @param animation + * @param sLine1 + * @param sLine2 + */ + @Override + public void writeVisor(int animation, String sLine1, String sLine2) { + } +} diff --git a/src/main/java/com/unicenta/pos/printer/DeviceFiscalPrinter.java b/src/main/java/com/unicenta/pos/printer/DeviceFiscalPrinter.java new file mode 100644 index 0000000..e124e6c --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/DeviceFiscalPrinter.java @@ -0,0 +1,83 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer; + +import javax.swing.JComponent; + +/** + * + * @author JG uniCenta + */ +public interface DeviceFiscalPrinter { + + /** + * + * @return + */ + public String getFiscalName(); + + /** + * + * @return + */ + public JComponent getFiscalComponent(); + + /** + * + */ + public void beginReceipt(); + + /** + * + */ + public void endReceipt(); + + /** + * + * @param sproduct + * @param dprice + * @param dunits + * @param taxinfo + */ + public void printLine(String sproduct, double dprice, double dunits, int taxinfo); + + /** + * + * @param smessage + */ + public void printMessage(String smessage); + + /** + * + * @param sPayment + * @param dpaid + */ + public void printTotal(String sPayment, double dpaid); + + /** + * + */ + public void printZReport(); + + /** + * + */ + public void printXReport(); +} diff --git a/src/main/java/com/unicenta/pos/printer/DeviceFiscalPrinterNull.java b/src/main/java/com/unicenta/pos/printer/DeviceFiscalPrinterNull.java new file mode 100644 index 0000000..22f21c1 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/DeviceFiscalPrinterNull.java @@ -0,0 +1,114 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer; + +import javax.swing.JComponent; + +/** + * + * @author JG uniCenta + */ +public class DeviceFiscalPrinterNull implements DeviceFiscalPrinter { + + /** Creates a new instance of DeviceFiscalPrinterNull */ + public DeviceFiscalPrinterNull() { + } + + /** + * + * @param desc + */ + public DeviceFiscalPrinterNull(String desc) { + } + + /** + * + * @return + */ + @Override + public String getFiscalName() { + return null; + } + + /** + * + * @return + */ + @Override + public JComponent getFiscalComponent() { + return null; + } + + /** + * + */ + @Override + public void beginReceipt() { + } + + /** + * + */ + @Override + public void endReceipt() { + } + + /** + * + * @param sproduct + * @param dprice + * @param dunits + * @param taxinfo + */ + @Override + public void printLine(String sproduct, double dprice, double dunits, int taxinfo) { + } + + /** + * + * @param smessage + */ + @Override + public void printMessage(String smessage) { + } + + /** + * + * @param sPayment + * @param dpaid + */ + @Override + public void printTotal(String sPayment, double dpaid) { + } + + /** + * + */ + @Override + public void printZReport() { + } + + /** + * + */ + @Override + public void printXReport() { + } +} diff --git a/src/main/java/com/unicenta/pos/printer/DevicePrinter.java b/src/main/java/com/unicenta/pos/printer/DevicePrinter.java new file mode 100644 index 0000000..9a73604 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/DevicePrinter.java @@ -0,0 +1,82 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer; + +import java.awt.image.BufferedImage; +import javax.swing.JComponent; + +/** + * + * @author JG uniCenta + */ +public interface DevicePrinter { + +// Font Sizes + public static final int SIZE_0 = 0; + public static final int SIZE_1 = 1; + public static final int SIZE_2 = 2; + public static final int SIZE_3 = 3; + +// Font Enhancers + public static final int STYLE_PLAIN = 0; + public static final int STYLE_BOLD = 1; + public static final int STYLE_UNDERLINE = 2; + +// Layout + public static final int ALIGN_LEFT = 0; + public static final int ALIGN_RIGHT = 1; + public static final int ALIGN_CENTER = 2; + + public static final String POSITION_BOTTOM = "bottom"; + public static final String POSITION_NONE = "none"; + +// Barcodes + public static final String BARCODE_EAN8 = "EAN8"; + public static final String BARCODE_EAN13 = "EAN13"; + public static final String BARCODE_UPCA = "UPC-A"; + public static final String BARCODE_UPCE = "UPC-E"; + public static final String BARCODE_CODE128 = "CODE128"; + public static final String BARCODE_CODE39 = "CODE39"; + + public String getPrinterName(); + public String getPrinterDescription(); + public JComponent getPrinterComponent(); + +// Initialise + public void reset(); + public void beginReceipt(); + +// Graphic renders + public void printImage(BufferedImage image); + public void printLogo(); + public void printBarCode(String type, String position, String code); + +// Do TextLine + public void beginLine(int iTextSize); + public void printText(int iStyle, String sText); + public void endLine(); + +// Close + public void endReceipt(); + +// Transact + public void openDrawer(); + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/printer/DevicePrinterNull.java b/src/main/java/com/unicenta/pos/printer/DevicePrinterNull.java new file mode 100644 index 0000000..45d0c25 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/DevicePrinterNull.java @@ -0,0 +1,149 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer; + +import com.unicenta.pos.forms.AppLocal; + +/** + * + * @author JG uniCenta + */ +public class DevicePrinterNull implements DevicePrinter { + + private String m_sName; + private String m_sDescription; + + /** Creates a new instance of DevicePrinterNull */ + public DevicePrinterNull() { + this(null); + } + + /** Creates a new instance of DevicePrinterNull + * @param desc */ + public DevicePrinterNull(String desc) { + m_sName = AppLocal.getIntString("printer.null"); + m_sDescription = desc; + } + + /** + * + * @return + */ + @Override + public String getPrinterName() { + return m_sName; + } + + /** + * + * @return + */ + @Override + public String getPrinterDescription() { + return m_sDescription; + } + + /** + * + * @return + */ + @Override + public javax.swing.JComponent getPrinterComponent() { + return null; + } + + /** + * + */ + @Override + public void reset() { + } + + /** + * + */ + @Override + public void beginReceipt() { + } + + /** + * + * @param type + * @param position + * @param code + */ + @Override + public void printBarCode(String type, String position, String code) { + } + + /** + * + * @param image + */ + @Override + public void printImage(java.awt.image.BufferedImage image) { + } + + /** + * + * @param iTextSize + */ + @Override + public void beginLine(int iTextSize) { + } + + /** + * + * @param iStyle + * @param sText + */ + @Override + public void printText(int iStyle, String sText) { + } + + /** + * + */ + @Override + public void endLine() { + } + + /** + * + */ + @Override + public void endReceipt() { + } + + /** + * + */ + @Override + public void openDrawer() { + } + + /** + * + */ + @Override + public void printLogo() { + + } +} diff --git a/src/main/java/com/unicenta/pos/printer/DeviceTicket.java b/src/main/java/com/unicenta/pos/printer/DeviceTicket.java new file mode 100644 index 0000000..9e2c27e --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/DeviceTicket.java @@ -0,0 +1,432 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +package com.unicenta.pos.printer; + +import com.unicenta.pos.forms.AppProperties; +import com.unicenta.pos.printer.escpos.*; +import com.unicenta.pos.printer.javapos.DeviceDisplayJavaPOS; +import com.unicenta.pos.printer.javapos.DeviceFiscalPrinterJavaPOS; +import com.unicenta.pos.printer.javapos.DevicePrinterJavaPOS; +import com.unicenta.pos.printer.printer.DevicePrinterPrinter; +import com.unicenta.pos.printer.screen.DeviceDisplayPanel; +import com.unicenta.pos.printer.screen.DeviceDisplayWindow; +import com.unicenta.pos.printer.screen.DevicePrinterPanel; +import com.unicenta.pos.util.StringParser; +import lombok.extern.slf4j.Slf4j; + +import java.awt.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author JG uniCenta + */ +@Slf4j +public class DeviceTicket { + + private DeviceFiscalPrinter m_deviceFiscal; + private DeviceDisplay m_devicedisplay; + private DevicePrinter m_nullprinter; + private Map<String, DevicePrinter> m_deviceprinters; + private List<DevicePrinter> m_deviceprinterslist; + + /** + * Creates a new instance of DeviceTicket + */ + public DeviceTicket() { + // Una impresora solo de pantalla. + + m_deviceFiscal = new DeviceFiscalPrinterNull(); + + m_devicedisplay = new DeviceDisplayNull(); + + m_nullprinter = new DevicePrinterNull(); + m_deviceprinters = new HashMap<>(); + m_deviceprinterslist = new ArrayList<>(); + + DevicePrinter p = new DevicePrinterPanel(); + m_deviceprinters.put("1", p); + m_deviceprinterslist.add(p); + } + + /** + * @param parent + * @param props + */ + public DeviceTicket(Component parent, AppProperties props) { + + PrinterWritterPool pws = new PrinterWritterPool(); + + // La impresora fiscal + StringParser sf = new StringParser(props.getProperty("machine.fiscalprinter")); + String sFiscalType = sf.nextToken(':'); + String sFiscalParam1 = sf.nextToken(','); + try { + if ("javapos".equals(sFiscalType)) { + m_deviceFiscal = new DeviceFiscalPrinterJavaPOS(sFiscalParam1); + } else { + m_deviceFiscal = new DeviceFiscalPrinterNull(); + } + } catch (TicketPrinterException e) { + m_deviceFiscal = new DeviceFiscalPrinterNull(e.getMessage()); + } + + StringParser sd = new StringParser(props.getProperty("machine.display")); + String sDisplayType = sd.nextToken(':'); + String sDisplayParam1 = sd.nextToken(','); + String sDisplayParam2 = sd.nextToken(','); + + if ("serial".equals(sDisplayType) + || "rxtx".equals(sDisplayType) + || "file".equals(sDisplayType)) { + sDisplayParam2 = sDisplayParam1; + sDisplayParam1 = sDisplayType; + sDisplayType = "epson"; + } + + try { + + switch (sDisplayType) { + case "screen": + m_devicedisplay = new DeviceDisplayPanel(); + break; + case "window": + m_devicedisplay = new DeviceDisplayWindow(); + break; + case "epson": + m_devicedisplay = new DeviceDisplayESCPOS( + pws.getPrinterWritter(sDisplayParam1, sDisplayParam2) + , new UnicodeTranslatorInt()); + break; + case "surepos": + m_devicedisplay = new DeviceDisplaySurePOS( + pws.getPrinterWritter(sDisplayParam1, sDisplayParam2)); + break; + case "ld200": + m_devicedisplay = new DeviceDisplayESCPOS( + pws.getPrinterWritter(sDisplayParam1, sDisplayParam2) + , new UnicodeTranslatorEur()); + break; + case "javapos": + m_devicedisplay = new DeviceDisplayJavaPOS(sDisplayParam1); + break; + default: + m_devicedisplay = new DeviceDisplayNull(); + break; + } + } catch (TicketPrinterException e) { + log.error(e.getMessage()); + m_devicedisplay = new DeviceDisplayNull(e.getMessage()); + } + + m_nullprinter = new DevicePrinterNull(); + + m_deviceprinters = new HashMap<>(); + m_deviceprinterslist = new ArrayList<>(); + + // Empezamos a iterar por las impresoras... + int iPrinterIndex = 1; + String sPrinterIndex = Integer.toString(iPrinterIndex); + String sprinter = props.getProperty("machine.printer"); + + while (sprinter != null && !"".equals(sprinter)) { + + StringParser sp = new StringParser(sprinter); + String sPrinterType = sp.nextToken(':'); + String sPrinterParam1 = sp.nextToken(','); + String sPrinterParam2 = sp.nextToken(','); + + + if ("serial".equals(sPrinterType) + || "rxtx".equals(sPrinterType) + || "file".equals(sPrinterType)) { + sPrinterParam2 = sPrinterParam1; + sPrinterParam1 = sPrinterType; + sPrinterType = "epson"; + } + + try { + + switch (sPrinterType) { + case "screen": + addPrinter(sPrinterIndex, new DevicePrinterPanel()); + break; + case "printer": + // backward compatibility + if (sPrinterParam2 == null || sPrinterParam2.equals("") + || sPrinterParam2.equals("true")) { + sPrinterParam2 = "receipt"; + } else if (sPrinterParam2.equals("false")) { + sPrinterParam2 = "standard"; + } + addPrinter(sPrinterIndex, new DevicePrinterPrinter(parent, sPrinterParam1, + Integer.parseInt(props.getProperty("paper." + sPrinterParam2 + ".x")), + Integer.parseInt(props.getProperty("paper." + sPrinterParam2 + ".y")), + Integer.parseInt(props.getProperty("paper." + sPrinterParam2 + ".width")), + Integer.parseInt(props.getProperty("paper." + sPrinterParam2 + ".height")), + props.getProperty("paper." + sPrinterParam2 + ".mediasizename") + )); + break; + case "epson": + addPrinter(sPrinterIndex, new DevicePrinterESCPOS( + pws.getPrinterWritter(sPrinterParam1, sPrinterParam2) + , new CodesEpson(), new UnicodeTranslatorInt())); + break; + case "tmu220": + addPrinter(sPrinterIndex, new DevicePrinterESCPOS( + pws.getPrinterWritter(sPrinterParam1, sPrinterParam2) + , new CodesTMU220(), new UnicodeTranslatorInt())); + break; + case "star": + addPrinter(sPrinterIndex, new DevicePrinterESCPOS( + pws.getPrinterWritter(sPrinterParam1, sPrinterParam2) + , new CodesStar(), new UnicodeTranslatorStar())); + break; + case "ithaca": + addPrinter(sPrinterIndex, new DevicePrinterESCPOS( + pws.getPrinterWritter(sPrinterParam1, sPrinterParam2) + , new CodesIthaca(), new UnicodeTranslatorInt())); + break; + case "surepos": + addPrinter(sPrinterIndex, new DevicePrinterESCPOS( + pws.getPrinterWritter(sPrinterParam1, sPrinterParam2) + , new CodesSurePOS(), new UnicodeTranslatorSurePOS())); + break; + case "plain": + addPrinter(sPrinterIndex, new DevicePrinterPlain( + pws.getPrinterWritter(sPrinterParam1, sPrinterParam2))); + break; + case "javapos": + addPrinter(sPrinterIndex, new DevicePrinterJavaPOS( + sPrinterParam1, sPrinterParam2)); + break; + } + } catch (TicketPrinterException e) { + log.error(e.getMessage()); + } + + iPrinterIndex++; + sPrinterIndex = Integer.toString(iPrinterIndex); + sprinter = props.getProperty("machine.printer." + sPrinterIndex); + } + } + + private void addPrinter(String sPrinterIndex, DevicePrinter p) { + m_deviceprinters.put(sPrinterIndex, p); + m_deviceprinterslist.add(p); + } + + private static class PrinterWritterPool { + + private final Map<String, PrinterWritter> m_apool = new HashMap<>(); + + public PrinterWritter getPrinterWritter(String con, String port) throws TicketPrinterException { + + String skey = con + "-->" + port; + PrinterWritter pw = (PrinterWritter) m_apool.get(skey); + if (pw == null) { + + switch (con) { + case "serial": + case "rxtx": + pw = new PrinterWritterRXTX(port); + m_apool.put(skey, pw); + break; + case "file": + pw = new PrinterWritterFile(port); + m_apool.put(skey, pw); + break; + default: + throw new TicketPrinterException(); + } + } + return pw; + } + } + + + /** + * @return Fiscal printer + */ + public DeviceFiscalPrinter getFiscalPrinter() { + return m_deviceFiscal; + } + + /** + * @return Device display + */ + public DeviceDisplay getDeviceDisplay() { + return m_devicedisplay; + } + + /** + * @param key + * @return Device printer + */ + public DevicePrinter getDevicePrinter(String key) { + DevicePrinter printer = m_deviceprinters.get(key); + return printer == null ? m_nullprinter : printer; + } + + /** + * @return Device printer list + */ + public List<DevicePrinter> getDevicePrinterAll() { + return m_deviceprinterslist; + } + + /** + * @param iSize + * @param cWhiteChar + * @return Spacing string length + */ + public static String getWhiteString(int iSize, char cWhiteChar) { + + char[] cFill = new char[iSize]; + for (int i = 0; i < iSize; i++) { + cFill[i] = cWhiteChar; + } + return new String(cFill); + } + + /** + * @param iSize + * @return Space sizing + */ + public static String getWhiteString(int iSize) { + + return getWhiteString(iSize, ' '); + } + + /** + * @param sLine + * @param iSize + * @return Barcode bar inter-spacing + */ + public static String alignBarCode(String sLine, int iSize) { + + if (sLine.length() > iSize) { + return sLine.substring(sLine.length() - iSize); + } else { + return getWhiteString(iSize - sLine.length(), '0') + sLine; + } + } + + /** + * @param sLine + * @param iSize + * @return Reduce spacing + */ + public static String alignLeft(String sLine, int iSize) { + + if (sLine.length() > iSize) { + return sLine.substring(0, iSize); + } else { + return sLine + getWhiteString(iSize - sLine.length()); + } + } + + /** + * @param sLine + * @param iSize + * @return Add spacing + */ + public static String alignRight(String sLine, int iSize) { + + if (sLine.length() > iSize) { + return sLine.substring(sLine.length() - iSize); + } else { + return getWhiteString(iSize - sLine.length()) + sLine; + } + } + + /** + * @param sLine + * @param iSize + * @return Adjusts Left/Right spacing + */ + public static String alignCenter(String sLine, int iSize) { + + if (sLine.length() > iSize) { + return alignRight(sLine.substring(0, (sLine.length() + iSize) / 2), iSize); + } else { + return alignRight(sLine + getWhiteString((iSize - sLine.length()) / 2), iSize); + } + } + + /** + * @param sLine + * @return Equalise Left/Right spacing + */ + public static String alignCenter(String sLine) { + return alignCenter(sLine, 42); + } + +// JG 16 May 12 public static final byte[] transNumber(String sCad) { + + /** + * @param sCad + * @return Convert number to string + */ + public static byte[] transNumber(String sCad) { + + if (sCad == null) { + return null; + } else { + byte bAux[] = new byte[sCad.length()]; + for (int i = 0; i < sCad.length(); i++) { + bAux[i] = transNumberChar(sCad.charAt(i)); + } + return bAux; + } + } + + /** + * @param sChar + * @return Convert hex to character + */ + public static byte transNumberChar(char sChar) { + switch (sChar) { + case '0': + return 0x30; + case '1': + return 0x31; + case '2': + return 0x32; + case '3': + return 0x33; + case '4': + return 0x34; + case '5': + return 0x35; + case '6': + return 0x36; + case '7': + return 0x37; + case '8': + return 0x38; + case '9': + return 0x39; + default: + return 0x30; + } + } +} diff --git a/src/main/java/com/unicenta/pos/printer/DisplayAnimator.java b/src/main/java/com/unicenta/pos/printer/DisplayAnimator.java new file mode 100644 index 0000000..2ff5fb2 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/DisplayAnimator.java @@ -0,0 +1,45 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer; + +/** + * + * @author adrianromero + */ +public interface DisplayAnimator { + + /** + * + * @param i + */ + public void setTiming(int i); + + /** + * + * @return + */ + public String getLine1(); + + /** + * + * @return + */ + public String getLine2(); +} diff --git a/src/main/java/com/unicenta/pos/printer/FlyerAnimator.java b/src/main/java/com/unicenta/pos/printer/FlyerAnimator.java new file mode 100644 index 0000000..fb9bb24 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/FlyerAnimator.java @@ -0,0 +1,54 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + + +package com.unicenta.pos.printer; + +/** + * + * @author adrianromero + */ +public class FlyerAnimator extends BaseAnimator { + + /** + * + * @param line1 + * @param line2 + */ + public FlyerAnimator(String line1, String line2) { + baseLine1 = DeviceTicket.alignLeft(line1, 20); + baseLine2 = DeviceTicket.alignLeft(line2, 20); + } + + /** + * + * @param i + */ + @Override + public void setTiming(int i) { + + if (i < 20) { + currentLine1 = DeviceTicket.alignRight(baseLine1.substring(0, i), 20); + currentLine2 = DeviceTicket.alignRight(baseLine2.substring(0, i), 20); + } else { + currentLine1 = baseLine1; + currentLine2 = baseLine2; + } + } +} diff --git a/src/main/java/com/unicenta/pos/printer/NullAnimator.java b/src/main/java/com/unicenta/pos/printer/NullAnimator.java new file mode 100644 index 0000000..b313fff --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/NullAnimator.java @@ -0,0 +1,73 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer; + +/** + * + * @author adrianromero + */ +public class NullAnimator implements DisplayAnimator { + + /** + * + */ + protected String currentLine1; + + /** + * + */ + protected String currentLine2; + + /** + * + * @param line1 + * @param line2 + */ + public NullAnimator(String line1, String line2) { + currentLine1 = DeviceTicket.alignLeft(line1, 20); + currentLine2 = DeviceTicket.alignLeft(line2, 20); + } + + /** + * + * @param i + */ + @Override + public void setTiming(int i) { + } + + /** + * + * @return + */ + @Override + public String getLine1() { + return currentLine1; + } + + /** + * + * @return + */ + @Override + public String getLine2() { + return currentLine2; + } +} diff --git a/src/main/java/com/unicenta/pos/printer/ScrollAnimator.java b/src/main/java/com/unicenta/pos/printer/ScrollAnimator.java new file mode 100644 index 0000000..1a001c8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/ScrollAnimator.java @@ -0,0 +1,56 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer; + +/** + * + * @author adrianromero + */ +public class ScrollAnimator extends BaseAnimator { + + private int msglength; + + /** + * + * @param line1 + * @param line2 + */ + public ScrollAnimator(String line1, String line2) { + msglength = Math.max(line1.length(), line2.length()); + baseLine1 = DeviceTicket.alignLeft(line1, msglength); + baseLine2 = DeviceTicket.alignLeft(line2, msglength); + } + + /** + * + * @param i + */ + @Override + public void setTiming(int i) { + int j = (i / 2) % (msglength + 20); + if (j < 20) { + currentLine1 = DeviceTicket.alignLeft(DeviceTicket.getWhiteString(20 - j) + baseLine1, 20); + currentLine2 = DeviceTicket.alignLeft(DeviceTicket.getWhiteString(20 - j) + baseLine2, 20); + } else { + currentLine1 = DeviceTicket.alignLeft(baseLine1.substring(j - 20), 20); + currentLine2 = DeviceTicket.alignLeft(baseLine2.substring(j - 20), 20); + } + } +} diff --git a/src/main/java/com/unicenta/pos/printer/TicketParser.java b/src/main/java/com/unicenta/pos/printer/TicketParser.java new file mode 100644 index 0000000..b988be9 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/TicketParser.java @@ -0,0 +1,506 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.LocalRes; +import com.unicenta.pos.forms.DataLogicSystem; +import com.unicenta.pos.ticket.TicketInfo; +import java.applet.Applet; +import java.applet.AudioClip; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Base64; +import java.util.Calendar; +import java.util.Date; +import javax.imageio.ImageIO; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * + * @author JG uniCenta + */ +public class TicketParser extends DefaultHandler { + + private static SAXParser m_sp = null; + + private DeviceTicket m_printer; + private DataLogicSystem m_system; + + private StringBuilder text; + + private String bctype; + private String bcposition; + private int m_iTextAlign; + private int m_iTextLength; + private int m_iTextStyle; + private int size; + + private StringBuilder m_sVisorLine; + private int m_iVisorAnimation; + private String m_sVisorLine1; + private String m_sVisorLine2; + + private double m_dValue1; + private double m_dValue2; + private int attribute3; + + private int m_iOutputType; + private static final int OUTPUT_NONE = 0; + private static final int OUTPUT_DISPLAY = 1; + private static final int OUTPUT_TICKET = 2; + private static final int OUTPUT_FISCAL = 3; + private DevicePrinter m_oOutputPrinter; + private DateFormat df= new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); + private Date today; + private String cUser; + private String ticketId; + private String pickupId; + + + /** Creates a new instance of TicketParser + * @param printer + * @param system */ + public TicketParser(DeviceTicket printer, DataLogicSystem system) { + m_printer = printer; + m_system = system; + today = Calendar.getInstance().getTime(); + } + + /** + * + * @param sIn + * @param ticket + * @throws TicketPrinterException + */ + public void printTicket(String sIn, TicketInfo ticket) throws TicketPrinterException { +// cUser=ticket.getUser().getName(); + cUser=ticket.getName(); + ticketId=Integer.toString(ticket.getTicketId()); + pickupId=Integer.toString(ticket.getPickupId()); + + if (ticket.getTicketId()==0){ + ticketId="No Sale"; + } + if (ticket.getPickupId()==0){ + pickupId="No PickupId"; + } + printTicket(new StringReader(sIn)); + + + } + + /** + * + * @param sIn + * @throws TicketPrinterException + */ + public void printTicket(String sIn) throws TicketPrinterException { + printTicket(new StringReader(sIn)); + } + + /** + * + * @param in + * @throws TicketPrinterException + */ + public void printTicket(Reader in) throws TicketPrinterException { + + try { + + if (m_sp == null) { + SAXParserFactory spf = SAXParserFactory.newInstance(); + m_sp = spf.newSAXParser(); + } + m_sp.parse(new InputSource(in), this); + + } catch (ParserConfigurationException ePC) { + throw new TicketPrinterException(LocalRes.getIntString("exception.parserconfig") , ePC); + } catch (SAXException eSAX) { + throw new TicketPrinterException(LocalRes.getIntString("exception.xmlfile") , eSAX); + } catch (IOException eIO) { + throw new TicketPrinterException(LocalRes.getIntString("exception.iofile") , eIO); + } + } + + @Override + public void startDocument() throws SAXException { + // inicalizo las variables pertinentes + text = null; + bctype = null; + bcposition = null; + m_sVisorLine = null; + m_iVisorAnimation = DeviceDisplayBase.ANIMATION_NULL; + m_sVisorLine1 = null; + m_sVisorLine2 = null; + m_iOutputType = OUTPUT_NONE; + m_oOutputPrinter = null; + } + + @Override + public void endDocument() throws SAXException { + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException{ + String openDate = df.format(today); + Date dNow = new Date(); + + switch (m_iOutputType) { + case OUTPUT_NONE: + switch (qName) { + case "opendrawer": + m_printer.getDevicePrinter(readString(attributes.getValue("printer"), "1")).openDrawer(); + // Cashdrawer has been activated record the data in the table + try { + m_system.execDrawerOpened( + //new Object[] {df.format(dNow),cUser,ticketId}); + new Object[] {cUser,ticketId}); + } catch (BasicException ex) {} + break; + case "play": + text = new StringBuilder(); + break; + case "ticket": + m_iOutputType = OUTPUT_TICKET; + m_oOutputPrinter = m_printer.getDevicePrinter(readString(attributes.getValue("printer"), "1")); + m_oOutputPrinter.beginReceipt(); + break; + case "display": + m_iOutputType = OUTPUT_DISPLAY; + String animation = attributes.getValue("animation"); + if ("scroll".equals(animation)) { + m_iVisorAnimation = DeviceDisplayBase.ANIMATION_SCROLL; + } else if ("flyer".equals(animation)) { + m_iVisorAnimation = DeviceDisplayBase.ANIMATION_FLYER; + } else if ("blink".equals(animation)) { + m_iVisorAnimation = DeviceDisplayBase.ANIMATION_BLINK; + } else if ("curtain".equals(animation)) { + m_iVisorAnimation = DeviceDisplayBase.ANIMATION_CURTAIN; + } else { // "none" + m_iVisorAnimation = DeviceDisplayBase.ANIMATION_NULL; + } + m_sVisorLine1 = null; + m_sVisorLine2 = null; + m_oOutputPrinter = null; + break; + case "fiscalreceipt": + m_iOutputType = OUTPUT_FISCAL; + m_printer.getFiscalPrinter().beginReceipt(); + break; + case "fiscalzreport": + m_printer.getFiscalPrinter().printZReport(); + break; + case "fiscalxreport": + m_printer.getFiscalPrinter().printXReport(); + break; + } + break; + case OUTPUT_TICKET: + if (null != qName)switch (qName) { + case "logo": + text = new StringBuilder(); + break; + case "image": + text = new StringBuilder(); + break; + case "barcode": + text = new StringBuilder(); + bctype = attributes.getValue("type"); + bcposition = attributes.getValue("position"); + break; + case "line": + m_oOutputPrinter.beginLine(parseInt(attributes.getValue("size"), DevicePrinter.SIZE_0)); + break; + case "text": + text = new StringBuilder(); + m_iTextStyle = ("true".equals(attributes.getValue("bold")) + ? DevicePrinter.STYLE_BOLD : DevicePrinter.STYLE_PLAIN) + | ("true".equals(attributes.getValue("underline")) + ? DevicePrinter.STYLE_UNDERLINE : DevicePrinter.STYLE_PLAIN); + String sAlign = attributes.getValue("align"); + if (null == sAlign) { + m_iTextAlign = DevicePrinter.ALIGN_LEFT; + } else switch (sAlign) { + case "right": + m_iTextAlign = DevicePrinter.ALIGN_RIGHT; + break; + case "center": + m_iTextAlign = DevicePrinter.ALIGN_CENTER; + break; + default: + m_iTextAlign = DevicePrinter.ALIGN_LEFT; + break; + } + m_iTextLength = parseInt(attributes.getValue("length"), 0); + break; + default: + break; + } + break; + case OUTPUT_DISPLAY: + if (null != qName) switch (qName) { + case "line": + // line 1 or 2 of the display + m_sVisorLine = new StringBuilder(); + break; + case "line1": + // linea 1 del visor + m_sVisorLine = new StringBuilder(); + break; + case "line2": + // linea 2 del visor + m_sVisorLine = new StringBuilder(); + break; + case "text": + text = new StringBuilder(); + String sAlign = attributes.getValue("align"); + if (null == sAlign) { + m_iTextAlign = DevicePrinter.ALIGN_LEFT; + } else switch (sAlign) { + case "right": + m_iTextAlign = DevicePrinter.ALIGN_RIGHT; + break; + case "center": + m_iTextAlign = DevicePrinter.ALIGN_CENTER; + break; + default: + m_iTextAlign = DevicePrinter.ALIGN_LEFT; + break; + } + m_iTextLength = parseInt(attributes.getValue("length")); + break; + default: + break; + } + break; + case OUTPUT_FISCAL: + if (null != qName) + switch (qName) { + case "line": + text = new StringBuilder(); + m_dValue1 = parseDouble(attributes.getValue("price")); + m_dValue2 = parseDouble(attributes.getValue("units"), 1.0); + attribute3 = parseInt(attributes.getValue("tax")); + break; + case "message": + text = new StringBuilder(); + break; + case "total": + text = new StringBuilder(); + m_dValue1 = parseDouble(attributes.getValue("paid")); + break; + default: + break; + } + break; + } + } + + @Override + public void endElement(String uri, String localName, String qName) throws SAXException { + + switch (m_iOutputType) { + case OUTPUT_NONE: + if ("play".equals(qName)) { + try { + AudioClip oAudio = Applet.newAudioClip(getClass().getClassLoader().getResource(text.toString())); + oAudio.play(); + } catch (Exception fnfe) { + //throw new ResourceNotFoundException( fnfe.getMessage() ); + } + text = null; + } + break; + +// Added 23.05.13 used by star TSP700 to print stored logo image JDL + case OUTPUT_TICKET: + if ("logo".equals(qName)){ + m_oOutputPrinter.printLogo(); + // } + }else if ("image".equals(qName)){ + try { +// BufferedImage image = ImageIO.read(getClass().getClassLoader().getResourceAsStream(text.toString())); + BufferedImage image = m_system.getResourceAsImage(text.toString()); + + if (image == null) { + image = decodeToImage(text.toString()); + } + if (image != null) { + m_oOutputPrinter.printImage(image); + } + + } catch (Exception fnfe) { + //throw new ResourceNotFoundException( fnfe.getMessage() ); + } + text = null; + } else if ("barcode".equals(qName)) { + m_oOutputPrinter.printBarCode(bctype, bcposition, text.toString()); + text = null; + } else if ("text".equals(qName)) { + if (m_iTextLength > 0) { + switch(m_iTextAlign) { + case DevicePrinter.ALIGN_RIGHT: + m_oOutputPrinter.printText(m_iTextStyle, DeviceTicket.alignRight(text.toString(), m_iTextLength)); + break; + case DevicePrinter.ALIGN_CENTER: + m_oOutputPrinter.printText(m_iTextStyle, DeviceTicket.alignCenter(text.toString(), m_iTextLength)); + break; + default: // DevicePrinter.ALIGN_LEFT + m_oOutputPrinter.printText(m_iTextStyle, DeviceTicket.alignLeft(text.toString(), m_iTextLength)); + break; + } + } else { + m_oOutputPrinter.printText(m_iTextStyle, text.toString()); + } + text = null; + } else if ("line".equals(qName)) { + m_oOutputPrinter.endLine(); + } else if ("ticket".equals(qName)) { + m_oOutputPrinter.endReceipt(); + m_iOutputType = OUTPUT_NONE; + m_oOutputPrinter = null; + } + break; + case OUTPUT_DISPLAY: + if ("line".equals(qName)) { // line 1 or 2 of the display + if (m_sVisorLine1 == null) { + m_sVisorLine1 = m_sVisorLine.toString(); + } else { + m_sVisorLine2 = m_sVisorLine.toString(); + } + m_sVisorLine = null; + } else if ("line1".equals(qName)) { // linea 1 del visor + m_sVisorLine1 = m_sVisorLine.toString(); + m_sVisorLine = null; + } else if ("line2".equals(qName)) { // linea 2 del visor + m_sVisorLine2 = m_sVisorLine.toString(); + m_sVisorLine = null; + } else if ("text".equals(qName)) { + if (m_iTextLength > 0) { + switch(m_iTextAlign) { + case DevicePrinter.ALIGN_RIGHT: + m_sVisorLine.append(DeviceTicket.alignRight(text.toString(), m_iTextLength)); + break; + case DevicePrinter.ALIGN_CENTER: + m_sVisorLine.append(DeviceTicket.alignCenter(text.toString(), m_iTextLength)); + break; + default: // DevicePrinter.ALIGN_LEFT + m_sVisorLine.append(DeviceTicket.alignLeft(text.toString(), m_iTextLength)); + break; + } + } else { + m_sVisorLine.append(text); + } + text = null; + } else if ("display".equals(qName)) { + m_printer.getDeviceDisplay().writeVisor(m_iVisorAnimation, m_sVisorLine1, m_sVisorLine2); + m_iVisorAnimation = DeviceDisplayBase.ANIMATION_NULL; + m_sVisorLine1 = null; + m_sVisorLine2 = null; + m_iOutputType = OUTPUT_NONE; + m_oOutputPrinter = null; + } + break; + case OUTPUT_FISCAL: + if ("fiscalreceipt".equals(qName)) { + m_printer.getFiscalPrinter().endReceipt(); + m_iOutputType = OUTPUT_NONE; + } else if ("line".equals(qName)) { + m_printer.getFiscalPrinter().printLine(text.toString(), m_dValue1, m_dValue2, attribute3); + text = null; + } else if ("message".equals(qName)) { + m_printer.getFiscalPrinter().printMessage(text.toString()); + text = null; + } else if ("total".equals(qName)) { + m_printer.getFiscalPrinter().printTotal(text.toString(), m_dValue1); + text = null; + } + break; + } + } + + @Override + public void characters(char[] ch, int start, int length) throws SAXException { + if (text != null) { + text.append(ch, start, length); + } + } + + private int parseInt(String sValue, int iDefault) { + try { + return Integer.parseInt(sValue); + } catch (NumberFormatException eNF) { + return iDefault; + } + } + + private int parseInt(String sValue) { + return parseInt(sValue, 0); + } + + private double parseDouble(String sValue, double ddefault) { + try { + return Double.parseDouble(sValue); + } catch (NumberFormatException eNF) { + return ddefault; + } + } + + private double parseDouble(String sValue) { + return parseDouble(sValue, 0.0); + } + + private String readString(String sValue, String sDefault) { + if (sValue == null || sValue.equals("")) { + return sDefault; + } else { + return sValue; + } + } + private static BufferedImage decodeToImage(String imageString) { + + BufferedImage image = null; + byte[] imageByte; + try { + Base64.Decoder decoder = Base64.getMimeDecoder(); + imageByte = decoder.decode(imageString); + ByteArrayInputStream bis = new ByteArrayInputStream(imageByte); + image = ImageIO.read(bis); + bis.close(); + } catch (Exception e) { + e.printStackTrace(); + } + return image; + + + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/printer/TicketPrinterException.java b/src/main/java/com/unicenta/pos/printer/TicketPrinterException.java new file mode 100644 index 0000000..7e496cf --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/TicketPrinterException.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer; + +/** + * + * @author JG uniCenta + */ +public class TicketPrinterException extends java.lang.Exception { + + /** + * + */ + public TicketPrinterException() { + } + + /** + * + * @param msg + */ + public TicketPrinterException(String msg) { + super(msg); + } + + /** + * + * @param msg + * @param cause + */ + public TicketPrinterException(String msg, Throwable cause) { + super(msg, cause); + } +} + + diff --git a/src/main/java/com/unicenta/pos/printer/escpos/Codes.java b/src/main/java/com/unicenta/pos/printer/escpos/Codes.java new file mode 100644 index 0000000..f395875 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/Codes.java @@ -0,0 +1,258 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +import com.unicenta.pos.printer.DevicePrinter; +import com.unicenta.pos.printer.DeviceTicket; +import java.awt.image.BufferedImage; + +/** + * + * @author JG uniCenta + */ +public abstract class Codes { + + /** Creates a new instance of Codes */ + public Codes() { + } + + /** + * + * @return + */ + public abstract byte[] getInitSequence(); + + /** + * + * @return + */ + public abstract byte[] getSize0(); + + /** + * + * @return + */ + public abstract byte[] getSize1(); + + /** + * + * @return + */ + public abstract byte[] getSize2(); + + /** + * + * @return + */ + public abstract byte[] getSize3(); + + /** + * + * @return + */ + public abstract byte[] getBoldSet(); + + /** + * + * @return + */ + public abstract byte[] getBoldReset(); + + /** + * + * @return + */ + public abstract byte[] getUnderlineSet(); + + /** + * + * @return + */ + public abstract byte[] getUnderlineReset(); + + /** + * + * @return + */ + public abstract byte[] getOpenDrawer(); + + /** + * + * @return + */ + public abstract byte[] getCutReceipt(); + + /** + * + * @return + */ + public abstract byte[] getNewLine(); + + /** + * + * @return + */ + public abstract byte[] getImageHeader(); + + /** + * + * @return + */ + public abstract int getImageWidth(); + + /** + * + * @return + */ + public abstract byte[] getImageLogo(); + + /** + * + * @param out + * @param type + * @param position + * @param code + */ + public void printBarcode(PrinterWritter out, String type, String position, String code) { + + if (DevicePrinter.BARCODE_EAN13.equals(type)) { + + out.write(getNewLine()); + + out.write(ESCPOS.BAR_HEIGHT); + if (DevicePrinter.POSITION_NONE.equals(position)) { + out.write(ESCPOS.BAR_POSITIONNONE); + } else { + out.write(ESCPOS.BAR_POSITIONDOWN); + } + out.write(ESCPOS.BAR_HRIFONT1); + out.write(ESCPOS.BAR_CODE02); + out.write(DeviceTicket.transNumber(DeviceTicket.alignBarCode(code,13).substring(0,12))); + out.write(new byte[] { 0x00 }); + + out.write(getNewLine()); + } + } + + /** + * + * @param image + * @return + */ + public byte[] transImage(BufferedImage image) { + + CenteredImage centeredimage = new CenteredImage(image, getImageWidth()); + + // Imprimo los par\u00e1metros en cu\u00e1druple + int iWidth = (centeredimage.getWidth() + 7) / 8; // n\u00famero de bytes + int iHeight = centeredimage.getHeight(); + + // Array de datos + byte[] bData = new byte[getImageHeader().length + 4 + iWidth * iHeight]; + + // Comando de impresion de imagen + System.arraycopy(getImageHeader(), 0, bData, 0, getImageHeader().length); + + int index = getImageHeader().length; + + // Dimension de la imagen + // JG note: nested ++'s not good construct need change later + bData[index ++] = (byte) (iWidth % 256); + bData[index ++] = (byte) (iWidth / 256); + bData[index ++] = (byte) (iHeight % 256); + bData[index ++] = (byte) (iHeight / 256); + + // Raw data + // JG note: nested ++'s and var assignments not good construct need change later + int iRGB; + int p; + for (int i = 0; i < centeredimage.getHeight(); i++) { + for (int j = 0; j < centeredimage.getWidth(); j = j + 8) { + p = 0x00; + for (int d = 0; d < 8; d ++) { + p = p << 1; + if (centeredimage.isBlack(j + d, i)) { + p = p | 0x01; + } + } + + bData[index ++] = (byte) p; + } + } + return bData; + } + + /** + * + */ + protected class CenteredImage { + + private BufferedImage image; + private int width; + + /** + * + * @param image + * @param width + */ + public CenteredImage(BufferedImage image, int width) { + this.image = image; + this.width = width; + } + + /** + * + * @return + */ + public int getHeight() { + return image.getHeight(); + } + + /** + * + * @return + */ + public int getWidth() { + return width; + } + + /** + * + * @param x + * @param y + * @return + */ + public boolean isBlack(int x, int y) { + + int centeredx = x + (image.getWidth() - width) / 2; + if (centeredx < 0 || centeredx >= image.getWidth() || y < 0 || y >= image.getHeight()) { + return false; + } else { + int rgb = image.getRGB(centeredx, y); + + int gray = (int)(0.30 * ((rgb >> 16) & 0xff) + + 0.59 * ((rgb >> 8) & 0xff) + + 0.11 * (rgb & 0xff)); + + return gray < 128; + } + } + } +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/CodesEpson.java b/src/main/java/com/unicenta/pos/printer/escpos/CodesEpson.java new file mode 100644 index 0000000..70eb05e --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/CodesEpson.java @@ -0,0 +1,155 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +/** + * + * @author JG uniCenta + */ +public class CodesEpson extends Codes { + + private static final byte[] INITSEQUENCE = {}; + + private static final byte[] CHAR_SIZE_0 = {0x1D, 0x21, 0x00}; + private static final byte[] CHAR_SIZE_1 = {0x1D, 0x21, 0x01}; + private static final byte[] CHAR_SIZE_2 = {0x1D, 0x21, 0x30}; + private static final byte[] CHAR_SIZE_3 = {0x1D, 0x21, 0x31}; + + public static final byte[] BOLD_SET = {0x1B, 0x45, 0x01}; + public static final byte[] BOLD_RESET = {0x1B, 0x45, 0x00}; + + public static final byte[] UNDERLINE_SET = {0x1B, 0x2D, 0x01}; + public static final byte[] UNDERLINE_RESET = {0x1B, 0x2D, 0x00}; + + private static final byte[] OPEN_DRAWER = {0x1B, 0x70, 0x00, 0x32, -0x06}; + private static final byte[] PARTIAL_CUT_1 = {0x1B, 0x69}; + private static final byte[] IMAGE_HEADER = {0x1D, 0x76, 0x30, 0x03}; + private static final byte[] NEW_LINE = {0x0D, 0x0A}; // Print and carriage return + private static final byte[] IMAGE_LOGO = {0x1B, 0x1C, 0x70, 0x01, 0x00}; + + /** Creates a new instance of CodesEpson */ + public CodesEpson() { + } + + /** + * + * @return + */ + @Override + public byte[] getInitSequence() { return INITSEQUENCE; } + + /** + * + * @return + */ + @Override + public byte[] getSize0() { return CHAR_SIZE_0; } + + /** + * + * @return + */ + @Override + public byte[] getSize1() { return CHAR_SIZE_1; } + + /** + * + * @return + */ + @Override + public byte[] getSize2() { return CHAR_SIZE_2; } + + /** + * + * @return + */ + @Override + public byte[] getSize3() { return CHAR_SIZE_3; } + + /** + * + * @return + */ + @Override + public byte[] getBoldSet() { return BOLD_SET; } + + /** + * + * @return + */ + @Override + public byte[] getBoldReset() { return BOLD_RESET; } + + /** + * + * @return + */ + @Override + public byte[] getUnderlineSet() { return UNDERLINE_SET; } + + /** + * + * @return + */ + @Override + public byte[] getUnderlineReset() { return UNDERLINE_RESET; } + + /** + * + * @return + */ + @Override + public byte[] getOpenDrawer() { return OPEN_DRAWER; } + + /** + * + * @return + */ + @Override + public byte[] getCutReceipt() { return PARTIAL_CUT_1; } + + /** + * + * @return + */ + @Override + public byte[] getNewLine() { return NEW_LINE; } + + /** + * + * @return + */ + @Override + public byte[] getImageHeader() { return IMAGE_HEADER; } + + /** + * + * @return + */ + @Override + public int getImageWidth() { return 256; } + + /** + * + * @return + */ + @Override + public byte[] getImageLogo(){ return IMAGE_LOGO; } +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/CodesIthaca.java b/src/main/java/com/unicenta/pos/printer/escpos/CodesIthaca.java new file mode 100644 index 0000000..def339d --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/CodesIthaca.java @@ -0,0 +1,154 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +/** + * + * @author JG uniCenta + */ +public class CodesIthaca extends Codes { + + private static final byte[] INITSEQUENCE = {}; + + private static final byte[] CHAR_SIZE_0 = {0x1D, 0x21, 0x00}; + private static final byte[] CHAR_SIZE_1 = {0x1D, 0x21, 0x01}; + private static final byte[] CHAR_SIZE_2 = {0x1D, 0x21, 0x30}; + private static final byte[] CHAR_SIZE_3 = {0x1D, 0x21, 0x31}; + + public static final byte[] BOLD_SET = {0x1B, 0x45, 0x01}; + public static final byte[] BOLD_RESET = {0x1B, 0x45, 0x00}; + public static final byte[] UNDERLINE_SET = {0x1B, 0x2D, 0x01}; + public static final byte[] UNDERLINE_RESET = {0x1B, 0x2D, 0x00}; + + private static final byte[] OPEN_DRAWER = {0x1B, 0x78, 0x01}; + private static final byte[] PARTIAL_CUT = {0x1B, 0x50, 0x00}; + private static final byte[] IMAGE_HEADER = {0x1D, 0x76, 0x30, 0x03}; + private static final byte[] NEW_LINE = {0x0D, 0x0A}; // Print and carriage return + + private static final byte[] IMAGE_LOGO = {0x1B, 0x1C, 0x70, 0x01, 0x00}; + /** Creates a new instance of CodesIthaca */ + public CodesIthaca() { + } + + /** + * + * @return + */ + @Override + public byte[] getInitSequence() { return INITSEQUENCE; } + + /** + * + * @return + */ + @Override + public byte[] getSize0() { return CHAR_SIZE_0; } + + /** + * + * @return + */ + @Override + public byte[] getSize1() { return CHAR_SIZE_1; } + + /** + * + * @return + */ + @Override + public byte[] getSize2() { return CHAR_SIZE_2; } + + /** + * + * @return + */ + @Override + public byte[] getSize3() { return CHAR_SIZE_3; } + + /** + * + * @return + */ + @Override + public byte[] getBoldSet() { return BOLD_SET; } + + /** + * + * @return + */ + @Override + public byte[] getBoldReset() { return BOLD_RESET; } + + /** + * + * @return + */ + @Override + public byte[] getUnderlineSet() { return UNDERLINE_SET; } + + /** + * + * @return + */ + @Override + public byte[] getUnderlineReset() { return UNDERLINE_RESET; } + + /** + * + * @return + */ + @Override + public byte[] getOpenDrawer() { return OPEN_DRAWER; } + + /** + * + * @return + */ + @Override + public byte[] getCutReceipt() { return PARTIAL_CUT; } + + /** + * + * @return + */ + @Override + public byte[] getNewLine() { return NEW_LINE; } + + /** + * + * @return + */ + @Override + public byte[] getImageHeader() { return IMAGE_HEADER; } + + /** + * + * @return + */ + @Override + public int getImageWidth() { return 256; } + + /** + * + * @return + */ + @Override + public byte[] getImageLogo(){ return IMAGE_LOGO; } +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/CodesStar.java b/src/main/java/com/unicenta/pos/printer/escpos/CodesStar.java new file mode 100644 index 0000000..0094df0 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/CodesStar.java @@ -0,0 +1,258 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +import com.unicenta.pos.printer.DevicePrinter; +import com.unicenta.pos.printer.DeviceTicket; +import java.awt.image.BufferedImage; + +/** + * + * @author JG uniCenta + */ +public class CodesStar extends Codes { + + // set line interspacing to 4mm + + /** + * + */ + public static final byte[] INITSEQUENCE = {0x1B, 0x7A, 0x01}; + + private static final byte[] CHAR_SIZE_0 = {0x1B, 0x69, 0x00, 0x00}; + private static final byte[] CHAR_SIZE_1 = {0x1B, 0x69, 0x01, 0x00}; + private static final byte[] CHAR_SIZE_2 = {0x1B, 0x69, 0x00, 0x01}; + private static final byte[] CHAR_SIZE_3 = {0x1B, 0x69, 0x01, 0x01}; + + private static final byte[] BOLD_SET = {0x1B, 0x45}; + private static final byte[] BOLD_RESET = {0x1B, 0x46}; + + private static final byte[] UNDERLINE_SET = {0x1B, 0x2D, 0x01}; + private static final byte[] UNDERLINE_RESET = {0x1B, 0x2D, 0x00}; + + private static final byte[] OPEN_DRAWER = {0x1C}; + private static final byte[] PARTIAL_CUT = {0x1B, 0x64, 0x30}; + private static final byte[] IMAGE_BEGIN = {0x1B, 0x30}; + private static final byte[] IMAGE_END = {0x1B, 0x7A, 0x01}; + private static final byte[] IMAGE_HEADER = {0x1B, 0x4B}; + private static final byte[] IMAGE_LOGO = {0x1B, 0x1C, 0x70,0x01, 0x00}; + private static final byte[] NEW_LINE = {0x0D, 0x0A}; // Print and carriage return + + + /** Creates a new instance of CodesStar */ + public CodesStar() { + } + + /** + * + * @return + */ + @Override + public byte[] getInitSequence() { return INITSEQUENCE; } + + /** + * + * @return + */ + @Override + public byte[] getSize0() { return CHAR_SIZE_0; } + + /** + * + * @return + */ + @Override + public byte[] getSize1() { return CHAR_SIZE_1; } + + /** + * + * @return + */ + @Override + public byte[] getSize2() { return CHAR_SIZE_2; } + + /** + * + * @return + */ + @Override + public byte[] getSize3() { return CHAR_SIZE_3; } + + /** + * + * @return + */ + @Override + public byte[] getBoldSet() { return BOLD_SET; } + + /** + * + * @return + */ + @Override + public byte[] getBoldReset() { return BOLD_RESET; } + + /** + * + * @return + */ + @Override + public byte[] getUnderlineSet() { return UNDERLINE_SET; } + + /** + * + * @return + */ + @Override + public byte[] getUnderlineReset() { return UNDERLINE_RESET; } + + /** + * + * @return + */ + @Override + public byte[] getOpenDrawer() { return OPEN_DRAWER; } + + /** + * + * @return + */ + @Override + public byte[] getCutReceipt() { return PARTIAL_CUT; } + + /** + * + * @return + */ + @Override + public byte[] getNewLine() { return NEW_LINE; } + + /** + * + * @return + */ + @Override + public byte[] getImageHeader() { return IMAGE_HEADER; } + + /** + * + * @return + */ + @Override + public int getImageWidth() { return 192; } + + /** + * + * @return + */ + @Override + public byte[] getImageLogo(){ return IMAGE_LOGO; } + + /** + * + * @param image + * @return + */ + @Override + public byte[] transImage(BufferedImage image) { + + CenteredImage centeredimage = new CenteredImage(image, getImageWidth()); + + int iWidth = centeredimage.getWidth(); + int iHeight = (centeredimage.getHeight() + 7) / 8; // + + // Array de datos + byte[] bData = new byte[ + IMAGE_BEGIN.length + + (getImageHeader().length + 2 + iWidth + getNewLine().length) * iHeight + + IMAGE_END.length]; + + // Comando de impresion de imagen + + int index = 0; + + System.arraycopy(IMAGE_BEGIN, 0, bData, index, IMAGE_BEGIN.length); + index += IMAGE_BEGIN.length; + + // Raw data + int p; + for (int i = 0; i < centeredimage.getHeight(); i += 8) { + System.arraycopy(getImageHeader(), 0, bData, index, getImageHeader().length); + index += getImageHeader().length; + + // Line Dimension + // JG note: nested ++'s not good construct need change later + bData[index ++] = (byte) (iWidth % 256); + bData[index ++] = (byte) (iWidth / 256); + + for (int j = 0; j < centeredimage.getWidth(); j++) { + p = 0x00; + for (int d = 0; d < 8; d ++) { + p = p << 1; + if (centeredimage.isBlack(j, i + d)) { + p = p | 0x01; + } + } + + bData[index ++] = (byte) p; + } + System.arraycopy(getNewLine(), 0, bData, index, getNewLine().length); + index += getNewLine().length; + + } + + System.arraycopy(IMAGE_END, 0, bData, index, IMAGE_END.length); + index += IMAGE_END.length; + + return bData; + } + + /** + * + * @param out + * @param type + * @param position + * @param code + */ + @Override + public void printBarcode(PrinterWritter out, String type, String position, String code) { + + if (DevicePrinter.BARCODE_EAN13.equals(type)) { + + // out.write(getNewLine()); + + out.write(new byte[] {0x1B, 0x1D, 0x61, 0x01}); // Align center + + out.write(new byte[] {0x1B, 0x62, 0x03}); + if (DevicePrinter.POSITION_NONE.equals(position)) { + out.write(new byte[]{0x01}); + } else { + out.write(new byte[]{0x02}); + } + out.write(new byte[]{0x02}); // dots + out.write(new byte[]{0x50}); // height + out.write(DeviceTicket.transNumber(DeviceTicket.alignBarCode(code,13).substring(0,12))); + out.write(new byte[] { 0x1E }); // end char + + out.write(new byte[] {0x1B, 0x1D, 0x61, 0x00}); // Align left + + } + } +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/CodesSurePOS.java b/src/main/java/com/unicenta/pos/printer/escpos/CodesSurePOS.java new file mode 100644 index 0000000..8b94437 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/CodesSurePOS.java @@ -0,0 +1,169 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +/** + * + * @author JG uniCenta + */ +public class CodesSurePOS extends Codes { + + private static final byte[] INITSEQUENCE = {}; + + private static final byte[] CHAR_SIZE_0 = {0x1D, 0x21, 0x00}; + private static final byte[] CHAR_SIZE_1 = {0x1D, 0x21, 0x01}; + private static final byte[] CHAR_SIZE_2 = {0x1D, 0x21, 0x30}; + private static final byte[] CHAR_SIZE_3 = {0x1D, 0x21, 0x31}; + + /** + * + */ + public static final byte[] BOLD_SET = {0x1B, 0x45, 0x01}; + + /** + * + */ + public static final byte[] BOLD_RESET = {0x1B, 0x45, 0x00}; + + /** + * + */ + public static final byte[] UNDERLINE_SET = {0x1B, 0x2D, 0x01}; + + /** + * + */ + public static final byte[] UNDERLINE_RESET = {0x1B, 0x2D, 0x00}; + + private static final byte[] OPEN_DRAWER = {0x1B, 0x70, 0x00, 0x32, -0x06}; + private static final byte[] PARTIAL_CUT_1 = {0x1B, 0x69}; + private static final byte[] IMAGE_HEADER = {0x1D, 0x76, 0x30, 0x02}; + private static final byte[] NEW_LINE = {0x0D}; // Print and carriage return + + private static final byte[] IMAGE_LOGO = {0x1B, 0x1C, 0x70, 0x01, 0x00}; + /** Creates a new instance of CodesEpson */ + public CodesSurePOS() { + } + + /** + * + * @return + */ + @Override + public byte[] getInitSequence() { return INITSEQUENCE; } + + /** + * + * @return + */ + @Override + public byte[] getSize0() { return CHAR_SIZE_0; } + + /** + * + * @return + */ + @Override + public byte[] getSize1() { return CHAR_SIZE_1; } + + /** + * + * @return + */ + @Override + public byte[] getSize2() { return CHAR_SIZE_2; } + + /** + * + * @return + */ + @Override + public byte[] getSize3() { return CHAR_SIZE_3; } + + /** + * + * @return + */ + @Override + public byte[] getBoldSet() { return BOLD_SET; } + + /** + * + * @return + */ + @Override + public byte[] getBoldReset() { return BOLD_RESET; } + + /** + * + * @return + */ + @Override + public byte[] getUnderlineSet() { return UNDERLINE_SET; } + + /** + * + * @return + */ + @Override + public byte[] getUnderlineReset() { return UNDERLINE_RESET; } + + /** + * + * @return + */ + @Override + public byte[] getOpenDrawer() { return OPEN_DRAWER; } + + /** + * + * @return + */ + @Override + public byte[] getCutReceipt() { return PARTIAL_CUT_1; } + + /** + * + * @return + */ + @Override + public byte[] getNewLine() { return NEW_LINE; } + + /** + * + * @return + */ + @Override + public byte[] getImageHeader() { return IMAGE_HEADER; } + + /** + * + * @return + */ + @Override + public int getImageWidth() { return 256; } + + /** + * + * @return + */ + @Override + public byte[] getImageLogo(){ return IMAGE_LOGO; } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/printer/escpos/CodesTMU220.java b/src/main/java/com/unicenta/pos/printer/escpos/CodesTMU220.java new file mode 100644 index 0000000..126f4c7 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/CodesTMU220.java @@ -0,0 +1,197 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +import java.awt.image.BufferedImage; + +/** + * + * @author JG uniCenta + */ +public class CodesTMU220 extends Codes { + + private static final byte[] INITSEQUENCE = {}; + + /** + * + */ + public static final byte[] CHAR_SIZE_0 = {0x1B, 0x21, 0x01}; // This sets 7x9 font + + /** + * + */ + public static final byte[] CHAR_SIZE_1 = {0x1B, 0x21, 0x11}; // This sets double hight 7x9 font + + /** + * + */ + public static final byte[] CHAR_SIZE_2 = {0x1B, 0x21, 0x21}; // This sets 7x9 double width font + + /** + * + */ + public static final byte[] CHAR_SIZE_3 = {0x1B, 0x21, 0x31}; // This sets 7x9 double width/hight font + + /** + * + */ + public static final byte[] BOLD_SET = {0x1B, 0x45, 0x01}; + + /** + * + */ + public static final byte[] BOLD_RESET = {0x1B, 0x45, 0x00}; + + /** + * + */ + public static final byte[] UNDERLINE_SET = {0x1B, 0x2D, 0x01}; + + /** + * + */ + public static final byte[] UNDERLINE_RESET = {0x1B, 0x2D, 0x00}; + + private static final byte[] OPEN_DRAWER = {0x1B, 0x70, 0x00, 0x32, -0x06}; + private static final byte[] PARTIAL_CUT_1 = {0x1B, 0x69}; + private static final byte[] IMAGE_HEADER = {0x1D, 0x76, 0x30, 0x03}; + private static final byte[] NEW_LINE = {0x0D, 0x0A}; // Print and carriage return + + private static final byte[] IMAGE_LOGO = {0x1B, 0x1C, 0x70, 0x01, 0x00}; + /** Creates a new instance of CodesTMU220 */ + public CodesTMU220() { + } + + /** + * + * @return + */ + @Override + public byte[] getInitSequence() { return INITSEQUENCE; } + + /** + * + * @return + */ + @Override + public byte[] getSize0() { return CHAR_SIZE_0; } + + /** + * + * @return + */ + @Override + public byte[] getSize1() { return CHAR_SIZE_1; } + + /** + * + * @return + */ + @Override + public byte[] getSize2() { return CHAR_SIZE_2; } + + /** + * + * @return + */ + @Override + public byte[] getSize3() { return CHAR_SIZE_3; } + + /** + * + * @return + */ + @Override + public byte[] getBoldSet() { return BOLD_SET; } + + /** + * + * @return + */ + @Override + public byte[] getBoldReset() { return BOLD_RESET; } + + /** + * + * @return + */ + @Override + public byte[] getUnderlineSet() { return UNDERLINE_SET; } + + /** + * + * @return + */ + @Override + public byte[] getUnderlineReset() { return UNDERLINE_RESET; } + + /** + * + * @return + */ + @Override + public byte[] getOpenDrawer() { return OPEN_DRAWER; } + + /** + * + * @return + */ + @Override + public byte[] getCutReceipt() { return PARTIAL_CUT_1; } + + /** + * + * @return + */ + @Override + public byte[] getNewLine() { return NEW_LINE; } + + /** + * + * @return + */ + @Override + public byte[] getImageHeader() { return IMAGE_HEADER; } // Not used + + /** + * + * @return + */ + @Override + public int getImageWidth() { return 256; } + + /** + * + * @param oImage + * @return + */ + @Override + public byte[] transImage(BufferedImage oImage) { + // Nothing to print + return new byte[0]; + } + + /** + * + * @return + */ + @Override + public byte[] getImageLogo(){ return IMAGE_LOGO; } +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/DeviceDisplayESCPOS.java b/src/main/java/com/unicenta/pos/printer/escpos/DeviceDisplayESCPOS.java new file mode 100644 index 0000000..245cc93 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/DeviceDisplayESCPOS.java @@ -0,0 +1,76 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +import com.unicenta.pos.printer.DeviceTicket; + +/** + * + * @author JG uniCenta + */ +public class DeviceDisplayESCPOS extends DeviceDisplaySerial { + + private UnicodeTranslator trans; + + /** Creates a new instance of DeviceDisplayESCPOS + * @param display + * @param trans */ + public DeviceDisplayESCPOS(PrinterWritter display, UnicodeTranslator trans) { + this.trans = trans; + init(display); + } + + /** + * + */ + @Override + public void initVisor() { + display.init(ESCPOS.INIT); + display.write(ESCPOS.SELECT_DISPLAY); // Al visor + display.write(trans.getCodeTable()); + display.write(ESCPOS.VISOR_HIDE_CURSOR); + display.write(ESCPOS.VISOR_CLEAR); + display.write(ESCPOS.VISOR_HOME); + display.flush(); + } + +// @Override +// public void clearLines() { +// display.write(ESCPOS.SELECT_DISPLAY); +// display.write(ESCPOS.VISOR_CLEAR); +// display.write(ESCPOS.VISOR_HOME); +// display.flush(); +// } + + /** + * + */ + + @Override + public void repaintLines() { + + display.write(ESCPOS.SELECT_DISPLAY); + display.write(ESCPOS.VISOR_CLEAR); + display.write(ESCPOS.VISOR_HOME); + display.write(trans.transString(DeviceTicket.alignLeft(m_displaylines.getLine1(), 20))); + display.write(trans.transString(DeviceTicket.alignLeft(m_displaylines.getLine2(), 20))); + display.flush(); + } +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/DeviceDisplaySerial.java b/src/main/java/com/unicenta/pos/printer/escpos/DeviceDisplaySerial.java new file mode 100644 index 0000000..842a6a7 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/DeviceDisplaySerial.java @@ -0,0 +1,121 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.printer.DeviceDisplay; +import com.unicenta.pos.printer.DeviceDisplayBase; +import com.unicenta.pos.printer.DeviceDisplayImpl; +/** + * + * @author adrianromero + */ +public abstract class DeviceDisplaySerial implements DeviceDisplay, DeviceDisplayImpl { + + private String m_sName; + + /** + * + */ + protected PrinterWritter display; + + /** + * + */ + protected DeviceDisplayBase m_displaylines; + + /** + * + */ + public DeviceDisplaySerial() { + m_displaylines = new DeviceDisplayBase(this); + } + + /** + * + * @param display + */ + protected void init(PrinterWritter display) { + m_sName = AppLocal.getIntString("printer.serial"); + this.display = display; + initVisor(); + } + + /** + * + * @return + */ + @Override + public String getDisplayName() { + return m_sName; + } + + /** + * + * @return + */ + @Override + public String getDisplayDescription() { + return null; + } + + /** + * + * @return + */ + @Override + public javax.swing.JComponent getDisplayComponent() { + return null; + } + + /** + * + * @param animation + * @param sLine1 + * @param sLine2 + */ + @Override + public void writeVisor(int animation, String sLine1, String sLine2) { + m_displaylines.writeVisor(animation, sLine1, sLine2); + } + + /** + * + * @param sLine1 + * @param sLine2 + */ + @Override + public void writeVisor(String sLine1, String sLine2) { + m_displaylines.writeVisor(sLine1, sLine2); + } + + /** + * + */ + @Override + public void clearVisor() { + m_displaylines.clearVisor(); + } + + /** + * + */ + public abstract void initVisor(); +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/DeviceDisplaySurePOS.java b/src/main/java/com/unicenta/pos/printer/escpos/DeviceDisplaySurePOS.java new file mode 100644 index 0000000..7c12414 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/DeviceDisplaySurePOS.java @@ -0,0 +1,66 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +import com.unicenta.pos.printer.DeviceTicket; + +/** + * + * @author adrianromero + */ +public class DeviceDisplaySurePOS extends DeviceDisplaySerial { + + private UnicodeTranslator trans; + + /** + * + * @param display + */ + public DeviceDisplaySurePOS(PrinterWritter display) { + trans = new UnicodeTranslatorSurePOS(); + init(display); + } + + /** + * + */ + @Override + public void initVisor() { + display.write(new byte[]{0x00, 0x01}); // IBM Mode + display.write(new byte[]{0x02}); // Set the code page + display.write(trans.getCodeTable()); + display.write(new byte[]{0x11}); // HIDE CURSOR + display.write(new byte[]{0x14}); // HIDE CURSOR + display.write(new byte[]{0x10, 0x00}); // VISOR HOME + display.flush(); + } + + /** + * + */ + @Override + public void repaintLines() { + display.write(new byte[]{0x10, 0x00}); // VISOR HOME + display.write(trans.transString(DeviceTicket.alignLeft(m_displaylines.getLine1(), 20))); + display.write(new byte[]{0x10, 0x14}); + display.write(trans.transString(DeviceTicket.alignLeft(m_displaylines.getLine2(), 20))); + display.flush(); + } +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/DevicePrinterESCPOS.java b/src/main/java/com/unicenta/pos/printer/escpos/DevicePrinterESCPOS.java new file mode 100644 index 0000000..a4e3912 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/DevicePrinterESCPOS.java @@ -0,0 +1,227 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.printer.DevicePrinter; +import com.unicenta.pos.printer.TicketPrinterException; +import java.awt.image.BufferedImage; +import javax.swing.JComponent; + +/** + * + * @author JG uniCenta + */ +public class DevicePrinterESCPOS implements DevicePrinter { + + private PrinterWritter m_CommOutputPrinter; + private Codes m_codes; + private UnicodeTranslator m_trans; + +// private boolean m_bInline; + private String m_sName; + + + // Creates new TicketPrinter + + /** + * + * @param CommOutputPrinter + * @param codes + * @param trans + * @throws TicketPrinterException + */ + public DevicePrinterESCPOS(PrinterWritter CommOutputPrinter, Codes codes, UnicodeTranslator trans) throws TicketPrinterException { + + m_sName = AppLocal.getIntString("printer.serial"); + m_CommOutputPrinter = CommOutputPrinter; + m_codes = codes; + m_trans = trans; + + // Inicializamos la impresora + m_CommOutputPrinter.init(ESCPOS.INIT); + + m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER); // A la impresora + m_CommOutputPrinter.init(m_codes.getInitSequence()); + m_CommOutputPrinter.write(m_trans.getCodeTable()); + + m_CommOutputPrinter.flush(); + } + + /** + * + * @return + */ + @Override + public String getPrinterName() { + return m_sName; + } + + /** + * + * @return + */ + @Override + public String getPrinterDescription() { + return null; + } + + /** + * + * @return + */ + @Override + public JComponent getPrinterComponent() { + return null; + } + + /** + * + */ + @Override + public void reset() { + } + + /** + * + */ + @Override + public void beginReceipt() { + } + + /** + * + * @param image + */ + @Override + public void printImage(BufferedImage image) { + + m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER); + m_CommOutputPrinter.write(m_codes.transImage(image)); + } + + /** + * + */ + @Override + public void printLogo() { + m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER); + m_CommOutputPrinter.write(m_codes.getImageLogo()); + } + + /** + * + * @param type + * @param position + * @param code + */ + @Override + public void printBarCode(String type, String position, String code) { + + m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER); + m_codes.printBarcode(m_CommOutputPrinter, type, position, code); + } + + /** + * + * @param iTextSize + */ + @Override + public void beginLine(int iTextSize) { + + m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER); + + if (iTextSize == DevicePrinter.SIZE_0) { + m_CommOutputPrinter.write(m_codes.getSize0()); + } else if (iTextSize == DevicePrinter.SIZE_1) { + m_CommOutputPrinter.write(m_codes.getSize1()); + } else if (iTextSize == DevicePrinter.SIZE_2) { + m_CommOutputPrinter.write(m_codes.getSize2()); + } else if (iTextSize == DevicePrinter.SIZE_3) { + m_CommOutputPrinter.write(m_codes.getSize3()); + } else { + m_CommOutputPrinter.write(m_codes.getSize0()); + } + } + + /** + * + * @param iStyle + * @param sText + */ + @Override + public void printText(int iStyle, String sText) { + + m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER); + + if ((iStyle & DevicePrinter.STYLE_BOLD) != 0) { + m_CommOutputPrinter.write(m_codes.getBoldSet()); + } + if ((iStyle & DevicePrinter.STYLE_UNDERLINE) != 0) { + m_CommOutputPrinter.write(m_codes.getUnderlineSet()); + } + m_CommOutputPrinter.write(m_trans.transString(sText)); + if ((iStyle & DevicePrinter.STYLE_UNDERLINE) != 0) { + m_CommOutputPrinter.write(m_codes.getUnderlineReset()); + } + if ((iStyle & DevicePrinter.STYLE_BOLD) != 0) { + m_CommOutputPrinter.write(m_codes.getBoldReset()); + } + } + + /** + * + */ + @Override + public void endLine() { + m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER); + m_CommOutputPrinter.write(m_codes.getNewLine()); + } + + /** + * + */ + @Override + public void endReceipt() { + m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER); + + m_CommOutputPrinter.write(m_codes.getNewLine()); + m_CommOutputPrinter.write(m_codes.getNewLine()); + m_CommOutputPrinter.write(m_codes.getNewLine()); + m_CommOutputPrinter.write(m_codes.getNewLine()); + m_CommOutputPrinter.write(m_codes.getNewLine()); + + m_CommOutputPrinter.write(m_codes.getCutReceipt()); + m_CommOutputPrinter.flush(); + } + + /** + * + */ + public void openDrawer() { + + m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER); +System.out.print(m_codes.getOpenDrawer()); + +m_CommOutputPrinter.write(m_codes.getOpenDrawer()); + m_CommOutputPrinter.flush(); + } +} + diff --git a/src/main/java/com/unicenta/pos/printer/escpos/DevicePrinterPlain.java b/src/main/java/com/unicenta/pos/printer/escpos/DevicePrinterPlain.java new file mode 100644 index 0000000..24ec481 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/DevicePrinterPlain.java @@ -0,0 +1,168 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +import com.unicenta.pos.printer.DevicePrinter; +import com.unicenta.pos.printer.TicketPrinterException; +import java.awt.image.BufferedImage; +import javax.swing.JComponent; + +/** + * + * @author JG uniCenta + */ +public class DevicePrinterPlain implements DevicePrinter { + + private static final byte[] NEW_LINE = {0x0D, 0x0A}; // Print and carriage return + + private final PrinterWritter out; + private final UnicodeTranslator trans; + + // Creates new TicketPrinter + + /** + * + * @param CommOutputPrinter + * @throws TicketPrinterException + */ + public DevicePrinterPlain(PrinterWritter CommOutputPrinter) throws TicketPrinterException { + + out = CommOutputPrinter; + trans = new UnicodeTranslatorStar(); // The star translator stands for the 437 int char page + } + + /** + * + * @return + */ + @Override + public String getPrinterName() { + return "Plain"; + } + + /** + * + * @return + */ + @Override + public String getPrinterDescription() { + return null; + } + + /** + * + * @return + */ + @Override + public JComponent getPrinterComponent() { + return null; + } + + /** + * + */ + @Override + public void reset() { + } + + /** + * + */ + @Override + public void beginReceipt() { + } + + /** + * + * @param image + */ + @Override + public void printImage(BufferedImage image) { + } + + /** + * + */ + @Override + public void printLogo(){ + + } + + /** + * + * @param type + * @param position + * @param code + */ + @Override + public void printBarCode(String type, String position, String code) { + if (! DevicePrinter.POSITION_NONE.equals(position)) { + out.write(code); + out.write(NEW_LINE); + } + } + + /** + * + * @param iTextSize + */ + @Override + public void beginLine(int iTextSize) { + } + + /** + * + * @param iStyle + * @param sText + */ + @Override + public void printText(int iStyle, String sText) { + out.write(trans.transString(sText)); + } + + /** + * + */ + @Override + public void endLine() { + out.write(NEW_LINE); + } + + /** + * + */ + @Override + public void endReceipt() { + out.write(NEW_LINE); + out.write(NEW_LINE); + out.write(NEW_LINE); + out.write(NEW_LINE); + out.write(NEW_LINE); + out.flush(); + } + + /** + * + */ + @Override + public void openDrawer() { + } +} + diff --git a/src/main/java/com/unicenta/pos/printer/escpos/ESCPOS.java b/src/main/java/com/unicenta/pos/printer/escpos/ESCPOS.java new file mode 100644 index 0000000..2bef2e7 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/ESCPOS.java @@ -0,0 +1,55 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +/** + * + * @author JG uniCenta + */ +public class ESCPOS { + + /** + * + */ + public static final byte[] INIT = {0x1B, 0x40}; + public static final byte[] SELECT_PRINTER = {0x1B, 0x3D, 0x01}; + public static final byte[] SELECT_DISPLAY = {0x1B, 0x3D, 0x02}; + public static final byte[] HT = {0x09}; // Horizontal Tab +// public static final byte[] LF = {0x0A}; // Print and line feed + public static final byte[] FF = {0x0C}; // +// public static final byte[] CR = {0x0D}; // Print and carriage return + public static final byte[] CHAR_FONT_0 = {0x1B, 0x4D, 0x00}; + public static final byte[] CHAR_FONT_1 = {0x1B, 0x4D, 0x01}; + public static final byte[] CHAR_FONT_2 = {0x1B, 0x4D, 0x30}; + public static final byte[] CHAR_FONT_3 = {0x1B, 0x4D, 0x31}; + public static final byte[] BAR_HEIGHT = {0x1D, 0x68, 0x40}; + public static final byte[] BAR_POSITIONDOWN = {0x1D, 0x48, 0x02}; + public static final byte[] BAR_POSITIONNONE = {0x1D, 0x48, 0x00}; + public static final byte[] BAR_HRIFONT1 = {0x1D, 0x66, 0x01}; + public static final byte[] BAR_CODE02 = {0x1D, 0x6B, 0x02}; // 12 numeros fijos + public static final byte[] VISOR_HIDE_CURSOR = {0x1F, 0x43, 0x00}; + public static final byte[] VISOR_SHOW_CURSOR = {0x1F, 0x43, 0x01}; + public static final byte[] VISOR_HOME = {0x0B}; + public static final byte[] VISOR_CLEAR = {0x0C}; + public static final byte[] CODE_TABLE_00 = {0x1B, 0x74, 0x00}; + public static final byte[] CODE_TABLE_13 = {0x1B, 0x74, 0x13}; + private ESCPOS() { + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/printer/escpos/PrinterWritter.java b/src/main/java/com/unicenta/pos/printer/escpos/PrinterWritter.java new file mode 100644 index 0000000..3e253f8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/PrinterWritter.java @@ -0,0 +1,114 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * + * @author JG uniCenta + */ +public abstract class PrinterWritter { + + private boolean initialized = false; + + private ExecutorService exec; + + /** + * + */ + public PrinterWritter() { + exec = Executors.newSingleThreadExecutor(); + } + + /** + * + * @param data + */ + protected abstract void internalWrite(byte[] data); + + /** + * + */ + protected abstract void internalFlush(); + + /** + * + */ + protected abstract void internalClose(); + + /** + * + * @param data + */ + public void init(final byte[] data) { + if (!initialized) { + write(data); + initialized = true; + } + } + + /** + * + * @param sValue + */ + public void write(String sValue) { + write(sValue.getBytes()); + } + + /** + * + * @param data + */ + public void write(final byte[] data) { + exec.execute(new Runnable() { + @Override + public void run() { + internalWrite(data); + } + }); + } + + /** + * + */ + public void flush() { + exec.execute(new Runnable() { + @Override + public void run() { + internalFlush(); + } + }); + } + + /** + * + */ + public void close() { + exec.execute(new Runnable() { + @Override + public void run() { + internalClose(); + } + }); + exec.shutdown(); + } +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/PrinterWritterFile.java b/src/main/java/com/unicenta/pos/printer/escpos/PrinterWritterFile.java new file mode 100644 index 0000000..a9c7b91 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/PrinterWritterFile.java @@ -0,0 +1,91 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * @author JG uniCenta + */ +public class PrinterWritterFile extends PrinterWritter { + + private String m_sFilePrinter; + private OutputStream m_out; + + /** + * + * @param sFilePrinter + */ + public PrinterWritterFile(String sFilePrinter) { + m_sFilePrinter = sFilePrinter; + m_out = null; + } + + /** + * + * @param data + */ + @Override + protected void internalWrite(byte[] data) { + try { + if (m_out == null) { + m_out = new FileOutputStream(m_sFilePrinter); // No poner append = true. + } + m_out.write(data); + } catch (IOException e) { + System.err.println(e); + } + } + + /** + * + */ + @Override + protected void internalFlush() { + try { + if (m_out != null) { + m_out.flush(); + m_out.close(); + m_out = null; + } + } catch (IOException e) { + System.err.println(e); + } + } + + /** + * + */ + @Override + protected void internalClose() { + try { + if (m_out != null) { + m_out.flush(); + m_out.close(); + m_out = null; + } + } catch (IOException e) { + System.err.println(e); + } + } +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/PrinterWritterRXTX.java b/src/main/java/com/unicenta/pos/printer/escpos/PrinterWritterRXTX.java new file mode 100644 index 0000000..fb2bc5e --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/PrinterWritterRXTX.java @@ -0,0 +1,111 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +// import javax.comm.*; // Java comm library +import com.unicenta.pos.printer.TicketPrinterException; +import gnu.io.*; +import java.io.IOException; +import java.io.OutputStream; + +/** + * + * @author JG uniCenta + */ +public class PrinterWritterRXTX extends PrinterWritter /* implements SerialPortEventListener */ { + + private CommPortIdentifier m_PortIdPrinter; + private CommPort m_CommPortPrinter; + + private String m_sPortPrinter; + private OutputStream m_out; + + /** Creates a new instance of PrinterWritterComm + * @param sPortPrinter + * @throws com.unicenta.pos.printer.TicketPrinterException */ + public PrinterWritterRXTX(String sPortPrinter) throws TicketPrinterException { + m_sPortPrinter = sPortPrinter; + m_out = null; + } + + /** + * + * @param data + */ + @Override + protected void internalWrite(byte[] data) { + try { + if (m_out == null) { + m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortPrinter); // Tomamos el puerto + m_CommPortPrinter = m_PortIdPrinter.open("PORTID", 2000); // Abrimos el puerto + + m_out = m_CommPortPrinter.getOutputStream(); // Tomamos el chorro de escritura + + if (m_PortIdPrinter.getPortType() == CommPortIdentifier.PORT_SERIAL) { + ((SerialPort)m_CommPortPrinter).setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); // Configuramos el puerto + ((SerialPort)m_CommPortPrinter).setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN); // this line prevents the printer tmu220 to stop printing after +-18 lines printed + // this line prevents the printer tmu220 to stop printing after +-18 lines printed. Bug 8324 + // But if added a regression error appears. Bug 9417, Better to keep it commented. + // ((SerialPort)m_CommPortPrinter).setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN); + // Not needed to set parallel properties + // } else if (m_PortIdPrinter.getPortType() == CommPortIdentifier.PORT_PARALLEL) { + // ((ParallelPort)m_CommPortPrinter).setMode(1); + + } + } + m_out.write(data); +// JG 16 May 12 use multicatch + } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | IOException e) { + System.err.println(e); + } + } + + /** + * + */ + @Override + protected void internalFlush() { + try { + if (m_out != null) { + m_out.flush(); + } + } catch (IOException e) { + System.err.println(e); + } + } + + /** + * + */ + @Override + protected void internalClose() { + try { + if (m_out != null) { + m_out.flush(); + m_out.close(); + m_out = null; + m_CommPortPrinter = null; + m_PortIdPrinter = null; + } + } catch (IOException e) { + System.err.println(e); + } + } +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/PrinterWritterRaw.java b/src/main/java/com/unicenta/pos/printer/escpos/PrinterWritterRaw.java new file mode 100644 index 0000000..dd50c45 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/PrinterWritterRaw.java @@ -0,0 +1,167 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Adrian Romero Corchado. +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.LinkedList; +import java.util.Locale; +import javax.print.Doc; +import javax.print.DocFlavor; +import javax.print.DocPrintJob; +import javax.print.PrintException; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.SimpleDoc; +import javax.print.attribute.DocAttributeSet; +import javax.print.attribute.HashDocAttributeSet; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.standard.DocumentName; +import javax.print.attribute.standard.JobName; + +public final class PrinterWritterRaw extends PrinterWritter { + + private byte[] m_printData; + private PrintService m_printService; + private final DocFlavor m_docFlavor; + private PrinterBuffer m_buff = null; + private OutputStream m_out; + + public PrinterWritterRaw(String sRawPrinter) { + m_printData = null; + m_docFlavor = DocFlavor.BYTE_ARRAY.AUTOSENSE; + m_buff = new PrinterBuffer(); + + init(); + + PrintService[] services = PrintServiceLookup.lookupPrintServices(m_docFlavor, null); + for (PrintService ps : services) { + if (ps.getName().contains(sRawPrinter)) { + // if we have found the prineter the start our print routine + m_printService = ps; + write(ESCPOS.INIT); + return; + } + } + } + + public void init() { + byte[] inicode = concatByteArrays(ESCPOS.SELECT_PRINTER, new UnicodeTranslatorInt().getCodeTable()); + m_printData = concatByteArrays(inicode, m_printData); + } + + @Override + public void write(byte[] data) { + m_printData = concatByteArrays(m_printData, data); + } + + @Override + public void write(String sValue) { + m_buff.putData(sValue.getBytes()); + } + + @Override + protected void internalWrite(byte[] data) { + } + + @Override + protected void internalClose() { + try { + if (m_out != null) { + m_out.flush(); + m_out.close(); + m_out = null; + } + } catch (IOException e) { + System.err.println(e); + } + } + + @Override + protected void internalFlush() { + } + + + @Override + public void flush() { + printJob(); + } + + private byte[] concatByteArrays(byte[] a, byte[] b) { + if (a == null) { + return b; + } + if (b == null) { + return a; + } + byte[] concat = new byte[a.length + b.length]; + System.arraycopy(a, 0, concat, 0, a.length); + System.arraycopy(b, 0, concat, a.length, b.length); + return concat; + } + + private void printJob() { + if (null != m_printService) { + try { + DocPrintJob pj = m_printService.createPrintJob(); + DocAttributeSet docattributes = new HashDocAttributeSet(); + + docattributes.add(new DocumentName("Ticket", Locale.getDefault())); + PrintRequestAttributeSet jobattributes = new HashPrintRequestAttributeSet(); + + jobattributes.add(new JobName("unicenta", Locale.getDefault())); + Doc doc = new SimpleDoc(m_printData, m_docFlavor, docattributes); + pj.print(doc, jobattributes); + } catch (PrintException ex) { + } finally { + m_printData = null; + } + } + } + + private class PrinterBuffer { + + private final LinkedList m_list; + + /** + * Creates a new instance of PrinterBuffer + */ + public PrinterBuffer() { + m_list = new LinkedList(); + } + + public synchronized void putData(Object data) { + m_list.addFirst(data); + notifyAll(); + } + + public synchronized Object getData() { + while (m_list.isEmpty()) { + try { + wait(); + } catch (InterruptedException e) { + } + } + notifyAll(); + return m_list.removeLast(); + } + } +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslator.java b/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslator.java new file mode 100644 index 0000000..80ab2de --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslator.java @@ -0,0 +1,188 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +/** + * + * @author JG uniCenta + */ +public abstract class UnicodeTranslator { + + /** + * + * @return + */ + public abstract byte[] getCodeTable(); + + /** + * + * @param sCad + * @return + */ + public final byte[] transString(String sCad) { + + if (sCad == null) { + return null; + } else { + byte bAux[] = new byte[sCad.length()]; + for( int i = 0; i < sCad.length(); i++) { + bAux[i] = transChar(sCad.charAt(i)); + } + return bAux; + } + } + + /** + * + * @param sChar + * @return + */ + public abstract byte transChar(char sChar); + +// case '\u0000': return -0x80; // 0x80 : +// case '\u0000': return -0x7F; // 0x81 : +// case '\u0000': return -0x7E; // 0x82 : +// case '\u0000': return -0x7D; // 0x83 : +// case '\u0000': return -0x7C; // 0x84 : +// case '\u0000': return -0x7B; // 0x85 : +// case '\u0000': return -0x7A; // 0x86 : +// case '\u0000': return -0x79; // 0x87 : +// case '\u0000': return -0x78; // 0x88 : +// case '\u0000': return -0x77; // 0x89 : +// case '\u0000': return -0x76; // 0x8A : +// case '\u0000': return -0x75; // 0x8B : +// case '\u0000': return -0x74; // 0x8C : +// case '\u0000': return -0x73; // 0x8D : +// case '\u0000': return -0x72; // 0x8E : +// case '\u0000': return -0x71; // 0x8F : +// case '\u0000': return -0x70; // 0x90 : +// case '\u0000': return -0x6F; // 0x91 : +// case '\u0000': return -0x6E; // 0x92 : +// case '\u0000': return -0x6D; // 0x93 : +// case '\u0000': return -0x6C; // 0x94 : +// case '\u0000': return -0x6B; // 0x95 : +// case '\u0000': return -0x6A; // 0x96 : +// case '\u0000': return -0x69; // 0x97 : +// case '\u0000': return -0x68; // 0x98 : +// case '\u0000': return -0x67; // 0x99 : +// case '\u0000': return -0x66; // 0x9A : +// case '\u0000': return -0x65; // 0x9B : +// case '\u0000': return -0x64; // 0x9C : +// case '\u0000': return -0x63; // 0x9D : +// case '\u0000': return -0x62; // 0x9E : +// case '\u0000': return -0x61; // 0x9F : +// case '\u0000': return -0x60; // 0xA0 : +// case '\u0000': return -0x5F; // 0xA1 : +// case '\u0000': return -0x5E; // 0xA2 : +// case '\u0000': return -0x5D; // 0xA3 : +// case '\u0000': return -0x5C; // 0xA4 : +// case '\u0000': return -0x5B; // 0xA5 : +// case '\u0000': return -0x5A; // 0xA6 : +// case '\u0000': return -0x59; // 0xA7 : +// case '\u0000': return -0x58; // 0xA8 : +// case '\u0000': return -0x57; // 0xA9 : +// case '\u0000': return -0x56; // 0xAA : +// case '\u0000': return -0x55; // 0xAB : +// case '\u0000': return -0x54; // 0xAC : +// case '\u0000': return -0x53; // 0xAD : +// case '\u0000': return -0x52; // 0xAE : +// case '\u0000': return -0x51; // 0xAF : +// case '\u0000': return -0x50; // 0xB0 : +// case '\u0000': return -0x4F; // 0xB1 : +// case '\u0000': return -0x4E; // 0xB2 : +// case '\u0000': return -0x4D; // 0xB3 : +// case '\u0000': return -0x4C; // 0xB4 : +// case '\u0000': return -0x4B; // 0xB5 : +// case '\u0000': return -0x4A; // 0xB6 : +// case '\u0000': return -0x49; // 0xB7 : +// case '\u0000': return -0x48; // 0xB8 : +// case '\u0000': return -0x47; // 0xB9 : +// case '\u0000': return -0x46; // 0xBA : +// case '\u0000': return -0x45; // 0xBB : +// case '\u0000': return -0x44; // 0xBC : +// case '\u0000': return -0x43; // 0xBD : +// case '\u0000': return -0x42; // 0xBE : +// case '\u0000': return -0x41; // 0xBF : +// case '\u0000': return -0x40; // 0xC0 : +// case '\u0000': return -0x3F; // 0xC1 : +// case '\u0000': return -0x3E; // 0xC2 : +// case '\u0000': return -0x3D; // 0xC3 : +// case '\u0000': return -0x3C; // 0xC4 : +// case '\u0000': return -0x3B; // 0xC5 : +// case '\u0000': return -0x3A; // 0xC6 : +// case '\u0000': return -0x39; // 0xC7 : +// case '\u0000': return -0x38; // 0xC8 : +// case '\u0000': return -0x37; // 0xC9 : +// case '\u0000': return -0x36; // 0xCA : +// case '\u0000': return -0x35; // 0xCB : +// case '\u0000': return -0x34; // 0xCC : +// case '\u0000': return -0x33; // 0xCD : +// case '\u0000': return -0x32; // 0xCE : +// case '\u0000': return -0x31; // 0xCF : +// case '\u0000': return -0x30; // 0xD0 : +// case '\u0000': return -0x2F; // 0xD1 : +// case '\u0000': return -0x2E; // 0xD2 : +// case '\u0000': return -0x2D; // 0xD3 : +// case '\u0000': return -0x2C; // 0xD4 : +// case '\u0000': return -0x2B; // 0xD5 : +// case '\u0000': return -0x2A; // 0xD6 : +// case '\u0000': return -0x29; // 0xD7 : +// case '\u0000': return -0x28; // 0xD8 : +// case '\u0000': return -0x27; // 0xD9 : +// case '\u0000': return -0x26; // 0xDA : +// case '\u0000': return -0x25; // 0xDB : +// case '\u0000': return -0x24; // 0xDC : +// case '\u0000': return -0x23; // 0xDD : +// case '\u0000': return -0x22; // 0xDE : +// case '\u0000': return -0x21; // 0xDF : +// case '\u0000': return -0x20; // 0xE0 : +// case '\u0000': return -0x2F; // 0xE1 : +// case '\u0000': return -0x1E; // 0xE2 : +// case '\u0000': return -0x1D; // 0xE3 : +// case '\u0000': return -0x1C; // 0xE4 : +// case '\u0000': return -0x1B; // 0xE5 : +// case '\u0000': return -0x1A; // 0xE6 : +// case '\u0000': return -0x19; // 0xE7 : +// case '\u0000': return -0x18; // 0xE8 : +// case '\u0000': return -0x17; // 0xE9 : +// case '\u0000': return -0x16; // 0xEA : +// case '\u0000': return -0x15; // 0xEB : +// case '\u0000': return -0x14; // 0xEC : +// case '\u0000': return -0x13; // 0xED : +// case '\u0000': return -0x12; // 0xEE : +// case '\u0000': return -0x11; // 0xEF : +// case '\u0000': return -0x10; // 0xF0 : +// case '\u0000': return -0x0F; // 0xF1 : +// case '\u0000': return -0x0E; // 0xF2 : +// case '\u0000': return -0x0D; // 0xF3 : +// case '\u0000': return -0x0C; // 0xF4 : +// case '\u0000': return -0x0B; // 0xF5 : +// case '\u0000': return -0x0A; // 0xF6 : +// case '\u0000': return -0x09; // 0xF7 : +// case '\u0000': return -0x08; // 0xF8 : +// case '\u0000': return -0x07; // 0xF9 : +// case '\u0000': return -0x06; // 0xFA : +// case '\u0000': return -0x05; // 0xFB : +// case '\u0000': return -0x04; // 0xFC : +// case '\u0000': return -0x03; // 0xFD : +// case '\u0000': return -0x02; // 0xFE : +// case '\u0000': return -0x01; // 0xFF : + +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslatorEur.java b/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslatorEur.java new file mode 100644 index 0000000..c45f24e --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslatorEur.java @@ -0,0 +1,76 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +/** + * + * @author JG uniCenta + */ +public class UnicodeTranslatorEur extends UnicodeTranslator { + + /** Creates a new instance of UnicodeTranslatorEur */ + public UnicodeTranslatorEur() { + } + + /** + * + * @return + */ + @Override + public byte[] getCodeTable() { + return ESCPOS.CODE_TABLE_13; + } + + /** + * + * @param sChar + * @return + */ + @Override + public byte transChar(char sChar) { + if ((sChar >= 0x0000) && (sChar < 0x0080)) { + return (byte) sChar; + } else { + switch (sChar) { + case '\u00e1': return -0x60; // a acute + case '\u00e9': return -0x7E; // e acute + case '\u00ed': return -0x5F; // i acute + case '\u00f3': return -0x5E; // o acute + case '\u00fa': return -0x5D; // u acute + case '\u00fc': return -0x7F; // u dieresis + case '\u00f1': return -0x5C; // n tilde + case '\u00d1': return -0x5B; // N tilde + + case '\u00c1': return 0x41; // A acute + case '\u00c9': return 0x45; // E acute + case '\u00cd': return 0x49; // I acute + case '\u00d3': return 0x4F; // O acute + case '\u00da': return 0x55; // U acute + case '\u00dc': return -0x66; // U dieresis + case '\u00bf': return -0x58; // abrir interrogacion + case '\u00a1': return -0x53; // abrir admiracion + case '\u20ac': return -0x12; // Euro Sign + + + default: return 0x3F; // ? Not valid character. + } + } + } +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslatorInt.java b/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslatorInt.java new file mode 100644 index 0000000..aee9eec --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslatorInt.java @@ -0,0 +1,214 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +/** + * + * @author JG uniCenta + */ +public class UnicodeTranslatorInt extends UnicodeTranslator { + + /** Creates a new instance of UnicodeTranslatorInt */ + public UnicodeTranslatorInt() { + } + + /** + * + * @return + */ + @Override + public byte[] getCodeTable() { + return ESCPOS.CODE_TABLE_13; + } + + /** + * + * @param sChar + * @return + */ + @Override + public byte transChar(char sChar) { + if ((sChar >= 0x0000) && (sChar < 0x0080)) { + return (byte) sChar; + } else { + switch (sChar) { + case '\u00c7': return -0x80; + case '\u00fc': return -0x7F; // u dieresis + case '\u00e2': return -0x7D; + case '\u00e4': return -0x7C; + case '\u00e0': return -0x7B; + case '\u00E5': return -0x7A; // ao + case '\u00e7': return -0x79; + case '\u00ea': return -0x78; + case '\u00eb': return -0x77; + case '\u00e8': return -0x76; + case '\u00ef': return -0x75; + case '\u00ee': return -0x74; + case '\u00ec': return -0x73; + case '\u00c4': return -0x72; + case '\u00C5': return -0x71; // Ao + + case '\u00c9': return -0x70; // E acute + case '\u00E6': return -0x6F; // ae + case '\u00C6': return -0x6E; // AE + case '\u00f4': return -0x6D; + case '\u00f6': return -0x6C; + case '\u00f2': return -0x6B; + case '\u00fb': return -0x6A; + case '\u00f9': return -0x69; + case '\u00ff': return -0x68; + case '\u00d6': return -0x67; + case '\u00dc': return -0x66; // U dieresis + case '\u00F8': return -0x65; // o/ + case '\u00A3': return -0x64; // L- Libra esterlina + case '\u00D8': return -0x63; // O/ + case '\u00D7': return -0x62; // X +// case '': return -0x61; // f + + case '\u00e1': return -0x60; // a acute + case '\u00e9': return -0x7E; // e acute + case '\u00ed': return -0x5F; // i acute + case '\u00f3': return -0x5E; // o acute + case '\u00fa': return -0x5D; // u acute + case '\u00f1': return -0x5C; // n tilde + case '\u00d1': return -0x5B; // N tilde + case '\u00aa': return -0x5A; + case '\u00ba': return -0x59; + case '\u00bf': return -0x58; // abrir interrogacion + case '\u00AE': return -0x57; // (R) Registrado + case '\u00ac': return -0x56; // Not sign + case '\u00BD': return -0x55; // 1/2 + case '\u00BC': return -0x54; // 1/4 + case '\u00a1': return -0x53; // abrir admiracion + case '\u00AB': return -0x52; // << + case '\u00BB': return -0x51; // >> + + case '\u2591': return -0x50; // Light shade + case '\u2592': return -0x4F; // Medium shade + case '\u2593': return -0x4E; // Dark shade + case '\u2502': return -0x4D; // BOX DRAWINGS LIGHT VERTICAL + case '\u2524': return -0x4C; // BOX DRAWINGS LIGHT VERTICAL AND LEFT + case '\u00c1': return -0x4B; // A acute + case '\u00c2': return -0x4A; + case '\u00c0': return -0x49; + case '\u00A9': return -0x48; // (c) Copyright + case '\u2563': return -0x47; // BOX DRAWINGS DOUBLE VERTICAL AND LEFT + case '\u2551': return -0x46; // BOX DRAWINGS DOUBLE VERTICAL + case '\u2557': return -0x45; // BOX DRAWINGS DOUBLE DOWN AND LEFT + case '\u255D': return -0x44; // BOX DRAWINGS DOUBLE UP AND LEFT + case '\u00A2': return -0x43; // Cent Sign + case '\u00A5': return -0x42; // Yen Sign + case '\u2510': return -0x41; // BOX DRAWINGS LIGHT DOWN AND LEFT + + case '\u2514': return -0x40; // BOX DRAWINGS LIGHT UP ANDRIGHT +// case '': return -0x3F; // +// case '': return -0x3E; // +// case '': return -0x3D; // +// case '': return -0x3C; // +// case '': return -0x3B; // +// case '': return -0x3A; // +// case '': return -0x39; // +// case '': return -0x38; // +// case '': return -0x37; // +// case '': return -0x36; // +// case '': return -0x35; // +// case '': return -0x34; // +// case '': return -0x33; // +// case '': return -0x32; // +// case '': return -0x31; // + +// case '': return -0x30; // +// case '': return -0x2F; // + case '\u00ca': return -0x2E; // + case '\u00cb': return -0x2D; // + case '\u00c8': return -0x2C; // + case '\u20ac': return -0x2B; // Euro Sign + case '\u00cd': return -0x2A; // I acute + case '\u00ce': return -0x29; // + case '\u00cf': return -0x28; // +// case '': return -0x27; // +// case '': return -0x26; // +// case '': return -0x25; // +// case '': return -0x24; // + case '|': return -0x23; // + case '\u00cc': return -0x22; // +// case '': return -0x21; // + + case '\u00d3': return -0x20; // O acute +// case '': return -0x1F; // + case '\u00d4': return -0x1E; // + case '\u00d2': return -0x1D; // +// case '': return -0x1C; // +// case '': return -0x1B; // +// case '': return -0x1A; // +// case '': return -0x19; // +// case '': return -0x18; // + case '\u00da': return -0x17; // U acute + case '\u00db': return -0x16; // + case '\u00d9': return -0x15; // + case '\u00fd': return -0x14; // + case '\u00dd': return -0x13; // +// case '': return -0x12; // + case '\u00b4': return -0x11; // + +// case '': return -0x10; // +// case '': return -0x0F; // +// case '': return -0x0E; // +// case '': return -0x0D; // +// case '': return -0x0C; // +// case '': return -0x0B; // +// case '': return -0x0A; // +// case '': return -0x09; // +// case '': return -0x08; // + case '\u00a8': return -0x07; // +// case '': return -0x06; // +// case '': return -0x05; // +// case '': return -0x04; // +// case '': return -0x03; // +// case '': return -0x02; // + // case ' ': return -0x01; // SP + + default: return 0x3F; // ? Not valid character. + +// Old translation +// case '\u00aa' : return (byte) 0xA6; +// case '\u00ba' : return (byte) 0xA7; +// case '\u00a1' : return (byte) 0xAD; +// case '\u00bf' : return (byte) 0xA8; +// case '\u00b7' : return (byte) 0xF9; +// case '\u00f1' : return (byte) 0xA4; +// case '\u00d1' : return (byte) 0xA5; +// case '\u00e1' : return (byte) 0xA0; +// case '\u00c1' : return (byte) 0x86; +// case '\u00e9' : return (byte) 0x82; +// case '\u00c9' : return (byte) 0x90; +// case '\u00ed' : return (byte) 0xA1; +// case '\u00cd' : return (byte) 0x8B; +// case '\u00f3' : return (byte) 0xA2; +// case '\u00d3' : return (byte) 0x9F; +// case '\u00fa' : return (byte) 0xA3; +// case '\u00da' : return (byte) 0x96; +// case '\u00fc' : return (byte) 0x81; +// case '\u00dc' : return (byte) 0x9A; +// default: return (byte) sChar; + } + } + } +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslatorStar.java b/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslatorStar.java new file mode 100644 index 0000000..fb7b144 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslatorStar.java @@ -0,0 +1,192 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +/** + * + * @author JG uniCenta + */ +public class UnicodeTranslatorStar extends UnicodeTranslator { + + /** Creates a UnicodeTranslatorStar instance of UnicodeTranslatorInt */ + public UnicodeTranslatorStar() { + } + + /** + * + * @return + */ + @Override + public byte[] getCodeTable() { + return new byte[] {0x1B, 0x1D, 0x74, 0x01}; // Select code page 437 + } + + /** + * + * @param sChar + * @return + */ + @Override + public byte transChar(char sChar) { + if ((sChar >= 0x0000) && (sChar < 0x0080)) { + return (byte) sChar; + } else { + switch (sChar) { + case '\u00c1': return 0x41; // A acute + case '\u00c9': return 0x45; // E acute + case '\u00cd': return 0x49; // I acute + case '\u00d3': return 0x4F; // O acute + case '\u00da': return 0x55; // U acute + + + case '\u00C7': return -0x80; // 0x80 : C cedilla + case '\u00FC': return -0x7F; // 0x81 : u dieresis + case '\u00E9': return -0x7E; // 0x82 : e acute +// case '\u0000': return -0x7D; // 0x83 : + case '\u00E4': return -0x7C; // 0x84 : a dieresis +// case '\u0000': return -0x7B; // 0x85 : + case '\u00E5': return -0x7A; // 0x86 : a circle + case '\u00E7': return -0x79; // 0x87 : c cedilla +// case '\u0000': return -0x78; // 0x88 : +// case '\u0000': return -0x77; // 0x89 : +// case '\u0000': return -0x76; // 0x8A : +// case '\u0000': return -0x75; // 0x8B : +// case '\u0000': return -0x74; // 0x8C :dieresis +// case '\u0000': return -0x73; // 0x8D : + case '\u00C4': return -0x72; // 0x8E : A dieresis + case '\u00C5': return -0x71; // 0x8F : A circle +// case '\u0000': return -0x70; // 0x90 : +// case '\u0000': return -0x6F; // 0x91 : +// case '\u0000': return -0x6E; // 0x92 : +// case '\u0000': return -0x6D; // 0x93 : + case '\u00F6': return -0x6C; // 0x94 : o dieresis +// case '\u0000': return -0x6B; // 0x95 : +// case '\u0000': return -0x6A; // 0x96 : +// case '\u0000': return -0x69; // 0x97 : +// case '\u0000': return -0x68; // 0x98 : + case '\u00D6': return -0x67; // 0x99 : O dieresis + case '\u00DC': return -0x66; // 0x9A : U dieresesis +// case '\u0000': return -0x65; // 0x9B : + case '\u00A3': return -0x64; // 0x9C : Pound currency + case '\u00A5': return -0x63; // 0x9D : Yen currency +// case '\u0000': return -0x62; // 0x9E : +// case '\u0000': return -0x61; // 0x9F : + case '\u00E1': return -0x60; // 0xA0 : a acute + case '\u00ED': return -0x5F; // 0xA1 : i acute + case '\u00F3': return -0x5E; // 0xA2 : o acute + case '\u00FA': return -0x5D; // 0xA3 : u acute + case '\u00F1': return -0x5C; // 0xA4 : n tilde + case '\u00D1': return -0x5B; // 0xA5 : N tilde +// case '\u0000': return -0x5A; // 0xA6 : +// case '\u0000': return -0x59; // 0xA7 : + case '\u00BF': return -0x58; // 0xA8 : open ? +// case '\u0000': return -0x57; // 0xA9 : +// case '\u0000': return -0x56; // 0xAA : +// case '\u0000': return -0x55; // 0xAB : +// case '\u0000': return -0x54; // 0xAC : + case '\u00A1': return -0x53; // 0xAD : open ! +// case '\u0000': return -0x52; // 0xAE : +// case '\u0000': return -0x51; // 0xAF : +// case '\u0000': return -0x50; // 0xB0 : +// case '\u0000': return -0x4F; // 0xB1 : +// case '\u0000': return -0x4E; // 0xB2 : +// case '\u0000': return -0x4D; // 0xB3 : +// case '\u0000': return -0x4C; // 0xB4 : +// case '\u0000': return -0x4B; // 0xB5 : +// case '\u0000': return -0x4A; // 0xB6 : +// case '\u0000': return -0x49; // 0xB7 : +// case '\u0000': return -0x48; // 0xB8 : +// case '\u0000': return -0x47; // 0xB9 : +// case '\u0000': return -0x46; // 0xBA : +// case '\u0000': return -0x45; // 0xBB : +// case '\u0000': return -0x44; // 0xBC : +// case '\u0000': return -0x43; // 0xBD : +// case '\u0000': return -0x42; // 0xBE : +// case '\u0000': return -0x41; // 0xBF : +// case '\u0000': return -0x40; // 0xC0 : +// case '\u0000': return -0x3F; // 0xC1 : +// case '\u0000': return -0x3E; // 0xC2 : +// case '\u0000': return -0x3D; // 0xC3 : +// case '\u0000': return -0x3C; // 0xC4 : +// case '\u0000': return -0x3B; // 0xC5 : +// case '\u0000': return -0x3A; // 0xC6 : +// case '\u0000': return -0x39; // 0xC7 : +// case '\u0000': return -0x38; // 0xC8 : +// case '\u0000': return -0x37; // 0xC9 : +// case '\u0000': return -0x36; // 0xCA : +// case '\u0000': return -0x35; // 0xCB : +// case '\u0000': return -0x34; // 0xCC : +// case '\u0000': return -0x33; // 0xCD : +// case '\u0000': return -0x32; // 0xCE : +// case '\u0000': return -0x31; // 0xCF : +// case '\u0000': return -0x30; // 0xD0 : +// case '\u0000': return -0x2F; // 0xD1 : +// case '\u0000': return -0x2E; // 0xD2 : +// case '\u0000': return -0x2D; // 0xD3 : +// case '\u0000': return -0x2C; // 0xD4 : +// case '\u0000': return -0x2B; // 0xD5 : +// case '\u0000': return -0x2A; // 0xD6 : +// case '\u0000': return -0x29; // 0xD7 : +// case '\u0000': return -0x28; // 0xD8 : +// case '\u0000': return -0x27; // 0xD9 : +// case '\u0000': return -0x26; // 0xDA : +// case '\u0000': return -0x25; // 0xDB : +// case '\u0000': return -0x24; // 0xDC : +// case '\u0000': return -0x23; // 0xDD : +// case '\u0000': return -0x22; // 0xDE : +// case '\u0000': return -0x21; // 0xDF : +// case '\u0000': return -0x20; // 0xE0 : +// case '\u0000': return -0x2F; // 0xE1 : +// case '\u0000': return -0x1E; // 0xE2 : +// case '\u0000': return -0x1D; // 0xE3 : +// case '\u0000': return -0x1C; // 0xE4 : +// case '\u0000': return -0x1B; // 0xE5 : +// case '\u0000': return -0x1A; // 0xE6 : +// case '\u0000': return -0x19; // 0xE7 : +// case '\u0000': return -0x18; // 0xE8 : +// case '\u0000': return -0x17; // 0xE9 : +// case '\u0000': return -0x16; // 0xEA : +// case '\u0000': return -0x15; // 0xEB : +// case '\u0000': return -0x14; // 0xEC : +// case '\u0000': return -0x13; // 0xED : + case '\u20AC': return -0x12; // 0xEE : euro sign +// case '\u0000': return -0x11; // 0xEF : +// case '\u0000': return -0x10; // 0xF0 : +// case '\u0000': return -0x0F; // 0xF1 : +// case '\u0000': return -0x0E; // 0xF2 : +// case '\u0000': return -0x0D; // 0xF3 : +// case '\u0000': return -0x0C; // 0xF4 : +// case '\u0000': return -0x0B; // 0xF5 : +// case '\u0000': return -0x0A; // 0xF6 : +// case '\u0000': return -0x09; // 0xF7 : +// case '\u0000': return -0x08; // 0xF8 : +// case '\u0000': return -0x07; // 0xF9 : +// case '\u0000': return -0x06; // 0xFA : +// case '\u0000': return -0x05; // 0xFB : +// case '\u0000': return -0x04; // 0xFC : +// case '\u0000': return -0x03; // 0xFD : +// case '\u0000': return -0x02; // 0xFE : +// case '\u0000': return -0x01; // 0xFF : + default: return 0x3F; // ? Not valid character. + + } + } + } +} diff --git a/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslatorSurePOS.java b/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslatorSurePOS.java new file mode 100644 index 0000000..f078930 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/escpos/UnicodeTranslatorSurePOS.java @@ -0,0 +1,214 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.escpos; + +/** + * + * @author JG uniCenta + */ +public class UnicodeTranslatorSurePOS extends UnicodeTranslator { + + /** Creates a new instance of UnicodeTranslatorInt */ + public UnicodeTranslatorSurePOS() { + } + + /** + * + * @return + */ + @Override + public byte[] getCodeTable() { + return new byte[] {0x02}; // Multilingual International 858 + } + + /** + * + * @param sChar + * @return + */ + @Override + public byte transChar(char sChar) { + if ((sChar >= 0x0000) && (sChar < 0x0080)) { + return (byte) sChar; + } else { + switch (sChar) { + case '\u00c7': return -0x80; + case '\u00fc': return -0x7F; // u dieresis + case '\u00e2': return -0x7D; + case '\u00e4': return -0x7C; + case '\u00e0': return -0x7B; + case '\u00E5': return -0x7A; // ao + case '\u00e7': return -0x79; + case '\u00ea': return -0x78; + case '\u00eb': return -0x77; + case '\u00e8': return -0x76; + case '\u00ef': return -0x75; + case '\u00ee': return -0x74; + case '\u00ec': return -0x73; + case '\u00c4': return -0x72; + case '\u00C5': return -0x71; // Ao + + case '\u00c9': return -0x70; // E acute + case '\u00E6': return -0x6F; // ae + case '\u00C6': return -0x6E; // AE + case '\u00f4': return -0x6D; + case '\u00f6': return -0x6C; + case '\u00f2': return -0x6B; + case '\u00fb': return -0x6A; + case '\u00f9': return -0x69; + case '\u00ff': return -0x68; + case '\u00d6': return -0x67; + case '\u00dc': return -0x66; // U dieresis + case '\u00F8': return -0x65; // o/ + case '\u00A3': return -0x64; // L- Libra esterlina + case '\u00D8': return -0x63; // O/ + case '\u00D7': return -0x62; // X +// case '': return -0x61; // f + + case '\u00e1': return -0x60; // a acute + case '\u00e9': return -0x7E; // e acute + case '\u00ed': return -0x5F; // i acute + case '\u00f3': return -0x5E; // o acute + case '\u00fa': return -0x5D; // u acute + case '\u00f1': return -0x5C; // n tilde + case '\u00d1': return -0x5B; // N tilde + case '\u00aa': return -0x5A; + case '\u00ba': return -0x59; + case '\u00bf': return -0x58; // abrir interrogacion + case '\u00AE': return -0x57; // (R) Registrado + case '\u00ac': return -0x56; // Not sign + case '\u00BD': return -0x55; // 1/2 + case '\u00BC': return -0x54; // 1/4 + case '\u00a1': return -0x53; // abrir admiracion + case '\u00AB': return -0x52; // << + case '\u00BB': return -0x51; // >> + + case '\u2591': return -0x50; // Light shade + case '\u2592': return -0x4F; // Medium shade + case '\u2593': return -0x4E; // Dark shade + case '\u2502': return -0x4D; // BOX DRAWINGS LIGHT VERTICAL + case '\u2524': return -0x4C; // BOX DRAWINGS LIGHT VERTICAL AND LEFT + case '\u00c1': return -0x4B; // A acute + case '\u00c2': return -0x4A; + case '\u00c0': return -0x49; + case '\u00A9': return -0x48; // (c) Copyright + case '\u2563': return -0x47; // BOX DRAWINGS DOUBLE VERTICAL AND LEFT + case '\u2551': return -0x46; // BOX DRAWINGS DOUBLE VERTICAL + case '\u2557': return -0x45; // BOX DRAWINGS DOUBLE DOWN AND LEFT + case '\u255D': return -0x44; // BOX DRAWINGS DOUBLE UP AND LEFT + case '\u00A2': return -0x43; // Cent Sign + case '\u00A5': return -0x42; // Yen Sign + case '\u2510': return -0x41; // BOX DRAWINGS LIGHT DOWN AND LEFT + + case '\u2514': return -0x40; // BOX DRAWINGS LIGHT UP ANDRIGHT +// case '': return -0x3F; // +// case '': return -0x3E; // +// case '': return -0x3D; // +// case '': return -0x3C; // +// case '': return -0x3B; // +// case '': return -0x3A; // +// case '': return -0x39; // +// case '': return -0x38; // +// case '': return -0x37; // +// case '': return -0x36; // +// case '': return -0x35; // +// case '': return -0x34; // +// case '': return -0x33; // +// case '': return -0x32; // +// case '': return -0x31; // + +// case '': return -0x30; // +// case '': return -0x2F; // + case '\u00ca': return -0x2E; // + case '\u00cb': return -0x2D; // + case '\u00c8': return -0x2C; // + case '\u20ac': return (byte) 0xD5; // Euro Sign + case '\u00cd': return -0x2A; // I acute + case '\u00ce': return -0x29; // + case '\u00cf': return -0x28; // +// case '': return -0x27; // +// case '': return -0x26; // +// case '': return -0x25; // +// case '': return -0x24; // + case '|': return -0x23; // + case '\u00cc': return -0x22; // +// case '': return -0x21; // + + case '\u00d3': return -0x20; // O acute +// case '': return -0x1F; // + case '\u00d4': return -0x1E; // + case '\u00d2': return -0x1D; // +// case '': return -0x1C; // +// case '': return -0x1B; // +// case '': return -0x1A; // +// case '': return -0x19; // +// case '': return -0x18; // + case '\u00da': return -0x17; // U acute + case '\u00db': return -0x16; // + case '\u00d9': return -0x15; // + case '\u00fd': return -0x14; // + case '\u00dd': return -0x13; // +// case '': return -0x12; // + case '\u00b4': return -0x11; // + +// case '': return -0x10; // +// case '': return -0x0F; // +// case '': return -0x0E; // +// case '': return -0x0D; // +// case '': return -0x0C; // +// case '': return -0x0B; // +// case '': return -0x0A; // +// case '': return -0x09; // +// case '': return -0x08; // + case '\u00a8': return -0x07; // +// case '': return -0x06; // +// case '': return -0x05; // +// case '': return -0x04; // +// case '': return -0x03; // +// case '': return -0x02; // + // case ' ': return -0x01; // SP + + default: return 0x3F; // ? Not valid character. + +// Old translation +// case '\u00aa' : return (byte) 0xA6; +// case '\u00ba' : return (byte) 0xA7; +// case '\u00a1' : return (byte) 0xAD; +// case '\u00bf' : return (byte) 0xA8; +// case '\u00b7' : return (byte) 0xF9; +// case '\u00f1' : return (byte) 0xA4; +// case '\u00d1' : return (byte) 0xA5; +// case '\u00e1' : return (byte) 0xA0; +// case '\u00c1' : return (byte) 0x86; +// case '\u00e9' : return (byte) 0x82; +// case '\u00c9' : return (byte) 0x90; +// case '\u00ed' : return (byte) 0xA1; +// case '\u00cd' : return (byte) 0x8B; +// case '\u00f3' : return (byte) 0xA2; +// case '\u00d3' : return (byte) 0x9F; +// case '\u00fa' : return (byte) 0xA3; +// case '\u00da' : return (byte) 0x96; +// case '\u00fc' : return (byte) 0x81; +// case '\u00dc' : return (byte) 0x9A; +// default: return (byte) sChar; + } + } + } +} diff --git a/src/main/java/com/unicenta/pos/printer/javapos/DeviceDisplayJavaPOS.java b/src/main/java/com/unicenta/pos/printer/javapos/DeviceDisplayJavaPOS.java new file mode 100644 index 0000000..dab9c64 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/javapos/DeviceDisplayJavaPOS.java @@ -0,0 +1,136 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.javapos; + +import com.unicenta.pos.printer.DeviceDisplay; +import com.unicenta.pos.printer.DeviceDisplayBase; +import com.unicenta.pos.printer.DeviceDisplayImpl; +import com.unicenta.pos.printer.TicketPrinterException; +import jpos.JposException; +import jpos.LineDisplay; +import jpos.LineDisplayConst; + +/** + * + * @author JG uniCenta + */ +public class DeviceDisplayJavaPOS implements DeviceDisplay, DeviceDisplayImpl { + + private String m_sName; + private LineDisplay m_ld; + + private DeviceDisplayBase m_displaylines; + + /** Creates a new instance of DeviceDisplayJavaPOS + * @param sDeviceName + * @throws com.unicenta.pos.printer.TicketPrinterException */ + public DeviceDisplayJavaPOS(String sDeviceName) throws TicketPrinterException { + m_sName = sDeviceName; + + m_ld = new LineDisplay(); + try { + m_ld.open(m_sName); + m_ld.claim(10000); + m_ld.setDeviceEnabled(true); + } catch (JposException e) { + throw new TicketPrinterException(e.getMessage(), e); + } + + m_displaylines = new DeviceDisplayBase(this); + } + + /** + * + * @return + */ + @Override + public String getDisplayName() { + return m_sName; + } + + /** + * + * @return + */ + @Override + public String getDisplayDescription() { + return null; + } + + /** + * + * @return + */ + @Override + public javax.swing.JComponent getDisplayComponent() { + return null; + } + + /** + * + * @param animation + * @param sLine1 + * @param sLine2 + */ + @Override + public void writeVisor(int animation, String sLine1, String sLine2) { + m_displaylines.writeVisor(animation, sLine1, sLine2); + } + + /** + * + * @param sLine1 + * @param sLine2 + */ + @Override + public void writeVisor(String sLine1, String sLine2) { + m_displaylines.writeVisor(sLine1, sLine2); + } + + /** + * + */ + @Override + public void clearVisor() { + m_displaylines.clearVisor(); + } + + /** + * + */ + @Override + public void repaintLines() { + try { + m_ld.displayTextAt(0, 0, m_displaylines.getLine1(), LineDisplayConst.DISP_DT_NORMAL); + m_ld.displayTextAt(1, 0, m_displaylines.getLine2(), LineDisplayConst.DISP_DT_NORMAL); + } catch (JposException e) { + } + } + + @Override + public void finalize() throws Throwable { + + m_ld.setDeviceEnabled(false); + m_ld.release(); + m_ld.close(); + + super.finalize(); + } +} diff --git a/src/main/java/com/unicenta/pos/printer/javapos/DeviceFiscalPrinterJavaPOS.form b/src/main/java/com/unicenta/pos/printer/javapos/DeviceFiscalPrinterJavaPOS.form new file mode 100644 index 0000000..d5d6060 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/javapos/DeviceFiscalPrinterJavaPOS.form @@ -0,0 +1,246 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,73,0,0,2,15"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="*X Report"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="30" y="10" width="130" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> + <TitledBorder title="*Receipt Title"/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="10" y="60" width="470" height="260"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JTextField" name="jTextField1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="jTextField1"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="30" width="260" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JCheckBox" name="jCheckBox1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="jCheckBox1"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="0" right="0" top="0"/> + </Border> + </Property> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 0, 0, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="290" y="30" width="110" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="jTextField2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="jTextField2"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="60" width="260" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JCheckBox" name="jCheckBox2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="jCheckBox2"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="0" right="0" top="0"/> + </Border> + </Property> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 0, 0, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="290" y="60" width="110" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="jTextField3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="jTextField3"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="90" width="260" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="jTextField4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="jTextField4"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="120" width="260" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="jTextField5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="jTextField5"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="150" width="260" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JCheckBox" name="jCheckBox3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="jCheckBox3"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="0" right="0" top="0"/> + </Border> + </Property> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 0, 0, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="290" y="90" width="110" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JCheckBox" name="jCheckBox4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="jCheckBox4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="0" right="0" top="0"/> + </Border> + </Property> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 0, 0, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="290" y="120" width="110" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JCheckBox" name="jCheckBox5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="jCheckBox5"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="0" right="0" top="0"/> + </Border> + </Property> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 0, 0, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="290" y="150" width="110" height="25"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="jButton2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="*Z Report"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="220" width="130" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/printer/javapos/DeviceFiscalPrinterJavaPOS.java b/src/main/java/com/unicenta/pos/printer/javapos/DeviceFiscalPrinterJavaPOS.java new file mode 100644 index 0000000..444ce64 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/javapos/DeviceFiscalPrinterJavaPOS.java @@ -0,0 +1,323 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.javapos; + +import com.unicenta.pos.printer.DeviceFiscalPrinter; +import com.unicenta.pos.printer.TicketPrinterException; +import com.unicenta.pos.util.RoundUtils; +import javax.swing.JComponent; +import jpos.FiscalPrinter; +import jpos.JposException; + +/** + * + * @author JG uniCenta + */ +public class DeviceFiscalPrinterJavaPOS extends javax.swing.JPanel implements DeviceFiscalPrinter { + + private String m_sName; + + private FiscalPrinter m_fiscal; + + /** Creates new form DeviceFiscalPrinterJavaPOSPanel + * @param sDeviceFiscalPrinterName + * @throws com.unicenta.pos.printer.TicketPrinterException */ + public DeviceFiscalPrinterJavaPOS(String sDeviceFiscalPrinterName) throws TicketPrinterException { + m_sName = sDeviceFiscalPrinterName; + + + m_fiscal = new FiscalPrinter(); + try { + m_fiscal.open(m_sName); + m_fiscal.claim(10000); + m_fiscal.setDeviceEnabled(true); + // m_printer.setMapMode(POSPrinterConst.PTR_MM_METRIC); // unit = 1/100 mm - i.e. 1 cm = 10 mm = 10 * 100 units + + m_fiscal.setCheckTotal(false); + + } catch (JposException e) { + throw new TicketPrinterException(e.getMessage(), e); + } + + initComponents(); + + + } + + /** + * + * @return + */ + @Override + public String getFiscalName() { + return m_sName; + } + + /** + * + * @return + */ + @Override + public JComponent getFiscalComponent() { + return this; + } + + /** + * + */ + @Override + public void beginReceipt() { + try { + m_fiscal.beginFiscalReceipt(true); + } catch (JposException e) { + } + } + + /** + * + */ + @Override + public void endReceipt() { + try { + m_fiscal.endFiscalReceipt(false); + } catch (JposException e) { + } + } + + /** + * + * @param sproduct + * @param dprice + * @param dunits + * @param taxinfo + */ + @Override + public void printLine(String sproduct, double dprice, double dunits, int taxinfo) { + try { + m_fiscal.printRecItem(sproduct, roundFiscal(dprice * dunits), (int)(dunits * 1000), taxinfo, roundFiscal(dprice), ""); + } catch (JposException e) { + } + } + + /** + * + * @param smessage + */ + @Override + public void printMessage(String smessage) { + try { + m_fiscal.printRecMessage(smessage); + } catch (JposException e) { + } + } + + /** + * + * @param sPayment + * @param dpaid + */ + @Override + public void printTotal(String sPayment, double dpaid) { + try { + // el primer valor es el total calculado por la aplicacion. + // al poner 0 no se debe chequear: CAPCHECKTOTAL = false. + m_fiscal.printRecTotal(0, roundFiscal(dpaid), sPayment); + } catch (JposException e) { + } + } + + /** + * + */ + @Override + public void printZReport() { + try { + m_fiscal.printZReport(); + } catch (JposException e) { + } + } + + /** + * + */ + @Override + public void printXReport() { + try { + m_fiscal.printXReport(); + } catch (JposException e) { + } + } + + @Override + public void finalize() throws Throwable { + + m_fiscal.setDeviceEnabled(false); + m_fiscal.release(); + m_fiscal.close(); + + super.finalize(); + } + + private int roundFiscal(double value) { + return (int) Math.floor(RoundUtils.round(value) * 10000.0 + 0.5); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jButton1 = new javax.swing.JButton(); + jPanel1 = new javax.swing.JPanel(); + jTextField1 = new javax.swing.JTextField(); + jCheckBox1 = new javax.swing.JCheckBox(); + jTextField2 = new javax.swing.JTextField(); + jCheckBox2 = new javax.swing.JCheckBox(); + jTextField3 = new javax.swing.JTextField(); + jTextField4 = new javax.swing.JTextField(); + jTextField5 = new javax.swing.JTextField(); + jCheckBox3 = new javax.swing.JCheckBox(); + jCheckBox4 = new javax.swing.JCheckBox(); + jCheckBox5 = new javax.swing.JCheckBox(); + jButton2 = new javax.swing.JButton(); + + setLayout(null); + + jButton1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jButton1.setText("*X Report"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + add(jButton1); + jButton1.setBounds(30, 10, 130, 23); + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("*Receipt Title")); + jPanel1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel1.setLayout(null); + + jTextField1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jTextField1.setText("jTextField1"); + jPanel1.add(jTextField1); + jTextField1.setBounds(20, 30, 260, 25); + + jCheckBox1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jCheckBox1.setText("jCheckBox1"); + jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0)); + jPanel1.add(jCheckBox1); + jCheckBox1.setBounds(290, 30, 110, 25); + + jTextField2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jTextField2.setText("jTextField2"); + jPanel1.add(jTextField2); + jTextField2.setBounds(20, 60, 260, 25); + + jCheckBox2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jCheckBox2.setText("jCheckBox2"); + jCheckBox2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + jCheckBox2.setMargin(new java.awt.Insets(0, 0, 0, 0)); + jPanel1.add(jCheckBox2); + jCheckBox2.setBounds(290, 60, 110, 25); + + jTextField3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jTextField3.setText("jTextField3"); + jPanel1.add(jTextField3); + jTextField3.setBounds(20, 90, 260, 25); + + jTextField4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jTextField4.setText("jTextField4"); + jPanel1.add(jTextField4); + jTextField4.setBounds(20, 120, 260, 25); + + jTextField5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jTextField5.setText("jTextField5"); + jPanel1.add(jTextField5); + jTextField5.setBounds(20, 150, 260, 25); + + jCheckBox3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jCheckBox3.setText("jCheckBox3"); + jCheckBox3.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + jCheckBox3.setMargin(new java.awt.Insets(0, 0, 0, 0)); + jPanel1.add(jCheckBox3); + jCheckBox3.setBounds(290, 90, 110, 25); + + jCheckBox4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jCheckBox4.setText("jCheckBox4"); + jCheckBox4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + jCheckBox4.setMargin(new java.awt.Insets(0, 0, 0, 0)); + jPanel1.add(jCheckBox4); + jCheckBox4.setBounds(290, 120, 110, 25); + + jCheckBox5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jCheckBox5.setText("jCheckBox5"); + jCheckBox5.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + jCheckBox5.setMargin(new java.awt.Insets(0, 0, 0, 0)); + jPanel1.add(jCheckBox5); + jCheckBox5.setBounds(290, 150, 110, 25); + + jButton2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jButton2.setText("*Z Report"); + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); + jPanel1.add(jButton2); + jButton2.setBounds(20, 220, 130, 23); + + add(jPanel1); + jPanel1.setBounds(10, 60, 470, 260); + }// </editor-fold>//GEN-END:initComponents + + private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed + + printZReport(); + + }//GEN-LAST:event_jButton2ActionPerformed + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + + printXReport(); + + }//GEN-LAST:event_jButton1ActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JCheckBox jCheckBox1; + private javax.swing.JCheckBox jCheckBox2; + private javax.swing.JCheckBox jCheckBox3; + private javax.swing.JCheckBox jCheckBox4; + private javax.swing.JCheckBox jCheckBox5; + private javax.swing.JPanel jPanel1; + private javax.swing.JTextField jTextField1; + private javax.swing.JTextField jTextField2; + private javax.swing.JTextField jTextField3; + private javax.swing.JTextField jTextField4; + private javax.swing.JTextField jTextField5; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/printer/javapos/DevicePrinterJavaPOS.java b/src/main/java/com/unicenta/pos/printer/javapos/DevicePrinterJavaPOS.java new file mode 100644 index 0000000..842afaf --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/javapos/DevicePrinterJavaPOS.java @@ -0,0 +1,280 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.javapos; + +import com.unicenta.data.loader.ImageUtils; +import com.unicenta.pos.printer.DevicePrinter; +import com.unicenta.pos.printer.TicketPrinterException; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import javax.swing.JComponent; +import jpos.CashDrawer; +import jpos.JposException; +import jpos.POSPrinter; +import jpos.POSPrinterConst; + +/** + * + * @author JG uniCenta + */ +public class DevicePrinterJavaPOS implements DevicePrinter { + + private static final String JPOS_SIZE0 = "\u001b|1C"; + private static final String JPOS_SIZE1 = "\u001b|2C"; + private static final String JPOS_SIZE2 = "\u001b|3C"; + private static final String JPOS_SIZE3 = "\u001b|4C"; + private static final String JPOS_LF = "\n"; + private static final String JPOS_BOLD = "\u001b|bC"; + private static final String JPOS_UNDERLINE = "\u001b|uC"; + private static final String JPOS_CUT = "\u001b|100fP"; + + private String m_sName; + + private POSPrinter m_printer = null; + private CashDrawer m_drawer = null; + + private StringBuilder m_sline; + + /** Creates a new instance of DevicePrinterJavaPOS + * @param sDevicePrinterName + * @param sDeviceDrawerName + * @throws com.unicenta.pos.printer.TicketPrinterException */ + public DevicePrinterJavaPOS(String sDevicePrinterName, String sDeviceDrawerName) throws TicketPrinterException { + + m_sName = sDevicePrinterName; + if (sDeviceDrawerName != null && !sDeviceDrawerName.equals("")) { + m_sName += " - " + sDeviceDrawerName; + } + + try { + m_printer = new POSPrinter(); + m_printer.open(sDevicePrinterName); + m_printer.claim(10000); + m_printer.setDeviceEnabled(true); + m_printer.setMapMode(POSPrinterConst.PTR_MM_METRIC); // unit = 1/100 mm - i.e. 1 cm = 10 mm = 10 * 100 units + } catch (JposException e) { + // cannot live without the printer. + throw new TicketPrinterException(e.getMessage(), e); + } + + try { + m_drawer = new CashDrawer(); + m_drawer.open(sDeviceDrawerName); + m_drawer.claim(10000); + m_drawer.setDeviceEnabled(true); + } catch (JposException e) { + // can live without the drawer; + m_drawer = null; + } + } + + /** + * + * @return + */ + @Override + public String getPrinterName() { + return m_sName; + } + + /** + * + * @return + */ + @Override + public String getPrinterDescription() { + return null; + } + + /** + * + * @return + */ + @Override + public JComponent getPrinterComponent() { + return null; + } + + /** + * + */ + @Override + public void reset() { + } + + /** + * + */ + @Override + public void beginReceipt() { + try { + m_printer.transactionPrint(POSPrinterConst.PTR_S_RECEIPT, POSPrinterConst.PTR_TP_TRANSACTION); + } catch (JposException e) { + } + } + + /** + * + * @param image + */ + @Override + public void printImage(BufferedImage image) { + try { + if (m_printer.getCapRecBitmap()) { // si podemos imprimir bitmaps. + + File f = File.createTempFile("jposimg", ".png"); + try (OutputStream out = new FileOutputStream(f)) { + out.write(ImageUtils.writeImage(image)); + } + + m_printer.printBitmap(POSPrinterConst.PTR_S_RECEIPT, f.getAbsolutePath(), POSPrinterConst.PTR_BM_ASIS, POSPrinterConst.PTR_BM_CENTER); + } +// JG 16 May 12 use multicatch + } catch (IOException | JposException eIO) { + } + } + + /** + * + */ + @Override + public void printLogo(){ + } + + /** + * + * @param type + * @param position + * @param code + */ + @Override + public void printBarCode(String type, String position, String code) { + try { + if (m_printer.getCapRecBarCode()) { // si podemos imprimir codigos de barras + if (DevicePrinter.POSITION_NONE.equals(position)) { + m_printer.printBarCode(POSPrinterConst.PTR_S_RECEIPT, code, POSPrinterConst.PTR_BCS_EAN13, 10 * 100, 60 * 100, POSPrinterConst.PTR_BC_CENTER, POSPrinterConst.PTR_BC_TEXT_NONE); + } else { + m_printer.printBarCode(POSPrinterConst.PTR_S_RECEIPT, code, POSPrinterConst.PTR_BCS_EAN13, 10 * 100, 60 * 100, POSPrinterConst.PTR_BC_CENTER, POSPrinterConst.PTR_BC_TEXT_BELOW); + } + } + } catch (JposException e) { + } + } + + /** + * + * @param iTextSize + */ + @Override + public void beginLine(int iTextSize) { + m_sline = new StringBuilder(); + if (iTextSize == DevicePrinter.SIZE_0) { + m_sline.append(JPOS_SIZE0); + } else if (iTextSize == DevicePrinter.SIZE_1) { + m_sline.append(JPOS_SIZE1); + } else if (iTextSize == DevicePrinter.SIZE_2) { + m_sline.append(JPOS_SIZE2); + } else if (iTextSize == DevicePrinter.SIZE_3) { + m_sline.append(JPOS_SIZE3); + } else { + m_sline.append(JPOS_SIZE0); + } + } + + /** + * + * @param iStyle + * @param sText + */ + @Override + public void printText(int iStyle, String sText) { + + if ((iStyle & DevicePrinter.STYLE_BOLD) != 0) { + m_sline.append(JPOS_BOLD); + } + if ((iStyle & DevicePrinter.STYLE_UNDERLINE) != 0) { + m_sline.append(JPOS_UNDERLINE); + } + m_sline.append(sText); + } + + /** + * + */ + @Override + public void endLine() { + + m_sline.append(JPOS_LF); + try { + m_printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, m_sline.toString()); + } catch (JposException e) { + } + m_sline = null; + } + + /** + * + */ + @Override + public void endReceipt() { + try { + // cut the receipt + m_printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, JPOS_CUT); + + // end of the transaction + m_printer.transactionPrint(POSPrinterConst.PTR_S_RECEIPT, POSPrinterConst.PTR_TP_NORMAL); + } catch (JposException e) { + } + } + + /** + * + */ + + @Override + public void openDrawer() { + + if (m_drawer != null) { + try { + m_drawer.openDrawer(); + } catch (JposException e) { + } + } + } + + @Override + public void finalize() throws Throwable { + + m_printer.setDeviceEnabled(false); + m_printer.release(); + m_printer.close(); + + if (m_drawer != null) { + m_drawer.setDeviceEnabled(false); + m_drawer.release(); + m_drawer.close(); + } + + super.finalize(); + } +} diff --git a/src/main/java/com/unicenta/pos/printer/printer/DevicePrinterPrinter.java b/src/main/java/com/unicenta/pos/printer/printer/DevicePrinterPrinter.java new file mode 100644 index 0000000..30d3987 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/printer/DevicePrinterPrinter.java @@ -0,0 +1,362 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.printer; + +import com.unicenta.data.gui.JMessageDialog; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.printer.DevicePrinter; +import com.unicenta.pos.printer.ticket.BasicTicket; +import com.unicenta.pos.printer.ticket.BasicTicketForPrinter; +import com.unicenta.pos.util.ReportUtils; +import com.unicenta.pos.util.SelectPrinter; +import lombok.extern.slf4j.Slf4j; + +import javax.print.*; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.standard.JobName; +import javax.print.attribute.standard.Media; +import javax.print.attribute.standard.MediaSizeName; +import javax.print.attribute.standard.OrientationRequested; +import javax.swing.*; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.util.HashMap; + +/** + * Class DevicePrinterPrinter is responsible for printing tickets using system <br> + * printers. It takes into consideration if a user set a printer as a receipt <br> + * printer or not. + * <p>For receipt printers lenght of a receipt must be calculated in this class.</p> + * <p>For normal printers number of pages must be calculated dynamically in the <br> + * class PrintableTicket @see com.unicenta.pos.printer.printer.PrintableTicket + * + * @author jaroslawwozniak + */ +@Slf4j +public class DevicePrinterPrinter implements DevicePrinter { + + private Component parent; + /*name of a printer*/ + private String m_sName; + /*a ticket to print*/ +// private BasicTicketForPrinter m_ticketcurrent; + private BasicTicket m_ticketcurrent; + /*system printer*/ + private PrintService printservice; + +// // For Page Size 72mm x 200mm && MediaSizeName A4. +// private static final int imageable_width = 190; +// private static final int imageable_height = 546; +// private static final int imageable_x = 10; +// private static final int imageable_y = 287; +// private static final Media media = MediaSizeName.ISO_A4; + +// // For Page Size A4 && MediaSizeName A4. +// private static final int imageable_width = 451; +// private static final int imageable_height = 698; +// private static final int imageable_x = 72; +// private static final int imageable_y = 72; +// private static final Media media = MediaSizeName.ISO_A4; + + private int imageable_width; + private int imageable_height; + private int imageable_x; + private int imageable_y; + private Media media; + + // JG 16 May 12 use multicatch + private static final HashMap<String, MediaSizeName> mediasizenamemap = new HashMap<>(); + + /** + * Creates a new instance of DevicePrinterPrinter + * + * @param parent + * @param printername - name of printer that will be called in the system + * @param imageable_x + * @param imageable_y + * @param imageable_height + * @param imageable_width + * @param mediasizename + */ + public DevicePrinterPrinter(Component parent, String printername, int imageable_x, int imageable_y, int imageable_width, int imageable_height, String mediasizename) { + + this.parent = parent; + m_sName = "Printer"; // "AppLocal.getIntString("printer.screen"); + m_ticketcurrent = null; + printservice = ReportUtils.getPrintService(printername); + + this.imageable_x = imageable_x; + this.imageable_y = imageable_y; + this.imageable_width = imageable_width; + this.imageable_height = imageable_height; + this.media = getMedia(mediasizename); + } + + /** + * Getter that returns the name of a printer + * + * @return m_sName a name of a printer + */ + @Override + public String getPrinterName() { + return m_sName; + } + + /** + * Getter that returns the description of a printer + * + * @return description of a printer + */ + @Override + public String getPrinterDescription() { + return null; + } + + /** + * Getter that returns the printer's component + * + * @return printer's component + */ + @Override + public JComponent getPrinterComponent() { + return null; + } + + /** + * Method that sets the current ticket as a null + */ + @Override + public void reset() { + m_ticketcurrent = null; + } + + /** + * Method that is responsible for start a new ticket + */ + @Override + public void beginReceipt() { + m_ticketcurrent = new BasicTicketForPrinter(); + } + + /** + * Method that is responsible for printing an image + * + * @param image a buffered image object + */ + @Override + public void printImage(BufferedImage image) { + m_ticketcurrent.printImage(image); + } + + @Override + public void printLogo() { + } + + /** + * @param type + * @param position + * @param code + */ + @Override + public void printBarCode(String type, String position, String code) { + m_ticketcurrent.printBarCode(type, position, code); + } + + /** + * Method that is responsible for starting a new line on a receipt + * + * @param iTextSize a size of text in the line + */ + @Override + public void beginLine(int iTextSize) { + m_ticketcurrent.beginLine(iTextSize); + } + + /** + * Method that is responsible for printing text + * + * @param iStyle style of text + * @param sText text to print + */ + @Override + public void printText(int iStyle, String sText) { + m_ticketcurrent.printText(iStyle, sText); + } + + /** + * Method that is responsible for ending a line + */ + @Override + public void endLine() { + m_ticketcurrent.endLine(); + } + + /** + * Method that is responsible for ending and printing a ticket<br> + * It manages to get a printerJob, set the name of the job, get a Book object<br> + * and print the receipt + */ + @Override + public void endReceipt() { + + try { + + PrintService ps; + + if (printservice == null) { + String[] printers = ReportUtils.getPrintNames(); + if (printers.length == 0) { + log.error(AppLocal.getIntString("message.noprinters")); + ps = null; + } else { + SelectPrinter selectprinter = SelectPrinter.getSelectPrinter(parent, printers); + selectprinter.setVisible(true); + if (selectprinter.isOK()) { + ps = ReportUtils.getPrintService(selectprinter.getPrintService()); + } else { + ps = null; + } + } + } else { + ps = printservice; + } + + if (ps != null) { + + PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); + aset.add(OrientationRequested.PORTRAIT); + aset.add(new JobName(AppLocal.APP_NAME + " - Document", null)); + aset.add(media); + + DocPrintJob printjob = ps.createPrintJob(); + Doc doc = new SimpleDoc(new PrintableBasicTicket(m_ticketcurrent, imageable_x, imageable_y, imageable_width, imageable_height), DocFlavor.SERVICE_FORMATTED.PRINTABLE, null); + + printjob.print(doc, aset); + } + + } catch (PrintException ex) { + log.error(ex.getMessage()); + JMessageDialog.showMessage(parent, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.printererror"), ex)); + } + + //ticket is not needed any more + m_ticketcurrent = null; + } + + /** + * Method that is responsible for opening a drawer + */ + + @Override + public void openDrawer() { + // Una simulacion + Toolkit.getDefaultToolkit().beep(); + } + + private static MediaSizeName getMedia(String mediasizename) { + return mediasizenamemap.get(mediasizename); + } + + static { + mediasizenamemap.put("Postcard", MediaSizeName.JAPANESE_POSTCARD); + mediasizenamemap.put("Statement", MediaSizeName.INVOICE); + + mediasizenamemap.put("Letter", MediaSizeName.NA_LETTER); + mediasizenamemap.put("Executive", MediaSizeName.EXECUTIVE); + mediasizenamemap.put("Legal", MediaSizeName.NA_LEGAL); + + mediasizenamemap.put("A0", MediaSizeName.ISO_A0); + mediasizenamemap.put("A1", MediaSizeName.ISO_A1); + mediasizenamemap.put("A2", MediaSizeName.ISO_A2); + mediasizenamemap.put("A3", MediaSizeName.ISO_A3); + mediasizenamemap.put("A4", MediaSizeName.ISO_A4); + mediasizenamemap.put("A5", MediaSizeName.ISO_A5); + mediasizenamemap.put("A6", MediaSizeName.ISO_A6); + mediasizenamemap.put("A7", MediaSizeName.ISO_A7); + mediasizenamemap.put("A8", MediaSizeName.ISO_A8); + mediasizenamemap.put("A9", MediaSizeName.ISO_A9); + mediasizenamemap.put("A10", MediaSizeName.ISO_A10); + + mediasizenamemap.put("B0", MediaSizeName.JIS_B0); + mediasizenamemap.put("B1", MediaSizeName.JIS_B1); + mediasizenamemap.put("B2", MediaSizeName.JIS_B2); + mediasizenamemap.put("B3", MediaSizeName.JIS_B3); + mediasizenamemap.put("B4", MediaSizeName.JIS_B4); + mediasizenamemap.put("B5", MediaSizeName.JIS_B5); + mediasizenamemap.put("B6", MediaSizeName.JIS_B6); + mediasizenamemap.put("B7", MediaSizeName.JIS_B7); + mediasizenamemap.put("B8", MediaSizeName.JIS_B8); + mediasizenamemap.put("B9", MediaSizeName.JIS_B9); + mediasizenamemap.put("B10", MediaSizeName.JIS_B10); + + mediasizenamemap.put("ISOB0", MediaSizeName.ISO_B0); + mediasizenamemap.put("ISOB1", MediaSizeName.ISO_B1); + mediasizenamemap.put("ISOB2", MediaSizeName.ISO_B2); + mediasizenamemap.put("ISOB3", MediaSizeName.ISO_B3); + mediasizenamemap.put("ISOB4", MediaSizeName.ISO_B4); + mediasizenamemap.put("ISOB5", MediaSizeName.ISO_B5); + mediasizenamemap.put("ISOB6", MediaSizeName.ISO_B6); + mediasizenamemap.put("ISOB7", MediaSizeName.ISO_B7); + mediasizenamemap.put("ISOB8", MediaSizeName.ISO_B8); + mediasizenamemap.put("ISOB9", MediaSizeName.ISO_B9); + mediasizenamemap.put("ISOB10", MediaSizeName.ISO_B10); + mediasizenamemap.put("EnvISOB0", MediaSizeName.ISO_B0); + mediasizenamemap.put("EnvISOB1", MediaSizeName.ISO_B1); + mediasizenamemap.put("EnvISOB2", MediaSizeName.ISO_B2); + mediasizenamemap.put("EnvISOB3", MediaSizeName.ISO_B3); + mediasizenamemap.put("EnvISOB4", MediaSizeName.ISO_B4); + mediasizenamemap.put("EnvISOB5", MediaSizeName.ISO_B5); + mediasizenamemap.put("EnvISOB6", MediaSizeName.ISO_B6); + mediasizenamemap.put("EnvISOB7", MediaSizeName.ISO_B7); + mediasizenamemap.put("EnvISOB8", MediaSizeName.ISO_B8); + mediasizenamemap.put("EnvISOB9", MediaSizeName.ISO_B9); + mediasizenamemap.put("EnvISOB10", MediaSizeName.ISO_B10); + + mediasizenamemap.put("C0", MediaSizeName.ISO_C0); + mediasizenamemap.put("C1", MediaSizeName.ISO_C1); + mediasizenamemap.put("C2", MediaSizeName.ISO_C2); + mediasizenamemap.put("C3", MediaSizeName.ISO_C3); + mediasizenamemap.put("C4", MediaSizeName.ISO_C4); + mediasizenamemap.put("C5", MediaSizeName.ISO_C5); + mediasizenamemap.put("C6", MediaSizeName.ISO_C6); + + mediasizenamemap.put("EnvPersonal", MediaSizeName.PERSONAL_ENVELOPE); + mediasizenamemap.put("EnvMonarch", MediaSizeName.MONARCH_ENVELOPE); + mediasizenamemap.put("Monarch", MediaSizeName.MONARCH_ENVELOPE); + mediasizenamemap.put("Env9", MediaSizeName.NA_NUMBER_9_ENVELOPE); + mediasizenamemap.put("Env10", MediaSizeName.NA_NUMBER_10_ENVELOPE); + mediasizenamemap.put("Env11", MediaSizeName.NA_NUMBER_11_ENVELOPE); + mediasizenamemap.put("Env12", MediaSizeName.NA_NUMBER_12_ENVELOPE); + mediasizenamemap.put("Env14", MediaSizeName.NA_NUMBER_14_ENVELOPE); + mediasizenamemap.put("c8x10", MediaSizeName.NA_8X10); + + mediasizenamemap.put("EnvDL", MediaSizeName.ISO_DESIGNATED_LONG); + mediasizenamemap.put("DL", MediaSizeName.ISO_DESIGNATED_LONG); + mediasizenamemap.put("EnvC0", MediaSizeName.ISO_C0); + mediasizenamemap.put("EnvC1", MediaSizeName.ISO_C1); + mediasizenamemap.put("EnvC2", MediaSizeName.ISO_C2); + mediasizenamemap.put("EnvC3", MediaSizeName.ISO_C3); + mediasizenamemap.put("EnvC4", MediaSizeName.ISO_C4); + mediasizenamemap.put("EnvC5", MediaSizeName.ISO_C5); + mediasizenamemap.put("EnvC6", MediaSizeName.ISO_C6); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/printer/printer/PrintableBasicTicket.java b/src/main/java/com/unicenta/pos/printer/printer/PrintableBasicTicket.java new file mode 100644 index 0000000..d179256 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/printer/PrintableBasicTicket.java @@ -0,0 +1,100 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-20162009 Openbravo, S.L. +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.printer; + +import com.unicenta.pos.printer.ticket.BasicTicket; +import com.unicenta.pos.printer.ticket.PrintItem; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.print.PageFormat; +import java.awt.print.Printable; +import java.awt.print.PrinterException; + +/** + * + * @author adrianromero + */ +public class PrintableBasicTicket implements Printable { + + private int imageable_width; + private int imageable_height; + private int imageable_x; + private int imageable_y; + + private BasicTicket ticket; + + /** + * + * @param ticket + * @param imageable_x + * @param imageable_y + * @param imageable_width + * @param imageable_height + */ + public PrintableBasicTicket(BasicTicket ticket, int imageable_x, int imageable_y, int imageable_width, int imageable_height) { + this.ticket = ticket; + this.imageable_x = imageable_x; + this.imageable_y = imageable_y; + this.imageable_width = imageable_width; + this.imageable_height = imageable_height; + } + + @Override + public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { + + Graphics2D g2d = (Graphics2D) graphics; + + int line = 0; + int currentpage = 0; + int currentpagey = 0; + boolean printed = false; + + g2d.translate(imageable_x, imageable_y); + + java.util.List<PrintItem> commands = ticket.getCommands(); + + while (line < commands.size()) { + + int itemheight = commands.get(line).getHeight(); + + if (currentpagey + itemheight <= imageable_height) { + currentpagey += itemheight; + } else { + currentpage ++; + currentpagey = itemheight; + } + + if (currentpage < pageIndex) { + line ++; + } else if (currentpage == pageIndex) { + printed = true; + commands.get(line).draw(g2d, 0, currentpagey - itemheight, imageable_width); + + line ++; + } else if (currentpage > pageIndex) { + line ++; + } + } + + return printed + ? Printable.PAGE_EXISTS + : Printable.NO_SUCH_PAGE; + } +} diff --git a/src/main/java/com/unicenta/pos/printer/screen/DeviceDisplayPanel.form b/src/main/java/com/unicenta/pos/printer/screen/DeviceDisplayPanel.form new file mode 100644 index 0000000..1868195 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/screen/DeviceDisplayPanel.form @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="window" palette="3" red="ff" type="palette"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder/> + </Border> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-127,0,0,1,126"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="16" left="16" right="16" top="16"/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="opaque" type="boolean" value="false"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JLabel" name="jline1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="jline1"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jline2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="jline2"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/printer/screen/DeviceDisplayPanel.java b/src/main/java/com/unicenta/pos/printer/screen/DeviceDisplayPanel.java new file mode 100644 index 0000000..413dab4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/screen/DeviceDisplayPanel.java @@ -0,0 +1,200 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.screen; + +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.printer.DeviceDisplay; +import com.unicenta.pos.printer.DeviceDisplayBase; +import com.unicenta.pos.printer.DeviceDisplayImpl; +import java.awt.*; +import javax.swing.JComponent; +import javax.swing.JPanel; + +/** + * + * @author adrianromero + */ +public class DeviceDisplayPanel extends JPanel implements DeviceDisplay, DeviceDisplayImpl { + + private String m_sName; + + private DeviceDisplayBase m_displaylines; + + /** Creates new form JVisor */ + public DeviceDisplayPanel() { + this(1.0); + } + + /** + * + * @param dZoom + */ + public DeviceDisplayPanel(double dZoom) { + + initComponents(); + + m_sName = AppLocal.getIntString("display.screen"); + + jline1.setFont(new Font("Monospaced", Font.BOLD, (int)(16 * dZoom))); + jline2.setFont(new Font("Monospaced", Font.BOLD, (int)(16 * dZoom))); +// JG Feb' 16 - Revert +// Consolas intro'd in v4.1 but causes issue in RightToLeft languages i.e.: Arabic +// jline1.setFont(new Font("Consolas", Font.BOLD, (int)(16 * dZoom))); +// jline2.setFont(new Font("Consolas", Font.BOLD, (int)(16 * dZoom))); + + m_displaylines = new DeviceDisplayBase(this); + } + + /** + * + * @return + */ + @Override + public String getDisplayName() { + return m_sName; + } + + /** + * + * @return + */ + @Override + public String getDisplayDescription() { + return null; + } + + /** + * + * @return + */ + @Override + public JComponent getDisplayComponent() { + return this; + } + + /** + * + * @param animation + * @param sLine1 + * @param sLine2 + */ + @Override + public void writeVisor(int animation, String sLine1, String sLine2) { + + m_displaylines.writeVisor(animation, sLine1, sLine2); + } + + /** + * + * @param sLine1 + * @param sLine2 + */ + @Override + public void writeVisor(String sLine1, String sLine2) { + + m_displaylines.writeVisor(sLine1, sLine2); + } + + /** + * + */ + @Override + public void clearVisor() { + m_displaylines.clearVisor(); + } + + /** + * + */ + @Override + public void repaintLines() { + jline1.setText(m_displaylines.getLine1()); + jline2.setText(m_displaylines.getLine2()); + } + + @Override + protected void paintComponent(Graphics g) { + + paintBorder(g); + + Graphics2D g2d = (Graphics2D) g; + + Insets i = getInsets(); + + //g.setColor(getBackground()); + g2d.setPaint(new GradientPaint(getWidth() - i.left - i.right - 50, + getHeight() - i.top - i.bottom - 50, + getBackground(), + getWidth() - i.left - i.right, + getHeight() - i.top - i.bottom, + new Color(0xf0f0f0), true)); + g2d.fillRect(i.left, i.top, + getWidth() - i.left - i.right, + getHeight() - i.top - i.bottom); + + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + jPanel1 = new javax.swing.JPanel(); + jline1 = new javax.swing.JLabel(); + jline2 = new javax.swing.JLabel(); + + setBackground(javax.swing.UIManager.getDefaults().getColor("window")); + setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + setLayout(new java.awt.BorderLayout()); + + jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(16, 16, 16, 16)); + jPanel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel1.setOpaque(false); + jPanel1.setLayout(new java.awt.GridBagLayout()); + + jline1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jline1.setText("jline1"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + jPanel1.add(jline1, gridBagConstraints); + + jline2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jline2.setText("jline2"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + jPanel1.add(jline2, gridBagConstraints); + + add(jPanel1, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JLabel jline1; + private javax.swing.JLabel jline2; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/printer/screen/DeviceDisplayWindow.form b/src/main/java/com/unicenta/pos/printer/screen/DeviceDisplayWindow.form new file mode 100644 index 0000000..c9a61fe --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/screen/DeviceDisplayWindow.form @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="Display.Window" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-11,0,0,2,-1"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generatePosition" type="boolean" value="false"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jContainer"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="11" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/printer/screen/DeviceDisplayWindow.java b/src/main/java/com/unicenta/pos/printer/screen/DeviceDisplayWindow.java new file mode 100644 index 0000000..d542de3 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/screen/DeviceDisplayWindow.java @@ -0,0 +1,134 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.screen; + +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.printer.DeviceDisplay; +import java.io.IOException; +import javax.imageio.ImageIO; +import javax.swing.JComponent; + +/** + * + * @author adrian + */ +public class DeviceDisplayWindow extends javax.swing.JFrame implements DeviceDisplay { + + private final String m_sName; + private final DeviceDisplayPanel m_display; + + /** Creates new form DeviceDisplayWindow */ + public DeviceDisplayWindow() { + initComponents(); + + m_sName = AppLocal.getIntString("display.window"); + m_display = new DeviceDisplayPanel(3.0); + + m_jContainer.add(m_display.getDisplayComponent()); + try { + this.setIconImage(ImageIO.read(DeviceDisplayWindow.class.getResourceAsStream("/com/unicenta/images/favicon.png"))); + } catch (IOException e) { + } + + setVisible(true); + } + + /** + * + * @return + */ + @Override + public String getDisplayName() { + return m_sName; + } + + /** + * + * @return + */ + @Override + public String getDisplayDescription() { + return null; + } + + /** + * + * @return + */ + @Override + public JComponent getDisplayComponent() { + return null; + } + + /** + * + * @param animation + * @param sLine1 + * @param sLine2 + */ + @Override + public void writeVisor(int animation, String sLine1, String sLine2) { + m_display.writeVisor(animation, sLine1, sLine2); + } + + /** + * + * @param sLine1 + * @param sLine2 + */ + @Override + public void writeVisor(String sLine1, String sLine2) { + m_display.writeVisor(sLine1, sLine2); + } + + /** + * + */ + @Override + public void clearVisor() { + m_display.clearVisor(); + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jContainer = new javax.swing.JPanel(); + + setTitle(AppLocal.getIntString("display.window")); // NOI18N + + m_jContainer.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + m_jContainer.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + m_jContainer.setLayout(new java.awt.BorderLayout()); + getContentPane().add(m_jContainer, java.awt.BorderLayout.CENTER); + + setSize(new java.awt.Dimension(767, 245)); + }// </editor-fold>//GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel m_jContainer; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/printer/screen/DevicePrinterPanel.form b/src/main/java/com/unicenta/pos/printer/screen/DevicePrinterPanel.form new file mode 100644 index 0000000..ce94b4f --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/screen/DevicePrinterPanel.form @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="m_jScrollView"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/printer/screen/DevicePrinterPanel.java b/src/main/java/com/unicenta/pos/printer/screen/DevicePrinterPanel.java new file mode 100644 index 0000000..c67c16b --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/screen/DevicePrinterPanel.java @@ -0,0 +1,188 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.screen; + +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.printer.DevicePrinter; +import com.unicenta.pos.printer.ticket.BasicTicket; +import com.unicenta.pos.printer.ticket.BasicTicketForScreen; +import java.awt.Toolkit; +import java.awt.image.BufferedImage; +import javax.swing.JComponent; + +/** + * + * @author JG uniCenta + */ +public class DevicePrinterPanel extends javax.swing.JPanel implements DevicePrinter { + + private final String m_sName; + + private final JTicketContainer m_jTicketContainer; + private BasicTicket m_ticketcurrent; + + /** Creates new form JPrinterScreen2 */ + public DevicePrinterPanel() { + initComponents(); + + m_sName = AppLocal.getIntString("printer.screen"); + + m_ticketcurrent = null; + + m_jTicketContainer = new JTicketContainer(); + m_jScrollView.setViewportView(m_jTicketContainer); + } + + /** + * + * @return + */ + @Override + public String getPrinterName() { + return m_sName; + } + + /** + * + */ + @Override + public void printLogo(){ + } + + /** + * + * @return + */ + @Override + public String getPrinterDescription() { + return null; + } + + /** + * + * @return + */ + @Override + public JComponent getPrinterComponent() { + return this; + } + + /** + * + */ + @Override + public void reset() { + m_ticketcurrent = null; + m_jTicketContainer.removeAllTickets(); + m_jTicketContainer.repaint(); + } + + @Override + public void beginReceipt() { + m_ticketcurrent = new BasicTicketForScreen(); + + } + + /** + * + * @param image + */ + @Override + public void printImage(BufferedImage image) { + m_ticketcurrent.printImage(image); + } + + /** + * + * @param type + * @param position + * @param code + */ + @Override + public void printBarCode(String type, String position, String code) { + m_ticketcurrent.printBarCode(type, position, code); + } + + /** + * + * @param iTextSize + */ + @Override + public void beginLine(int iTextSize) { + m_ticketcurrent.beginLine(iTextSize); + } + + /** + * + * @param iStyle + * @param sText + */ + @Override + public void printText(int iStyle, String sText) { + m_ticketcurrent.printText(iStyle, sText); + } + + /** + * + */ + @Override + public void endLine() { + m_ticketcurrent.endLine(); + } + + /** + * + */ + @Override + public void endReceipt() { + m_jTicketContainer.addTicket(new JTicket(m_ticketcurrent)); + m_ticketcurrent = null; + } + + /** + * + */ + @Override + public void openDrawer() { + Toolkit.getDefaultToolkit().beep(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jScrollView = new javax.swing.JScrollPane(); + + setLayout(new java.awt.BorderLayout()); + + m_jScrollView.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + add(m_jScrollView, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JScrollPane m_jScrollView; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/printer/screen/JTicket.form b/src/main/java/com/unicenta/pos/printer/screen/JTicket.form new file mode 100644 index 0000000..5218648 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/screen/JTicket.form @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-93,0,0,0,-103"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> +</Form> diff --git a/src/main/java/com/unicenta/pos/printer/screen/JTicket.java b/src/main/java/com/unicenta/pos/printer/screen/JTicket.java new file mode 100644 index 0000000..b75c21b --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/screen/JTicket.java @@ -0,0 +1,107 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.screen; + +import com.unicenta.pos.printer.ticket.BasicTicket; +import java.awt.*; +import java.util.Map; + +class JTicket extends javax.swing.JPanel { + + private static final int H_GAP = 8; + private static final int V_GAP = 8; + private static final int COLUMNS = 42; + private static final int LINEWIDTH = COLUMNS * 7; + + private final BasicTicket basict; + private final Map desktophints; + + /** Creates new form JTicket */ + public JTicket(BasicTicket t) { + + basict = t; + desktophints = (Map) Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"); + initComponents(); + } + + @Override + protected void paintComponent(Graphics g) { + paintBorder(g); + + Graphics2D g2d = (Graphics2D) g; + + if (desktophints != null) { + g2d.addRenderingHints(desktophints); + } + + Insets i = getInsets(); + g2d.setPaint(new GradientPaint( + getWidth() - i.left - i.right - 100, + getHeight() - i.top - i.bottom - 100, + getBackground(), + getWidth() - i.left - i.right, + getHeight() - i.top - i.bottom, + new Color(0xf0f0f0), true)); + g2d.fillRect(i.left, i.top, + getWidth() - i.left - i.right, + getHeight() - i.top - i.bottom); + + g.setColor(getForeground()); + basict.draw(g2d, i.left + H_GAP, i.top + V_GAP, LINEWIDTH); + } + + + @Override + public Dimension getPreferredSize() { + Insets ins = getInsets(); + return new Dimension((int) ( + LINEWIDTH + 2 * H_GAP) + ins.left + ins.right + , (int) (basict.getHeight() + 2 * V_GAP) + ins.top + ins.bottom); + } + + @Override + public Dimension getMaximumSize() { + return getPreferredSize(); + } + + @Override + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + setBackground(new java.awt.Color(255, 255, 255)); + setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setLayout(new java.awt.BorderLayout()); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/printer/screen/JTicketContainer.form b/src/main/java/com/unicenta/pos/printer/screen/JTicketContainer.form new file mode 100644 index 0000000..cccf762 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/screen/JTicketContainer.form @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 600]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-114,0,0,2,122"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> +</Form> diff --git a/src/main/java/com/unicenta/pos/printer/screen/JTicketContainer.java b/src/main/java/com/unicenta/pos/printer/screen/JTicketContainer.java new file mode 100644 index 0000000..5e09aeb --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/screen/JTicketContainer.java @@ -0,0 +1,133 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.screen; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Insets; +import java.awt.Rectangle; + +// JG 16 May 12 replace +// import java.awt.*; +// import java.awt.event.*; +// import java.awt.image.*; +// import java.util.*; +// import java.awt.print.*; + +// import javax.swing.*; +// import javax.swing.border.*; +// import javax.swing.event.*; + +/** + * + * @author Adrian + */ +class JTicketContainer extends javax.swing.JPanel { + + protected int H_GAP = 8; + protected int V_GAP = 8; + + /** Creates new form JTicketContainer */ + public JTicketContainer() { + initComponents(); + setLayout(null); + } + + @Override + public Dimension getPreferredSize() { + + Insets ins = getInsets(); + int iMaxx = 0; + int iMaxy = ins.top + V_GAP; + int n = getComponentCount(); + for(int i = 0; i < n; i++) { + Component comp = getComponent(i); + Dimension dc = comp.getPreferredSize(); + if (dc.width > iMaxx) { + iMaxx = dc.width; + } + iMaxy += V_GAP + dc.height; + } + + return new Dimension(iMaxx + 2 * H_GAP + ins.left + ins.right, iMaxy + ins.bottom); + } + + @Override + public Dimension getMaximumSize() { + return getPreferredSize(); + } + + @Override + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + @Override + public void doLayout() { + Insets ins = getInsets(); + int x = ins.left + H_GAP; + int y = ins.top + V_GAP; + + int n = getComponentCount(); + for(int i = 0; i < n; i++) { + Component comp = getComponent(i); + Dimension dc = comp.getPreferredSize(); + + comp.setBounds(x, y, dc.width, dc.height); + y += V_GAP + dc.height; + } + } + + public void addTicket(JTicket ticket) { + + add(ticket); + + doLayout(); + revalidate(); + scrollRectToVisible(new Rectangle(0, getPreferredSize().height - 1, 1, 1)); + } + + public void removeAllTickets() { + + removeAll(); + + doLayout(); + revalidate(); + scrollRectToVisible(new Rectangle(0, 0, 1, 1)); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setPreferredSize(new java.awt.Dimension(700, 600)); + setLayout(new java.awt.BorderLayout()); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/printer/ticket.dtd b/src/main/java/com/unicenta/pos/printer/ticket.dtd new file mode 100644 index 0000000..7c4687b --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/ticket.dtd @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + uniCenta oPOS - Touch Friendly Point Of Sale + Copyright (c) 2009-2016 uniCenta & previous Openbravo POS works + http://sourceforge.net/projects/unicentaopos + + This program 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 2 of the License, or + (at your option) any later version. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +--> + +<!ELEMENT output (ticket | display | opendrawer | play | )*> + +<!ELEMENT ticket (line | image | barcode | cut)*> +<!ATTLIST ticket printer CDATA "0"> + +<!ELEMENT line (text)*> +<!ATTLIST line size (0 | 1 | 2 | 3) "0"> + +<!ELEMENT text (#PCDATA)> +<!ATTLIST text align (left | right | center) "left"> +<!ATTLIST text length CDATA #IMPLIED> +<!ATTLIST text bold (true | false) "false"> +<!ATTLIST text underline (true | false) "false"> + +<!ELEMENT image (#PCDATA)> + +<!ELEMENT barcode (#PCDATA)> +<!ATTLIST barcode type (EAN13 | CODE128) "EAN13"> + +<!ELEMENT display (line)*> +<!ATTLIST display animation (scroll | flyer | blink | curtain | none) "none"> + +<!ELEMENT play (#PCDATA)> + +<!ELEMENT opendrawer EMPTY> +<!ATTLIST opendrawer printer CDATA "0"> \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/printer/ticket/BasicTicket.java b/src/main/java/com/unicenta/pos/printer/ticket/BasicTicket.java new file mode 100644 index 0000000..aa4ab1b --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/ticket/BasicTicket.java @@ -0,0 +1,169 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.ticket; + +import lombok.extern.log4j.Log4j2; +import lombok.extern.slf4j.Slf4j; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; + +/** + * + * @author JG uniCenta + */ +@Slf4j +public abstract class BasicTicket implements PrintItem { + + /** + * + */ + protected java.util.List<PrintItem> m_aCommands; + + /** + * + */ + protected PrintItemLine pil; + + /** + * + */ + protected int m_iBodyHeight; + + /** Creates a new instance of AbstractTicket */ + public BasicTicket() { +// JG 16 May 12 use diamond inference + m_aCommands = new ArrayList<>(); + pil = null; + m_iBodyHeight = 0; + } + + /** + * + * @return + */ + protected abstract Font getBaseFont(); + + /** + * + * @return + */ + protected abstract int getFontHeight(); + + /** + * + * @return + */ + protected abstract double getImageScale(); + + /** + * + * @return + */ + @Override + public int getHeight() { + return m_iBodyHeight; + } + + /** + * + * @param g2d + * @param x + * @param y + * @param width + */ + @Override + public void draw(Graphics2D g2d, int x, int y, int width) { + + int currenty = y; + for (PrintItem pi : m_aCommands) { + pi.draw(g2d, x, currenty, width); + currenty += pi.getHeight(); + } + } + + /** + * + * @return + */ + public java.util.List<PrintItem> getCommands() { + return m_aCommands; + } + + // INTERFAZ PRINTER 2 + + /** + * + * @param image + */ + public void printImage(BufferedImage image) { + + PrintItem pi = new PrintItemImage(image, getImageScale()); + m_aCommands.add(pi); + m_iBodyHeight += pi.getHeight(); + } + + /** + * + * @param type + * @param position + * @param code + */ + public void printBarCode(String type, String position, String code) { + + PrintItem pi = new PrintItemBarcode(type, position, code, getImageScale()); + m_aCommands.add(pi); + m_iBodyHeight += pi.getHeight(); + } + + /** + * + * @param iTextSize + */ + public void beginLine(int iTextSize) { + pil = new PrintItemLine(iTextSize, getBaseFont(), getFontHeight()); + } + + /** + * + * @param iStyle + * @param sText + */ + public void printText(int iStyle, String sText) { + if (pil != null) { + pil.addText(iStyle, sText); + } + } + + /** + * + */ + public void endLine() { + if (pil != null) { + m_aCommands.add(pil); + m_iBodyHeight += pil.getHeight(); + pil = null; + } + } + } \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/printer/ticket/BasicTicketForPrinter.java b/src/main/java/com/unicenta/pos/printer/ticket/BasicTicketForPrinter.java new file mode 100644 index 0000000..90f5669 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/ticket/BasicTicketForPrinter.java @@ -0,0 +1,73 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.ticket; + +import java.awt.Font; +import java.awt.geom.AffineTransform; + +/** + * + * @author jaroslawwozniak + * @author adrianromero + + */ +public class BasicTicketForPrinter extends BasicTicket { + +// private static final Font BASEFONT = new Font("Monospaced", + private static final Font BASEFONT = new Font("Courier New", + Font.PLAIN, 7).deriveFont(AffineTransform.getScaleInstance(1.0, 1.50)); + private static final int FONTHEIGHT = 12; + +// private static Font BASEFONT = new Font("Monospaced", + // Font.PLAIN, 7).deriveFont(AffineTransform.getScaleInstance(1.0, 1.40)); + +// JG Feb' 16 - Revert +// Consolas intro'd in v4.1 but causes issue in RightToLeft languages i.e.: Arabic +// private static Font BASEFONT = new Font("Consolas", Font.PLAIN,8).deriveFont(AffineTransform.getScaleInstance(1.0, 1.40)); +// private static int FONTHEIGHT = 12; + + private static final double IMAGE_SCALE = 0.65; + + /** + * + * @return + */ + @Override + protected Font getBaseFont() { + return BASEFONT; + } + + /** + * + * @return + */ + @Override + protected int getFontHeight() { + return FONTHEIGHT; + } + + /** + * + * @return + */ + @Override protected double getImageScale() { + return IMAGE_SCALE; + } + } \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/printer/ticket/BasicTicketForScreen.java b/src/main/java/com/unicenta/pos/printer/ticket/BasicTicketForScreen.java new file mode 100644 index 0000000..dce5fb6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/ticket/BasicTicketForScreen.java @@ -0,0 +1,68 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + + +package com.unicenta.pos.printer.ticket; + +import java.awt.Font; +import java.awt.geom.AffineTransform; + +/** + * + * @author JG uniCenta + */ +public class BasicTicketForScreen extends BasicTicket { + +// private static Font BASEFONT = new Font("Monospaced", + private static Font BASEFONT = new Font("Courier New", + Font.PLAIN, 12).deriveFont(AffineTransform.getScaleInstance(1.0, 1.40)); +// JG Feb' 16 - Revert +// Consolas intro'd in v4.1 but causes issue in RightToLeft languages i.e.: Arabic +// private static Font BASEFONT = new Font("Consolas", Font.PLAIN, 12).deriveFont(AffineTransform.getScaleInstance(1.0, 1.40)); + + private static int FONTHEIGHT = 20; + private static double IMAGE_SCALE = 1.0; + + /** + * + * @return + */ + @Override + protected Font getBaseFont() { + return BASEFONT; + } + + /** + * + * @return + */ + @Override + protected int getFontHeight() { + return FONTHEIGHT; + } + + /** + * + * @return + */ + @Override + protected double getImageScale() { + return IMAGE_SCALE; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/printer/ticket/MyPrinterState.java b/src/main/java/com/unicenta/pos/printer/ticket/MyPrinterState.java new file mode 100644 index 0000000..36fed3d --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/ticket/MyPrinterState.java @@ -0,0 +1,103 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.ticket; + +import com.unicenta.pos.printer.DevicePrinter; +import java.awt.Font; +import java.awt.geom.AffineTransform; + +/** + * + * @author JG uniCenta + */ +public class MyPrinterState { + + private int m_iSize; + + /** Creates a new instance of PrinterState + * @param iSize */ + public MyPrinterState(int iSize) { + m_iSize = iSize; + } + + /** + * + * @return + */ + public int getLineMult() { + return getLineMult(m_iSize); + } + + /** + * + * @param iSize + * @return + */ + public static int getLineMult(int iSize) { + switch (iSize) { + case 0: + case 2: + return 1; + case 1: + case 3: + return 2; + default: + return 1; + } + } + + /** + * + * @param baseFont + * @param iStyle + * @return + */ + public Font getFont(Font baseFont, int iStyle) { + + Font f; + AffineTransform a; + switch (m_iSize) { + case 0: + f = baseFont; + break; + case 2: + a = AffineTransform.getScaleInstance(2.0, 1.0); + a.preConcatenate(baseFont.getTransform()); + f = baseFont.deriveFont(a); + break; + case 1: + a = AffineTransform.getScaleInstance(1.0, 2.0); + a.preConcatenate(baseFont.getTransform()); + f = baseFont.deriveFont(a); + break; + case 3: + a = AffineTransform.getScaleInstance(2.0, 2.0); + a.preConcatenate(baseFont.getTransform()); + f = baseFont.deriveFont(a); + break; + default: + f = baseFont; + break; + } + f = f.deriveFont((iStyle & DevicePrinter.STYLE_BOLD) != 0 ? Font.BOLD : baseFont.getStyle()); + // Falta aplicar el subrayado + return f; + } +} diff --git a/src/main/java/com/unicenta/pos/printer/ticket/PrintItem.java b/src/main/java/com/unicenta/pos/printer/ticket/PrintItem.java new file mode 100644 index 0000000..917844c --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/ticket/PrintItem.java @@ -0,0 +1,44 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.ticket; + +import java.awt.Graphics2D; + +/** + * + * @author JG uniCenta + */ +public interface PrintItem { + + /** + * + * @return + */ + public int getHeight(); + + /** + * + * @param g + * @param x + * @param y + * @param width + */ + public void draw(Graphics2D g, int x, int y, int width); +} diff --git a/src/main/java/com/unicenta/pos/printer/ticket/PrintItemBarcode.java b/src/main/java/com/unicenta/pos/printer/ticket/PrintItemBarcode.java new file mode 100644 index 0000000..8e7136c --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/ticket/PrintItemBarcode.java @@ -0,0 +1,118 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.ticket; + +import com.unicenta.pos.printer.DevicePrinter; +import java.awt.Graphics2D; +import java.awt.geom.AffineTransform; +import org.krysalis.barcode4j.BarcodeDimension; +import org.krysalis.barcode4j.HumanReadablePlacement; +import org.krysalis.barcode4j.impl.AbstractBarcodeBean; +import org.krysalis.barcode4j.impl.code128.Code128Bean; +import org.krysalis.barcode4j.impl.upcean.*; +import org.krysalis.barcode4j.output.java2d.Java2DCanvasProvider; + +/** + * + * @author JG uniCenta + */ +public class PrintItemBarcode implements PrintItem { + + /** + * + */ + protected AbstractBarcodeBean m_barcode; + protected String m_sCode; + protected int m_iWidth; + protected int m_iHeight; + protected double scale; + + /** Creates a new instance of PrinterItemBarcode + * @param type + * @param position + * @param code + * @param scale */ + public PrintItemBarcode(String type, String position, String code, double scale) { + + m_sCode = code; + this.scale = scale; + + if (DevicePrinter.BARCODE_CODE128.equals(type)) { + m_barcode = new Code128Bean(); + } else { + m_barcode = new EAN13Bean(); + } + + if (m_barcode != null) { + m_barcode.setModuleWidth(1.0); + m_barcode.setBarHeight(40.0); + m_barcode.setFontSize(10.0); + m_barcode.setQuietZone(10.0); + m_barcode.doQuietZone(true); + if (DevicePrinter.POSITION_NONE.equals(position)) { + m_barcode.setMsgPosition(HumanReadablePlacement.HRP_NONE); + } else { + m_barcode.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); + } + BarcodeDimension dim = m_barcode.calcDimensions(m_sCode); + m_iWidth = (int) dim.getWidth(0); + m_iHeight = (int) dim.getHeight(0); + } + } + + /** + * + * @param g + * @param x + * @param y + * @param width + */ + @Override + public void draw(Graphics2D g, int x, int y, int width) { + + if (m_barcode != null) { + Graphics2D g2d = (Graphics2D) g; + + AffineTransform oldt = g2d.getTransform(); + + g2d.translate(x - 10 + (width - (int)(m_iWidth * scale)) / 2, y + 10); + g2d.scale(scale, scale); + + try { + m_barcode.generateBarcode(new Java2DCanvasProvider(g2d, 0), m_sCode); + } catch (IllegalArgumentException e) { + g2d.drawRect(0, 0, m_iWidth, m_iHeight); + g2d.drawLine(0, 0, m_iWidth, m_iHeight); + g2d.drawLine(m_iWidth, 0, 0, m_iHeight); + } + + g2d.setTransform(oldt); + } + } + + /** + * + * @return + */ + @Override + public int getHeight() { + return (int) (m_iHeight * scale) + 20; + } +} diff --git a/src/main/java/com/unicenta/pos/printer/ticket/PrintItemImage.java b/src/main/java/com/unicenta/pos/printer/ticket/PrintItemImage.java new file mode 100644 index 0000000..5201b1f --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/ticket/PrintItemImage.java @@ -0,0 +1,73 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.ticket; + +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; + +/** + * + * @author JG uniCenta + */ +public class PrintItemImage implements PrintItem { + + /** + * + */ + protected BufferedImage image; + + /** + * + */ + protected double scale; + + /** Creates a new instance of PrintItemImage + * @param image + * @param scale + */ + public PrintItemImage(BufferedImage image, double scale) { + this.image = image; + this.scale = scale; + } + + /** + * + * @param g + * @param x + * @param y + * @param width + */ + @Override + public void draw(Graphics2D g, int x, int y, int width) { + g.drawImage(image, x + (width - (int)(image.getWidth() * scale)) / 2, y, + (int)(image.getWidth() * scale), + (int)(image.getHeight() * scale) + , null); + } + + /** + * + * @return + */ + @Override + public int getHeight() { + return (int) (image.getHeight() * scale); + } +} diff --git a/src/main/java/com/unicenta/pos/printer/ticket/PrintItemLine.java b/src/main/java/com/unicenta/pos/printer/ticket/PrintItemLine.java new file mode 100644 index 0000000..db58c84 --- /dev/null +++ b/src/main/java/com/unicenta/pos/printer/ticket/PrintItemLine.java @@ -0,0 +1,129 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.printer.ticket; + +import java.awt.Font; +import java.awt.Graphics2D; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public class PrintItemLine implements PrintItem { + + /** + * + */ + protected Font font; + + /** + * + */ + protected int fontheight; + + /** + * + */ + protected int textsize; + + /** + * + */ + protected List<StyledText> m_atext; + + /** Creates a new instance of PrinterItemLine + * @param textsize + * @param font + * @param fontheight */ + public PrintItemLine(int textsize, Font font, int fontheight) { + this.textsize = textsize; + this.font = font; + this.fontheight = fontheight; + +// JG 16 May 12 use diamond inference + m_atext = new ArrayList<>(); + } + + /** + * + * @param style + * @param text + */ + public void addText(int style, String text) { + m_atext.add(new StyledText(style, text)); + } + + /** + * + * @param g + * @param x + * @param y + * @param width + */ + @Override + public void draw(Graphics2D g, int x, int y, int width) { + + MyPrinterState ps = new MyPrinterState(textsize); + float left = x; + for (int i = 0; i < m_atext.size(); i++) { + StyledText t = m_atext.get(i); + g.setFont(ps.getFont(font, t.style)); + g.drawString(t.text, left, (float) y); + left += g.getFontMetrics().getStringBounds(t.text, g).getWidth(); + } + } + + /** + * + * @return + */ + @Override + public int getHeight() { + return fontheight * MyPrinterState.getLineMult(textsize); + } + + /** + * + */ + protected static class StyledText { + + /** + * + * @param style + * @param text + */ + public StyledText(int style, String text) { + this.style = style; + this.text = text; + } + + /** + * + */ + public int style; + + /** + * + */ + public String text; + } +} diff --git a/src/main/java/com/unicenta/pos/reports/JPanelReport.form b/src/main/java/com/unicenta/pos/reports/JPanelReport.form new file mode 100644 index 0000000..e364854 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JPanelReport.form @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanelHeader"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanelFilter"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="2"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JToggleButton" name="jToggleFilter"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/1downarrow.png"/> + </Property> + <Property name="selected" type="boolean" value="true"/> + <Property name="toolTipText" type="java.lang.String" value="Hide/Show Filter"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="selectedIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/1uparrow.png"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jToggleFilterActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.executereport" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Execute Report"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/reports/JPanelReport.java b/src/main/java/com/unicenta/pos/reports/JPanelReport.java new file mode 100644 index 0000000..3f24800 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JPanelReport.java @@ -0,0 +1,330 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.BaseSentence; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.Session; +import com.unicenta.data.user.EditorCreator; +import com.unicenta.pos.forms.*; +import com.unicenta.pos.sales.TaxesLogic; +import com.unicenta.pos.util.JRViewer400; +import java.awt.BorderLayout; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.sql.Connection; +import java.util.HashMap; +import java.util.Map; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import javax.swing.JComponent; +import javax.swing.JPanel; +import net.sf.jasperreports.engine.*; +import net.sf.jasperreports.engine.design.JasperDesign; +import net.sf.jasperreports.engine.xml.JRXmlLoader; + +/** + * + * @author JG uniCenta + */ +public abstract class JPanelReport extends JPanel implements JPanelView, BeanFactoryApp { + + private JRViewer400 reportviewer = null; + private JasperReport jr = null; + private EditorCreator editor = null; + + /** + * + */ + protected AppView m_App; + private Session s; + private Connection con; + + /** + * + */ + protected SentenceList taxsent; + + /** + * + */ + protected TaxesLogic taxeslogic; + + /** Creates new form JPanelReport */ + public JPanelReport() { + + initComponents(); + } + + /** + * + * @param app + * @throws BeanFactoryException + */ + @Override + public void init(AppView app) throws BeanFactoryException { + + m_App = app; + + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + taxsent = dlSales.getTaxList(); + + editor = getEditorCreator(); + if (editor instanceof ReportEditorCreator) { + jPanelFilter.add(((ReportEditorCreator) editor).getComponent(), BorderLayout.CENTER); + } + + reportviewer = new JRViewer400(null); + + add(reportviewer, BorderLayout.CENTER); + + try { + + InputStream in = getClass().getResourceAsStream(getReport() + ".ser"); + if (in == null) { + // read and compile the report + JasperDesign jd = JRXmlLoader.load(getClass().getResourceAsStream(getReport() + ".jrxml")); + jr = JasperCompileManager.compileReport(jd); + } else { +// JG 16 May 12 use try-with-resources + try (ObjectInputStream oin = new ObjectInputStream(in)) { + jr = (JasperReport) oin.readObject(); + } + } +// JG 16 May 12 use multicatch + } catch (JRException | IOException | ClassNotFoundException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadreport"), e); + msg.show(this); + jr = null; + } + } + + /** + * + * @return + */ + @Override + public Object getBean() { + return this; + } + + /** + * + * @return + */ + protected abstract String getReport(); + + /** + * + * @return + */ + protected abstract String getResourceBundle(); + + /** + * + * @return + */ + protected abstract BaseSentence getSentence(); + + /** + * + * @return + */ + protected abstract ReportFields getReportFields(); + + /** + * + * @return + */ + protected EditorCreator getEditorCreator() { + return null; + } + + /** + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + setVisibleFilter(true); + taxeslogic = new TaxesLogic(taxsent.list()); + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + + reportviewer.loadJasperPrint(null); + return true; + } + + /** + * + * @param value + */ + protected void setVisibleButtonFilter(boolean value) { + jToggleFilter.setVisible(value); + } + + /** + * + * @param value + */ + protected void setVisibleFilter(boolean value) { + jToggleFilter.setSelected(value); + jToggleFilterActionPerformed(null); + } + + private void launchreport() { + + m_App.waitCursorBegin(); + + if (jr != null) { + try { + + // Archivo de recursos + String res = getResourceBundle(); + + // Parametros y los datos + Object params = (editor == null) ? null : editor.createValue(); + JRDataSource data = new JRDataSourceBasic(getSentence(), getReportFields(), params); + + // Construyo el mapa de los parametros. + Map reportparams = new HashMap(); + reportparams.put("ARG", params); + if (res != null) { + reportparams.put("REPORT_RESOURCE_BUNDLE", ResourceBundle.getBundle(res)); + } + reportparams.put("TAXESLOGIC", taxeslogic); + + JasperPrint jp = JasperFillManager.fillReport(jr, reportparams, data); + + reportviewer.loadJasperPrint(jp); + + setVisibleFilter(false); + + } catch (MissingResourceException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadresourcedata"), e); + msg.show(this); + } catch (JRException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfillreport"), e); + msg.show(this); + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadreportdata"), e); + msg.show(this); + } + } + + m_App.waitCursorEnd(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanelHeader = new javax.swing.JPanel(); + jPanelFilter = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jToggleFilter = new javax.swing.JToggleButton(); + jButton1 = new javax.swing.JButton(); + + setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setLayout(new java.awt.BorderLayout()); + + jPanelHeader.setLayout(new java.awt.BorderLayout()); + + jPanelFilter.setLayout(new java.awt.BorderLayout()); + jPanelHeader.add(jPanelFilter, java.awt.BorderLayout.CENTER); + + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + jToggleFilter.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/1downarrow.png"))); // NOI18N + jToggleFilter.setSelected(true); + jToggleFilter.setToolTipText("Hide/Show Filter"); + jToggleFilter.setPreferredSize(new java.awt.Dimension(80, 45)); + jToggleFilter.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/1uparrow.png"))); // NOI18N + jToggleFilter.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jToggleFilterActionPerformed(evt); + } + }); + jPanel1.add(jToggleFilter); + + jButton1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jButton1.setText(AppLocal.getIntString("button.executereport")); // NOI18N + jButton1.setToolTipText("Execute Report"); + jButton1.setPreferredSize(new java.awt.Dimension(150, 45)); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + jPanel1.add(jButton1); + + jPanelHeader.add(jPanel1, java.awt.BorderLayout.SOUTH); + + add(jPanelHeader, java.awt.BorderLayout.NORTH); + }// </editor-fold>//GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + + launchreport(); + + }//GEN-LAST:event_jButton1ActionPerformed + + private void jToggleFilterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleFilterActionPerformed + + jPanelFilter.setVisible(jToggleFilter.isSelected()); + + }//GEN-LAST:event_jToggleFilterActionPerformed + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanelFilter; + private javax.swing.JPanel jPanelHeader; + private javax.swing.JToggleButton jToggleFilter; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/reports/JParamsComposed.form b/src/main/java/com/unicenta/pos/reports/JParamsComposed.form new file mode 100644 index 0000000..7dc1eb1 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsComposed.form @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,111,0,0,1,-124"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> +</Form> diff --git a/src/main/java/com/unicenta/pos/reports/JParamsComposed.java b/src/main/java/com/unicenta/pos/reports/JParamsComposed.java new file mode 100644 index 0000000..013a31b --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsComposed.java @@ -0,0 +1,142 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteComposed; +import com.unicenta.pos.forms.AppView; +import java.awt.Component; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public class JParamsComposed extends javax.swing.JPanel implements ReportEditorCreator { + +// JG 16 May 12 use diamond inference + private List<ReportEditorCreator> editors = new ArrayList<>(); + + /** Creates new form JParamsComposed */ + public JParamsComposed() { + initComponents(); + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + for (ReportEditorCreator qbff : editors) { + qbff.init(app); + } + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + for (ReportEditorCreator qbff : editors) { + qbff.activate(); + } + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + + SerializerWriteComposed sw = new SerializerWriteComposed(); + + for (ReportEditorCreator qbff : editors) { + sw.add(qbff.getSerializerWrite()); + } + + return sw; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] value = new Object[editors.size()]; + + for(int i = 0; i < editors.size(); i++) { + value[i] = editors.get(i).createValue(); + } + + return value; + } + + /** + * + * @param c + */ + public void addEditor(ReportEditorCreator c) { + editors.add(c); + add(c.getComponent()); + } + + /** + * + * @return + */ + public boolean isEmpty() { + + return editors.isEmpty(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.Y_AXIS)); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/reports/JParamsCustomer.form b/src/main/java/com/unicenta/pos/reports/JParamsCustomer.form new file mode 100644 index 0000000..c1ced7d --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsCustomer.form @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[550, 50]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.bycustomer" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </AccessibilityProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jTextField1" min="-2" pref="300" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="btnCustomer" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jTextField1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="btnCustomer" pref="0" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JTextField" name="jTextField1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="btnCustomer"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/customer_sml.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Get Customers"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCustomerActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.customer" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/reports/JParamsCustomer.java b/src/main/java/com/unicenta/pos/reports/JParamsCustomer.java new file mode 100644 index 0000000..dbbd05e --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsCustomer.java @@ -0,0 +1,204 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.pos.customers.CustomerInfo; +import com.unicenta.pos.customers.DataLogicCustomers; +import com.unicenta.pos.customers.JCustomerFinder; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import java.awt.Component; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +/** + * + * @author adrianromero + */ +public class JParamsCustomer extends javax.swing.JPanel implements ReportEditorCreator { + + private DataLogicCustomers dlCustomers; + private CustomerInfo currentcustomer; + + /** Creates new form JParamsCustomer */ + public JParamsCustomer() { + + initComponents(); + + jTextField1.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + currentcustomer = null; + } + @Override + public void removeUpdate(DocumentEvent e) { + currentcustomer = null; + } + @Override + public void changedUpdate(DocumentEvent e) { + currentcustomer = null; + } + }); + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + dlCustomers = (DataLogicCustomers) app.getBean("com.unicenta.pos.customers.DataLogicCustomers"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + currentcustomer = null; + jTextField1.setText(null); + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + return new SerializerWriteBasic(new Datas[] {Datas.OBJECT, Datas.STRING, Datas.OBJECT, Datas.STRING}); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + if (currentcustomer == null) { + if (jTextField1.getText() == null || jTextField1.getText().equals("")) { + return new Object[] {QBFCompareEnum.COMP_NONE, null, QBFCompareEnum.COMP_NONE, null}; + } else { + return new Object[] {QBFCompareEnum.COMP_NONE, null, QBFCompareEnum.COMP_RE, jTextField1.getText()}; + } + } else { + return new Object[] {QBFCompareEnum.COMP_EQUALS, currentcustomer.getId(), QBFCompareEnum.COMP_NONE, null}; + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jTextField1 = new javax.swing.JTextField(); + btnCustomer = new javax.swing.JButton(); + jLabel2 = new javax.swing.JLabel(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setPreferredSize(new java.awt.Dimension(550, 50)); + + jTextField1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextField1.setPreferredSize(new java.awt.Dimension(250, 30)); + + btnCustomer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer_sml.png"))); // NOI18N + btnCustomer.setToolTipText("Get Customers"); + btnCustomer.setPreferredSize(new java.awt.Dimension(80, 45)); + btnCustomer.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCustomerActionPerformed(evt); + } + }); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.customer")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(btnCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) + .addContainerGap()) + ); + + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + getAccessibleContext().setAccessibleName(bundle.getString("label.bycustomer")); // NOI18N + }// </editor-fold>//GEN-END:initComponents + + private void btnCustomerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCustomerActionPerformed + + JCustomerFinder finder = JCustomerFinder.getCustomerFinder(this, dlCustomers); + finder.search(currentcustomer); + finder.setVisible(true); + currentcustomer = finder.getSelectedCustomer(); + if (currentcustomer == null) { + jTextField1.setText(null); + } else { + jTextField1.setText(currentcustomer.getName()); + } + + }//GEN-LAST:event_btnCustomerActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCustomer; + private javax.swing.JLabel jLabel2; + private javax.swing.JTextField jTextField1; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/reports/JParamsDatesInterval.form b/src/main/java/com/unicenta/pos/reports/JParamsDatesInterval.form new file mode 100644 index 0000000..6754958 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsDatesInterval.form @@ -0,0 +1,156 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[750, 50]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jTxtStartDate" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="btnDateStart" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jTxtEndDate" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="btnDateEnd" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jTxtEndDate" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="btnDateStart" alignment="0" pref="0" max="32767" attributes="0"/> + <Group type="103" alignment="1" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jTxtStartDate" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="btnDateEnd" alignment="0" pref="0" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.StartDate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTxtStartDate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JParamsDatesInterval_jTxtStartDate"/> + </AuxValues> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.EndDate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTxtEndDate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="btnDateStart"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/date.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Open Calendar"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnDateStartActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="btnDateEnd"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/date.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Open Calendar"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnDateEndActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/reports/JParamsDatesInterval.java b/src/main/java/com/unicenta/pos/reports/JParamsDatesInterval.java new file mode 100644 index 0000000..17dd0c7 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsDatesInterval.java @@ -0,0 +1,242 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +import com.unicenta.basic.BasicException; +import com.unicenta.beans.JCalendarDialog; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import java.awt.Component; +import java.util.Date; + +/** + * + * @author JG uniCenta + */ +public class JParamsDatesInterval extends javax.swing.JPanel implements ReportEditorCreator { + + /** Creates new form JParamsClosedPos */ + public JParamsDatesInterval() { + initComponents(); + } + + /** + * + * @param d + */ + public void setStartDate(Date d) { + jTxtStartDate.setText(Formats.TIMESTAMP.formatValue(d)); + } + + /** + * + * @param d + */ + public void setEndDate(Date d) { + jTxtEndDate.setText(Formats.TIMESTAMP.formatValue(d)); + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + return new SerializerWriteBasic(new Datas[] {Datas.OBJECT, Datas.TIMESTAMP, Datas.OBJECT, Datas.TIMESTAMP}); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + Object startdate = Formats.TIMESTAMP.parseValue(jTxtStartDate.getText()); + Object enddate = Formats.TIMESTAMP.parseValue(jTxtEndDate.getText()); + + return new Object[] { + startdate == null ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_GREATEROREQUALS, + startdate, + enddate == null ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_LESS, + enddate + }; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jTxtStartDate = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + jTxtEndDate = new javax.swing.JTextField(); + btnDateStart = new javax.swing.JButton(); + btnDateEnd = new javax.swing.JButton(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setPreferredSize(new java.awt.Dimension(750, 50)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.StartDate")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(110, 30)); + + jTxtStartDate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTxtStartDate.setPreferredSize(new java.awt.Dimension(160, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.EndDate")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + + jTxtEndDate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTxtEndDate.setPreferredSize(new java.awt.Dimension(160, 30)); + + btnDateStart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/date.png"))); // NOI18N + btnDateStart.setToolTipText("Open Calendar"); + btnDateStart.setMaximumSize(new java.awt.Dimension(40, 33)); + btnDateStart.setMinimumSize(new java.awt.Dimension(40, 33)); + btnDateStart.setPreferredSize(new java.awt.Dimension(80, 45)); + btnDateStart.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnDateStartActionPerformed(evt); + } + }); + + btnDateEnd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/date.png"))); // NOI18N + btnDateEnd.setToolTipText("Open Calendar"); + btnDateEnd.setMaximumSize(new java.awt.Dimension(40, 33)); + btnDateEnd.setMinimumSize(new java.awt.Dimension(40, 33)); + btnDateEnd.setPreferredSize(new java.awt.Dimension(80, 45)); + btnDateEnd.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnDateEndActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTxtStartDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnDateStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTxtEndDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnDateEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTxtEndDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(btnDateStart, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTxtStartDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(btnDateEnd, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void btnDateStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDateStartActionPerformed + + Date date; + try { + date = (Date) Formats.TIMESTAMP.parseValue(jTxtStartDate.getText()); + } catch (BasicException e) { + date = null; + } + date = JCalendarDialog.showCalendarTimeHours(this, date); + if (date != null) { + jTxtStartDate.setText(Formats.TIMESTAMP.formatValue(date)); + } + }//GEN-LAST:event_btnDateStartActionPerformed + + private void btnDateEndActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDateEndActionPerformed + + Date date; + try { + date = (Date) Formats.TIMESTAMP.parseValue(jTxtEndDate.getText()); + } catch (BasicException e) { + date = null; + } + date = JCalendarDialog.showCalendarTimeHours(this, date); + if (date != null) { + jTxtEndDate.setText(Formats.TIMESTAMP.formatValue(date)); + } + }//GEN-LAST:event_btnDateEndActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnDateEnd; + private javax.swing.JButton btnDateStart; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JTextField jTxtEndDate; + private javax.swing.JTextField jTxtStartDate; + // End of variables declaration//GEN-END:variables + +} + diff --git a/src/main/java/com/unicenta/pos/reports/JParamsLocation.form b/src/main/java/com/unicenta/pos/reports/JParamsLocation.form new file mode 100644 index 0000000..8713db6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsLocation.form @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[384, 50]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel8" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jLocation" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace min="-2" pref="11" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jLocation" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JComboBox" name="m_jLocation"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.warehouse" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/reports/JParamsLocation.java b/src/main/java/com/unicenta/pos/reports/JParamsLocation.java new file mode 100644 index 0000000..1c2185a --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsLocation.java @@ -0,0 +1,179 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.*; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import java.awt.Component; +import java.awt.event.ActionListener; +import java.util.List; + +/** + * + * @author adrianromero + */ +public class JParamsLocation extends javax.swing.JPanel implements ReportEditorCreator { + + private SentenceList m_sentlocations; + private ComboBoxValModel m_LocationsModel; + + /** Creates new form JParamsLocation */ + public JParamsLocation() { + initComponents(); + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + // El modelo de locales + m_sentlocations = dlSales.getLocationsList(); + m_LocationsModel = new ComboBoxValModel(); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + List a = m_sentlocations.list(); + addFirst(a); + m_LocationsModel = new ComboBoxValModel(a); + m_LocationsModel.setSelectedFirst(); + m_jLocation.setModel(m_LocationsModel); // refresh model + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + return new SerializerWriteBasic(new Datas[] {Datas.OBJECT, Datas.STRING}); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @param a + */ + protected void addFirst(List a) { + a.add(0, null); + } + + /** + * + * @param l + */ + public void addActionListener(ActionListener l) { + m_jLocation.addActionListener(l); + } + + /** + * + * @param l + */ + public void removeActionListener(ActionListener l) { + m_jLocation.removeActionListener(l); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + return new Object[] { + m_LocationsModel.getSelectedKey() == null + ? QBFCompareEnum.COMP_NONE + : QBFCompareEnum.COMP_EQUALS, + m_LocationsModel.getSelectedKey() + }; + } + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jLocation = new javax.swing.JComboBox(); + jLabel8 = new javax.swing.JLabel(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setPreferredSize(new java.awt.Dimension(384, 50)); + + m_jLocation.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jLocation.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.warehouse")); // NOI18N + jLabel8.setPreferredSize(new java.awt.Dimension(110, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jLocation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(11, 11, 11) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jLocation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel8; + private javax.swing.JComboBox m_jLocation; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/reports/JParamsLocationWithFirst.java b/src/main/java/com/unicenta/pos/reports/JParamsLocationWithFirst.java new file mode 100644 index 0000000..12769a0 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsLocationWithFirst.java @@ -0,0 +1,43 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +import java.util.List; + +/** + * + * @author adrian + */ +public class JParamsLocationWithFirst extends JParamsLocation { + + /** Creates a new instance of JParamsLocationWithFirst */ + public JParamsLocationWithFirst() { + super(); + } + + /** + * + * @param a + */ + @Override + protected void addFirst(List a) { + a.add(0, null); + } +} diff --git a/src/main/java/com/unicenta/pos/reports/JParamsReason.form b/src/main/java/com/unicenta/pos/reports/JParamsReason.form new file mode 100644 index 0000000..ab0e239 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsReason.form @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 50]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jreason" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jreason" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.stockreason" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jreason"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="maximumRowCount" type="int" value="12"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/reports/JParamsReason.java b/src/main/java/com/unicenta/pos/reports/JParamsReason.java new file mode 100644 index 0000000..6d5105c --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsReason.java @@ -0,0 +1,161 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.inventory.MovementReason; +import java.awt.Component; + +/** + * + * @author JG uniCenta + */ +public class JParamsReason extends javax.swing.JPanel implements ReportEditorCreator { + + private ComboBoxValModel m_ReasonModel; + + /** Creates new form JParamsReason */ + public JParamsReason() { + initComponents(); + + m_ReasonModel = new ComboBoxValModel(); + m_ReasonModel.add(null); + m_ReasonModel.add(MovementReason.IN_PURCHASE); //Supplier Purchase + m_ReasonModel.add(MovementReason.OUT_SALE); //Sale + m_ReasonModel.add(MovementReason.IN_REFUND); //Customer Refund + m_ReasonModel.add(MovementReason.OUT_REFUND); //Supplier Return + m_ReasonModel.add(MovementReason.IN_MOVEMENT); //Adjust Add + m_ReasonModel.add(MovementReason.OUT_MOVEMENT); //Adjust Subtract + m_ReasonModel.add(MovementReason.OUT_SUBTRACT); //Rectify error per JM requirement + m_ReasonModel.add(MovementReason.OUT_BREAK); //Breakage + m_ReasonModel.add(MovementReason.OUT_FREE); //Given Free + m_ReasonModel.add(MovementReason.OUT_SAMPLE); //Given Sample + m_ReasonModel.add(MovementReason.OUT_USED); //Used item + m_ReasonModel.add(MovementReason.OUT_CROSSING); //Inter-Location move + + m_jreason.setModel(m_ReasonModel); + // m_jreason.setSelectedItem(null); + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + return new SerializerWriteBasic(new Datas[] {Datas.OBJECT, Datas.INT}); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + return new Object[] { + m_ReasonModel.getSelectedItem() == null ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_EQUALS, m_ReasonModel.getSelectedKey() + }; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel2 = new javax.swing.JLabel(); + m_jreason = new javax.swing.JComboBox(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setPreferredSize(new java.awt.Dimension(400, 50)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.stockreason")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jreason.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jreason.setMaximumRowCount(12); + m_jreason.setPreferredSize(new java.awt.Dimension(250, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jreason, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jreason, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel2; + private javax.swing.JComboBox m_jreason; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/reports/JParamsSuppliers.form b/src/main/java/com/unicenta/pos/reports/JParamsSuppliers.form new file mode 100644 index 0000000..cc5272d --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsSuppliers.form @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[550, 50]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.bycustomer" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </AccessibilityProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jTextField1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="btnSupplier" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jTextField1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" pref="14" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Component id="btnSupplier" min="-2" pref="34" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JTextField" name="jTextField1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="btnSupplier"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/customer_sml.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Get Suppliers"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSupplierActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.supplier" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/reports/JParamsSuppliers.java b/src/main/java/com/unicenta/pos/reports/JParamsSuppliers.java new file mode 100644 index 0000000..efc8e69 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsSuppliers.java @@ -0,0 +1,207 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2016 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.pos.suppliers.SupplierInfo; +import com.unicenta.pos.suppliers.DataLogicSuppliers; +import com.unicenta.pos.suppliers.JSupplierFinder; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import java.awt.Component; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +/** + * + * @author Jack Gerrard + */ +public class JParamsSuppliers extends javax.swing.JPanel implements ReportEditorCreator { + + private DataLogicSuppliers dlSuppliers; + private SupplierInfo currentsupplier; + + /** Creates new form JParamsSupplier */ + public JParamsSuppliers() { + + initComponents(); + + jTextField1.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + currentsupplier = null; + } + @Override + public void removeUpdate(DocumentEvent e) { + currentsupplier = null; + } + @Override + public void changedUpdate(DocumentEvent e) { + currentsupplier = null; + } + }); + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + dlSuppliers = (DataLogicSuppliers) app.getBean("com.unicenta.pos.suppliers.DataLogicSuppliers"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + currentsupplier = null; + jTextField1.setText(null); + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + return new SerializerWriteBasic(new Datas[] {Datas.OBJECT, Datas.STRING, Datas.OBJECT, Datas.STRING}); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + if (currentsupplier == null) { + if (jTextField1.getText() == null || jTextField1.getText().equals("")) { + return new Object[] {QBFCompareEnum.COMP_NONE, null, QBFCompareEnum.COMP_NONE, null}; + } else { + return new Object[] {QBFCompareEnum.COMP_NONE, null, QBFCompareEnum.COMP_RE, jTextField1.getText()}; + } + } else { + return new Object[] {QBFCompareEnum.COMP_EQUALS, currentsupplier.getID(), QBFCompareEnum.COMP_NONE, null}; + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jTextField1 = new javax.swing.JTextField(); + btnSupplier = new javax.swing.JButton(); + jLabel2 = new javax.swing.JLabel(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setPreferredSize(new java.awt.Dimension(550, 50)); + + jTextField1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextField1.setPreferredSize(new java.awt.Dimension(300, 30)); + + btnSupplier.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer_sml.png"))); // NOI18N + btnSupplier.setToolTipText("Get Suppliers"); + btnSupplier.setPreferredSize(new java.awt.Dimension(80, 45)); + btnSupplier.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnSupplierActionPerformed(evt); + } + }); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.supplier")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnSupplier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(14, 14, 14)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(btnSupplier, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()))) + ); + + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + getAccessibleContext().setAccessibleName(bundle.getString("label.bycustomer")); // NOI18N + }// </editor-fold>//GEN-END:initComponents + + private void btnSupplierActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSupplierActionPerformed + + JSupplierFinder finder = JSupplierFinder.getSupplierFinder(this, dlSuppliers); + finder.search(currentsupplier); + finder.setVisible(true); + currentsupplier = finder.getSelectedSupplier(); + if (currentsupplier == null) { + jTextField1.setText(null); + } else { + jTextField1.setText(currentsupplier.getName()); + } + + }//GEN-LAST:event_btnSupplierActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnSupplier; + private javax.swing.JLabel jLabel2; + private javax.swing.JTextField jTextField1; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/reports/JParamsText.form b/src/main/java/com/unicenta/pos/reports/JParamsText.form new file mode 100644 index 0000000..f90777e --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsText.form @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,43,0,0,1,-64"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="lblField"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="***"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="20" y="10" width="120" height="-1"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtField"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="140" y="10" width="200" height="-1"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/reports/JParamsText.java b/src/main/java/com/unicenta/pos/reports/JParamsText.java new file mode 100644 index 0000000..d181609 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsText.java @@ -0,0 +1,234 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import java.awt.Component; + +/** + * + * @author adrianromero + */ +public final class JParamsText extends javax.swing.JPanel implements ReportEditorCreator { + + private Datas datasvalue; + private Formats formatsvalue; + private QBFCompareEnum comparevalue; + + /** Creates new form JParamsText */ + public JParamsText() { + initComponents(); + + setLabel(AppLocal.getIntString("label.value")); + setType(Formats.STRING); + } + + /** + * + * @param label + */ + public JParamsText(String label) { + + initComponents(); + + setLabel(label); + setType(Formats.STRING); + } + + /** + * + * @param label + * @param format + */ + public JParamsText(String label, Formats format) { + + initComponents(); + + setLabel(label); + setType(format); + } + + /** + * + * @param label + * @param format + * @param data + */ + public JParamsText(String label, Formats format, Datas data) { + + initComponents(); + + setLabel(label); + setType(format, data); + } + + /** + * + * @param label + */ + public void setLabel(String label) { + lblField.setText(label); + } + + /** + * + * @param format + * @param data + */ + public void setType(Formats format, Datas data) { + formatsvalue = format; + datasvalue = data; + setDefaultCompare(); + } + + /** + * + * @param format + */ + public void setType(Formats format) { + + if (Formats.INT == format) { + setType(format, Datas.INT); + } else if (Formats.DOUBLE == format || Formats.CURRENCY == format || Formats.PERCENT == format) { + setType(format, Datas.DOUBLE); + } else if (Formats.DATE == format || Formats.TIME == format || Formats.TIMESTAMP == format) { + setType(format, Datas.TIMESTAMP); + } else if (Formats.BOOLEAN == format) { + setType(format, Datas.BOOLEAN); + } else { // if (Formats.STRING == format) { + setType(format, Datas.STRING); + } + } + + /** + * + * @param compare + */ + public void setCompare(QBFCompareEnum compare) { + comparevalue = compare; + } + + private void setDefaultCompare() { + if (Formats.INT == formatsvalue) { + comparevalue = QBFCompareEnum.COMP_LESSOREQUALS; + } else if (Formats.DOUBLE == formatsvalue || Formats.CURRENCY == formatsvalue || Formats.PERCENT == formatsvalue) { + comparevalue = QBFCompareEnum.COMP_LESSOREQUALS; + } else if (Formats.DATE == formatsvalue || Formats.TIME == formatsvalue || Formats.TIMESTAMP == formatsvalue) { + comparevalue = QBFCompareEnum.COMP_GREATEROREQUALS; + } else if (Formats.BOOLEAN == formatsvalue) { + comparevalue = QBFCompareEnum.COMP_EQUALS; + } else { // if (Formats.STRING == formatsvalue) { + comparevalue = QBFCompareEnum.COMP_RE; + } + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + txtField.setText(null); + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + return new SerializerWriteBasic(new Datas[] {Datas.OBJECT, datasvalue}); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object value = formatsvalue.parseValue(txtField.getText()); + txtField.setText(formatsvalue.formatValue(value)); + + if (value == null) { + return new Object[] {QBFCompareEnum.COMP_NONE, null}; + } else { + return new Object[] {comparevalue, value}; + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + lblField = new javax.swing.JLabel(); + txtField = new javax.swing.JTextField(); + + setPreferredSize(new java.awt.Dimension(0, 30)); + setLayout(null); + + lblField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + lblField.setText("***"); + lblField.setPreferredSize(new java.awt.Dimension(0, 30)); + add(lblField); + lblField.setBounds(20, 10, 120, 30); + + txtField.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtField.setPreferredSize(new java.awt.Dimension(0, 30)); + add(txtField); + txtField.setBounds(140, 10, 200, 30); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel lblField; + private javax.swing.JTextField txtField; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/reports/JParamsUser.form b/src/main/java/com/unicenta/pos/reports/JParamsUser.form new file mode 100644 index 0000000..1b67516 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsUser.form @@ -0,0 +1,93 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[425, 50]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="6" max="-2" attributes="0"/> + <Component id="jTextField1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="btnUser" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jTextField1" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="btnUser" pref="0" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.user" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTextField1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="btnUser"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/customer_sml.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Get Customers"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnUserActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/reports/JParamsUser.java b/src/main/java/com/unicenta/pos/reports/JParamsUser.java new file mode 100644 index 0000000..565359f --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JParamsUser.java @@ -0,0 +1,201 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.pos.admin.PeopleInfo; +import com.unicenta.pos.admin.DataLogicAdmin; +import com.unicenta.pos.admin.JPeopleFinder; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import java.awt.Component; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +/** + * + * @author adrianromero + */ +public class JParamsUser extends javax.swing.JPanel implements ReportEditorCreator { + + private DataLogicAdmin dlPeople; + private PeopleInfo currentpeople; + + /** Creates new form JParamsUser */ + public JParamsUser() { + + initComponents(); + + jTextField1.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void insertUpdate(DocumentEvent e) { + currentpeople = null; + } + @Override + public void removeUpdate(DocumentEvent e) { + currentpeople = null; + } + @Override + public void changedUpdate(DocumentEvent e) { + currentpeople = null; + } + }); + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + dlPeople = (DataLogicAdmin) app.getBean("com.unicenta.pos.admin.DataLogicAdmin"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + currentpeople = null; + jTextField1.setText(null); + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + return new SerializerWriteBasic(new Datas[] {Datas.OBJECT, Datas.STRING, Datas.OBJECT, Datas.STRING}); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + if (currentpeople == null) { + if (jTextField1.getText() == null || jTextField1.getText().equals("")) { + return new Object[] {QBFCompareEnum.COMP_NONE, null, QBFCompareEnum.COMP_NONE, null}; + } else { + return new Object[] {QBFCompareEnum.COMP_NONE, null, QBFCompareEnum.COMP_RE, jTextField1.getText()}; + } + } else { + return new Object[] {QBFCompareEnum.COMP_EQUALS, currentpeople.getID(), QBFCompareEnum.COMP_NONE, null}; + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jTextField1 = new javax.swing.JTextField(); + btnUser = new javax.swing.JButton(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setPreferredSize(new java.awt.Dimension(425, 50)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.user")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(110, 30)); + + jTextField1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTextField1.setPreferredSize(new java.awt.Dimension(200, 30)); + + btnUser.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer_sml.png"))); // NOI18N + btnUser.setToolTipText("Get Customers"); + btnUser.setPreferredSize(new java.awt.Dimension(80, 45)); + btnUser.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnUserActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(6, 6, 6) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(btnUser, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void btnUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUserActionPerformed + + JPeopleFinder finder = JPeopleFinder.getPeopleFinder(this, dlPeople); + finder.search(currentpeople); + finder.setVisible(true); + currentpeople = finder.getSelectedPeople(); + if (currentpeople == null) { + jTextField1.setText(null); + } else { + jTextField1.setText(currentpeople.getName()); + } + + }//GEN-LAST:event_btnUserActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnUser; + private javax.swing.JLabel jLabel1; + private javax.swing.JTextField jTextField1; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/reports/JRDataSourceBasic.java b/src/main/java/com/unicenta/pos/reports/JRDataSourceBasic.java new file mode 100644 index 0000000..2bdccd6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/JRDataSourceBasic.java @@ -0,0 +1,97 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.BaseSentence; +import com.unicenta.data.loader.DataResultSet; +import com.unicenta.pos.forms.AppLocal; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRField; + +/** + * + * @author JG uniCenta + */ +public class JRDataSourceBasic implements JRDataSource { + + private BaseSentence sent; + private DataResultSet SRS = null; + private Object current = null; + + private ReportFields m_fields = null; + + /** Creates a new instance of JRDataSourceBasic + * @param sent + * @param fields + * @param params + * @throws com.unicenta.basic.BasicException */ + public JRDataSourceBasic(BaseSentence sent, ReportFields fields, Object params) throws BasicException { + + this.sent = sent; + SRS = sent.openExec(params); + m_fields = fields; + } + + /** + * + * @param jrField + * @return + * @throws JRException + */ + @Override + public Object getFieldValue(JRField jrField) throws JRException { + + try { + return m_fields.getField(current, jrField.getName()); + } catch (ReportException er) { + throw new JRException(er); + } + } + + /** + * + * @return + * @throws JRException + */ + @Override + public boolean next() throws JRException { + + if (SRS == null) { + throw new JRException(AppLocal.getIntString("exception.unavailabledataset")); + } + + try { + if (SRS.next()) { + current = SRS.getCurrent(); + return true; + } else { + current = null; + SRS = null; + sent.closeExec(); + sent = null; + return false; + } + } catch (BasicException e) { + throw new JRException(e); + } + } +} diff --git a/src/main/java/com/unicenta/pos/reports/PanelReportBean.java b/src/main/java/com/unicenta/pos/reports/PanelReportBean.java new file mode 100644 index 0000000..c6f6abc --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/PanelReportBean.java @@ -0,0 +1,201 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.*; +import com.unicenta.data.user.EditorCreator; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.BeanFactoryException; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author adrianromero + */ +public class PanelReportBean extends JPanelReport { + + private String title; + private String report; + + private String resourcebundle = null; + + private String sentence; + + +// JG 16 May 12 use diamond inference + private List<Datas> fielddatas = new ArrayList<>(); + private List<String> fieldnames = new ArrayList<>(); + + private List<String> paramnames = new ArrayList<>(); + + private JParamsComposed qbffilter = new JParamsComposed(); + + /** + * + * @param app + * @throws BeanFactoryException + */ + @Override + public void init(AppView app) throws BeanFactoryException { + + qbffilter.init(app); + super.init(app); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + qbffilter.activate(); + super.activate(); + + if (qbffilter.isEmpty()) { + setVisibleFilter(false); + setVisibleButtonFilter(false); + } + } + + /** + * + * @return + */ + @Override + protected EditorCreator getEditorCreator() { + + return qbffilter; + } + + /** + * + * @param title + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * + * @param titlekey + */ + public void setTitleKey(String titlekey) { + title = AppLocal.getIntString(titlekey); + } + + /** + * + * @return + */ + public String getTitle() { + return title; + } + + /** + * + * @param report + */ + public void setReport(String report) { + this.report = report; + } + + /** + * + * @return + */ + protected String getReport() { + return report; + } + + /** + * + * @param resourcebundle + */ + public void setResourceBundle(String resourcebundle) { + this.resourcebundle = resourcebundle; + } + + /** + * + * @return + */ + protected String getResourceBundle() { + return resourcebundle == null + ? report + : resourcebundle; + } + + /** + * + * @param sentence + */ + public void setSentence(String sentence) { + this.sentence = sentence; + } + + /** + * + * @param name + * @param data + */ + public void addField(String name, Datas data) { + fieldnames.add(name); + fielddatas.add(data); + } + + /** + * + * @param name + */ + public void addParameter(String name) { + paramnames.add(name); + } + + /** + * + * @return + */ + protected BaseSentence getSentence() { + return new StaticSentence(m_App.getSession() + , new QBFBuilder(sentence, paramnames.toArray(new String[paramnames.size()])) + , qbffilter.getSerializerWrite() + , new SerializerReadBasic(fielddatas.toArray(new Datas[fielddatas.size()]))); + } + + /** + * + * @return + */ + protected ReportFields getReportFields() { + return new ReportFieldsArray(fieldnames.toArray(new String[fieldnames.size()])); + } + + /** + * + * @param qbff + */ + public void addQBFFilter(ReportEditorCreator qbff) { + qbffilter.addEditor(qbff); + } +} diff --git a/src/main/java/com/unicenta/pos/reports/ReportEditorCreator.java b/src/main/java/com/unicenta/pos/reports/ReportEditorCreator.java new file mode 100644 index 0000000..51ca132 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/ReportEditorCreator.java @@ -0,0 +1,50 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.FilterEditorCreator; +import com.unicenta.pos.forms.AppView; +import java.awt.Component; + +/** + * + * @author adrianromero + */ +public interface ReportEditorCreator extends FilterEditorCreator { + + /** + * + * @param app + */ + public void init(AppView app); + + /** + * + * @throws BasicException + */ + public void activate() throws BasicException; + + /** + * + * @return + */ + public Component getComponent(); +} diff --git a/src/main/java/com/unicenta/pos/reports/ReportException.java b/src/main/java/com/unicenta/pos/reports/ReportException.java new file mode 100644 index 0000000..65b213e --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/ReportException.java @@ -0,0 +1,49 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +/** + * + * @author JG uniCenta + */ +public class ReportException extends Exception { + + /** + * + */ + public ReportException() { + } + + /** + * + * @param msg + */ + public ReportException(String msg) { + super(msg); + } + + /** + * + * @param e + */ + public ReportException(Exception e) { + super(e); + } +} diff --git a/src/main/java/com/unicenta/pos/reports/ReportFields.java b/src/main/java/com/unicenta/pos/reports/ReportFields.java new file mode 100644 index 0000000..1188893 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/ReportFields.java @@ -0,0 +1,36 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +/** + * + * @author JG uniCenta + */ +public interface ReportFields { + + /** + * + * @param record + * @param field + * @return + * @throws ReportException + */ + public Object getField(Object record, String field) throws ReportException; +} diff --git a/src/main/java/com/unicenta/pos/reports/ReportFieldsArray.java b/src/main/java/com/unicenta/pos/reports/ReportFieldsArray.java new file mode 100644 index 0000000..d4de182 --- /dev/null +++ b/src/main/java/com/unicenta/pos/reports/ReportFieldsArray.java @@ -0,0 +1,68 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.reports; + +import java.util.HashMap; +import java.util.Map; +import com.unicenta.pos.forms.AppLocal; + +/** + * + * @author JG uniCenta + */ +public class ReportFieldsArray implements ReportFields { + + private Map m_keys = null; + + /** Creates a new instance of ReportFieldsArray + * @param afields */ + public ReportFieldsArray(String[] afields) { + + // Creo el mapa de claves + m_keys = new HashMap(); + for (int i = 0; i < afields.length; i++) { + m_keys.put(afields[i], new Integer(i)); + } + } + + /** + * + * @param record + * @param field + * @return + * @throws ReportException + */ + @Override + public Object getField(Object record, String field) throws ReportException { + + Integer i = (Integer) m_keys.get(field); + if (i == null) { + throw new ReportException(AppLocal.getIntString("exception.unavailablefield", new Object[] {field})); + } else { + Object[] arecord = (Object[]) record; + if (arecord == null || i.intValue() < 0 + || i.intValue() >= arecord.length) { + throw new ReportException(AppLocal.getIntString("exception.unavailablefields")); + } else { + return arecord[i.intValue()]; + } + } + } +} diff --git a/src/main/java/com/unicenta/pos/resets/JPanelResets.form b/src/main/java/com/unicenta/pos/resets/JPanelResets.form new file mode 100644 index 0000000..86321ea --- /dev/null +++ b/src/main/java/com/unicenta/pos/resets/JPanelResets.form @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="400" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="300" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> +</Form> diff --git a/src/main/java/com/unicenta/pos/resets/JPanelResets.java b/src/main/java/com/unicenta/pos/resets/JPanelResets.java new file mode 100644 index 0000000..cce1727 --- /dev/null +++ b/src/main/java/com/unicenta/pos/resets/JPanelResets.java @@ -0,0 +1,53 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2016 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// CSV Import Panel added by JDL - February 2013 +// Additonal library required - javacsv + +package com.unicenta.pos.resets; + +public class JPanelResets extends javax.swing.JPanel { + + + public JPanelResets() { + initComponents(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 400, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 300, Short.MAX_VALUE) + ); + }// </editor-fold>//GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/resets/JResetPickupID.java b/src/main/java/com/unicenta/pos/resets/JResetPickupID.java new file mode 100644 index 0000000..a3c7059 --- /dev/null +++ b/src/main/java/com/unicenta/pos/resets/JResetPickupID.java @@ -0,0 +1,134 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.resets; + +import com.unicenta.basic.BasicException; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppProperties; +import com.unicenta.pos.forms.JRootFrame; +import com.unicenta.pos.sales.JPanelResetPickupId; +import java.awt.BorderLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.IOException; +import javax.imageio.ImageIO; +import javax.swing.LookAndFeel; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; + + +/** + * + * @author adrianromero + */ +public class JResetPickupID extends javax.swing.JFrame { + + private JPanelResetPickupId config; + + /** + * + * @param props + */ + public JResetPickupID(AppProperties props) { + + initComponents(); + + try { + this.setIconImage(ImageIO.read(JRootFrame.class.getResourceAsStream("/com/unicenta/images/favicon.png"))); + } catch (IOException e) { + } + setTitle(AppLocal.APP_NAME + " - " + AppLocal.APP_VERSION + " - " + AppLocal.getIntString("Menu.Resetpickup")); + + addWindowListener(new MyFrameListener()); + + config = new JPanelResetPickupId(props); + + getContentPane().add(config, BorderLayout.CENTER); + + try { + config.activate(); + } catch (BasicException e) { // never thrown ;-) + } + } + + private class MyFrameListener extends WindowAdapter{ + + @Override + public void windowClosing(WindowEvent evt) { + if (config.deactivate()) { + dispose(); + } + } + @Override + public void windowClosed(WindowEvent evt) { + System.exit(0); + } + } + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); + + java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); + setBounds((screenSize.width-507)/2, (screenSize.height-304)/2, 507, 304); + }// </editor-fold>//GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(final String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + + AppConfig config = new AppConfig(args); + config.load(); + +// Set the look and feel. +// JG 6 May 2013 to Multicatch + try { + Object laf = Class.forName(config.getProperty("swing.defaultlaf")).newInstance(); + if (laf instanceof LookAndFeel){ + UIManager.setLookAndFeel((LookAndFeel) laf); +// } else if (laf instanceof SubstanceSkin) { +// SubstanceLookAndFeel.setSkin((SubstanceSkin) laf); + } +// JG 6 May 2013 to multicatch + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { + } + + JResetPickupID resetFrame = new JResetPickupID(config);// + resetFrame.setSize(360, 120); + resetFrame.setVisible(true); + + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/DataLogicReceipts.java b/src/main/java/com/unicenta/pos/sales/DataLogicReceipts.java new file mode 100644 index 0000000..1028db0 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/DataLogicReceipts.java @@ -0,0 +1,384 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.PreparedSentence; +import com.unicenta.data.loader.SerializerReadBasic; +import com.unicenta.data.loader.SerializerReadClass; +import com.unicenta.data.loader.SerializerWriteBasicExt; +import com.unicenta.data.loader.SerializerWriteString; +import com.unicenta.data.loader.Session; +import com.unicenta.data.loader.StaticSentence; +import com.unicenta.pos.forms.BeanFactoryDataSingle; +import com.unicenta.pos.ticket.TicketInfo; +import java.util.List; + +/** + * + * @author adrianromero + */ +public class DataLogicReceipts extends BeanFactoryDataSingle { + + private Session s; + + /** Creates a new instance of DataLogicReceipts */ + public DataLogicReceipts() { + } + + /** + * + * @param s + */ + @Override + public void init(Session s){ + this.s = s; + } + + /** + * + * @param Id + * @return + * @throws BasicException + */ + public final TicketInfo getSharedTicket(String Id) throws BasicException { + + if (Id == null) { + return null; + } else { + Object[]record = (Object[]) new StaticSentence(s + , "SELECT CONTENT, LOCKED FROM sharedtickets WHERE ID = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[] { + Datas.SERIALIZABLE})).find(Id); + return record == null ? null : (TicketInfo) record[0]; + } + } + + /** + * + * @param pickupId + * @return + * @throws BasicException + */ + public final TicketInfo getSharedTicketPickupId(String pickupId) throws BasicException { + + if (pickupId == null) { + return null; + } else { + Object[]record = (Object[]) new StaticSentence(s + , "SELECT CONTENT, LOCKED FROM sharedtickets WHERE PICKUPID = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[] { + Datas.SERIALIZABLE})).find(pickupId); + return record == null ? null : (TicketInfo) record[0]; + } + } + + /** + * JG Dec 14 Administrator and Manager Roles always have access to ALL SHAREDtickets + * @return + * @throws BasicException + */ + public final List<SharedTicketInfo> getSharedTicketList() throws BasicException { + + return (List<SharedTicketInfo>) new StaticSentence(s +// , "SELECT ID, NAME, CONTENT, APPUSER, PICKUPID, LOCKED FROM sharedtickets ORDER BY ID" + , "SELECT ID, NAME, CONTENT, APPUSER, PICKUPID, LOCKED " + + "FROM sharedtickets ORDER BY PICKUPID" + , null + , new SerializerReadClass(SharedTicketInfo.class)).list(); + } + + /** + * Return only current APPUSER SHAREDtickets + * @param appuser + * @return + * @throws BasicException + */ + public final List<SharedTicketInfo> getUserSharedTicketList(String appuser) throws BasicException { + String sql = "SELECT ID, NAME, CONTENT, APPUSER, PICKUPID, LOCKED " + + "FROM sharedtickets " + + "WHERE APPUSER =\""+ appuser +"\" ORDER BY PICKUPID"; + + return (List<SharedTicketInfo>) new StaticSentence(s + , sql + , null + , new SerializerReadClass(SharedTicketInfo.class)).list(); + } + + /** + * For Standard View + * @param id + * @param ticket + * @param pickupid + * @throws BasicException + */ + public final void insertSharedTicket(final String id, final TicketInfo ticket, int pickupid) throws BasicException { + + Object[] values = new Object[] { + id, + ticket.getName(), + ticket, + ticket.getUser().getId(), + pickupid + + }; + Datas[] datas; + datas = new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.SERIALIZABLE, + Datas.STRING, + Datas.INT + + }; + new PreparedSentence(s + , "INSERT INTO sharedtickets (" + + "ID, " + + "NAME, " + + "CONTENT, " + + "APPUSER, " + + "PICKUPID) " + + "VALUES (?, ?, ?, ?, ?)" + , new SerializerWriteBasicExt(datas, new int[] {0, 1, 2, 3, 4})).exec(values); + } + + /** + * + * @param id + * @param ticket + * @param pickupid + * @throws BasicException + */ + public final void updateSharedTicket(final String id, final TicketInfo ticket, int pickupid) throws BasicException { + + Object[] values = new Object[] { + id, + ticket.getName(), + ticket, + ticket.getUser().getId(), + pickupid + }; + Datas[] datas = new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.SERIALIZABLE, + Datas.STRING, + Datas.INT + }; + new PreparedSentence(s + , "UPDATE sharedtickets SET " + + "NAME = ?, " + + "CONTENT = ?, " + + "APPUSER = ?, " + + "PICKUPID = ? " + + "WHERE ID = ?" + , new SerializerWriteBasicExt(datas, + new int[] { + 1, 2, 3, 4, 0})).exec(values); + } + + /** + * + * @param id + * @param ticket + * @param pickupid + * @throws BasicException + */ + public final void updateRSharedTicket( + final String id, + final TicketInfo ticket, + int pickupid) throws BasicException { + + Object[] values = new Object[] { + id, + ticket.getName(), + ticket, + pickupid + }; + Datas[] datas = new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.SERIALIZABLE, + Datas.INT + }; + new PreparedSentence(s + , "UPDATE sharedtickets SET " + + "NAME = ?, " + + "CONTENT = ?, " + + "PICKUPID = ? " + + "WHERE ID = ?" + , new SerializerWriteBasicExt(datas, new int[] {1, 2, 3, 0})).exec(values); + } + + /** + * In place for multi-purposing like containing data from elsewhere and/or + * using Place and User for Notifications + * @param id + * @param locked + * @throws BasicException + */ + public final void lockSharedTicket(final String id, final String locked) throws BasicException { + + Object[] values = new Object[] { + id, + locked + }; + Datas[] datas = new Datas[] { + Datas.STRING, + Datas.STRING + }; + new PreparedSentence(s + , "UPDATE sharedtickets SET " + + "LOCKED = ? " + + "WHERE ID = ?" + , new SerializerWriteBasicExt(datas, new int[] {1, 0})).exec(values); + } + + /** + * In place for multi-purposing like flushing locks from elsewhere and/or + * using Place and User for Notifications + * @param id + * @param unlocked + * @throws BasicException + */ + public final void unlockSharedTicket(final String id, final String unlocked) throws BasicException { + + Object[] values = new Object[] { + id, + unlocked + }; + Datas[] datas = new Datas[] { + Datas.STRING, + Datas.STRING + }; + new PreparedSentence(s + , "UPDATE sharedtickets SET " + + "LOCKED = ? " + + "WHERE ID = ?" + , new SerializerWriteBasicExt(datas, new int[] {1, 0})).exec(values); + } + + /** + * For Restaurant View + * @param id + * @param ticket + * @param pickupid + * @throws BasicException + */ + public final void insertRSharedTicket( + final String id, + final TicketInfo ticket, + int pickupid) throws BasicException { + + Object[] values = new Object[] { + id, + ticket.getName(), + ticket, + ticket.getUser(), + ticket.getPickupId(), + ticket.getHost() + }; + Datas[] datas; + datas = new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.SERIALIZABLE, + Datas.STRING, + Datas.INT + + }; + new PreparedSentence(s + , "INSERT INTO sharedtickets (" + + "ID, " + + "NAME, " + + "CONTENT, " + + "APPUSER, " + + "PICKUPID) " + + "VALUES (?, ?, ?, ?, ?)" + , new SerializerWriteBasicExt(datas, new int[] {0, 1, 2, 3, 4})).exec(values); + } + + /** + * + * @param id + * @throws BasicException + */ + public final void deleteSharedTicket(final String id) throws BasicException { + + new StaticSentence(s + , "DELETE FROM sharedtickets WHERE ID = ?" + , SerializerWriteString.INSTANCE).exec(id); + } + + /** + * + * @param Id + * @return + * @throws BasicException + */ + public final Integer getPickupId(String Id) throws BasicException { + + if (Id == null) { + return null; + } else { + Object[]record = (Object[]) new StaticSentence(s + , "SELECT PICKUPID FROM sharedtickets WHERE ID = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[] {Datas.INT})).find(Id); + return record == null ? 0 : (Integer)record[0]; + } + } + + + public final String getUserId(final String id) throws BasicException { + Object[] userID = (Object []) new StaticSentence(s + , "SELECT APPUSER FROM sharedtickets WHERE ID = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[] {Datas.STRING})).find(id); + if( userID == null ) { + return null; + } else { + return (String) userID[0]; + } + } + + public final String getLockState(final String id, String lockState) throws BasicException { + Object[] state = (Object[]) new StaticSentence(s + , "SELECT LOCKED FROM sharedtickets WHERE ID = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[] { + Datas.STRING + })).find(id); + return (String) state[0]; + } + + public final String getServer(final String id, String user) throws BasicException { + Object[] server = (Object[]) new StaticSentence(s + , "SELECT appuser FROM sharedtickets WHERE ID = ?" + , SerializerWriteString.INSTANCE + , new SerializerReadBasic(new Datas[] { + Datas.STRING + })).find(id); + return (String) server[0]; + } +} diff --git a/src/main/java/com/unicenta/pos/sales/JMooringDetails.form b/src/main/java/com/unicenta/pos/sales/JMooringDetails.form new file mode 100644 index 0000000..2dff394 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JMooringDetails.form @@ -0,0 +1,159 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.6" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,18,0,0,2,24"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jScrollPane2" pref="508" max="32767" attributes="0"/> + <Group type="102" attributes="0"> + <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" pref="107" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jText" min="-2" pref="222" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jbtnCreateTicket" min="-2" pref="150" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Component id="jScrollPane2" min="-2" pref="179" max="-2" attributes="0"/> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jText" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jbtnCreateTicket" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="jbtnCreateTicket"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.mooringcreatebtn" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnCreateTicketActionPerformed"/> + </Events> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane2"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="jTableSelector"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="4" rowCount="6"> + <Column editable="false" title="Vessel Name" type="java.lang.Object"/> + <Column editable="false" title="Size" type="java.lang.Object"/> + <Column editable="false" title="Days" type="java.lang.Object"/> + <Column editable="false" title="Power" type="java.lang.Object"/> + </Table> + </Property> + <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> + <TableColumnModel selectionModel="0"> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="50" resizable="false"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="50" resizable="false"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="70" resizable="false"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="rowHeight" type="int" value="25"/> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="true" resizingAllowed="true"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jTableSelectorMouseClicked"/> + </Events> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JTextField" name="jText"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="0" type="rgb"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTextActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.mooringscreatefor" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JMooringDetails.java b/src/main/java/com/unicenta/pos/sales/JMooringDetails.java new file mode 100644 index 0000000..c91d286 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JMooringDetails.java @@ -0,0 +1,307 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.data.loader.Session; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Window; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; +import net.proteanit.sql.DbUtils; + +/** + * + * @author JG uniCenta + */ +public class JMooringDetails extends javax.swing.JDialog { + + private Connection con; + private ResultSet rs; + private Statement stmt; + private String ID; + private String SQL; + private String vesselName = ""; + private Integer vesselSize; + private Integer vesselDays; + private Boolean vesselPower; + private boolean create = false; + + + private JMooringDetails(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + + + private JMooringDetails(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + private void init(Session s) { + + initComponents(); + setTitle("Select Vessel details"); + + try{ + con=s.getConnection(); + stmt = (Statement) con.createStatement(); + + SQL = "SELECT * FROM moorers"; + rs = stmt.executeQuery(SQL); + + jTableSelector.setModel(DbUtils.resultSetToTableModel(rs)); + jTableSelector.getColumnModel().getColumn(0).setPreferredWidth(200); + jTableSelector.getColumnModel().getColumn(1).setPreferredWidth(40); + jTableSelector.getColumnModel().getColumn(2).setPreferredWidth(40); + jTableSelector.getColumnModel().getColumn(3).setPreferredWidth(40); + jTableSelector.setRowSelectionAllowed(true); + jTableSelector.getTableHeader().setReorderingAllowed(true); + + + } catch (Exception e) { + } + + + } + + /** + * + * @param parent + * @param s + * @return + */ + public static JMooringDetails getMooringDetails(Component parent, Session s) { + Window window = SwingUtilities.getWindowAncestor(parent); + // m_oticket = new ticket(); + JMooringDetails myMsg; + if (window instanceof Frame) { + myMsg = new JMooringDetails((Frame) window, true); + } else { + myMsg = new JMooringDetails((Dialog) window, true); + } + myMsg.init(s); + myMsg.applyComponentOrientation(parent.getComponentOrientation()); + + + return myMsg; + } + + /** + * + * @return + */ + public boolean isCreate() { + return create; + } + + /** + * + * @return + */ + public String getVesselName() { + return vesselName; + } + + /** + * + * @return + */ + public Integer getVesselSize() { + return vesselSize; + } + + /** + * + * @return + */ + public Integer getVesselDays() { + return vesselDays; + } + + /** + * + * @return + */ + public Boolean getVesselPower() { + return vesselPower; + } + + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jbtnCreateTicket = new javax.swing.JButton(); + jScrollPane2 = new javax.swing.JScrollPane(); + jTableSelector = new javax.swing.JTable(); + jText = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + jbtnCreateTicket.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnCreateTicket.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jbtnCreateTicket.setText(bundle.getString("label.mooringcreatebtn")); // NOI18N + jbtnCreateTicket.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnCreateTicketActionPerformed(evt); + } + }); + + jTableSelector.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jTableSelector.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null} + }, + new String [] { + "Vessel Name", "Size", "Days", "Power" + } + ) { + boolean[] canEdit = new boolean [] { + false, false, false, false + }; + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + jTableSelector.setRowHeight(25); + jTableSelector.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jTableSelectorMouseClicked(evt); + } + }); + jScrollPane2.setViewportView(jTableSelector); + jTableSelector.getColumnModel().getColumn(1).setResizable(false); + jTableSelector.getColumnModel().getColumn(1).setPreferredWidth(50); + jTableSelector.getColumnModel().getColumn(2).setResizable(false); + jTableSelector.getColumnModel().getColumn(2).setPreferredWidth(50); + jTableSelector.getColumnModel().getColumn(3).setResizable(false); + jTableSelector.getColumnModel().getColumn(3).setPreferredWidth(70); + + jText.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jText.setDisabledTextColor(new java.awt.Color(0, 0, 0)); + jText.setEnabled(false); + jText.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextActionPerformed(evt); + } + }); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jLabel1.setText(bundle.getString("label.mooringscreatefor")); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 508, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addGap(10, 10, 10) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jText, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jbtnCreateTicket, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1) + .addComponent(jbtnCreateTicket)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); + setBounds((screenSize.width-536)/2, (screenSize.height-274)/2, 536, 274); + }// </editor-fold>//GEN-END:initComponents + + private void jbtnCreateTicketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnCreateTicketActionPerformed + // use the passed parameters to add line to the ticket + + if (vesselName.equals("")){ + this.create = false; + dispose(); + }else{ + this.create = true; + dispose(); + } + + }//GEN-LAST:event_jbtnCreateTicketActionPerformed + + private void jTableSelectorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableSelectorMouseClicked + + try{ + int row = jTableSelector.getSelectedRow(); + vesselName =(jTableSelector.getModel().getValueAt(row, 0).toString()); + SQL = "SELECT * FROM moorers WHERE VESSELNAME ='" + vesselName +"';"; + rs = stmt.executeQuery(SQL); + if (rs.next()){ + vesselDays=rs.getInt("DAYS"); + vesselSize=rs.getInt("SIZE"); + vesselPower=rs.getBoolean("POWER"); + jText.setText(vesselName); + } + }catch (Exception e){ + JOptionPane.showMessageDialog(null, e); + } + + + }//GEN-LAST:event_jTableSelectorMouseClicked + + private void jTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jTextActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JTable jTableSelector; + private javax.swing.JTextField jText; + private javax.swing.JButton jbtnCreateTicket; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/JPanelButtons.form b/src/main/java/com/unicenta/pos/sales/JPanelButtons.form new file mode 100644 index 0000000..92cafed --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JPanelButtons.form @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JPanelButtons.java b/src/main/java/com/unicenta/pos/sales/JPanelButtons.java new file mode 100644 index 0000000..9414514 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JPanelButtons.java @@ -0,0 +1,221 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.data.loader.LocalRes; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppUser; +import com.unicenta.pos.util.ThumbNailBuilder; +import lombok.extern.slf4j.Slf4j; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +import javax.swing.*; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.io.IOException; +import java.io.StringReader; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +/** + * + * @author JG uniCenta + */ +@Slf4j +public class JPanelButtons extends javax.swing.JPanel { + + private static SAXParser m_sp = null; + + private Properties props; + private Map<String, String> events; + + private ThumbNailBuilder tnbmacro; + + private JPanelTicket panelticket; + + /** Creates new form JPanelButtons + * @param sConfigKey + * @param panelticket */ + public JPanelButtons(String sConfigKey, JPanelTicket panelticket) { + initComponents(); + + // Load categories default thumbnail + tnbmacro = new ThumbNailBuilder(42, 36, "com/unicenta/images/run_script.png"); + + this.panelticket = panelticket; + + props = new Properties(); + events = new HashMap<>(); + + String sConfigRes = panelticket.getResourceAsXML(sConfigKey); + + if (sConfigRes != null) { + try { + if (m_sp == null) { + SAXParserFactory spf = SAXParserFactory.newInstance(); + m_sp = spf.newSAXParser(); + } + m_sp.parse(new InputSource(new StringReader(sConfigRes)), new ConfigurationHandler()); + + } catch (ParserConfigurationException ePC) { + log.error(LocalRes.getIntString("exception.parserconfig"), ePC.getMessage()); + } catch (SAXException eSAX) { + log.error(LocalRes.getIntString("exception.xmlfile"), eSAX.getMessage()); + } catch (IOException eIO) { + log.error(LocalRes.getIntString("exception.iofile"), eIO.getMessage()); + } + } + + } + + /** + * + * @param user + */ + public void setPermissions(AppUser user) { + for (Component c : this.getComponents()) { + String sKey = c.getName(); + if (sKey == null || sKey.equals("")) { + c.setEnabled(true); + } else { + c.setEnabled(user.hasPermission(c.getName())); + } + } + } + + /** + * + * @param key + * @return + */ + public String getProperty(String key) { + return props.getProperty(key); + } + + /** + * + * @param key + * @param defaultvalue + * @return + */ + public String getProperty(String key, String defaultvalue) { + return props.getProperty(key, defaultvalue); + } + + /** + * + * @param key + * @return + */ + public String getEvent(String key) { + return events.get(key); + } + + private class ConfigurationHandler extends DefaultHandler { + @Override + public void startDocument() throws SAXException {} + @Override + public void endDocument() throws SAXException {} + @Override + public void startElement(String uri, String localName, String qName, + Attributes attributes) throws SAXException{ + switch (qName) { + case "button": + // The button title text + String titlekey = attributes.getValue("titlekey"); + if (titlekey == null) { + titlekey = attributes.getValue("name"); + } + String title = titlekey == null + ? attributes.getValue("title") + : AppLocal.getIntString(titlekey); + // adding the button to the panel + JButton btn = new JButtonFunc(attributes.getValue("key"), + attributes.getValue("image"), + title); + // The template resource or the code resource + final String template = attributes.getValue("template"); + if (template == null) { + final String code = attributes.getValue("code"); + btn.addActionListener((ActionEvent evt) -> { + panelticket.evalScriptAndRefresh(code); + }); + } else { + btn.addActionListener((ActionEvent evt) -> { + panelticket.printTicket(template); + }); + } + add(btn); + break; + case "event": + events.put(attributes.getValue("key"), attributes.getValue("code")); + break; + default: + String value = attributes.getValue("value"); + if (value != null) { + props.setProperty(qName, attributes.getValue("value")); + } + break; + } + } + @Override + public void endElement(String uri, String localName, String qName) throws SAXException {} + @Override + public void characters(char[] ch, int start, int length) throws SAXException {} + } + + private class JButtonFunc extends JButton { + + public JButtonFunc(String sKey, String sImage, String title) { + + setName(sKey); + setText(title); + setIcon(new ImageIcon(tnbmacro.getThumbNail(panelticket.getResourceAsImage(sImage)))); + setFocusPainted(false); + setFocusable(false); + setRequestFocusEnabled(false); + setMargin(new Insets(8, 14, 8, 14)); + setPreferredSize(new Dimension(80,45)); + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/JPanelResetPickupId.form b/src/main/java/com/unicenta/pos/sales/JPanelResetPickupId.form new file mode 100644 index 0000000..20907e2 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JPanelResetPickupId.form @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 100]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel1" alignment="1" max="32767" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel1" min="-2" max="-2" attributes="0"/> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[342, 80]"/> + </Property> + </Properties> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="20" max="-2" attributes="0"/> + <Component id="jbtnUpdate" min="-2" pref="155" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="56" max="-2" attributes="0"/> + <Component id="jbtnExit" min="-2" pref="101" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="22" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jbtnUpdate" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jbtnExit" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace pref="25" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="jbtnUpdate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.resetpickup" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 33]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnUpdateActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jbtnExit"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="Button.Exit" replaceFormat="AppLocal.getIntString("Button.Exit")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 33]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnExitActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JPanelResetPickupId.java b/src/main/java/com/unicenta/pos/sales/JPanelResetPickupId.java new file mode 100644 index 0000000..f7cb7c7 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JPanelResetPickupId.java @@ -0,0 +1,275 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.JMessageDialog; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.Session; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppProperties; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.AppViewConnection; +import com.unicenta.pos.forms.JPanelView; +import com.unicenta.pos.util.AltEncrypter; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JPanel; + +/** + * + * @author JG uniCenta + */ +public class JPanelResetPickupId extends JPanel implements JPanelView { + + + private AppConfig config; + private Connection con; + private String sdbmanager; + private Session session; + private AppProperties m_props; + private String SQL; + private Statement stmt; + + /** Creates new form JPaneldbUpdate + * @param oApp */ + public JPanelResetPickupId(AppView oApp) { + this(oApp.getProperties()); + } + + /** + * + * @param props + */ + public JPanelResetPickupId(AppProperties props) { + + initComponents(); + config = new AppConfig(props.getConfigFile()); + m_props=props; + + + } + + /** + * + */ + public void performReset(){ + + if ("HSQL Database Engine".equals(sdbmanager)) { + SQL = "ALTER SEQUENCE pickup_number RESTART WITH 1"; + try { + stmt.executeUpdate(SQL); +// } catch (SQLException e){System.out.println(e.getMessage());} + } catch (SQLException e){} + } else if ("MySQL".equals(sdbmanager)) { + SQL = "UPDATE pickup_number SET ID=0"; + try { + stmt.executeUpdate(SQL); +// } catch (SQLException e){System.out.println(e.getMessage());} + } catch (SQLException e){} + } else if ("PostgreSQL".equals(sdbmanager)) { + SQL = "ALTER SEQUENCE pickup_number RESTART WITH 1"; + try { + stmt.executeUpdate(SQL); +// } catch (SQLException e){System.out.println(e.getMessage());} + } catch (SQLException e){} + } else if ("Oracle".equals(sdbmanager)) { + SQL = "ALTER SEQUENCE pickup_number RESTART WITH 1"; + try { + stmt.executeUpdate(SQL); +// } catch (SQLException e){System.out.println(e.getMessage());} + } catch (SQLException e){} + } else if ("Apache Derby".equals(sdbmanager)) { + SQL = "ALTER TABLE pickup_number ALTER COLUMN ID RESTART WITH 1"; + try { + stmt.executeUpdate(SQL); +// } catch (SQLException e){System.out.println(e.getMessage());} + } catch (SQLException e){} + } else if ("Derby".equals(sdbmanager)) { + SQL = "UPDATE pickup_number SET ID=0"; + try { + stmt.executeUpdate(SQL); +// } catch (SQLException e){System.out.println(e.getMessage());} + } catch (SQLException e){} + } else { + SQL = "ALTER SEQUENCE pickup_number RESTART WITH 1"; + try { + stmt.executeUpdate(SQL); +// } catch (SQLException e){System.out.println(e.getMessage());} + } catch (SQLException e){} + } + JOptionPane.showMessageDialog(this,"Reset complete."); + + } + + /** + * + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Resetpickup"); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + // connect to the database + String db_user =(m_props.getProperty("db.user")); + String db_url = (m_props.getProperty("db.URL")); + String db_password = (m_props.getProperty("db.password")); + + if (db_user != null && db_password != null && db_password.startsWith("crypt:")) { + // the password is encrypted + AltEncrypter cypher = new AltEncrypter("cypherkey" + db_user); + db_password = cypher.decrypt(db_password.substring(6)); + } + + try{ + session = AppViewConnection.createSession(m_props); + con = DriverManager.getConnection(db_url,db_user,db_password); + sdbmanager = con.getMetaData().getDatabaseProductName(); + stmt = (Statement) con.createStatement(); + } catch (BasicException | SQLException e) { + + JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_DANGER, AppLocal.getIntString("database.UnableToConnect"), e)); + System.exit(0); + } + + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + return(true); + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jbtnUpdate = new javax.swing.JButton(); + jbtnExit = new javax.swing.JButton(); + + setPreferredSize(new java.awt.Dimension(200, 100)); + + jPanel1.setPreferredSize(new java.awt.Dimension(342, 80)); + + jbtnUpdate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnUpdate.setText(AppLocal.getIntString("label.resetpickup")); // NOI18N + jbtnUpdate.setMaximumSize(new java.awt.Dimension(70, 33)); + jbtnUpdate.setMinimumSize(new java.awt.Dimension(70, 33)); + jbtnUpdate.setPreferredSize(new java.awt.Dimension(70, 33)); + jbtnUpdate.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnUpdateActionPerformed(evt); + } + }); + + jbtnExit.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnExit.setText(AppLocal.getIntString("button.exit")); // NOI18N + jbtnExit.setMaximumSize(new java.awt.Dimension(70, 33)); + jbtnExit.setMinimumSize(new java.awt.Dimension(70, 33)); + jbtnExit.setPreferredSize(new java.awt.Dimension(70, 33)); + jbtnExit.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnExitActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(20, 20, 20) + .addComponent(jbtnUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(56, 56, 56) + .addComponent(jbtnExit, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGap(22, 22, 22) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jbtnUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnExit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(25, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jbtnUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnUpdateActionPerformed + performReset(); + + }//GEN-LAST:event_jbtnUpdateActionPerformed + + private void jbtnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnExitActionPerformed + deactivate(); + System.exit(0); + }//GEN-LAST:event_jbtnExitActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JButton jbtnExit; + private javax.swing.JButton jbtnUpdate; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/JPanelTicket.form b/src/main/java/com/unicenta/pos/sales/JPanelTicket.form new file mode 100644 index 0000000..4023123 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JPanelTicket.form @@ -0,0 +1,1072 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="99" green="cc" red="ff" type="rgb"/> + </Property> + <Property name="opaque" type="boolean" value="false"/> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-21,0,0,3,67"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jPanContainer"> + <Events> + <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="m_jPanContainerFocusLost"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription"> + <CardConstraints cardName="ticket"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jOptions"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jPanelBag"> + <Properties> + <Property name="autoscrolls" type="boolean" value="true"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[10, 10]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 60]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="First"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JToggleButton" name="jTBtnShow"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/resources.png"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTBtnShowActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jbtnScale"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/scale.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.scale" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.scale" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 44]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 44]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[85, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnScaleActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jbtnMooring"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.moorings" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnMooringActionPerformed"/> + </Events> + </Component> + <Container class="javax.swing.JPanel" name="m_jButtons"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[350, 55]"/> + </Property> + </Properties> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jBtnCustomer" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="btnSplit" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="j_btnRemotePrt" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="btnReprint1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="5" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="j_btnRemotePrt" max="32767" attributes="0"/> + <Component id="btnSplit" alignment="1" max="32767" attributes="0"/> + <Component id="btnReprint1" alignment="1" max="32767" attributes="0"/> + <Component id="jBtnCustomer" max="32767" attributes="0"/> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="btnSplit"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/sale_split_sml.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.salesplit" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSplitActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="btnReprint1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reprint24.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.reprintLastTicket" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnReprint1ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="j_btnRemotePrt"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/remote_print.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.sendorder" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.printtoremote" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="j_btnRemotePrtActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jBtnCustomer"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/customer.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.salescustomer" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnCustomerActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="m_jPanelScripts"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 60]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" value=""/> + </AccessibilityProperties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jButtonsExt"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[20, 60]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="First"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[235, 50]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[10, 55]"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="m_jPanTicket"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[75, 270]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Before"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="5" right="5" top="0"/> + </Border> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 250]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout"> + <Property name="columns" type="int" value="1"/> + <Property name="horizontalGap" type="int" value="5"/> + <Property name="rows" type="int" value="0"/> + <Property name="verticalGap" type="int" value="5"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jDelete"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/editdelete.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.saleremoveline" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jDeleteActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jList"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/search32.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.saleproductfind" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jListActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jEditLine"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/sale_editline.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.saleeditline" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jEditLineActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jEditAttributes"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/attributes.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.saleattributes" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jEditAttributesActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jCheckStock"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="1"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ed" green="c5" red="4c" type="rgb"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/info.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.salecheckstock" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="horizontalTextPosition" type="int" value="2"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 4, 8, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[42, 36]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + <Property name="verticalTextPosition" type="int" value="1"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jCheckStockMouseClicked"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCheckStockActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="m_jPanelCentral"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 240]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="javax.swing.Box$Filler" name="filler2"> + <Properties> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 32767]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 0]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 0]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalStrut"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Before"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="m_jTicketId"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="1"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="verticalAlignment" type="int" value="1"/> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 40]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + <Property name="verticalTextPosition" type="int" value="1"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="m_jPanTotals"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[375, 60]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout"> + <Property name="columns" type="int" value="3"/> + <Property name="horizontalGap" type="int" value="4"/> + <Property name="rows" type="int" value="2"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="m_jLblTotalEuros3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="1"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="m_jSubtotalEuros"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.subtotalcash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jLblTotalEuros2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="1"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="m_jSubtotalEuros"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.taxcash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jLblTotalEuros1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="1"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="m_jTotalEuros"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.totalcash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jSubtotalEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection component="m_jEditLine" name="background" type="property"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection component="m_jEditLine" name="foreground" type="property"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="m_jSubtotalEuros"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.salesubtotal" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder roundedCorners="true"> + <Color PropertyName="color" blue="99" green="99" red="99" type="rgb"/> + </LineBorder> + </Border> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 25]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jTaxesEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection component="m_jEditLine" name="background" type="property"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection component="m_jEditLine" name="foreground" type="property"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="m_jTaxesEuros"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.saletax" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder roundedCorners="true"> + <Color PropertyName="color" blue="99" green="99" red="99" type="rgb"/> + </LineBorder> + </Border> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 25]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jTotalEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection component="m_jEditLine" name="background" type="property"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="1"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection component="m_jEditLine" name="foreground" type="property"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="m_jTotalEuros"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.saletotal" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder roundedCorners="true"> + <Color PropertyName="color" blue="99" green="99" red="99" type="rgb"/> + </LineBorder> + </Border> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 25]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="m_jContEntries"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 350]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jPanEntries"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 350]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.beans.JNumberKeys" name="m_jNumberKeys"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 300]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 250]"/> + </Property> + </Properties> + <Events> + <EventHandler event="keyPerformed" listener="com.unicenta.beans.JNumberEventListener" parameters="com.unicenta.beans.JNumberEvent" handler="m_jNumberKeysKeyPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JPanelTicket_m_jNumberKeys"/> + </AuxValues> + </Component> + <Container class="javax.swing.JPanel" name="jPanel9"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="m_jPor" min="-2" max="-2" attributes="0"/> + <Component id="m_jKeyFactory" max="32767" attributes="0"/> + </Group> + <EmptySpace pref="7" max="32767" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="m_jaddtax" max="32767" attributes="0"/> + <EmptySpace min="-2" pref="7" max="-2" attributes="0"/> + <Component id="m_jTax" min="-2" pref="128" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="m_jPrice" max="32767" attributes="0"/> + <EmptySpace min="-2" pref="5" max="-2" attributes="0"/> + </Group> + </Group> + <Component id="m_jEnter" min="-2" pref="71" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="m_jEnter" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="m_jPrice" min="-2" pref="44" max="-2" attributes="0"/> + <EmptySpace pref="7" max="32767" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jTax" alignment="1" min="-2" pref="30" max="-2" attributes="0"/> + <Component id="m_jaddtax" alignment="1" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Component id="m_jPor" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="m_jKeyFactory" min="-2" pref="1" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="com.alee.extended.button.WebSwitch" name="m_jaddtax"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.switchtax" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jaddtaxActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="m_jPrice"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="16" style="1"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ed" green="c5" red="4c" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="ed" green="c5" red="4c" type="rgb"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 25]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jPor"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="m_jEnter"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/barcode.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.salebarcode" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jEnterActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="m_jTax"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.salestaxswitch" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[28, 25]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jKeyFactory"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="11" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ee" green="ee" id="Panel.background" palette="3" red="ee" type="palette"/> + </Property> + <Property name="autoscrolls" type="boolean" value="false"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="caretColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ee" green="ee" id="Panel.background" palette="3" red="ee" type="palette"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 0]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1, 1]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + <Property name="verifyInputWhenFocusTarget" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="m_jKeyFactoryKeyTyped"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="m_jPanEntriesE"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="catcontainer"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JPanelTicket.java b/src/main/java/com/unicenta/pos/sales/JPanelTicket.java new file mode 100644 index 0000000..def840d --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JPanelTicket.java @@ -0,0 +1,3515 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import bsh.EvalError; +import bsh.Interpreter; +import com.alee.extended.time.ClockType; +import com.alee.extended.time.WebClock; +import com.alee.managers.notification.NotificationIcon; +import com.alee.managers.notification.NotificationManager; +import com.alee.managers.notification.WebNotification; +import com.unicenta.basic.BasicException; +import com.unicenta.beans.JNumberPop; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.ListKeyed; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.plugins.Application; +import com.unicenta.pos.catalog.JCatalog; +import com.unicenta.pos.customers.*; +import com.unicenta.pos.forms.*; +import com.unicenta.pos.inventory.ProductStock; +import com.unicenta.pos.inventory.TaxCategoryInfo; +import com.unicenta.pos.panels.JProductFinder; +import com.unicenta.pos.payment.JPaymentSelect; +import com.unicenta.pos.payment.JPaymentSelectReceipt; +import com.unicenta.pos.payment.JPaymentSelectRefund; +import com.unicenta.pos.printer.DeviceTicket; +import com.unicenta.pos.printer.TicketParser; +import com.unicenta.pos.printer.TicketPrinterException; +import com.unicenta.pos.sales.restaurant.RestaurantDBUtils; +import com.unicenta.pos.scale.ScaleException; +import com.unicenta.pos.scripting.ScriptEngine; +import com.unicenta.pos.scripting.ScriptException; +import com.unicenta.pos.scripting.ScriptFactory; +import com.unicenta.pos.ticket.*; +import com.unicenta.pos.util.AltEncrypter; +import com.unicenta.pos.util.InactivityListener; +import com.unicenta.pos.util.JRPrinterAWT300; +import com.unicenta.pos.util.ReportUtils; +import lombok.extern.slf4j.Slf4j; +import net.sf.jasperreports.engine.*; +import net.sf.jasperreports.engine.data.JRMapArrayDataSource; +import net.sf.jasperreports.engine.design.JasperDesign; +import net.sf.jasperreports.engine.xml.JRXmlLoader; + +import javax.print.PrintService; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.FocusEvent; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.util.*; + +import static java.awt.Window.getWindows; + + +/** + * @author JG uniCenta + */ +@Slf4j +public abstract class JPanelTicket extends JPanel implements JPanelView, BeanFactoryApp, TicketsEditor { + + private final static int NUMBERZERO = 0; + private final static int NUMBERVALID = 1; + + private final static int NUMBER_INPUTZERO = 0; + private final static int NUMBER_INPUTZERODEC = 1; + private final static int NUMBER_INPUTINT = 2; + private final static int NUMBER_INPUTDEC = 3; + private final static int NUMBER_PORZERO = 4; + private final static int NUMBER_PORZERODEC = 5; + private final static int NUMBER_PORINT = 6; + private final static int NUMBER_PORDEC = 7; + + protected JTicketLines m_ticketlines; + + private TicketParser m_TTP; + + protected TicketInfo m_oTicket; + protected Object m_oTicketExt; + + private int m_iNumberStatus; + private int m_iNumberStatusInput; + private int m_iNumberStatusPor; + private StringBuffer m_sBarcode; + + private JTicketsBag m_ticketsbag; + + private SentenceList senttax; + private ListKeyed taxcollection; + + private SentenceList senttaxcategories; + private ListKeyed taxcategoriescollection; + private ComboBoxValModel taxcategoriesmodel; + + private TaxesLogic taxeslogic; + + protected JPanelButtons m_jbtnconfig; + protected AppView m_App; + + protected DataLogicSystem dlSystem; + protected DataLogicSales dlSales; + protected DataLogicCustomers dlCustomers; + + private JPaymentSelect paymentdialogreceipt; + private JPaymentSelect paymentdialogrefund; + + private JRootApp root; + private Object m_principalapp; + private Boolean restaurant; + private Boolean orderlistopen; + + private Action logout; + private InactivityListener listener; + private Integer delay = 0; + private final String m_sCurrentTicket = null; + + protected TicketsEditor m_panelticket; + private DataLogicReceipts dlReceipts = null; + private Boolean priceWith00; + private final String temp_jPrice = ""; + private String tableDetails; + private RestaurantDBUtils restDB; + private KitchenDisplay kitchenDisplay; + private String ticketPrintType; + + private Boolean warrantyPrint = false; + + private TicketInfo m_ticket; + private TicketInfo m_ticketCopy; + private AppConfig m_config; + + private Integer count = 0; + private Integer oCount = 0; + private Boolean pinOK; + + + /** + * Creates new form JTicketView + */ + public JPanelTicket() { + + initComponents(); + } + + /** + * @param app + * @throws BeanFactoryException + */ + @Override + public void init(AppView app) throws BeanFactoryException { + + m_config = new AppConfig(new File((System.getProperty("user.home")), AppLocal.APP_ID + ".properties")); + m_config.load(); + + m_App = app; + restDB = new RestaurantDBUtils(m_App); + + dlSystem = (DataLogicSystem) m_App.getBean("com.unicenta.pos.forms.DataLogicSystem"); + dlSales = (DataLogicSales) m_App.getBean("com.unicenta.pos.forms.DataLogicSales"); + dlCustomers = (DataLogicCustomers) m_App.getBean("com.unicenta.pos.customers.DataLogicCustomers"); + dlReceipts = (DataLogicReceipts) app.getBean("com.unicenta.pos.sales.DataLogicReceipts"); + + + /* uniCenta Feb 2018 + * Changed for 4.3 + * Set up main toolbar area with two rows to add cater for additional scripts + * else over-crowding and some dynamic buttons off screen/not visible + * m_jPanelScripts contains m_jButtonsExt panel for buttons Enabled/Disabled in + * Resources>Menu.Root + */ + +// Set Configuration>General>Tickets toolbar simple : standard : restaurant option + m_ticketsbag = getJTicketsBag(); + m_jPanelBag.add(m_ticketsbag.getBagComponent(), BorderLayout.LINE_START); + add(m_ticketsbag.getNullComponent(), "null"); + +// Script event buttons + m_jbtnconfig = new JPanelButtons("Ticket.Buttons", this); + m_jButtonsExt.add(m_jbtnconfig); + +// Configuration>Peripheral options + if (!m_App.getDeviceScale().existsScale()) { + m_jbtnScale.setVisible(false); + } + jbtnMooring.setVisible(Boolean.valueOf(m_App.getProperties().getProperty("till.marineoption"))); + m_jPanelScripts.setVisible(false); + m_jButtonsExt.setVisible(false); + jTBtnShow.setSelected(false); + + if (Boolean.valueOf(m_App.getProperties().getProperty("till.amountattop"))) { + m_jPanEntries.remove(jPanel9); + m_jPanEntries.remove(m_jNumberKeys); + m_jPanEntries.add(jPanel9); + m_jPanEntries.add(m_jNumberKeys); + } + + priceWith00 = ("true".equals(m_App.getProperties().getProperty("till.pricewith00"))); + + if (priceWith00) { + m_jNumberKeys.dotIs00(true); + } + + m_ticketlines = new JTicketLines(dlSystem.getResourceAsXML("Ticket.Line")); + m_jPanelCentral.add(m_ticketlines, java.awt.BorderLayout.CENTER); + m_TTP = new TicketParser(m_App.getDeviceTicket(), dlSystem); + catcontainer.add(getSouthComponent(), BorderLayout.CENTER); + + senttax = dlSales.getTaxList(); + senttaxcategories = dlSales.getTaxCategoriesList(); + taxcategoriesmodel = new ComboBoxValModel(); + + stateToZero(); + + m_oTicket = null; + m_oTicketExt = null; + jCheckStock.setText(AppLocal.getIntString("message.title.checkstock")); + + if (this instanceof JPanelTicketSales) { + // 2016-10-14 TJMChan - Sales screen Layout code starts here. + if (AppConfig.getInstance().getProperty("machine.saleslayout") != null) { + JSalesLayoutManager.createLayout(); + + if (AppConfig.getInstance().getProperty("machine.saleslayout").equals("Layout1")) { + Component southcomponent = getSouthComponent(); + catcontainer.add(southcomponent, BorderLayout.CENTER); + JPanel southpanel = (JPanel) southcomponent; + ((JPanel) southpanel.getComponent(0)).setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + + JPanel fpanel = new JPanel(new BorderLayout()); + fpanel.add(m_jPanEntries, BorderLayout.WEST); + if (southcomponent instanceof JCatalog) { + fpanel.add(((JCatalog) southpanel).getCatComponent(), BorderLayout.EAST); + } + + m_jPanEntriesE.add(jPanel5, BorderLayout.WEST); + m_jPanEntriesE.add(fpanel, BorderLayout.EAST); + + m_jTicketId.setPreferredSize(new Dimension(300, 16)); + m_jPanTicket.add(m_jTicketId, BorderLayout.BEFORE_FIRST_LINE); + jPanel2.setPreferredSize(new Dimension(90, 305)); + jPanel5.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); + jPanel4.add(m_jPanTotals, BorderLayout.CENTER); + m_jContEntries.add(m_jPanEntriesE, BorderLayout.NORTH); + if (southcomponent instanceof JCatalog) { + JCatalog catpanel = (JCatalog) southpanel; + m_jContEntries.add(catpanel.getProductComponent(), BorderLayout.CENTER); + catpanel.setControls("south"); + catpanel.getCatComponent().setPreferredSize(new Dimension(230, 10)); + catpanel.getProductComponent().setPreferredSize(new Dimension(230, 350)); + } else { + m_jContEntries.add(southpanel, BorderLayout.CENTER); + } + southcomponent.setPreferredSize(new Dimension(0, 0)); + } else if (AppConfig.getInstance().getProperty("machine.saleslayout").equals("Layout2")) { + if (catcontainer.getComponent(0) instanceof JCatalog) { + JCatalog catpanel = (JCatalog) catcontainer.getComponent(0); + catpanel.setControls("south"); + catpanel.getCatComponent().setPreferredSize(new Dimension(230, 10)); + } + jPanel4.add(m_jPanTotals, BorderLayout.CENTER); + m_jPanContainer.add(m_jPanTicket, BorderLayout.EAST); + m_jPanContainer.add(catcontainer, BorderLayout.CENTER); + jPanel5.setPreferredSize(new Dimension(80, 0)); + jPanel2.setPreferredSize(new Dimension(90, 310)); + m_jPanEntriesE.add(jPanel5, BorderLayout.CENTER); + m_jPanEntriesE.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0)); + m_jContEntries.add(m_jPanEntries, BorderLayout.CENTER); + m_jPanEntries.setPreferredSize(new Dimension(250, 316)); + m_jTicketId.setPreferredSize(new Dimension(300, 16)); + m_jPanTicket.add(m_jTicketId, BorderLayout.BEFORE_FIRST_LINE); + m_jPanTicket.setPreferredSize(new Dimension(390, 316)); + m_jPanTicket.add(m_jContEntries, BorderLayout.SOUTH); + } else if (AppConfig.getInstance().getProperty("machine.saleslayout").equals("Layout3")) { + JPanel catPanel = null; + JPanel jpanelA = new JPanel(new BorderLayout()); + if (catcontainer.getComponent(0) instanceof JCatalog) { + JCatalog myCatpanel = (JCatalog) catcontainer.getComponent(0); + myCatpanel.setControls("south"); + myCatpanel.getCatComponent().setPreferredSize(new Dimension(230, 10)); + catPanel = (JPanel) myCatpanel.getCatComponent(); + catPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); + m_jPanContainer.add(jpanelA, BorderLayout.EAST); + jpanelA.add(catPanel, BorderLayout.CENTER); + } + jPanel4.add(m_jPanTotals, BorderLayout.CENTER); + m_jPanContainer.add(m_jPanTicket, BorderLayout.EAST); + m_jPanContainer.add(catcontainer, BorderLayout.CENTER); + jPanel5.setPreferredSize(new Dimension(80, 0)); + jPanel2.setPreferredSize(new Dimension(90, 310)); + m_jPanEntriesE.add(jPanel5, BorderLayout.CENTER); + m_jPanEntriesE.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0)); + m_jContEntries.add(m_jPanEntries, BorderLayout.CENTER); + m_jPanEntries.setPreferredSize(new Dimension(250, 316)); + m_jTicketId.setPreferredSize(new Dimension(300, 16)); + m_jPanTicket.add(m_jTicketId, BorderLayout.BEFORE_FIRST_LINE); + if (catPanel != null) { + m_jPanTicket.setPreferredSize(new Dimension(500, 316)); + jpanelA.add(m_jContEntries, BorderLayout.EAST); + m_jPanTicket.add(jpanelA, BorderLayout.SOUTH); + } else { + m_jPanTicket.setPreferredSize(new Dimension(390, 316)); + m_jPanTicket.add(m_jContEntries, BorderLayout.SOUTH); + } + } + } + } + + + } + + @Override + public Object getBean() { + return this; + } + + @Override + public JComponent getComponent() { + return this; + } + + private void jPanContainerFocusLost(FocusEvent evt) { + System.out.println("PanelContainer : Focus Lost"); + } + + private class logout extends AbstractAction { + + public logout() { + } + + @Override + public void actionPerformed(ActionEvent ae) { + closeAllDialogs(); + switch (m_App.getProperties().getProperty("machine.ticketsbag")) { + case "restaurant": + if ("false".equals(m_App.getProperties().getProperty("till.autoLogoffrestaurant"))) { + deactivate(); + ((JRootApp) m_App).closeAppView(); + break; + } + + deactivate(); + setActiveTicket(null, null); + break; + + default: + deactivate(); + ((JRootApp) m_App).closeAppView(); + } + } + } + + private void closeAllDialogs() { + Window[] windows = getWindows(); + + for (Window window : windows) { + if (window instanceof JDialog) { + window.dispose(); + } + } + } + + private void saveCurrentTicket() { + String currentTicket = (String) m_oTicketExt; + if (currentTicket != null) { + try { + dlReceipts.updateSharedTicket(currentTicket, m_oTicket, m_oTicket.getPickupId()); +// } catch (BasicException e) { +// new MessageInf(e).show(this); +// } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + } + + /** + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + Action logout = new logout(); + String autoLogoff = (m_App.getProperties().getProperty("till.autoLogoff")); + + if (autoLogoff != null) { + if (autoLogoff.equals("true")) { + try { + delay = Integer.parseInt(m_App.getProperties().getProperty("till.autotimer")); + } catch (NumberFormatException e) { + delay = 0; + } + delay *= 1000; + } + } + + if (delay != 0) { + listener = new InactivityListener(logout, delay); + listener.start(); + } + + paymentdialogreceipt = JPaymentSelectReceipt.getDialog(this); + paymentdialogreceipt.init(m_App); + paymentdialogrefund = JPaymentSelectRefund.getDialog(this); + paymentdialogrefund.init(m_App); + + m_jaddtax.setSelected("true".equals(m_jbtnconfig.getProperty("taxesincluded"))); + + java.util.List<TaxInfo> taxlist = senttax.list(); + taxcollection = new ListKeyed<>(taxlist); + java.util.List<TaxCategoryInfo> taxcategorieslist = senttaxcategories.list(); + taxcategoriescollection = new ListKeyed<>(taxcategorieslist); + + taxcategoriesmodel = new ComboBoxValModel(taxcategorieslist); + m_jTax.setModel(taxcategoriesmodel); + + String taxesid = m_jbtnconfig.getProperty("taxcategoryid"); + + if (taxesid == null) { + if (m_jTax.getItemCount() > 0) { + m_jTax.setSelectedIndex(0); + } + } else { + taxcategoriesmodel.setSelectedKey(taxesid); + } + + taxeslogic = new TaxesLogic(taxlist); + m_jaddtax.setSelected((Boolean.parseBoolean(m_App.getProperties().getProperty("till.taxincluded")))); + + if (m_App.getAppUserView().getUser().hasPermission("sales.ChangeTaxOptions")) { + m_jTax.setVisible(true); + m_jaddtax.setVisible(true); + } else { + m_jTax.setVisible(false); + m_jaddtax.setVisible(false); + } + + m_jDelete.setEnabled(m_App.getAppUserView().getUser().hasPermission("sales.EditLines")); + m_jNumberKeys.setMinusEnabled(m_App.getAppUserView().getUser().hasPermission("sales.EditLines")); + m_jNumberKeys.setEqualsEnabled(m_App.getAppUserView().getUser().hasPermission("sales.Total")); + m_jbtnconfig.setPermissions(m_App.getAppUserView().getUser()); + + m_ticketsbag.setEnabled(false); + m_ticketsbag.activate(); + + CustomerInfoGlobal customerInfoGlobal = CustomerInfoGlobal.getInstance(); + + if (customerInfoGlobal.getCustomerInfoExt() != null) { + + if (m_oTicket != null) { + m_oTicket.setCustomer(customerInfoGlobal.getCustomerInfoExt()); + } + } + + refreshTicket(); + } + + @Override + public boolean deactivate() { + if (listener != null) { + listener.stop(); + } + + return m_ticketsbag.deactivate(); + } + + protected abstract JTicketsBag getJTicketsBag(); + + protected abstract Component getSouthComponent(); + + protected abstract void resetSouthComponent(); + + /** + * @param oTicket + * @param oTicketExt + */ + @SuppressWarnings("empty-statement") + @Override + public void setActiveTicket(TicketInfo oTicket, Object oTicketExt) { + + switch (m_App.getProperties().getProperty("machine.ticketsbag")) { + case "restaurant": + if ("true".equals(m_App.getProperties().getProperty("till.autoLogoffrestaurant"))) { + if (listener != null) { + listener.restart(); + } + } + } + + m_oTicket = oTicket; + m_oTicketExt = oTicketExt; + + if (m_oTicket != null) { + m_oTicket.setUser(m_App.getAppUserView().getUser().getUserInfo()); + m_oTicket.setActiveCash(m_App.getActiveCashIndex()); + m_oTicket.setDate(new Date()); + + if ("restaurant".equals(m_App.getProperties().getProperty("machine.ticketsbag")) + && !oTicket.getOldTicket()) { + if (restDB.getCustomerNameInTable(oTicketExt.toString()) == null) { + if (m_oTicket.getCustomer() != null) { + restDB.setCustomerNameInTable(m_oTicket.getCustomer().toString(), + oTicketExt.toString()); + } + } + if (restDB.getWaiterNameInTable(oTicketExt.toString()) == null + || "".equals(restDB.getWaiterNameInTable(oTicketExt.toString()))) { + restDB.setWaiterNameInTable(m_App.getAppUserView().getUser().getName(), + oTicketExt.toString()); + } + + restDB.setTicketIdInTable(m_oTicket.getId(), oTicketExt.toString()); + restDB.setGuestsInTable(restDB.getGuestsInTable(m_oTicket.getId()), m_oTicket.getId()); + restDB.setOccupied(m_oTicket.getId()); + } + } + + if ((m_oTicket != null) && (((Boolean.parseBoolean(m_App.getProperties() + .getProperty("table.showwaiterdetails"))) + || (Boolean.valueOf(m_App.getProperties().getProperty( + "table.showcustomerdetails")))))) { + } + + if ((m_oTicket != null) && (((Boolean.valueOf(m_App.getProperties() + .getProperty("table.showcustomerdetails"))) || + (Boolean.parseBoolean(m_App.getProperties().getProperty("table.showwaiterdetails")))))) { + if (restDB.getTableMovedFlag(m_oTicket.getId())) { + restDB.moveCustomer(oTicketExt.toString(), m_oTicket.getId()); + } + } + + executeEvent(m_oTicket, m_oTicketExt, "ticket.show"); + + if (m_App.getAppUserView().getUser().hasPermission("sales.PrintRemote")) { + j_btnRemotePrt.setEnabled(true); + + } else { + j_btnRemotePrt.setEnabled(false); + } + + refreshTicket(); + } + + /** + * @return + */ + @Override + public TicketInfo getActiveTicket() { + return m_oTicket; + } + + private void refreshTicket() { + + CardLayout cl = (CardLayout) (getLayout()); + + if (m_oTicket == null) { + m_jTicketId.setText(null); + m_ticketlines.clearTicketLines(); + + m_jSubtotalEuros.setText(null); + m_jTaxesEuros.setText(null); + m_jTotalEuros.setText(null); + jCheckStock.setText(null); + + checkStock(); + stateToZero(); + repaint(); + + cl.show(this, "null"); + + if ((m_oTicket != null) && (m_oTicket.getLinesCount() == 0)) { + resetSouthComponent(); + } + } else { + if (m_oTicket.getTicketType() == TicketInfo.RECEIPT_REFUND) { + m_jEditLine.setVisible(false); + m_jList.setVisible(false); + } + + m_oTicket.getLines().forEach((line) -> { + line.setTaxInfo(taxeslogic.getTaxInfo(line + .getProductTaxCategoryID(), m_oTicket.getCustomer())); + }); + + m_jTicketId.setText(m_oTicket.getName(m_oTicketExt)); + m_ticketlines.clearTicketLines(); + + for (int i = 0; i < m_oTicket.getLinesCount(); i++) { + m_ticketlines.addTicketLine(m_oTicket.getLine(i)); + } +// set line here? + + countArticles(); + printPartialTotals(); + stateToZero(); + + cl.show(this, "ticket"); + + if (m_oTicket.getLinesCount() == 0) { + resetSouthComponent(); + } + + m_jKeyFactory.setText(null); + java.awt.EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + m_jKeyFactory.requestFocus(); + } + }); + } + } + + private void countArticles() { + oCount = count; // existing line before change + count = (int) m_oTicket.getArticlesCount(); //existing line after change + + if (m_oTicket != null) { + for (int i = 0; i < m_oTicket.getLinesCount(); i++) { + if (m_App.getAppUserView().getUser().hasPermission("sales.Total") + && m_oTicket.getArticlesCount() > 1) { + btnSplit.setEnabled(true); + } else { + btnSplit.setEnabled(false); + } + } + } + } + + private boolean changeCount(boolean pinOK) { + + pinOK = false; + + if (m_oTicket != null) { + + if (m_App.getProperties().getProperty("override.check").equals("true")) { + Integer secret = Integer.parseInt(m_App.getProperties().getProperty("override.pin")); + Integer iValue = JNumberPop.showEditNumber(this, AppLocal.getIntString("title.override.enterpin")); + + if (iValue == null ? secret == null : iValue.equals(secret)) { + pinOK = true; + JOptionPane.showMessageDialog(this, "Units changed from " + + count + " to " + oCount); + return pinOK; + + } else { + pinOK = false; + JOptionPane.showMessageDialog(this, AppLocal.getIntString("message.override.badpin")); + return pinOK; + } + } + } + return pinOK; + } + + private void printPartialTotals() { + + if (m_oTicket.getLinesCount() == 0) { + m_jSubtotalEuros.setText(null); + m_jTaxesEuros.setText(null); + m_jTotalEuros.setText(null); + } else { + m_jSubtotalEuros.setText(m_oTicket.printSubTotal()); + m_jTaxesEuros.setText(m_oTicket.printTax()); + m_jTotalEuros.setText(m_oTicket.printTotal()); + } + repaint(); + } + + private void paintTicketLine(int index, TicketLineInfo oLine) { + if (executeEventAndRefresh("ticket.setline", + new ScriptArg("index", index), new ScriptArg("line", oLine)) == null) { + + m_oTicket.setLine(index, oLine); + m_ticketlines.setTicketLine(index, oLine); + m_ticketlines.setSelectedIndex(index); + + oCount = count; // pass line old multiplier value + + countArticles(); + visorTicketLine(oLine); + printPartialTotals(); + stateToZero(); + + executeEventAndRefresh("ticket.change"); + } + } + + private void addTicketLine(ProductInfoExt oProduct, double dMul, double dPrice) { + +// if (oProduct.isVprice() || oProduct.getID().equals("xxx999_999xxx_x9x9x9")){ + if (oProduct.isVprice()) { + TaxInfo tax = taxeslogic.getTaxInfo(oProduct.getTaxCategoryID(), m_oTicket.getCustomer()); + + if (m_jaddtax.isSelected()) { + dPrice /= (1 + tax.getRate()); + } + + addTicketLine(new TicketLineInfo(oProduct, dMul, dPrice, tax, + (java.util.Properties) (oProduct.getProperties().clone()))); + + } else if (oProduct.getID().equals("xxx998_998xxx_x8x8x8")) { + + if (m_App.getProperties().getProperty("till.SCOnOff").equals("true")) { + TaxInfo tax = taxeslogic.getTaxInfo(oProduct.getTaxCategoryID(), + m_oTicket.getCustomer()); + String SCRate = (m_App.getProperties().getProperty("till.SCRate")); + + double scharge; + scharge = Double.parseDouble(SCRate); + scharge = m_oTicket.getTotal() * (scharge / 100); + + addTicketLine(new TicketLineInfo(oProduct, 1, scharge, tax, + (java.util.Properties) (oProduct.getProperties().clone()))); + + } else { + JOptionPane.showMessageDialog(this, "Service Charge Not Enabled"); + } + + } else { +// get the line product tax + TaxInfo tax = taxeslogic.getTaxInfo(oProduct.getTaxCategoryID(), m_oTicket.getCustomer()); + + addTicketLine(new TicketLineInfo(oProduct, dMul, dPrice, tax, + (java.util.Properties) (oProduct.getProperties().clone()))); + +// if (oProduct.getID().equals("xxx999_999xxx_x9x9x9")){ +// m_jEditLine.doClick(); +// } + refreshTicket(); + + } + + j_btnRemotePrt.setEnabled(true); + + } + + /** + * @param oLine + */ + protected void addTicketLine(TicketLineInfo oLine) { + if (executeEventAndRefresh("ticket.addline", new ScriptArg("line", oLine)) == null) { + if (oLine.isProductCom()) { + int i = m_ticketlines.getSelectedIndex(); + + if (i >= 0 && !m_oTicket.getLine(i).isProductCom()) { + i++; + } + + while (i >= 0 && i < m_oTicket.getLinesCount() && m_oTicket.getLine(i).isProductCom()) { + i++; + } + + if (i >= 0) { + m_oTicket.insertLine(i, oLine); + m_ticketlines.insertTicketLine(i, oLine); + } else { + Toolkit.getDefaultToolkit().beep(); + } + } else { + m_oTicket.addLine(oLine); + m_ticketlines.addTicketLine(oLine); + + try { + int i = m_ticketlines.getSelectedIndex(); + TicketLineInfo line = m_oTicket.getLine(i); + + if (line.isProductVerpatrib()) { + JProductAttEdit2 attedit = JProductAttEdit2.getAttributesEditor(this, m_App.getSession()); + attedit.editAttributes(line.getProductAttSetId(), line.getProductAttSetInstId()); + attedit.setVisible(true); + + if (attedit.isOK()) { + line.setProductAttSetInstId(attedit.getAttributeSetInst()); + line.setProductAttSetInstDesc(attedit.getAttributeSetInstDescription()); + paintTicketLine(i, line); + } + } + + } catch (BasicException ex) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotfindattributes"), ex); + msg.show(this); + } + } + + visorTicketLine(oLine); + printPartialTotals(); + stateToZero(); + checkStock(); + countArticles(); + + executeEvent(m_oTicket, m_oTicketExt, "ticket.change"); + } + } + + private void removeTicketLine(int i) { + +// if (m_App.getProperties().getProperty("override.check").equals("true")) { + if (!m_oTicket.getLine(i).getUpdated()) { + JOptionPane.showMessageDialog(this + , AppLocal.getIntString("message.deletelinesent") + , AppLocal.getIntString("label.deleteline") + , JOptionPane.WARNING_MESSAGE); + } else { + if (executeEventAndRefresh("ticket.removeline", new ScriptArg("index", i)) == null) { + String ticketID = Integer.toString(m_oTicket.getTicketId()); + if (m_oTicket.getTicketId() == 0) { + ticketID = "Void"; + } + dlSystem.execLineRemoved( + new Object[]{ + m_App.getAppUserView().getUser().getName(), + ticketID, + m_oTicket.getLine(i).getProductID(), + m_oTicket.getLine(i).getProductName(), + m_oTicket.getLine(i).getMultiply() + } + ); + + if (m_oTicket.getLine(i).isProductCom()) { + m_oTicket.removeLine(i); + m_ticketlines.removeTicketLine(i); + } else { + if (i < 1) { + + if (m_App.getAppUserView().getUser().hasPermission("sales.DeleteLines")) { + int input = JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.deletelineyes") + , AppLocal.getIntString("label.deleteline"), JOptionPane.YES_NO_OPTION); + + if (input == 0) { + m_oTicket.removeLine(i); + m_ticketlines.removeTicketLine(i); + } + } else { + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.deletelineno") + , AppLocal.getIntString("label.deleteline"), JOptionPane.WARNING_MESSAGE); + } + } else { + m_oTicket.removeLine(i); + m_ticketlines.removeTicketLine(i); + + while (i < m_oTicket.getLinesCount() && m_oTicket.getLine(i).isProductCom()) { + m_oTicket.removeLine(i); + m_ticketlines.removeTicketLine(i); + } + } + } + + visorTicketLine(null); + printPartialTotals(); + stateToZero(); + checkStock(); + countArticles(); + + executeEventAndRefresh("ticket.change"); + } + } +// } + } + + private ProductInfoExt getInputProduct() { + ProductInfoExt oProduct = new ProductInfoExt(); +// Always add Default Prod ID + Add Name to Misc. if empty + oProduct.setID("xxx999_999xxx_x9x9x9"); + oProduct.setReference("xxx999"); + oProduct.setCode("xxx999"); + oProduct.setName("***"); + oProduct.setTaxCategoryID(((TaxCategoryInfo) taxcategoriesmodel + .getSelectedItem()).getID()); + oProduct.setPriceSell(includeTaxes(oProduct.getTaxCategoryID(), getInputValue())); + + return oProduct; + } + + private double includeTaxes(String tcid, double dValue) { + if (m_jaddtax.isSelected()) { + TaxInfo tax = taxeslogic.getTaxInfo(tcid, m_oTicket.getCustomer()); + double dTaxRate = tax == null ? 0.0 : tax.getRate(); + return dValue / (1.0 + dTaxRate); + } else { + return dValue; + } + } + + private double excludeTaxes(String tcid, double dValue) { + TaxInfo tax = taxeslogic.getTaxInfo(tcid, m_oTicket.getCustomer()); + double dTaxRate = tax == null ? 0.0 : tax.getRate(); + return dValue / (1.0 + dTaxRate); + } + + + private double getInputValue() { + try { + return Double.parseDouble(m_jPrice.getText()); + } catch (NumberFormatException e) { + return 0.0; + } + } + + private double getPorValue() { + try { + return Double.parseDouble(m_jPor.getText().substring(1)); + } catch (NumberFormatException | StringIndexOutOfBoundsException e) { + return 1.0; + } + } + + private void stateToZero() { + m_jPor.setText(""); + m_jPrice.setText(""); + m_sBarcode = new StringBuffer(); + + m_iNumberStatus = NUMBER_INPUTZERO; + m_iNumberStatusInput = NUMBERZERO; + m_iNumberStatusPor = NUMBERZERO; + repaint(); + } + + private void incProductByCode(String sCode) { + + try { + ProductInfoExt oProduct = dlSales.getProductInfoByCode(sCode); + + if (oProduct == null) { + Toolkit.getDefaultToolkit().beep(); + JOptionPane.showMessageDialog(null, + sCode + " - " + AppLocal.getIntString("message.noproduct"), + "Check", JOptionPane.WARNING_MESSAGE); + stateToZero(); + } else { + incProduct(oProduct); + } + } catch (BasicException eData) { + stateToZero(); + new MessageInf(eData).show(this); + } + } + + private void incProductByCodePrice(String sCode, double dPriceSell) { + + try { + ProductInfoExt oProduct = dlSales.getProductInfoByCode(sCode); + if (oProduct == null) { + Toolkit.getDefaultToolkit().beep(); + new MessageInf(MessageInf.SGN_WARNING, AppLocal + .getIntString("message.noproduct")).show(this); + stateToZero(); + } else { + if (m_jaddtax.isSelected()) { + TaxInfo tax = taxeslogic.getTaxInfo(oProduct.getTaxCategoryID(), m_oTicket.getCustomer()); + addTicketLine(oProduct, 1.0, dPriceSell / (1.0 + tax.getRate())); + } else { + addTicketLine(oProduct, 1.0, dPriceSell); + } + } + } catch (BasicException eData) { + stateToZero(); + new MessageInf(eData).show(this); + } + } + + private void incProduct(ProductInfoExt prod) { + + if (prod.isScale() && m_App.getDeviceScale().existsScale()) { + try { + Double value = m_App.getDeviceScale().readWeight(); + if (value != null) { + incProduct(value, prod); + } + } catch (ScaleException e) { + Toolkit.getDefaultToolkit().beep(); + new MessageInf(MessageInf.SGN_WARNING, AppLocal + .getIntString("message.noweight"), e).show(this); + stateToZero(); + } + } else { + if (!prod.isVprice()) { + incProduct(1.0, prod); + } else { + Toolkit.getDefaultToolkit().beep(); + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.novprice")); + } + } + } + + private void incProduct(double dPor, ProductInfoExt prod) { + + if (prod.isVprice()) { + addTicketLine(prod, getPorValue(), getInputValue()); + } else { + addTicketLine(prod, dPor, prod.getPriceSell()); + } + } + + /** + * @param prod + */ + protected void buttonTransition(ProductInfoExt prod) { + + if (m_iNumberStatusInput == NUMBERZERO && m_iNumberStatusPor == NUMBERZERO) { + incProduct(prod); + } else if (m_iNumberStatusInput == NUMBERVALID && m_iNumberStatusPor == NUMBERZERO) { + incProduct(getInputValue(), prod); + } else if (prod.isVprice()) { + addTicketLine(prod, getPorValue(), getInputValue()); + } else { + Toolkit.getDefaultToolkit().beep(); + } + } + + @SuppressWarnings("empty-statement") + private void stateTransition(char cTrans) { + + if ((cTrans == '\n') || (cTrans == '?')) { + + if (m_sBarcode.length() > 0) { + + String sCode = m_sBarcode.toString(); + String sCodetype = "EAN"; // Declare EAN. It's default + + if ("true".equals(m_App.getProperties() + .getProperty("machine.barcodetype"))) { + sCodetype = "UPC"; + } else { + sCodetype = "EAN"; // Ensure not null + } + + if (sCode.startsWith("C") + || sCode.startsWith("c")) { + try { + String card = sCode; + CustomerInfoExt newcustomer = dlSales.findCustomerExt(card); + + if (newcustomer == null) { + Toolkit.getDefaultToolkit().beep(); + new MessageInf(MessageInf.SGN_WARNING, AppLocal + .getIntString("message.nocustomer")).show(this); + } else { + m_oTicket.setCustomer(newcustomer); + m_jTicketId.setText(m_oTicket.getName(m_oTicketExt)); + } + } catch (BasicException e) { + Toolkit.getDefaultToolkit().beep(); + new MessageInf(MessageInf.SGN_WARNING, AppLocal + .getIntString("message.nocustomer"), e).show(this); + } + stateToZero(); + + } else if (sCode.startsWith(";")) { + stateToZero(); + + + // START OF BARCODE PARSING + /* This block is deliberately verbose and is base for future scanner handling + * Some scanners inject a CR+LF... some don't... + * stateTransition() must allow for this as these add characters to .length() + * First 3 digits are GS1 CountryCode OR Retailer internal use + * + * Prefix ManCodeProdCode CheckCode + * PPP MMMMMCCCCC K + * 012 3456789012 K + * Barcode CCCCC must be unique + * Notes: + * ManufacturerCode and ProductCode must be exactly 10 digits + * If code begins with 0 then is actually a UPC-A with prepended 0 + * + * uniCenta oPOS Retailer instore uses these RULES + * Prefixes 020 to 029 are set aside for Retailer internal use + * This means that CCCC becomes price/weight values + * Prefixes 978 and 979 are set aside for ISBN - Future use + * + * Prefix ManCode ProdCode CheckCode + * PPP MMMMM CCCCC K Format + * 012 34567 89012 K Human + * + */ + + } else if ("EAN".equals(sCodetype) + && ((sCode.startsWith("2")) || (sCode.startsWith("02"))) // check code prefix + && ((sCode.length() == 13) || (sCode.length() == 12))) { // check code length variances + + try { + ProductInfoExt oProduct // get product(s) with PMMMMM + = dlSales.getProductInfoByShortCode(sCode); + + if (oProduct == null) { // nothing returned so display message to user + Toolkit.getDefaultToolkit().beep(); + JOptionPane.showMessageDialog(null, + sCode + " - " + + AppLocal.getIntString("message.noproduct"), + "Check", JOptionPane.WARNING_MESSAGE); + stateToZero(); // clear the user input + + } else if ("EAN-13".equals(oProduct.getCodetype())) { // have a valid barcode + oProduct.setProperty("product.barcode", sCode); // set the screen's barcode from input + double dPriceSell = oProduct.getPriceSell(); // default price for product + double weight = 0; // used if barcode includes weight of product + double dUnits = 0; // used for pro-rata unit + String sVariableTypePrefix = sCode.substring(0, 2); // get first two PPP digits + String sVariableNum; // CCCCC variable value of barcode + + if (sCode.length() == 13) { // full barcode from scanner + sVariableNum = sCode.substring(8, 12); // get the 5 CCCCC digits + } else { // barcode can be any length + sVariableNum = sCode.substring(7, 11); // get the 5 CCCCC digits + } // scanner has dropped 1st digit so shift get to left + +// PRICE - SET value decimals + switch (sVariableTypePrefix) { // Use CCCCC value of 01049 as example + case "02": // first 2 PPP digits determine decimal position + dUnits = (Double.parseDouble(sVariableNum) // position decimal in CCC.CC + / 100) / oProduct.getPriceSell(); // 2 decimal = 010.49 + break; + case "20": + dUnits = (Double.parseDouble(sVariableNum) // position decimal in CCC.CC + / 100) / oProduct.getPriceSell(); // 2 decimal = 010.49 + break; + case "21": + dUnits = (Double.parseDouble(sVariableNum) // position decimal in CC.CCC + / 10) / oProduct.getPriceSell(); // 2 decimal = 0104.9 + break; + case "22": + dUnits = Double.parseDouble(sVariableNum) // position decimal in CCCC.C + / oProduct.getPriceSell(); // Price = 01049. + break; + +// WEIGHT - SET value decimals + case "23": // Use CCCCC 01049kg as example + weight = Double.parseDouble(sVariableNum) + / 1000; // Weight = 01.049 + dUnits = weight; // set Units for price calculation + break; + case "24": + weight = Double.parseDouble(sVariableNum) + / 100; // Weight = 010.49 + dUnits = weight; // set Units for price calculation + break; + case "25": + weight = Double.parseDouble(sVariableNum) + / 10; // Weight = 0104.9 + dUnits = weight; // set Units for price calculation + break; + default: + break; + } + + TaxInfo tax = taxeslogic // get the TaxRate for the product + .getTaxInfo(oProduct.getTaxCategoryID() + , m_oTicket.getCustomer()); // calculate if ticket has a Customer + + switch (sVariableTypePrefix) { +// PRICE - Assign var's + case "02": // now we need to calculate some values + dPriceSell = oProduct.getPriceSellTax(tax) + / (1.0 + tax.getRate()); // selling price with tax + dUnits = (Double.parseDouble(sVariableNum) + / 100) / oProduct.getPriceSellTax(tax); // Units as proportion of selling price + oProduct.setProperty("product.price" + , Double.toString(oProduct.getPriceSell())); // push to screen + break; + case "20": // as above + dPriceSell = oProduct.getPriceSellTax(tax) + / (1.0 + tax.getRate()); + dUnits = (Double.parseDouble(sVariableNum) + / 100) / oProduct.getPriceSellTax(tax); + oProduct.setProperty("product.price" + , Double.toString(oProduct.getPriceSellTax(tax))); + break; + case "21": + dPriceSell = oProduct.getPriceSellTax(tax) + / (1.0 + tax.getRate()); + dUnits = (Double.parseDouble(sVariableNum) + / 10) / oProduct.getPriceSellTax(tax); + oProduct.setProperty("product.price" + , Double.toString(oProduct.getPriceSell())); + break; + case "22": + dPriceSell = oProduct.getPriceSellTax(tax) + / (1.0 + tax.getRate()); + dUnits = (Double.parseDouble(sVariableNum) + / 1) / oProduct.getPriceSellTax(tax); + oProduct.setProperty("product.price" + , Double.toString(oProduct.getPriceSell())); + break; + +// WEIGHT - Assign variable to Unit + case "23": + weight = Double.parseDouble(sVariableNum) + / 1000; // 3 decimals = 01.049 kg + dUnits = weight; // which represents 1gramme Units + oProduct.setProperty("product.weight" + , Double.toString(weight)); + oProduct.setProperty("product.price" + , Double.toString(dPriceSell)); + break; + case "24": + weight = Double.parseDouble(sVariableNum) + / 100; // 2 decimals = 010.49 kg + dUnits = weight; // which represents 10gramme Units + oProduct.setProperty("product.weight" + , Double.toString(weight)); + oProduct.setProperty("product.price" + , Double.toString(dPriceSell)); + break; + case "25": + weight = Double.parseDouble(sVariableNum) + / 10; // 1 decimal = 0104.9 kg + dUnits = weight; // which represents 100gramme Units + oProduct.setProperty("product.weight" + , Double.toString(weight)); + oProduct.setProperty("product.price" + , Double.toString(dPriceSell)); + break; + +/* + * Some countries use different barcode prefix 26-29 or 250 etc. + * Use this section to add more case statements but these are not mandatory + * If you have your own internal or other barcode schema then... + * Example: + case "28": + { + // price has tax. Remove it from sPriceSell + TaxInfo tax = taxeslogic.getTaxInfo(oProduct.getTaxCategoryID(), m_oTicket.getCustomer()); + dPriceSell /= (1.0 + tax.getRate()); + oProduct.setProperty("product.price", Double.toString(dPriceSell)); + weight = -1.0; + break; +*/ + default: + break; + } + + if (m_jaddtax.isSelected()) { + addTicketLine(oProduct + , dUnits //weight + , dPriceSell = oProduct.getPriceSellTax(tax)); + } else { + addTicketLine(oProduct + , dUnits + , dPriceSell); + } + } + } catch (BasicException eData) { + stateToZero(); + new MessageInf(eData).show(this); + } + +// UPC-A +/* Note: if begins 02 then its a standard +// UPC-A max value limitation is 4 digit price +// UPC-A Extended uses State digit to give 5 digit price +// uniCenta oPOS does not support UPC-A Extended at this time +// Identifier Prod State Cost CheckCode +// I PPPPP S CCCC K +// 1 23456 7 8901 2 + + * 0 = Standard UPC number (must have a zero to do zero-suppressed numbers) + * 1 = Reserved + * 2 = Random-weight items (fruits, vegetables, meats, etc.) + * 3 = Pharmaceuticals + * 4 = In-store marketing for retailers (Other stores will not understand) + * 5 = Coupons + * 6 = Standard UPC number + * 7 = Standard UPC number + * 8 = Reserved + * 9 = Reserved +*/ + + } else if ("UPC".equals(sCodetype) + && (sCode.startsWith("2")) + && (sCode.length() == 12)) { + + try { + ProductInfoExt oProduct + = dlSales.getProductInfoByUShortCode(sCode); // Return only UPC product + + if (oProduct == null) { + Toolkit.getDefaultToolkit().beep(); + JOptionPane.showMessageDialog(null, + sCode + " - " + + AppLocal.getIntString("message.noproduct"), + "Check", JOptionPane.WARNING_MESSAGE); + stateToZero(); + } else if ("Upc-A".equals(oProduct.getCodetype())) { + oProduct.setProperty("product.barcode", sCode); + double dPriceSell = oProduct.getPriceSell(); // default price for product + double weight = 0; // used if barcode includes weight of product + double dUnits = 0; // used for pro-rata unit + String sVariableNum = sCode.substring(7, 11); // grab the value from the code only using 4 digit price + + TaxInfo tax = taxeslogic // get the TaxRate for the product + .getTaxInfo(oProduct.getTaxCategoryID() + , m_oTicket.getCustomer()); + + if (oProduct.getPriceSell() != 0.0) { // we have a weight barcode + weight = Double.parseDouble(sVariableNum) / 100; // 2 decimals (e.g. 10.49 kg) + dUnits = weight; // Units is now transformed to weight + + oProduct.setProperty("product.weight" // catch-all for weight + , Double.toString(weight)); + oProduct.setProperty("product.price" // get the prod sellprice + , Double.toString(oProduct.getPriceSell())); + dPriceSell = oProduct.getPriceSellTax(tax); // calculate the tax on sellprice + dUnits = (Double.parseDouble(sVariableNum) // calculate Units in sellprice with Tax + / 100) + / oProduct.getPriceSellTax(tax); + + } else { // no sellprice so we have a price barcode + dPriceSell = (Double.parseDouble(sVariableNum) // calculate Units in sellprice with Tax + / 100); + dUnits = 1; // no sellprice to calculate so must be 1 Unit + } + + if (m_jaddtax.isSelected()) { + addTicketLine(oProduct + , dUnits + , dPriceSell); + } else { + addTicketLine(oProduct + , dUnits + , dPriceSell / (1.0 + tax.getRate())); + } + } + } catch (BasicException eData) { + stateToZero(); + new MessageInf(eData).show(this); + } + + } else { + incProductByCode(sCode); // returned is standard so go get it + } +// END OF BARCODE + + } else { + Toolkit.getDefaultToolkit().beep(); + } + + } else { + + m_sBarcode.append(cTrans); + + if (cTrans == '\u007f') { + stateToZero(); + + } else if ((cTrans == '0') && (m_iNumberStatus == NUMBER_INPUTZERO)) { + m_jPrice.setText(Character.toString('0')); + + } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' + || cTrans == '4' || cTrans == '5' || cTrans == '6' + || cTrans == '7' || cTrans == '8' || cTrans == '9') + && (m_iNumberStatus == NUMBER_INPUTZERO)) { + + if (!priceWith00) { + m_jPrice.setText(m_jPrice.getText() + cTrans); + } else { + m_jPrice.setText(setTempjPrice(m_jPrice.getText() + cTrans)); + } + + m_iNumberStatus = NUMBER_INPUTINT; + m_iNumberStatusInput = NUMBERVALID; + + } else if ((cTrans == '0' || cTrans == '1' || cTrans == '2' + || cTrans == '3' || cTrans == '4' || cTrans == '5' + || cTrans == '6' || cTrans == '7' || cTrans == '8' + || cTrans == '9') + && (m_iNumberStatus == NUMBER_INPUTINT)) { + + if (!priceWith00) { + m_jPrice.setText(m_jPrice.getText() + cTrans); + } else { + m_jPrice.setText(setTempjPrice(m_jPrice.getText() + cTrans)); + } + + + } else if (cTrans == '.' + && m_iNumberStatus == NUMBER_INPUTZERO && !priceWith00) { + m_jPrice.setText("0."); + m_iNumberStatus = NUMBER_INPUTZERODEC; + } else if (cTrans == '.' + && m_iNumberStatus == NUMBER_INPUTZERO) { + m_jPrice.setText(""); + m_iNumberStatus = NUMBER_INPUTZERO; + } else if (cTrans == '.' + && m_iNumberStatus == NUMBER_INPUTINT && !priceWith00) { + m_jPrice.setText(m_jPrice.getText() + "."); + m_iNumberStatus = NUMBER_INPUTDEC; + } else if (cTrans == '.' + && m_iNumberStatus == NUMBER_INPUTINT) { + + if (!priceWith00) { + m_jPrice.setText(m_jPrice.getText() + "00"); + } else { + m_jPrice.setText(setTempjPrice(m_jPrice.getText() + "00")); + } + + m_iNumberStatus = NUMBER_INPUTINT; + + } else if ((cTrans == '0') + && (m_iNumberStatus == NUMBER_INPUTZERODEC + || m_iNumberStatus == NUMBER_INPUTDEC)) { + + if (!priceWith00) { + m_jPrice.setText(m_jPrice.getText() + cTrans); + } else { + m_jPrice.setText(setTempjPrice(m_jPrice.getText() + cTrans)); + } + + } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' + || cTrans == '4' || cTrans == '5' || cTrans == '6' + || cTrans == '7' || cTrans == '8' || cTrans == '9') + && (m_iNumberStatus == NUMBER_INPUTZERODEC + || m_iNumberStatus == NUMBER_INPUTDEC)) { + + m_jPrice.setText(m_jPrice.getText() + cTrans); + m_iNumberStatus = NUMBER_INPUTDEC; + m_iNumberStatusInput = NUMBERVALID; + + } else if (cTrans == '*' + && (m_iNumberStatus == NUMBER_INPUTINT + || m_iNumberStatus == NUMBER_INPUTDEC)) { + m_jPor.setText("x"); + m_iNumberStatus = NUMBER_PORZERO; + } else if (cTrans == '*' + && (m_iNumberStatus == NUMBER_INPUTZERO + || m_iNumberStatus == NUMBER_INPUTZERODEC)) { + m_jPrice.setText("0"); + m_jPor.setText("x"); + m_iNumberStatus = NUMBER_PORZERO; + + } else if ((cTrans == '0') + && (m_iNumberStatus == NUMBER_PORZERO)) { + m_jPor.setText("x0"); + } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' + || cTrans == '4' || cTrans == '5' || cTrans == '6' + || cTrans == '7' || cTrans == '8' || cTrans == '9') + && (m_iNumberStatus == NUMBER_PORZERO)) { + + m_jPor.setText("x" + Character.toString(cTrans)); + m_iNumberStatus = NUMBER_PORINT; + m_iNumberStatusPor = NUMBERVALID; + } else if ((cTrans == '0' || cTrans == '1' || cTrans == '2' + || cTrans == '3' || cTrans == '4' || cTrans == '5' + || cTrans == '6' || cTrans == '7' || cTrans == '8' + || cTrans == '9') && (m_iNumberStatus == NUMBER_PORINT)) { + + m_jPor.setText(m_jPor.getText() + cTrans); + + } else if (cTrans == '.' + && m_iNumberStatus == NUMBER_PORZERO && !priceWith00) { + m_jPor.setText("x0."); + m_iNumberStatus = NUMBER_PORZERODEC; + } else if (cTrans == '.' + && m_iNumberStatus == NUMBER_PORZERO) { + m_jPor.setText("x"); + m_iNumberStatus = NUMBERVALID; + } else if (cTrans == '.' + && m_iNumberStatus == NUMBER_PORINT && !priceWith00) { + m_jPor.setText(m_jPor.getText() + "."); + m_iNumberStatus = NUMBER_PORDEC; + } else if (cTrans == '.' + && m_iNumberStatus == NUMBER_PORINT) { + m_jPor.setText(m_jPor.getText() + "00"); + m_iNumberStatus = NUMBERVALID; + + } else if ((cTrans == '0') + && (m_iNumberStatus == NUMBER_PORZERODEC + || m_iNumberStatus == NUMBER_PORDEC)) { + m_jPor.setText(m_jPor.getText() + cTrans); + } else if ((cTrans == '1' || cTrans == '2' || cTrans == '3' + || cTrans == '4' || cTrans == '5' || cTrans == '6' + || cTrans == '7' || cTrans == '8' || cTrans == '9') + && (m_iNumberStatus == NUMBER_PORZERODEC || m_iNumberStatus == NUMBER_PORDEC)) { + + m_jPor.setText(m_jPor.getText() + cTrans); + m_iNumberStatus = NUMBER_PORDEC; + m_iNumberStatusPor = NUMBERVALID; + + } else if (cTrans == '\u00a7' + && m_iNumberStatusInput == NUMBERVALID + && m_iNumberStatusPor == NUMBERZERO) { + + if (m_App.getDeviceScale().existsScale() + && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { + try { + Double value = m_App.getDeviceScale().readWeight(); + if (value != null) { + ProductInfoExt product = getInputProduct(); + addTicketLine(product, value, product.getPriceSell()); + } + } catch (ScaleException e) { + Toolkit.getDefaultToolkit().beep(); + new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.noweight"), e).show(this); + stateToZero(); + } + } else { + + Toolkit.getDefaultToolkit().beep(); + } + } else if (cTrans == '\u00a7' + && m_iNumberStatusInput == NUMBERZERO + && m_iNumberStatusPor == NUMBERZERO) { + + int i = m_ticketlines.getSelectedIndex(); + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); + } else if (m_App.getDeviceScale().existsScale()) { + try { + Double value = m_App.getDeviceScale().readWeight(); + if (value != null) { + TicketLineInfo newline = new TicketLineInfo(m_oTicket.getLine(i)); + newline.setMultiply(value); + newline.setPrice(Math.abs(newline.getPrice())); + paintTicketLine(i, newline); + } + } catch (ScaleException e) { + Toolkit.getDefaultToolkit().beep(); + new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.noweight"), e).show(this); + stateToZero(); + } + } else { + + Toolkit.getDefaultToolkit().beep(); + } + + } else if (cTrans == '+' + && m_iNumberStatusInput == NUMBERZERO + && m_iNumberStatusPor == NUMBERZERO) { + int i = m_ticketlines.getSelectedIndex(); + + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + TicketLineInfo newline = new TicketLineInfo(m_oTicket.getLine(i)); + //If it's a refund + button means one unit less + if (m_oTicket.getTicketType() == TicketInfo.RECEIPT_REFUND) { + if (m_App.getProperties().getProperty("override.check").equals("true")) { + oCount = count - 1; //increment existing line + pinOK = false; + changeCount(pinOK); + newline.setMultiply(newline.getMultiply() - 1.0); + newline.setProperty("ticket.updated", "true"); + paintTicketLine(i, newline); + } else { + newline.setMultiply(newline.getMultiply() - 1.0); + newline.setProperty("ticket.updated", "true"); + paintTicketLine(i, newline); + } + } else { + if (m_App.getProperties().getProperty("override.check").equals("true")) { + oCount = count + 1; //increment existing line + pinOK = false; + if (changeCount(pinOK)) { + newline.setMultiply(newline.getMultiply() + 1.0); + newline.setProperty("ticket.updated", "true"); + paintTicketLine(i, newline); + } + } else { + newline.setMultiply(newline.getMultiply() + 1.0); + newline.setProperty("ticket.updated", "true"); + paintTicketLine(i, newline); + } + } + } + } else if (cTrans == '-' + && m_iNumberStatusInput == NUMBERZERO + && m_iNumberStatusPor == NUMBERZERO + && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { + + int i = m_ticketlines.getSelectedIndex(); + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + TicketLineInfo newline = new TicketLineInfo(m_oTicket.getLine(i)); + + if (m_oTicket.getTicketType() == TicketInfo.RECEIPT_REFUND) { + if (m_App.getProperties().getProperty("override.check").equals("true")) { + oCount = count - 1; //increment existing line + pinOK = false; + changeCount(pinOK); + newline.setMultiply(newline.getMultiply() - 1.0); + newline.setProperty("ticket.updated", "true"); + paintTicketLine(i, newline); + } else { + newline.setMultiply(newline.getMultiply() - 1.0); + newline.setProperty("ticket.updated", "true"); + paintTicketLine(i, newline); + } + + if (newline.getMultiply() >= 0) { + removeTicketLine(i); + } else { + paintTicketLine(i, newline); + } + } else { + if (m_App.getProperties().getProperty("override.check").equals("true")) { + oCount = count - 1; //increment existing line + pinOK = false; + if (changeCount(pinOK)) { + newline.setMultiply(newline.getMultiply() - 1.0); + newline.setProperty("ticket.updated", "true"); + paintTicketLine(i, newline); + } + } else { + newline.setMultiply(newline.getMultiply() - 1.0); + newline.setProperty("ticket.updated", "true"); + paintTicketLine(i, newline); + } + + if (newline.getMultiply() <= 0.0) { + removeTicketLine(i); + } else { + paintTicketLine(i, newline); + } + } + } + + } else if (cTrans == '+' + && m_iNumberStatusInput == NUMBERZERO + && m_iNumberStatusPor == NUMBERVALID) { + int i = m_ticketlines.getSelectedIndex(); + + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + double dPor = getPorValue(); + TicketLineInfo newline = new TicketLineInfo(m_oTicket.getLine(i)); + + if (m_oTicket.getTicketType() == TicketInfo.RECEIPT_REFUND) { + if (m_App.getProperties().getProperty("override.check").equals("true")) { + oCount = count - 1; //increment existing line + pinOK = false; + changeCount(pinOK); + newline.setMultiply(-dPor); + newline.setProperty("ticket.updated", "true"); + newline.setPrice(Math.abs(newline.getPrice())); + paintTicketLine(i, newline); + } else { + newline.setMultiply(-dPor); + newline.setProperty("ticket.updated", "true"); + newline.setPrice(Math.abs(newline.getPrice())); + paintTicketLine(i, newline); + } + } else { + if (m_App.getProperties().getProperty("override.check").equals("true")) { + oCount = count + 1; //increment existing line + pinOK = false; + if (changeCount(pinOK)) { + newline.setMultiply(dPor); + newline.setProperty("ticket.updated", "true"); + newline.setPrice(Math.abs(newline.getPrice())); + paintTicketLine(i, newline); + } + } else { + newline.setMultiply(dPor); + newline.setProperty("ticket.updated", "true"); + newline.setPrice(Math.abs(newline.getPrice())); + paintTicketLine(i, newline); + } + } + } + } else if (cTrans == '-' + && m_iNumberStatusInput == NUMBERZERO + && m_iNumberStatusPor == NUMBERVALID + && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { + int i = m_ticketlines.getSelectedIndex(); + + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + double dPor = getPorValue(); + TicketLineInfo newline = new TicketLineInfo(m_oTicket.getLine(i)); + + if (m_oTicket.getTicketType() == TicketInfo.RECEIPT_REFUND) { + if (m_App.getProperties().getProperty("override.check").equals("true")) { + oCount = count - 1; //increment existing line + pinOK = false; + changeCount(pinOK); + newline.setMultiply(-dPor); + newline.setProperty("ticket.updated", "true"); + newline.setPrice(Math.abs(newline.getPrice())); + paintTicketLine(i, newline); + } else { + newline.setMultiply(-dPor); + newline.setProperty("ticket.updated", "true"); + newline.setPrice(Math.abs(newline.getPrice())); + paintTicketLine(i, newline); + } + } else { + if (m_App.getProperties().getProperty("override.check").equals("true")) { + oCount = count - 1; //increment existing line + pinOK = false; + if (changeCount(pinOK)) { + newline.setMultiply(dPor); + newline.setProperty("ticket.updated", "true"); + newline.setPrice(Math.abs(newline.getPrice())); + paintTicketLine(i, newline); + } + } else { + newline.setMultiply(dPor); + newline.setProperty("ticket.updated", "true"); + newline.setPrice(Math.abs(newline.getPrice())); + paintTicketLine(i, newline); + } + } + } + } else if (cTrans == '+' + && m_iNumberStatusInput == NUMBERVALID + && m_iNumberStatusPor == NUMBERZERO + && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { + ProductInfoExt product = getInputProduct(); + addTicketLine(product, 1.0, product.getPriceSell()); + m_jEditLine.doClick(); + + } else if (cTrans == '-' + && m_iNumberStatusInput == NUMBERVALID + && m_iNumberStatusPor == NUMBERZERO + && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { + ProductInfoExt product = getInputProduct(); + addTicketLine(product, 1.0, -product.getPriceSell()); + m_jEditLine.doClick(); + + } else if (cTrans == '+' + && m_iNumberStatusInput == NUMBERVALID + && m_iNumberStatusPor == NUMBERVALID + && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { + ProductInfoExt product = getInputProduct(); + addTicketLine(product, getPorValue(), product.getPriceSell()); + + } else if (cTrans == '-' + && m_iNumberStatusInput == NUMBERVALID + && m_iNumberStatusPor == NUMBERVALID + && m_App.getAppUserView().getUser().hasPermission("sales.EditLines")) { + ProductInfoExt product = getInputProduct(); + addTicketLine(product, getPorValue(), -product.getPriceSell()); + + } else if (cTrans == ' ' || cTrans == '=') { + if (m_oTicket.getLinesCount() > 0) { + if (closeTicket(m_oTicket, m_oTicketExt)) { + m_ticketsbag.deleteTicket(); + String autoLogoff = (m_App.getProperties().getProperty("till.autoLogoff")); + if (autoLogoff != null) { + if (autoLogoff.equals("true")) { + if ("restaurant".equals( + m_App.getProperties().getProperty("machine.ticketsbag")) + && ("true".equals(m_App.getProperties().getProperty("till.autoLogoffrestaurant")))) { + deactivate(); + setActiveTicket(null, null); + } else { + ((JRootApp) m_App).closeAppView(); + } + } + } + ; + } else { + refreshTicket(); + } + } else { + Toolkit.getDefaultToolkit().beep(); + } + } + } + } + + + private Window getActiveWindow() { + for (Window window: getWindows()) { + if (window instanceof JRootFrame) { + return window; + } + } + return null; + } + + private boolean closeTicket(TicketInfo ticket, Object ticketext) { + if (listener != null) { + listener.stop(); + } + boolean resultok = false; + + if (m_App.getAppUserView().getUser().hasPermission("sales.Total")) { + + warrantyCheck(ticket); + + try { + + taxeslogic.calculateTaxes(ticket); + if (ticket.getTotal() >= 0.0) { + ticket.resetPayments(); + } + + if (executeEvent(ticket, ticketext, "ticket.total") == null) { + if (listener != null) { + listener.stop(); + } + + printTicket("Printer.TicketTotal", ticket, ticketext); + + JPaymentSelect paymentdialog = ticket.getTicketType() == TicketInfo.RECEIPT_NORMAL + ? paymentdialogreceipt + : paymentdialogrefund; + paymentdialog.setPrintSelected("true".equals(m_jbtnconfig.getProperty("printselected", "true"))); + + paymentdialog.setTransactionID(ticket.getTransactionID()); + + if (paymentdialog.showDialog(ticket.getTotal(), ticket.getCustomer())) { + + ticket.setPayments(paymentdialog.getSelectedPayments()); + + ticket.setUser(m_App.getAppUserView().getUser().getUserInfo()); + ticket.setActiveCash(m_App.getActiveCashIndex()); + ticket.setDate(new Date()); + + if (executeEvent(ticket, ticketext, "ticket.save") == null) { + + try { + dlSales.saveTicket(ticket, m_App.getInventoryLocation()); + m_config.setProperty("lastticket.number", Integer.toString(ticket.getTicketId())); + m_config.setProperty("lastticket.type", Integer.toString(ticket.getTicketType())); + m_config.saveWithExistingProperties(); + + } catch (BasicException eData) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, AppLocal.getIntString("message.nosaveticket"), eData); + msg.show(this); + } catch (IOException ex) { + log.error(ex.getMessage()); + } + + if (m_config.getProperty("till.digital-receipt") != null && m_config.getProperty("till.digital-receipt").equals("true")){ + log.debug("Send digital receipt"); + String xml = dlSystem.getResourceAsXML("Printer.Ticket"); + new Application().sendReceipt(ticket, xml, getActiveWindow()); + } + + executeEvent(ticket, ticketext, "ticket.close", + new ScriptArg("print", paymentdialog.isPrintSelected())); + + printTicket(paymentdialog.isPrintSelected() || warrantyPrint + ? "Printer.Ticket" + : "Printer.Ticket2", ticket, ticketext); + Notify(AppLocal.getIntString("notify.printing")); + + resultok = true; + + if ("restaurant".equals(m_App.getProperties() + .getProperty("machine.ticketsbag")) && !ticket.getOldTicket()) { + /* Deliberately Explicit to allow for reassignments - future + * even though we could do a single SQL statment sweep for reset + */ + restDB.clearCustomerNameInTable(ticketext.toString()); + restDB.clearWaiterNameInTable(ticketext.toString()); + restDB.clearTicketIdInTable(ticketext.toString()); + } + } + } + } + } catch (TaxesException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotcalculatetaxes")); + msg.show(this); + resultok = false; + } + + m_oTicket.resetTaxes(); + m_oTicket.resetPayments(); + + jCheckStock.setText(""); + + } + + return resultok; + } + + private boolean warrantyCheck(TicketInfo ticket) { + warrantyPrint = false; + int lines = 0; + while (lines < ticket.getLinesCount()) { + if (!warrantyPrint) { + warrantyPrint = ticket.getLine(lines).isProductWarranty(); + return (true); + } + lines++; + } + return false; + } + + /** + * @param pTicket + * @return + */ + public String getPickupString(TicketInfo pTicket) { + if (pTicket == null) { + return ("0"); + } + String tmpPickupId = Integer.toString(pTicket.getPickupId()); + String pickupSize = (m_App.getProperties().getProperty("till.pickupsize")); + if (pickupSize != null && (Integer.parseInt(pickupSize) >= tmpPickupId.length())) { + while (tmpPickupId.length() < (Integer.parseInt(pickupSize))) { + tmpPickupId = "0" + tmpPickupId; + } + } + return (tmpPickupId); + } + + + private void printTicket(String sresourcename, TicketInfo ticket, Object ticketext) { + + String sresource = dlSystem.getResourceAsXML(sresourcename); + if (sresource == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket")); + msg.show(JPanelTicket.this); + } else { + if (ticket.getPickupId() == 0) { + try { + ticket.setPickupId(dlSales.getNextPickupIndex()); + } catch (BasicException e) { + ticket.setPickupId(0); + } + } + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); + + if (Boolean.parseBoolean(m_App.getProperties().getProperty("receipt.newlayout"))) { + script.put("taxes", ticket.getTaxLines()); + } else { + script.put("taxes", taxcollection); + } + + script.put("taxeslogic", taxeslogic); + script.put("ticket", ticket); + script.put("place", ticketext); + script.put("warranty", warrantyPrint); + script.put("pickupid", getPickupString(ticket)); + + refreshTicket(); + + m_TTP.printTicket(script.eval(sresource).toString(), ticket); + + } catch (ScriptException | TicketPrinterException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), e); + msg.show(JPanelTicket.this); + } + } + } + + public void printTicket(String resource) { +// this method is intended to be called only from JPanelButtons. + + if (resource == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotexecute")); + msg.show(this); + } else { +// JG 5 Jul 17 calculate taxes disabled as causing incorrect tax recalc +// taxeslogic.calculateTaxes(m_oTicket); + printTicket(resource, m_oTicket, m_oTicketExt); + } + + Notify(AppLocal.getIntString("notify.printed")); + j_btnRemotePrt.setEnabled(false); + } + + public void customerAdd(String resource) { + Notify(AppLocal.getIntString("notify.customeradd")); + } + + public void customerRemove(String resource) { + Notify(AppLocal.getIntString("notify.customerremove")); + } + + public void customerChange(String resource) { + Notify(AppLocal.getIntString("notify.customerchange")); + } + + public void Notify(String msg) { + final WebNotification notification = new WebNotification(); + notification.setIcon(NotificationIcon.information); + notification.setDisplayTime(4000); + + final WebClock clock = new WebClock(); + clock.setClockType(ClockType.timer); + clock.setTimeLeft(5000); + notification.setContent(msg); + + NotificationManager.showNotification(notification); + clock.start(); + } + + private void printReport(String resourcefile, TicketInfo ticket, Object ticketext) { + + try { + + JasperReport jr; + + InputStream in = getClass().getResourceAsStream(resourcefile + ".ser"); + if (in == null) { + // read and compile the report + JasperDesign jd = JRXmlLoader.load(getClass().getResourceAsStream(resourcefile + ".jrxml")); + jr = JasperCompileManager.compileReport(jd); + } else { + try (ObjectInputStream oin = new ObjectInputStream(in)) { + jr = (JasperReport) oin.readObject(); + } + } + + + Map reportparams = new HashMap(); + + try { + reportparams.put("REPORT_RESOURCE_BUNDLE", ResourceBundle.getBundle(resourcefile + ".properties")); + } catch (MissingResourceException e) { + } + reportparams.put("TAXESLOGIC", taxeslogic); + + Map reportfields = new HashMap(); + reportfields.put("TICKET", ticket); + reportfields.put("PLACE", ticketext); + + JasperPrint jp = JasperFillManager.fillReport(jr, reportparams, new JRMapArrayDataSource(new Object[]{reportfields})); + + PrintService service = ReportUtils.getPrintService(m_App.getProperties().getProperty("machine.printername")); + + JRPrinterAWT300.printPages(jp, 0, jp.getPages().size() - 1, service); + + } catch (JRException | IOException | ClassNotFoundException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadreport"), e); + msg.show(this); + } + } + + private void visorTicketLine(TicketLineInfo oLine) { + if (oLine == null) { + m_App.getDeviceTicket().getDeviceDisplay().clearVisor(); + } else { + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); + script.put("ticketline", oLine); + m_TTP.printTicket(script.eval(dlSystem.getResourceAsXML("Printer.TicketLine")).toString()); + + } catch (ScriptException | TicketPrinterException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintline"), e); + msg.show(JPanelTicket.this); + } + } + } + + private Object evalScript(ScriptObject scr, String resource, ScriptArg... args) { + + // resource here is guaranteed to be not null + try { + scr.setSelectedIndex(m_ticketlines.getSelectedIndex()); + return scr.evalScript(dlSystem.getResourceAsXML(resource), args); + } catch (ScriptException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotexecute"), e); + msg.show(this); + return msg; + } + } + + /** + * @param resource + * @param args + */ + public void evalScriptAndRefresh(String resource, ScriptArg... args) { + + if (resource == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotexecute")); + msg.show(this); + } else { + ScriptObject scr = new ScriptObject(m_oTicket, m_oTicketExt); + scr.setSelectedIndex(m_ticketlines.getSelectedIndex()); + evalScript(scr, resource, args); + refreshTicket(); + + setSelectedIndex(scr.getSelectedIndex()); + } + } + + /** + * + */ + private Object executeEventAndRefresh(String eventkey, ScriptArg... args) { + + String resource = m_jbtnconfig.getEvent(eventkey); + + if (resource == null) { + return null; + } else { + ScriptObject scr = new ScriptObject(m_oTicket, m_oTicketExt); + scr.setSelectedIndex(m_ticketlines.getSelectedIndex()); + Object result = evalScript(scr, resource, args); + refreshTicket(); + setSelectedIndex(scr.getSelectedIndex()); + return result; + } + } + + + private Object executeEvent(TicketInfo ticket, Object ticketext, String eventkey, ScriptArg... args) { + + String resource = m_jbtnconfig.getEvent(eventkey); + if (resource == null) { + return null; + } else { + ScriptObject scr = new ScriptObject(ticket, ticketext); + return evalScript(scr, resource, args); + } + } + + /** + * @param sresourcename + * @return + */ + public String getResourceAsXML(String sresourcename) { + return dlSystem.getResourceAsXML(sresourcename); + } + + /** + * @param sresourcename + * @return + */ + public BufferedImage getResourceAsImage(String sresourcename) { + return dlSystem.getResourceAsImage(sresourcename); + } + + private void setSelectedIndex(int i) { + + if (i >= 0 && i < m_oTicket.getLinesCount()) { + m_ticketlines.setSelectedIndex(i); + } else if (m_oTicket.getLinesCount() > 0) { + m_ticketlines.setSelectedIndex(m_oTicket.getLinesCount() - 1); + } + } + + /** + * + */ + public static class ScriptArg { + private final String key; + private final Object value; + + /** + * @param key + * @param value + */ + public ScriptArg(String key, Object value) { + this.key = key; + this.value = value; + } + + /** + * @return + */ + public String getKey() { + return key; + } + + /** + * @return + */ + public Object getValue() { + return value; + } + } + + private String setTempjPrice(String jPrice) { + jPrice = jPrice.replace(".", ""); +// remove all leading zeros from the string + long tempL = Long.parseLong(jPrice); + jPrice = Long.toString(tempL); + + while (jPrice.length() < 3) { + jPrice = "0" + jPrice; + } + return (jPrice.length() <= 2) ? jPrice : (new StringBuffer(jPrice).insert(jPrice.length() - 2, ".").toString()); + } + + public void checkStock() { + int i = m_ticketlines.getSelectedIndex(); + + if (i < 0) { + } else { + try { + TicketLineInfo line = m_oTicket.getLine(i); + String pId = line.getProductID(); + + String lName = (m_App.getProperties().getProperty("machine.department")); + lName = "'" + lName + "'"; + ProductStock checkProduct; + String location = m_App.getInventoryLocation(); + checkProduct = dlSales.getProductStockState(pId, location); + + if (checkProduct != null) { + + if (checkProduct.getUnits() <= 0) { + jCheckStock.setForeground(Color.magenta); + } else { + jCheckStock.setForeground(Color.darkGray); + } + + double dUnits = checkProduct.getUnits(); + int iUnits; + iUnits = (int) dUnits; + jCheckStock.setText(Integer.toString(iUnits)); + } else { + jCheckStock.setText(null); + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + } + + public void checkCustomer() { + if (m_oTicket.getCustomer().isVIP() == true) { + + String content; + String vip; + String discount; + + if (m_oTicket.getCustomer().isVIP() == true) { + vip = AppLocal.getIntString("message.vipyes"); + } else { + vip = AppLocal.getIntString("message.vipno"); + } + if (m_oTicket.getCustomer().getDiscount() > 0) { + discount = AppLocal.getIntString("message.discyes") + m_oTicket.getCustomer().getDiscount() + "%"; + } else { + discount = AppLocal.getIntString("message.discno"); + } + + content = "<html>" + + "<b>" + AppLocal.getIntString("label.vip") + " : " + "</b>" + vip + "<br>" + + "<b>" + AppLocal.getIntString("label.discount") + " : " + "</b>" + discount + "<br>"; + + + JFrame frame = new JFrame(); + JOptionPane.showMessageDialog(frame, + content, + "Info", + JOptionPane.WARNING_MESSAGE); + } + } + + /** + * + */ + public class ScriptObject { + + private final TicketInfo ticket; + private final Object ticketext; + + private int selectedindex; + + private ScriptObject(TicketInfo ticket, Object ticketext) { + this.ticket = ticket; + this.ticketext = ticketext; + } + + /** + * @return + */ + public double getInputValue() { + if (m_iNumberStatusInput == NUMBERVALID && m_iNumberStatusPor == NUMBERZERO) { + return JPanelTicket.this.getInputValue(); + } else { + return 0.0; + } + } + + /** + * @return + */ + public int getSelectedIndex() { + return selectedindex; + } + + /** + * @param i + */ + public void setSelectedIndex(int i) { + selectedindex = i; + } + + /** + * @param resourcefile + */ + public void printReport(String resourcefile) { + JPanelTicket.this.printReport(resourcefile, ticket, ticketext); + } + + /** + * @param sresourcename + */ + public void printTicket(String sresourcename) { + JPanelTicket.this.printTicket(sresourcename, ticket, ticketext); + j_btnRemotePrt.setEnabled(false); + } + + /** + * @param code + * @param args + * @return Script object and value + * @throws ScriptException + */ + public Object evalScript(String code, ScriptArg... args) throws ScriptException { + + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.BEANSHELL); + + String sDBUser = m_App.getProperties().getProperty("db.user"); + String sDBPassword = m_App.getProperties().getProperty("db.password"); + + if (sDBUser != null && sDBPassword != null && sDBPassword.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + sDBUser); + sDBPassword = cypher.decrypt(sDBPassword.substring(6)); + } + script.put("hostname", m_App.getProperties().getProperty("machine.hostname")); + script.put("dbURL", m_App.getProperties().getProperty("db.URL") + m_App.getProperties().getProperty("db.schema")); + script.put("dbUser", sDBUser); + script.put("dbPassword", sDBPassword); + + script.put("ticket", ticket); + script.put("place", ticketext); + script.put("taxes", taxcollection); + script.put("taxeslogic", taxeslogic); + script.put("user", m_App.getAppUserView().getUser()); + script.put("sales", this); + script.put("taxesinc", m_jaddtax.isSelected()); + script.put("warranty", warrantyPrint); + script.put("pickupid", getPickupString(ticket)); + + for (ScriptArg arg : args) { + script.put(arg.getKey(), arg.getValue()); + } + + return script.eval(code); + } + } + + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the FormEditor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jPanContainer = new javax.swing.JPanel(); + m_jOptions = new javax.swing.JPanel(); + m_jPanelBag = new javax.swing.JPanel(); + jTBtnShow = new javax.swing.JToggleButton(); + m_jbtnScale = new javax.swing.JButton(); + jbtnMooring = new javax.swing.JButton(); + m_jButtons = new javax.swing.JPanel(); + btnSplit = new javax.swing.JButton(); + btnReprint1 = new javax.swing.JButton(); + j_btnRemotePrt = new javax.swing.JButton(); + jBtnCustomer = new javax.swing.JButton(); + m_jPanelScripts = new javax.swing.JPanel(); + m_jButtonsExt = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + m_jPanTicket = new javax.swing.JPanel(); + jPanel5 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + m_jDelete = new javax.swing.JButton(); + m_jList = new javax.swing.JButton(); + m_jEditLine = new javax.swing.JButton(); + jEditAttributes = new javax.swing.JButton(); + jCheckStock = new javax.swing.JButton(); + m_jPanelCentral = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 0), new java.awt.Dimension(5, 32767)); + m_jTicketId = new javax.swing.JLabel(); + m_jPanTotals = new javax.swing.JPanel(); + m_jLblTotalEuros3 = new javax.swing.JLabel(); + m_jLblTotalEuros2 = new javax.swing.JLabel(); + m_jLblTotalEuros1 = new javax.swing.JLabel(); + m_jSubtotalEuros = new javax.swing.JLabel(); + m_jTaxesEuros = new javax.swing.JLabel(); + m_jTotalEuros = new javax.swing.JLabel(); + m_jContEntries = new javax.swing.JPanel(); + m_jPanEntries = new javax.swing.JPanel(); + m_jNumberKeys = new com.unicenta.beans.JNumberKeys(); + jPanel9 = new javax.swing.JPanel(); + m_jaddtax = new com.alee.extended.button.WebSwitch(); + m_jPrice = new javax.swing.JLabel(); + m_jPor = new javax.swing.JLabel(); + m_jEnter = new javax.swing.JButton(); + m_jTax = new javax.swing.JComboBox(); + m_jKeyFactory = new javax.swing.JTextField(); + m_jPanEntriesE = new javax.swing.JPanel(); + catcontainer = new javax.swing.JPanel(); + + setBackground(new java.awt.Color(255, 204, 153)); + setOpaque(false); + setLayout(new java.awt.CardLayout()); + + m_jPanContainer.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + m_jPanContainerFocusLost(evt); + } + }); + m_jPanContainer.setLayout(new java.awt.BorderLayout()); + + m_jOptions.setLayout(new java.awt.BorderLayout()); + + m_jPanelBag.setAutoscrolls(true); + m_jPanelBag.setMaximumSize(new java.awt.Dimension(10, 10)); + m_jPanelBag.setPreferredSize(new java.awt.Dimension(0, 60)); + + jTBtnShow.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTBtnShow.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/resources.png"))); // NOI18N + jTBtnShow.setPreferredSize(new java.awt.Dimension(80, 45)); + jTBtnShow.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTBtnShowActionPerformed(evt); + } + }); + m_jPanelBag.add(jTBtnShow); + + m_jbtnScale.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jbtnScale.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/scale.png"))); // NOI18N + m_jbtnScale.setText(AppLocal.getIntString("button.scale")); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + m_jbtnScale.setToolTipText(bundle.getString("tooltip.scale")); // NOI18N + m_jbtnScale.setFocusPainted(false); + m_jbtnScale.setFocusable(false); + m_jbtnScale.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jbtnScale.setMaximumSize(new java.awt.Dimension(85, 44)); + m_jbtnScale.setMinimumSize(new java.awt.Dimension(85, 44)); + m_jbtnScale.setPreferredSize(new java.awt.Dimension(85, 45)); + m_jbtnScale.setRequestFocusEnabled(false); + m_jbtnScale.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnScaleActionPerformed(evt); + } + }); + m_jPanelBag.add(m_jbtnScale); + + jbtnMooring.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnMooring.setText(bundle.getString("button.moorings")); // NOI18N + jbtnMooring.setMargin(new java.awt.Insets(8, 14, 8, 14)); + jbtnMooring.setMaximumSize(new java.awt.Dimension(80, 40)); + jbtnMooring.setMinimumSize(new java.awt.Dimension(80, 40)); + jbtnMooring.setPreferredSize(new java.awt.Dimension(80, 45)); + jbtnMooring.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnMooringActionPerformed(evt); + } + }); + m_jPanelBag.add(jbtnMooring); + + m_jButtons.setPreferredSize(new java.awt.Dimension(350, 55)); + + btnSplit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_split_sml.png"))); // NOI18N + btnSplit.setToolTipText(bundle.getString("tooltip.salesplit")); // NOI18N + btnSplit.setEnabled(false); + btnSplit.setFocusPainted(false); + btnSplit.setFocusable(false); + btnSplit.setMargin(new java.awt.Insets(8, 14, 8, 14)); + btnSplit.setMaximumSize(new java.awt.Dimension(50, 40)); + btnSplit.setMinimumSize(new java.awt.Dimension(50, 40)); + btnSplit.setPreferredSize(new java.awt.Dimension(80, 45)); + btnSplit.setRequestFocusEnabled(false); + btnSplit.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnSplitActionPerformed(evt); + } + }); + + btnReprint1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + btnReprint1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reprint24.png"))); // NOI18N + btnReprint1.setToolTipText(bundle.getString("tooltip.reprintLastTicket")); // NOI18N + btnReprint1.setFocusPainted(false); + btnReprint1.setFocusable(false); + btnReprint1.setMargin(new java.awt.Insets(8, 14, 8, 14)); + btnReprint1.setMaximumSize(new java.awt.Dimension(50, 40)); + btnReprint1.setMinimumSize(new java.awt.Dimension(50, 40)); + btnReprint1.setPreferredSize(new java.awt.Dimension(80, 45)); + btnReprint1.setRequestFocusEnabled(false); + btnReprint1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnReprint1ActionPerformed(evt); + } + }); + + j_btnRemotePrt.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + j_btnRemotePrt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/remote_print.png"))); // NOI18N + j_btnRemotePrt.setText(bundle.getString("button.sendorder")); // NOI18N + j_btnRemotePrt.setToolTipText(bundle.getString("tooltip.printtoremote")); // NOI18N + j_btnRemotePrt.setMargin(new java.awt.Insets(0, 4, 0, 4)); + j_btnRemotePrt.setMaximumSize(new java.awt.Dimension(50, 40)); + j_btnRemotePrt.setMinimumSize(new java.awt.Dimension(50, 40)); + j_btnRemotePrt.setPreferredSize(new java.awt.Dimension(80, 45)); + j_btnRemotePrt.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + j_btnRemotePrtActionPerformed(evt); + } + }); + + jBtnCustomer.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jBtnCustomer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer.png"))); // NOI18N + jBtnCustomer.setToolTipText(bundle.getString("tooltip.salescustomer")); // NOI18N + jBtnCustomer.setPreferredSize(new java.awt.Dimension(80, 45)); + jBtnCustomer.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnCustomerActionPerformed(evt); + } + }); + + javax.swing.GroupLayout m_jButtonsLayout = new javax.swing.GroupLayout(m_jButtons); + m_jButtons.setLayout(m_jButtonsLayout); + m_jButtonsLayout.setHorizontalGroup( + m_jButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(m_jButtonsLayout.createSequentialGroup() + .addContainerGap() + .addComponent(jBtnCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnSplit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(j_btnRemotePrt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnReprint1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + m_jButtonsLayout.setVerticalGroup( + m_jButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(m_jButtonsLayout.createSequentialGroup() + .addGap(5, 5, 5) + .addGroup(m_jButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(j_btnRemotePrt, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btnSplit, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btnReprint1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jBtnCustomer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + m_jPanelBag.add(m_jButtons); + + m_jOptions.add(m_jPanelBag, java.awt.BorderLayout.PAGE_START); + + m_jPanelScripts.setPreferredSize(new java.awt.Dimension(200, 60)); + m_jPanelScripts.setLayout(new java.awt.BorderLayout()); + + m_jButtonsExt.setPreferredSize(new java.awt.Dimension(20, 60)); + + jPanel1.setMinimumSize(new java.awt.Dimension(235, 50)); + jPanel1.setPreferredSize(new java.awt.Dimension(10, 55)); + m_jButtonsExt.add(jPanel1); + + m_jPanelScripts.add(m_jButtonsExt, java.awt.BorderLayout.PAGE_START); + + m_jOptions.add(m_jPanelScripts, java.awt.BorderLayout.CENTER); + m_jPanelScripts.getAccessibleContext().setAccessibleDescription(""); + + m_jPanContainer.add(m_jOptions, java.awt.BorderLayout.NORTH); + + m_jPanTicket.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + m_jPanTicket.setLayout(new java.awt.BorderLayout()); + + jPanel5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel5.setPreferredSize(new java.awt.Dimension(75, 270)); + jPanel5.setLayout(new java.awt.BorderLayout()); + + jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 5)); + jPanel2.setPreferredSize(new java.awt.Dimension(70, 250)); + jPanel2.setLayout(new java.awt.GridLayout(0, 1, 5, 5)); + + m_jDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/editdelete.png"))); // NOI18N + m_jDelete.setToolTipText(bundle.getString("tooltip.saleremoveline")); // NOI18N + m_jDelete.setFocusPainted(false); + m_jDelete.setFocusable(false); + m_jDelete.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jDelete.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jDelete.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jDelete.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jDelete.setRequestFocusEnabled(false); + m_jDelete.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jDeleteActionPerformed(evt); + } + }); + jPanel2.add(m_jDelete); + + m_jList.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/search32.png"))); // NOI18N + m_jList.setToolTipText(bundle.getString("tooltip.saleproductfind")); // NOI18N + m_jList.setFocusPainted(false); + m_jList.setFocusable(false); + m_jList.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jList.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jList.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jList.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jList.setRequestFocusEnabled(false); + m_jList.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jListActionPerformed(evt); + } + }); + jPanel2.add(m_jList); + + m_jEditLine.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_editline.png"))); // NOI18N + m_jEditLine.setToolTipText(bundle.getString("tooltip.saleeditline")); // NOI18N + m_jEditLine.setFocusPainted(false); + m_jEditLine.setFocusable(false); + m_jEditLine.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jEditLine.setMaximumSize(new java.awt.Dimension(42, 36)); + m_jEditLine.setMinimumSize(new java.awt.Dimension(42, 36)); + m_jEditLine.setPreferredSize(new java.awt.Dimension(50, 45)); + m_jEditLine.setRequestFocusEnabled(false); + m_jEditLine.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jEditLineActionPerformed(evt); + } + }); + jPanel2.add(m_jEditLine); + + jEditAttributes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/attributes.png"))); // NOI18N + jEditAttributes.setToolTipText(bundle.getString("tooltip.saleattributes")); // NOI18N + jEditAttributes.setFocusPainted(false); + jEditAttributes.setFocusable(false); + jEditAttributes.setMargin(new java.awt.Insets(8, 14, 8, 14)); + jEditAttributes.setMaximumSize(new java.awt.Dimension(42, 36)); + jEditAttributes.setMinimumSize(new java.awt.Dimension(42, 36)); + jEditAttributes.setPreferredSize(new java.awt.Dimension(50, 45)); + jEditAttributes.setRequestFocusEnabled(false); + jEditAttributes.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jEditAttributesActionPerformed(evt); + } + }); + jPanel2.add(jEditAttributes); + + jCheckStock.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + jCheckStock.setForeground(new java.awt.Color(76, 197, 237)); + jCheckStock.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/info.png"))); // NOI18N + jCheckStock.setToolTipText(bundle.getString("tooltip.salecheckstock")); // NOI18N + jCheckStock.setFocusPainted(false); + jCheckStock.setFocusable(false); + jCheckStock.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + jCheckStock.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); + jCheckStock.setMargin(new java.awt.Insets(8, 4, 8, 4)); + jCheckStock.setMaximumSize(new java.awt.Dimension(42, 36)); + jCheckStock.setMinimumSize(new java.awt.Dimension(42, 36)); + jCheckStock.setPreferredSize(new java.awt.Dimension(80, 45)); + jCheckStock.setRequestFocusEnabled(false); + jCheckStock.setVerticalTextPosition(javax.swing.SwingConstants.TOP); + jCheckStock.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jCheckStockMouseClicked(evt); + } + }); + jCheckStock.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jCheckStockActionPerformed(evt); + } + }); + jPanel2.add(jCheckStock); + + jPanel5.add(jPanel2, java.awt.BorderLayout.NORTH); + + m_jPanTicket.add(jPanel5, java.awt.BorderLayout.LINE_START); + + m_jPanelCentral.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPanelCentral.setPreferredSize(new java.awt.Dimension(450, 240)); + m_jPanelCentral.setLayout(new java.awt.BorderLayout()); + + jPanel4.setLayout(new java.awt.BorderLayout()); + jPanel4.add(filler2, java.awt.BorderLayout.LINE_START); + + m_jTicketId.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N + m_jTicketId.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + m_jTicketId.setVerticalAlignment(javax.swing.SwingConstants.TOP); + m_jTicketId.setOpaque(true); + m_jTicketId.setPreferredSize(new java.awt.Dimension(300, 40)); + m_jTicketId.setRequestFocusEnabled(false); + m_jTicketId.setVerticalTextPosition(javax.swing.SwingConstants.TOP); + jPanel4.add(m_jTicketId, java.awt.BorderLayout.CENTER); + + m_jPanTotals.setPreferredSize(new java.awt.Dimension(375, 60)); + m_jPanTotals.setLayout(new java.awt.GridLayout(2, 3, 4, 0)); + + m_jLblTotalEuros3.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + m_jLblTotalEuros3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jLblTotalEuros3.setLabelFor(m_jSubtotalEuros); + m_jLblTotalEuros3.setText(AppLocal.getIntString("label.subtotalcash")); // NOI18N + m_jPanTotals.add(m_jLblTotalEuros3); + + m_jLblTotalEuros2.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + m_jLblTotalEuros2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jLblTotalEuros2.setLabelFor(m_jSubtotalEuros); + m_jLblTotalEuros2.setText(AppLocal.getIntString("label.taxcash")); // NOI18N + m_jPanTotals.add(m_jLblTotalEuros2); + + m_jLblTotalEuros1.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + m_jLblTotalEuros1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jLblTotalEuros1.setLabelFor(m_jTotalEuros); + m_jLblTotalEuros1.setText(AppLocal.getIntString("label.totalcash")); // NOI18N + m_jPanTotals.add(m_jLblTotalEuros1); + + m_jSubtotalEuros.setBackground(m_jEditLine.getBackground()); + m_jSubtotalEuros.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + m_jSubtotalEuros.setForeground(m_jEditLine.getForeground()); + m_jSubtotalEuros.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jSubtotalEuros.setLabelFor(m_jSubtotalEuros); + m_jSubtotalEuros.setToolTipText(bundle.getString("tooltip.salesubtotal")); // NOI18N + m_jSubtotalEuros.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true)); + m_jSubtotalEuros.setMaximumSize(new java.awt.Dimension(125, 25)); + m_jSubtotalEuros.setMinimumSize(new java.awt.Dimension(80, 25)); + m_jSubtotalEuros.setPreferredSize(new java.awt.Dimension(80, 25)); + m_jSubtotalEuros.setRequestFocusEnabled(false); + m_jPanTotals.add(m_jSubtotalEuros); + + m_jTaxesEuros.setBackground(m_jEditLine.getBackground()); + m_jTaxesEuros.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + m_jTaxesEuros.setForeground(m_jEditLine.getForeground()); + m_jTaxesEuros.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jTaxesEuros.setLabelFor(m_jTaxesEuros); + m_jTaxesEuros.setToolTipText(bundle.getString("tooltip.saletax")); // NOI18N + m_jTaxesEuros.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true)); + m_jTaxesEuros.setMaximumSize(new java.awt.Dimension(125, 25)); + m_jTaxesEuros.setMinimumSize(new java.awt.Dimension(80, 25)); + m_jTaxesEuros.setPreferredSize(new java.awt.Dimension(80, 25)); + m_jTaxesEuros.setRequestFocusEnabled(false); + m_jPanTotals.add(m_jTaxesEuros); + + m_jTotalEuros.setBackground(m_jEditLine.getBackground()); + m_jTotalEuros.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N + m_jTotalEuros.setForeground(m_jEditLine.getForeground()); + m_jTotalEuros.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jTotalEuros.setLabelFor(m_jTotalEuros); + m_jTotalEuros.setToolTipText(bundle.getString("tooltip.saletotal")); // NOI18N + m_jTotalEuros.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true)); + m_jTotalEuros.setMaximumSize(new java.awt.Dimension(125, 25)); + m_jTotalEuros.setMinimumSize(new java.awt.Dimension(80, 25)); + m_jTotalEuros.setPreferredSize(new java.awt.Dimension(100, 25)); + m_jTotalEuros.setRequestFocusEnabled(false); + m_jPanTotals.add(m_jTotalEuros); + + jPanel4.add(m_jPanTotals, java.awt.BorderLayout.LINE_END); + + m_jPanelCentral.add(jPanel4, java.awt.BorderLayout.SOUTH); + + m_jPanTicket.add(m_jPanelCentral, java.awt.BorderLayout.CENTER); + + m_jPanContainer.add(m_jPanTicket, java.awt.BorderLayout.CENTER); + + m_jContEntries.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jContEntries.setMinimumSize(new java.awt.Dimension(300, 350)); + m_jContEntries.setLayout(new java.awt.BorderLayout()); + + m_jPanEntries.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPanEntries.setPreferredSize(new java.awt.Dimension(300, 350)); + m_jPanEntries.setLayout(new javax.swing.BoxLayout(m_jPanEntries, javax.swing.BoxLayout.Y_AXIS)); + + m_jNumberKeys.setMinimumSize(new java.awt.Dimension(300, 300)); + m_jNumberKeys.setPreferredSize(new java.awt.Dimension(250, 250)); + m_jNumberKeys.addJNumberEventListener(new com.unicenta.beans.JNumberEventListener() { + public void keyPerformed(com.unicenta.beans.JNumberEvent evt) { + m_jNumberKeysKeyPerformed(evt); + } + }); + m_jPanEntries.add(m_jNumberKeys); + + jPanel9.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + + m_jaddtax.setBorder(null); + m_jaddtax.setToolTipText(bundle.getString("tooltip.switchtax")); // NOI18N + m_jaddtax.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jaddtax.setPreferredSize(new java.awt.Dimension(60, 30)); + m_jaddtax.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jaddtaxActionPerformed(evt); + } + }); + + m_jPrice.setFont(new java.awt.Font("Arial", 1, 16)); // NOI18N + m_jPrice.setForeground(new java.awt.Color(76, 197, 237)); + m_jPrice.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + m_jPrice.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(76, 197, 237)), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jPrice.setOpaque(true); + m_jPrice.setPreferredSize(new java.awt.Dimension(100, 25)); + m_jPrice.setRequestFocusEnabled(false); + + m_jPor.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jPor.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jPor.setRequestFocusEnabled(false); + + m_jEnter.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/barcode.png"))); // NOI18N + m_jEnter.setToolTipText(bundle.getString("tooltip.salebarcode")); // NOI18N + m_jEnter.setFocusPainted(false); + m_jEnter.setFocusable(false); + m_jEnter.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jEnter.setRequestFocusEnabled(false); + m_jEnter.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jEnterActionPerformed(evt); + } + }); + + m_jTax.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTax.setToolTipText(bundle.getString("tooltip.salestaxswitch")); // NOI18N + m_jTax.setFocusable(false); + m_jTax.setPreferredSize(new java.awt.Dimension(28, 25)); + m_jTax.setRequestFocusEnabled(false); + + m_jKeyFactory.setEditable(false); + m_jKeyFactory.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + m_jKeyFactory.setForeground(javax.swing.UIManager.getDefaults().getColor("Panel.background")); + m_jKeyFactory.setAutoscrolls(false); + m_jKeyFactory.setBorder(null); + m_jKeyFactory.setCaretColor(javax.swing.UIManager.getDefaults().getColor("Panel.background")); + m_jKeyFactory.setMinimumSize(new java.awt.Dimension(0, 0)); + m_jKeyFactory.setPreferredSize(new java.awt.Dimension(1, 1)); + m_jKeyFactory.setRequestFocusEnabled(false); + m_jKeyFactory.setVerifyInputWhenFocusTarget(false); + m_jKeyFactory.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { + m_jKeyFactoryKeyTyped(evt); + } + }); + + javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9); + jPanel9.setLayout(jPanel9Layout); + jPanel9Layout.setHorizontalGroup( + jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel9Layout.createSequentialGroup() + .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(m_jPor) + .addComponent(m_jKeyFactory, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE) + .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel9Layout.createSequentialGroup() + .addComponent(m_jaddtax, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(7, 7, 7) + .addComponent(m_jTax, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)) + .addGroup(jPanel9Layout.createSequentialGroup() + .addComponent(m_jPrice, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(5, 5, 5))) + .addComponent(m_jEnter, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel9Layout.setVerticalGroup( + jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel9Layout.createSequentialGroup() + .addComponent(m_jEnter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(jPanel9Layout.createSequentialGroup() + .addComponent(m_jPrice, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE) + .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jTax, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jaddtax, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup() + .addComponent(m_jPor) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(m_jKeyFactory, javax.swing.GroupLayout.PREFERRED_SIZE, 1, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + + m_jPanEntries.add(jPanel9); + + m_jContEntries.add(m_jPanEntries, java.awt.BorderLayout.NORTH); + + m_jPanEntriesE.setLayout(new java.awt.BorderLayout()); + m_jContEntries.add(m_jPanEntriesE, java.awt.BorderLayout.LINE_END); + + m_jPanContainer.add(m_jContEntries, java.awt.BorderLayout.LINE_END); + + catcontainer.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + catcontainer.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + catcontainer.setLayout(new java.awt.BorderLayout()); + m_jPanContainer.add(catcontainer, java.awt.BorderLayout.SOUTH); + + add(m_jPanContainer, "ticket"); + }// </editor-fold>//GEN-END:initComponents + + private void m_jbtnScaleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnScaleActionPerformed + + stateTransition('\u00a7'); + + }//GEN-LAST:event_m_jbtnScaleActionPerformed + + private void m_jEditLineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jEditLineActionPerformed + + count = (int) m_oTicket.getArticlesCount(); // get existing line value + + int i = m_ticketlines.getSelectedIndex(); + + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); // no line selected + } else { + try { + TicketLineInfo newline = JProductLineEdit.showMessage(this, m_App, m_oTicket.getLine(i)); + if (newline != null) { + paintTicketLine(i, newline); + } + + } catch (BasicException e) { + new MessageInf(e).show(this); + } + } + + }//GEN-LAST:event_m_jEditLineActionPerformed + + private void m_jEnterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jEnterActionPerformed + + stateTransition('\n'); + + }//GEN-LAST:event_m_jEnterActionPerformed + + private void m_jNumberKeysKeyPerformed(com.unicenta.beans.JNumberEvent evt) {//GEN-FIRST:event_m_jNumberKeysKeyPerformed + + stateTransition(evt.getKey()); + + j_btnRemotePrt.setEnabled(true); + j_btnRemotePrt.revalidate(); + + }//GEN-LAST:event_m_jNumberKeysKeyPerformed + + private void m_jKeyFactoryKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_m_jKeyFactoryKeyTyped + + m_jKeyFactory.setText(null); + + stateTransition(evt.getKeyChar()); + + }//GEN-LAST:event_m_jKeyFactoryKeyTyped + + private void m_jDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jDeleteActionPerformed + int i = m_ticketlines.getSelectedIndex(); + if (m_App.getProperties().getProperty("override.check").equals("true")) { + pinOK = false; + if (changeCount(pinOK)) { + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + removeTicketLine(i); + jCheckStock.setText(""); + } + } + } else { + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + removeTicketLine(i); + jCheckStock.setText(""); + } + } + }//GEN-LAST:event_m_jDeleteActionPerformed + + private void m_jListActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jListActionPerformed + + ProductInfoExt prod = JProductFinder.showMessage(JPanelTicket.this, dlSales); + if (prod != null) { + buttonTransition(prod); + } + + }//GEN-LAST:event_m_jListActionPerformed + + private void jEditAttributesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jEditAttributesActionPerformed + if (listener != null) { + listener.stop(); + } + int i = m_ticketlines.getSelectedIndex(); + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); // no line selected + } else { + try { + TicketLineInfo line = m_oTicket.getLine(i); + JProductAttEdit2 attedit = JProductAttEdit2.getAttributesEditor(this, m_App.getSession()); + attedit.editAttributes(line.getProductAttSetId(), line.getProductAttSetInstId()); + attedit.setVisible(true); + if (attedit.isOK()) { + line.setProductAttSetInstId(attedit.getAttributeSetInst()); + line.setProductAttSetInstDesc(attedit.getAttributeSetInstDescription()); + paintTicketLine(i, line); + } + } catch (BasicException ex) { + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.cannotfindattributes"), + AppLocal.getIntString("message.title"), + JOptionPane.INFORMATION_MESSAGE); + } + } + + if (listener != null) { + listener.restart(); + } + }//GEN-LAST:event_jEditAttributesActionPerformed + + private void jbtnMooringActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnMooringActionPerformed +// Display vessel selection box on screen if reply is good add to the ticket + if (listener != null) { + listener.stop(); + } + JMooringDetails mooring = JMooringDetails.getMooringDetails(this, m_App.getSession()); + mooring.setVisible(true); + if (mooring.isCreate()) { + if (((mooring.getVesselDays() > 0)) && ((mooring.getVesselSize() > 1))) { + try { + ProductInfoExt vProduct = dlSales.getProductInfoByCode("BFeesDay1"); + vProduct.setName("Berth Fees 1st Day " + mooring.getVesselName()); + addTicketLine(vProduct, mooring.getVesselSize(), vProduct.getPriceSell()); + + if (mooring.getVesselDays() > 1) { + vProduct = dlSales.getProductInfoByCode("BFeesDay2"); + vProduct.setName("Additional Days " + (mooring.getVesselDays() - 1)); + addTicketLine(vProduct, mooring.getVesselSize() * (mooring.getVesselDays() - 1), vProduct.getPriceSell()); + } + + if (mooring.getVesselPower()) { + vProduct = dlSales.getProductInfoByCode("PowerSupplied"); + addTicketLine(vProduct, mooring.getVesselDays(), vProduct.getPriceSell()); + } + } catch (BasicException e) { + } + } + } + refreshTicket(); + }//GEN-LAST:event_jbtnMooringActionPerformed + + private void j_btnRemotePrtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_j_btnRemotePrtActionPerformed + + String rScript = (dlSystem.getResourceAsText("script.SendOrder")); + + Interpreter i = new Interpreter(); + try { + i.set("ticket", m_oTicket); + i.set("place", m_oTicketExt); + i.set("user", m_App.getAppUserView().getUser()); + i.set("sales", this); + i.set("pickupid", m_oTicket.getPickupId()); + + Object result; + result = i.eval(rScript); + + } catch (EvalError ex) { + log.error(ex.getMessage()); + } + + remoteOrderDisplay(); + + }//GEN-LAST:event_j_btnRemotePrtActionPerformed + + private void btnReprint1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReprint1ActionPerformed + if (m_config.getProperty("lastticket.number") != null) { + try { + TicketInfo ticket = dlSales.loadTicket( + Integer.parseInt((m_config.getProperty("lastticket.type"))), + Integer.parseInt((m_config.getProperty("lastticket.number")))); + if (ticket == null) { + JFrame frame = new JFrame(); + JOptionPane.showMessageDialog(frame, + AppLocal.getIntString("message.notexiststicket"), + AppLocal.getIntString("message.notexiststickettitle"), + JOptionPane.WARNING_MESSAGE); + } else { + m_ticket = ticket; + m_ticketCopy = null; + try { + taxeslogic.calculateTaxes(m_ticket); + TicketTaxInfo[] taxlist = m_ticket.getTaxLines(); + } catch (TaxesException ex) { + } + printTicket("Printer.ReprintTicket", m_ticket, null); + Notify("'Printed'"); + } + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadticket"), e); + msg.show(this); + } + } + }//GEN-LAST:event_btnReprint1ActionPerformed + + private void btnSplitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSplitActionPerformed + + if (m_oTicket.getLinesCount() > 0) { + ReceiptSplit splitdialog = ReceiptSplit.getDialog(this, + dlSystem.getResourceAsXML("Ticket.Line"), dlSales, dlCustomers, taxeslogic); + + TicketInfo ticket1 = m_oTicket.copyTicket(); + TicketInfo ticket2 = new TicketInfo(); + ticket2.setCustomer(m_oTicket.getCustomer()); + + if (splitdialog.showDialog(ticket1, ticket2, m_oTicketExt)) { + if (closeTicket(ticket2, m_oTicketExt)) { // already checked that number of lines > 0 + setActiveTicket(ticket1, m_oTicketExt);// set result ticket + } + } + } + + }//GEN-LAST:event_btnSplitActionPerformed + + private void jCheckStockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckStockActionPerformed + + if (listener != null) { + listener.stop(); + } + + int i = m_ticketlines.getSelectedIndex(); + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + try { + TicketLineInfo line = m_oTicket.getLine(i); + String pId = line.getProductID(); + String location = m_App.getInventoryLocation(); + ProductStock checkProduct; + checkProduct = dlSales.getProductStockState(pId, location); + + if (checkProduct != null) { + + if (checkProduct.getUnits() <= 0) { + jCheckStock.setForeground(Color.magenta); + } else { + jCheckStock.setForeground(Color.darkGray); + } + + String content; + + if (!location.equals(checkProduct.getLocation())) { + content = AppLocal.getIntString("message.location.current"); + JFrame frame = new JFrame(); + JOptionPane.showMessageDialog(frame, + content, + "Info", + JOptionPane.INFORMATION_MESSAGE); + } else { + double dUnits = checkProduct.getUnits(); + int iUnits; + iUnits = (int) dUnits; + + jCheckStock.setText(Integer.toString(iUnits)); + } + + } else { + jCheckStock.setText(null); + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + if (listener != null) { + listener.restart(); + } + }//GEN-LAST:event_jCheckStockActionPerformed + + private void jCheckStockMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jCheckStockMouseClicked + if (evt.getClickCount() == 2) { + if (listener != null) { + listener.stop(); + } + + int i = m_ticketlines.getSelectedIndex(); + if (i < 0) { + Toolkit.getDefaultToolkit().beep(); + } else { + try { + TicketLineInfo line = m_oTicket.getLine(i); + String pId = line.getProductID(); + String location = m_App.getInventoryLocation(); + ProductStock checkProduct; + checkProduct = dlSales.getProductStockState(pId, location); + + Double pMin; + Double pMax; + Double pUnits; + Date pMemoDate; + String content; + + if (!location.equals(checkProduct.getLocation())) { + content = AppLocal.getIntString("message.location.current"); + JFrame frame = new JFrame(); + JOptionPane.showMessageDialog(frame, + content, + "Info", + JOptionPane.INFORMATION_MESSAGE); + } else { + if (checkProduct.getMinimum() != null) { + pMin = checkProduct.getMinimum(); + } else { + pMin = 0.; + } + if (checkProduct.getMaximum() != null) { + pMax = checkProduct.getMaximum(); + } else { + pMax = 0.; + } + if (checkProduct.getUnits() != null) { + pUnits = checkProduct.getUnits(); + } else { + pUnits = 0.; + } + if (checkProduct.getMemoDate() != null) { + pMemoDate = checkProduct.getMemoDate(); + } else { + pMemoDate = null; + } + + content = "<html>" + + "<b>" + AppLocal.getIntString("label.currentstock") + + " : " + "</b>" + checkProduct.getUnits() + "<br>" + + "<b>" + AppLocal.getIntString("label.maximum") + + " : " + "</b>" + pMax + "<br>" + + "<b>" + AppLocal.getIntString("label.minimum") + + " : " + "</b>" + pMin + "<br>" + + "<b>" + AppLocal.getIntString("label.proddate") + + " : " + "</b>" + pMemoDate + "<br>"; + + JFrame frame = new JFrame(); + JOptionPane.showMessageDialog(frame, + content, + "Info", + JOptionPane.INFORMATION_MESSAGE); + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + if (listener != null) { + listener.restart(); + } + } + }//GEN-LAST:event_jCheckStockMouseClicked + + private void m_jaddtaxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jaddtaxActionPerformed + m_jKeyFactory.requestFocus(); + }//GEN-LAST:event_m_jaddtaxActionPerformed + + private void jTBtnShowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTBtnShowActionPerformed + if (jTBtnShow.isSelected()) { + m_jPanelScripts.setVisible(true); + m_jButtonsExt.setVisible(true); + } else { + m_jPanelScripts.setVisible(false); + m_jButtonsExt.setVisible(false); + } + refreshTicket(); + m_jKeyFactory.requestFocus(); + }//GEN-LAST:event_jTBtnShowActionPerformed + + private void jBtnCustomerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnCustomerActionPerformed + if (listener != null) { + listener.stop(); + } + Object[] options = {"Create", "Find", "Cancel"}; + + int n = JOptionPane.showOptionDialog(null, + AppLocal.getIntString("message.customeradd"), + AppLocal.getIntString("label.customer"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE, + null, + options, + options[2]); + + if (n == 0) { + JDialogNewCustomer dialog = JDialogNewCustomer.getDialog(this, m_App); + dialog.setVisible(true); + + CustomerInfoExt m_customerInfo = dialog.getSelectedCustomer(); + if (dialog.getSelectedCustomer() != null) { + try { + m_oTicket.setCustomer(dlSales.loadCustomerExt + (dialog.getSelectedCustomer().getId())); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + } + + if (n == 1) { + JCustomerFinder finder = JCustomerFinder.getCustomerFinder(this, dlCustomers); + + if (m_oTicket.getCustomerId() == null) { + finder.setAppView(m_App); + finder.search(m_oTicket.getCustomer()); + finder.executeSearch(); + finder.setVisible(true); + + if (finder.getSelectedCustomer() != null) { + try { + m_oTicket.setCustomer(dlSales.loadCustomerExt + (finder.getSelectedCustomer().getId())); + if ("restaurant".equals(m_App.getProperties().getProperty("machine.ticketsbag"))) { + restDB.setCustomerNameInTableByTicketId(dlSales.loadCustomerExt + (finder.getSelectedCustomer().getId()).toString(), m_oTicket.getId()); + } + + checkCustomer(); + + m_jTicketId.setText(m_oTicket.getName(m_oTicketExt)); + + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotfindcustomer"), e); + msg.show(this); + } + } else { + restDB.setCustomerNameInTableByTicketId(null, m_oTicket.getId()); + m_oTicket.setCustomer(null); + Notify("notify.customerremove"); + } + + } else { + if (JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.customerchange"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { + + finder.setAppView(m_App); + finder.search(m_oTicket.getCustomer()); + finder.executeSearch(); + finder.setVisible(true); + + if (finder.getSelectedCustomer() != null) { + try { + m_oTicket.setCustomer(dlSales.loadCustomerExt + (finder.getSelectedCustomer().getId())); + if ("restaurant".equals(m_App.getProperties().getProperty("machine.ticketsbag"))) { + restDB.setCustomerNameInTableByTicketId(dlSales.loadCustomerExt + (finder.getSelectedCustomer().getId()).toString(), m_oTicket.getId()); + } + + checkCustomer(); + + m_jTicketId.setText(m_oTicket.getName()); + + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotfindcustomer"), e); + msg.show(this); + } + } else { + restDB.setCustomerNameInTableByTicketId(null, m_oTicket.getId()); + m_oTicket.setCustomer(null); + } + } + } + } + + refreshTicket(); + + }//GEN-LAST:event_jBtnCustomerActionPerformed + + private void m_jPanContainerFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_m_jPanContainerFocusLost + jPanContainerFocusLost(evt); + }//GEN-LAST:event_m_jPanContainerFocusLost + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnReprint1; + private javax.swing.JButton btnSplit; + private javax.swing.JPanel catcontainer; + private javax.swing.Box.Filler filler2; + private javax.swing.JButton jBtnCustomer; + private javax.swing.JButton jCheckStock; + private javax.swing.JButton jEditAttributes; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel9; + private javax.swing.JToggleButton jTBtnShow; + private javax.swing.JButton j_btnRemotePrt; + private javax.swing.JButton jbtnMooring; + private javax.swing.JPanel m_jButtons; + private javax.swing.JPanel m_jButtonsExt; + private javax.swing.JPanel m_jContEntries; + private javax.swing.JButton m_jDelete; + private javax.swing.JButton m_jEditLine; + private javax.swing.JButton m_jEnter; + private javax.swing.JTextField m_jKeyFactory; + private javax.swing.JLabel m_jLblTotalEuros1; + private javax.swing.JLabel m_jLblTotalEuros2; + private javax.swing.JLabel m_jLblTotalEuros3; + private javax.swing.JButton m_jList; + private com.unicenta.beans.JNumberKeys m_jNumberKeys; + private javax.swing.JPanel m_jOptions; + private javax.swing.JPanel m_jPanContainer; + private javax.swing.JPanel m_jPanEntries; + private javax.swing.JPanel m_jPanEntriesE; + private javax.swing.JPanel m_jPanTicket; + private javax.swing.JPanel m_jPanTotals; + private javax.swing.JPanel m_jPanelBag; + private javax.swing.JPanel m_jPanelCentral; + private javax.swing.JPanel m_jPanelScripts; + private javax.swing.JLabel m_jPor; + private javax.swing.JLabel m_jPrice; + private javax.swing.JLabel m_jSubtotalEuros; + private javax.swing.JComboBox m_jTax; + private javax.swing.JLabel m_jTaxesEuros; + private javax.swing.JLabel m_jTicketId; + private javax.swing.JLabel m_jTotalEuros; + private com.alee.extended.button.WebSwitch m_jaddtax; + private javax.swing.JButton m_jbtnScale; + // End of variables declaration//GEN-END:variables + +/* Remote Orders Display + We only know about uniCenta oPOS orders and won't try and handle any + that are injected from an external source +*/ + + public void remoteOrderDisplay() { + remoteOrderDisplay(remoteOrderId(), 1, true); + } + + public void remoteOrderDisplay(String id) { + remoteOrderDisplay(id, 1, true); + } + + public void remoteOrderDisplay(Integer display) { + remoteOrderDisplay(remoteOrderId(), display, false); + } + + public String remoteOrderId() { + + String id = ""; + + if ((m_oTicket.getCustomer() != null)) { + return m_oTicket.getCustomer().getName(); + } else if (m_oTicketExt != null) { + return m_oTicketExt.toString(); + } else { + if (m_oTicket.getPickupId() == 0) { + try { + m_oTicket.setPickupId(dlSales.getNextPickupIndex()); + } catch (BasicException e) { + m_oTicket.setPickupId(0); + } + } + + return getPickupString(m_oTicket); + } + } + + public void remoteOrderDisplay(String id, Integer display, boolean primary) { + + try { + // may use later if/when external order injection + // String orderUUID = UUID.randomUUID().toString(); + + dlSystem.deleteOrder(id); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + + for (int i = 0; i < m_oTicket.getLinesCount(); i++) { + try { + if (primary) { + if ((m_oTicket.getLine(i).getProperty("display") == null) + || ("".equals(m_oTicket.getLine(i).getProperty("display")))) { + display = 1; + } else { + display = Integer.parseInt(m_oTicket.getLine(i).getProperty("display")); + } + } + + dlSystem.addOrder(getPickupString(m_oTicket) + , (int) m_oTicket.getLine(i).getMultiply() + , m_oTicket.getLine(i).getProductName() + , m_oTicket.getLine(i).getProductAttSetInstDesc() + , m_oTicket.getLine(i).getProperty("notes") + , id + , null + , display + , null + , null); + +/* this block for future - right now we're deleting all ticketlines + and resending for consistency with actual ticketlines + dlSystem.updateOrder(getPickupString(m_oTicket) + , (int) m_oTicket.getLine(i).getMultiply() + , m_oTicket.getLine(i).getProductName() + , m_oTicket.getLine(i).getProductAttSetInstDesc() + , m_oTicket.getLine(i).getProperty("notes") + , id + , null + , display + , null + , null); +*/ + + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + } + +} diff --git a/src/main/java/com/unicenta/pos/sales/JPanelTicketEdits.java b/src/main/java/com/unicenta/pos/sales/JPanelTicketEdits.java new file mode 100644 index 0000000..31516cf --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JPanelTicketEdits.java @@ -0,0 +1,126 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + + +package com.unicenta.pos.sales; + +import com.unicenta.basic.BasicException; +import com.unicenta.pos.ticket.ProductInfoExt; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + + +/** + * + * @author JG uniCenta + */ +public class JPanelTicketEdits extends JPanelTicket { + + private JTicketCatalogLines m_catandlines; + + /** Creates a new instance of JPanelTicketRefunds */ + public JPanelTicketEdits() { + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return null; + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + super.activate(); + m_catandlines.loadCatalog(); + } + + public void reLoadCatalog(){ + } + + /** + * + */ + public void showCatalog() { + m_jbtnconfig.setVisible(true); + m_catandlines.showCatalog(); + } + + /** + * + * @param aRefundLines + */ + public void showRefundLines(List aRefundLines) { + // anado las lineas de refund + // m_reflines.setLines(aRefundLines); + m_jbtnconfig.setVisible(false); + m_catandlines.showRefundLines(aRefundLines); + } + + /** + * + * @return + */ + @Override + protected JTicketsBag getJTicketsBag() { + return new JTicketsBagTicket(m_App, this); + } + + /** + * + * @return + */ + @Override + protected Component getSouthComponent() { + + m_catandlines = new JTicketCatalogLines(m_App, this, + "true".equals(m_jbtnconfig.getProperty("pricevisible")), + "true".equals(m_jbtnconfig.getProperty("taxesincluded")), + Integer.parseInt(m_jbtnconfig.getProperty("img-width", "64")), + Integer.parseInt(m_jbtnconfig.getProperty("img-height", "54"))); + m_catandlines.setPreferredSize(new Dimension(0, + Integer.parseInt(m_jbtnconfig.getProperty("cat-height", "245")))); + m_catandlines.addActionListener(new CatalogListener()); + return m_catandlines; + } + + /** + * + */ + @Override + protected void resetSouthComponent() { + } + + private class CatalogListener implements ActionListener { + @Override + public void actionPerformed(ActionEvent e) { + buttonTransition((ProductInfoExt) e.getSource()); + } + } + +} diff --git a/src/main/java/com/unicenta/pos/sales/JPanelTicketSales.java b/src/main/java/com/unicenta/pos/sales/JPanelTicketSales.java new file mode 100644 index 0000000..4bf2af0 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JPanelTicketSales.java @@ -0,0 +1,150 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; +import com.unicenta.basic.BasicException; +import com.unicenta.pos.catalog.CatalogSelector; +import com.unicenta.pos.catalog.JCatalog; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.ticket.ProductInfoExt; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +/** + * + * @author JG uniCenta + */ +public class JPanelTicketSales extends JPanelTicket { + + private CatalogSelector m_cat; + + /** Creates a new instance of JPanelTicketSales */ + public JPanelTicketSales() { + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + super.init(app); + m_ticketlines.addListSelectionListener(new CatalogSelectionListener()); + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return null; + } + + /** + * + * @return + */ + @Override + protected Component getSouthComponent() { + m_cat = new JCatalog(dlSales, + "true".equals(m_jbtnconfig.getProperty("pricevisible")), + "true".equals(m_jbtnconfig.getProperty("taxesincluded")), + Integer.parseInt(m_jbtnconfig.getProperty("img-width", "64")), + Integer.parseInt(m_jbtnconfig.getProperty("img-height", "54"))); + // Integer.parseInt(m_jbtnconfig.getProperty("img-width", "32")), + // Integer.parseInt(m_jbtnconfig.getProperty("img-height", "32"))); + m_cat.addActionListener(new CatalogListener()); + m_cat.getComponent().setPreferredSize(new Dimension( + 0, + Integer.parseInt(m_jbtnconfig.getProperty("cat-height", "245")))); + return m_cat.getComponent(); + } + + /** + * + */ + @Override + protected void resetSouthComponent() { + m_cat.showCatalogPanel(null); + } + + /** + * + * @return + */ + @Override + protected JTicketsBag getJTicketsBag() { + return JTicketsBag.createTicketsBag(m_App.getProperties().getProperty("machine.ticketsbag"), m_App, this); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + super.activate(); + m_cat.loadCatalog(); + } + + public void reLoadCatalog() { + try { + m_cat.loadCatalog(); + } catch (BasicException ex) { + } + + } + + private class CatalogListener implements ActionListener { + @Override + public void actionPerformed(ActionEvent e) { + buttonTransition((ProductInfoExt) e.getSource()); + } + } + + private class CatalogSelectionListener implements ListSelectionListener { + @Override + public void valueChanged(ListSelectionEvent e) { + + if (!e.getValueIsAdjusting()) { + int i = m_ticketlines.getSelectedIndex(); + + if (i >= 0) { + // Look for the first non auxiliar product. + while (i >= 0 && m_oTicket.getLine(i).isProductCom()) { + i--; + } + + // Show the accurate catalog panel... + if (i >= 0) { + m_cat.showCatalogPanel(m_oTicket.getLine(i).getProductID()); + } else { + m_cat.showCatalogPanel(null); + } + } + } + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/sales/JProductAttEdit.form b/src/main/java/com/unicenta/pos/sales/JProductAttEdit.form new file mode 100644 index 0000000..fbed0be --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductAttEdit.form @@ -0,0 +1,149 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-124,0,0,2,-110"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="3"/> + </Layout> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Last"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="2"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jButtonCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jButtonOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JProductAttEdit.java b/src/main/java/com/unicenta/pos/sales/JProductAttEdit.java new file mode 100644 index 0000000..efb1a0f --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductAttEdit.java @@ -0,0 +1,426 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.*; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.inventory.AttributeSetInfo; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/** + * @author adrianromero + */ +@Slf4j +public class JProductAttEdit extends javax.swing.JDialog { + + private SentenceFind attsetSent; + private SentenceList attvaluesSent; + private SentenceList attinstSent; + private SentenceList attinstSent2; + private SentenceFind attsetinstExistsSent; + + private SentenceExec attsetSave; + private SentenceExec attinstSave; + + private List<JProductAttEditI> itemslist; + private String attsetid; + private String attInstanceId; + private String attInstanceDescription; + + private boolean ok; + + /** + * Creates new form JProductAttEdit + */ + private JProductAttEdit(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + + /** + * Creates new form JProductAttEdit + */ + private JProductAttEdit(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + private void init(Session s) { + + initComponents(); + + attsetSave = new PreparedSentence(s, + "INSERT INTO attributesetinstance (ID, ATTRIBUTESET_ID, DESCRIPTION) VALUES (?, ?, ?)", + new SerializerWriteBasic(Datas.STRING, Datas.STRING, Datas.STRING)); + attinstSave = new PreparedSentence(s, + "INSERT INTO attributeinstance(ID, ATTRIBUTESETINSTANCE_ID, ATTRIBUTE_ID, VALUE) VALUES (?, ?, ?, ?)", + new SerializerWriteBasic(Datas.STRING, Datas.STRING, Datas.STRING, Datas.STRING)); + + attsetSent = new PreparedSentence(s, + "SELECT ID, NAME FROM attributeset WHERE ID = ?", + SerializerWriteString.INSTANCE, + new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + return new AttributeSetInfo(dr.getString(1), dr.getString(2)); + } + }); + attsetinstExistsSent = new PreparedSentence(s, + "SELECT ID FROM attributesetinstance WHERE ATTRIBUTESET_ID = ? AND DESCRIPTION = ?", + new SerializerWriteBasic(Datas.STRING, Datas.STRING), + SerializerReadString.INSTANCE); + + attinstSent = new PreparedSentence(s, "SELECT A.ID, A.NAME, " + s.DB.CHAR_NULL() + ", " + s.DB.CHAR_NULL() + " " + + "FROM attributeuse AU JOIN attribute A ON AU.ATTRIBUTE_ID = A.ID " + + "WHERE AU.ATTRIBUTESET_ID = ? " + + "ORDER BY AU.LINENO", + SerializerWriteString.INSTANCE, + new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + return new AttributeInstInfo(dr.getString(1), dr.getString(2), dr.getString(3), dr.getString(4)); + } + }); + attinstSent2 = new PreparedSentence(s, "SELECT A.ID, A.NAME, AI.ID, AI.VALUE " + + "FROM attributeuse AU JOIN attribute A ON AU.ATTRIBUTE_ID = A.ID LEFT OUTER JOIN attributeinstance AI ON AI.ATTRIBUTE_ID = A.ID " + + "WHERE AU.ATTRIBUTESET_ID = ? AND AI.ATTRIBUTESETINSTANCE_ID = ?" + + "ORDER BY AU.LINENO", + new SerializerWriteBasic(Datas.STRING, Datas.STRING), + new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + return new AttributeInstInfo(dr.getString(1), dr.getString(2), dr.getString(3), dr.getString(4)); + } + }); + attvaluesSent = new PreparedSentence(s, "SELECT VALUE FROM attributevalue WHERE ATTRIBUTE_ID = ? ORDER BY VALUE", + SerializerWriteString.INSTANCE, + SerializerReadString.INSTANCE); + + getRootPane().setDefaultButton(m_jButtonOK); + } + + /** + * @param parent + * @param s + * @return + */ + public static JProductAttEdit getAttributesEditor(Component parent, Session s) { + + Window window = SwingUtilities.getWindowAncestor(parent); + + JProductAttEdit myMsg; + if (window instanceof Frame) { + myMsg = new JProductAttEdit((Frame) window, true); + } else { + myMsg = new JProductAttEdit((Dialog) window, true); + } + myMsg.init(s); + myMsg.applyComponentOrientation(parent.getComponentOrientation()); + return myMsg; + } + + /** + * @param attsetid + * @param attsetinstid + * @throws BasicException + */ + public void editAttributes(String attsetid, String attsetinstid) throws BasicException { + + if (attsetid == null) { +// throw new BasicException(AppLocal.getIntString("message.attsetnotexists")); + throw new BasicException(AppLocal.getIntString("message.cannotfindattributes")); + } else { + + this.attsetid = attsetid; + this.attInstanceId = null; + this.attInstanceDescription = null; + + this.ok = false; + + // get attsetinst values + AttributeSetInfo asi = (AttributeSetInfo) attsetSent.find(attsetid); + + if (asi == null) { +// throw new BasicException(AppLocal.getIntString("message.attsetnotexists")); + throw new BasicException(AppLocal.getIntString("message.cannotfindattributes")); + } + + setTitle(asi.getName()); + + List<AttributeInstInfo> attinstinfo = attsetinstid == null + ? attinstSent.list(attsetid) + : attinstSent2.list(attsetid, attsetinstid); + + itemslist = new ArrayList<>(); + + for (AttributeInstInfo aii : attinstinfo) { + + JProductAttEditI item; + + List<String> values = attvaluesSent.list(aii.getAttid()); + if (values.isEmpty()) { + // Does not exist a list of values then a textfield + item = new JProductAttEditItem(aii.getAttid(), aii.getAttname(), aii.getValue(), m_jKeys); + } else { + // Does exist a list with the values + item = new JProductAttListItem(aii.getAttid(), aii.getAttname(), aii.getValue(), values); + } + + itemslist.add(item); + jPanel2.add(item.getComponent()); + } + + if (itemslist.size() > 0) { + itemslist.get(0).assignSelection(); + } + } + } + + /** + * @return + */ + public boolean isOK() { + return ok; + } + + /** + * @return + */ + public String getAttributeSetInst() { + return attInstanceId; + } + + /** + * @return + */ + public String getAttributeSetInstDescription() { + return attInstanceDescription; + } + + private static class AttributeInstInfo { + + private String attid; + private String attname; + private String id; + private String value; + + public AttributeInstInfo(String attid, String attname, String id, String value) { + this.attid = attid; + this.attname = attname; + this.id = id; + this.value = value; + } + + /** + * @return the attid + */ + public String getAttid() { + return attid; + } + + /** + * @return the attname + */ + public String getAttname() { + return attname; + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return the value + */ + public String getValue() { + return value; + } + + /** + * @param value the value to set + */ + public void setValue(String value) { + this.value = value; + } + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel5 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + jPanel3 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel1 = new javax.swing.JPanel(); + m_jButtonCancel = new javax.swing.JButton(); + m_jButtonOK = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + jPanel5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel5.setLayout(new java.awt.BorderLayout()); + + jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.PAGE_AXIS)); + jPanel5.add(jPanel2, java.awt.BorderLayout.NORTH); + + getContentPane().add(jPanel5, java.awt.BorderLayout.CENTER); + + jPanel3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel3.setLayout(new java.awt.BorderLayout()); + + jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS)); + jPanel4.add(m_jKeys); + + jPanel3.add(jPanel4, java.awt.BorderLayout.NORTH); + + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + m_jButtonCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + m_jButtonCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N + m_jButtonCancel.setFocusPainted(false); + m_jButtonCancel.setFocusable(false); + m_jButtonCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jButtonCancel.setRequestFocusEnabled(false); + m_jButtonCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonCancelActionPerformed(evt); + } + }); + jPanel1.add(m_jButtonCancel); + + m_jButtonOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + m_jButtonOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + m_jButtonOK.setFocusPainted(false); + m_jButtonOK.setFocusable(false); + m_jButtonOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonOK.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jButtonOK.setRequestFocusEnabled(false); + m_jButtonOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonOKActionPerformed(evt); + } + }); + jPanel1.add(m_jButtonOK); + + jPanel3.add(jPanel1, java.awt.BorderLayout.PAGE_END); + + getContentPane().add(jPanel3, java.awt.BorderLayout.EAST); + + setSize(new java.awt.Dimension(658, 388)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void m_jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonOKActionPerformed + + StringBuilder description = new StringBuilder(); + for (JProductAttEditI item : itemslist) { + String value = item.getValue(); + if (value != null && value.length() > 0) { + if (description.length() > 0) { + description.append(", "); + } + description.append(value); + } + } + + String id; + + if (description.length() == 0) { + // No values then id is null + id = null; + } else { + // Some values then an instance should exists. + try { + // Exist an attribute set instance with these values for the attributeset selected + id = (String) attsetinstExistsSent.find(attsetid, description.toString()); + } catch (BasicException ex) { + log.error(ex.getMessage()); + return; + } + + + if (id == null) { + // No, create a new ATTRIBUTESETINSTANCE and return the ID generated + // or return null... That means that that product does not exists.... + // Maybe these two modes must be supported one for selection and other for creation.... + id = UUID.randomUUID().toString(); + try { + attsetSave.exec(id, attsetid, description.toString()); + for (JProductAttEditI item : itemslist) { + attinstSave.exec(UUID.randomUUID().toString(), id, item.getAttribute(), item.getValue()); + } + + } catch (BasicException ex) { + log.error(ex.getMessage()); + return; + } + } + } + + ok = true; + attInstanceId = id; + attInstanceDescription = description.toString(); + + dispose(); + }//GEN-LAST:event_m_jButtonOKActionPerformed + + private void m_jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonCancelActionPerformed + + dispose(); + }//GEN-LAST:event_m_jButtonCancelActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JButton m_jButtonCancel; + private javax.swing.JButton m_jButtonOK; + private com.unicenta.editor.JEditorKeys m_jKeys; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/JProductAttEdit1.form b/src/main/java/com/unicenta/pos/sales/JProductAttEdit1.form new file mode 100644 index 0000000..fbed0be --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductAttEdit1.form @@ -0,0 +1,149 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-124,0,0,2,-110"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="3"/> + </Layout> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Last"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="2"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jButtonCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jButtonOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JProductAttEdit1.java b/src/main/java/com/unicenta/pos/sales/JProductAttEdit1.java new file mode 100644 index 0000000..09ddfe7 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductAttEdit1.java @@ -0,0 +1,427 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.*; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.inventory.AttributeSetInfo; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/** + * @author adrianromero + */ +@Slf4j +public class JProductAttEdit1 extends javax.swing.JDialog { + + private SentenceFind attsetSent; + private SentenceList attvaluesSent; + private SentenceList attinstSent; + private SentenceList attinstSent2; + private SentenceFind attsetinstExistsSent; + + private SentenceExec attsetSave; + private SentenceExec attinstSave; + + private List<JProductAttEditI> itemslist; + private String attsetid; + private String attInstanceId; + private String attInstanceDescription; + + private boolean ok; + + /** + * Creates new form JProductAttEdit + */ + private JProductAttEdit1(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + + /** + * Creates new form JProductAttEdit + */ + private JProductAttEdit1(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + private void init(Session s) { + + initComponents(); + + attsetSave = new PreparedSentence(s, + "INSERT INTO attributesetinstance (ID, ATTRIBUTESET_ID, DESCRIPTION) VALUES (?, ?, ?)", + new SerializerWriteBasic(Datas.STRING, Datas.STRING, Datas.STRING)); + attinstSave = new PreparedSentence(s, + "INSERT INTO attributeinstance(ID, ATTRIBUTESETINSTANCE_ID, ATTRIBUTE_ID, VALUE) VALUES (?, ?, ?, ?)", + new SerializerWriteBasic(Datas.STRING, Datas.STRING, Datas.STRING, Datas.STRING)); + + attsetSent = new PreparedSentence(s, + "SELECT ID, NAME FROM attributeset WHERE ID = ?", + SerializerWriteString.INSTANCE, + new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + return new AttributeSetInfo(dr.getString(1), dr.getString(2)); + } + }); + attsetinstExistsSent = new PreparedSentence(s, + "SELECT ID FROM attributesetinstance WHERE ATTRIBUTESET_ID = ? AND DESCRIPTION = ?", + new SerializerWriteBasic(Datas.STRING, Datas.STRING), + SerializerReadString.INSTANCE); + + attinstSent = new PreparedSentence(s, "SELECT A.ID, A.NAME, " + s.DB.CHAR_NULL() + ", " + s.DB.CHAR_NULL() + " " + + "FROM attributeuse AU JOIN ATTRIBUTE A ON AU.ATTRIBUTE_ID = A.ID " + + "WHERE AU.ATTRIBUTESET_ID = ? " + + "ORDER BY AU.LINENO", + SerializerWriteString.INSTANCE, + new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + return new AttributeInstInfo(dr.getString(1), dr.getString(2), dr.getString(3), dr.getString(4)); + } + }); + attinstSent2 = new PreparedSentence(s, "SELECT A.ID, A.NAME, AI.ID, AI.VALUE " + + "FROM attributeuse AU JOIN ATTRIBUTE A ON AU.ATTRIBUTE_ID = A.ID LEFT OUTER JOIN attributeinstance AI ON AI.ATTRIBUTE_ID = A.ID " + + "WHERE AU.ATTRIBUTESET_ID = ? AND AI.ATTRIBUTESETINSTANCE_ID = ?" + + "ORDER BY AU.LINENO", + new SerializerWriteBasic(Datas.STRING, Datas.STRING), + new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + return new AttributeInstInfo(dr.getString(1), dr.getString(2), dr.getString(3), dr.getString(4)); + } + }); + attvaluesSent = new PreparedSentence(s, "SELECT VALUE FROM attributevalue WHERE ATTRIBUTE_ID = ? ORDER BY VALUE", + SerializerWriteString.INSTANCE, + SerializerReadString.INSTANCE); + + getRootPane().setDefaultButton(m_jButtonOK); + } + + /** + * @param parent + * @param s + * @return + */ + public static JProductAttEdit1 getAttributesEditor(Component parent, Session s) { + + Window window = SwingUtilities.getWindowAncestor(parent); + + JProductAttEdit1 myMsg; + if (window instanceof Frame) { + myMsg = new JProductAttEdit1((Frame) window, true); + } else { + myMsg = new JProductAttEdit1((Dialog) window, true); + } + myMsg.init(s); + myMsg.applyComponentOrientation(parent.getComponentOrientation()); + return myMsg; + } + + /** + * @param attsetid + * @param attsetinstid + * @throws BasicException + */ + public void editAttributes(String attsetid, String attsetinstid) throws BasicException { + + if (attsetid == null) { +// throw new BasicException(AppLocal.getIntString("message.attsetnotexists")); + throw new BasicException(AppLocal.getIntString("message.cannotfindattributes")); + } else { + + this.attsetid = attsetid; + this.attInstanceId = null; + this.attInstanceDescription = null; + + this.ok = false; + + // get attsetinst values + AttributeSetInfo asi = (AttributeSetInfo) attsetSent.find(attsetid); + + if (asi == null) { +// throw new BasicException(AppLocal.getIntString("message.attsetnotexists")); + throw new BasicException(AppLocal.getIntString("message.cannotfindattributes")); + } + + setTitle(asi.getName()); + + List<AttributeInstInfo> attinstinfo = attsetinstid == null + ? attinstSent.list(attsetid) + : attinstSent2.list(attsetid, attsetinstid); + + itemslist = new ArrayList<>(); + + for (AttributeInstInfo aii : attinstinfo) { + + JProductAttEditI item; + + List<String> values = attvaluesSent.list(aii.getAttid()); + if (values.isEmpty()) { + // Does not exist a list of values then a textfield + item = new JProductAttEditItem(aii.getAttid(), aii.getAttname(), aii.getValue(), m_jKeys); + } else { + // Does exist a list with the values + item = new JProductAttListItem(aii.getAttid(), aii.getAttname(), aii.getValue(), values); + } + + itemslist.add(item); + jPanel2.add(item.getComponent()); + } + + if (itemslist.size() > 0) { + itemslist.get(0).assignSelection(); + } + } + } + + /** + * @return + */ + public boolean isOK() { + return ok; + } + + /** + * @return + */ + public String getAttributeSetInst() { + return attInstanceId; + } + + /** + * @return + */ + public String getAttributeSetInstDescription() { + return attInstanceDescription; + } + + private static class AttributeInstInfo { + + private String attid; + private String attname; + private String id; + private String value; + + public AttributeInstInfo(String attid, String attname, String id, String value) { + this.attid = attid; + this.attname = attname; + this.id = id; + this.value = value; + } + + /** + * @return the attid + */ + public String getAttid() { + return attid; + } + + /** + * @return the attname + */ + public String getAttname() { + return attname; + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return the value + */ + public String getValue() { + return value; + } + + /** + * @param value the value to set + */ + public void setValue(String value) { + this.value = value; + } + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel5 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + jPanel3 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel1 = new javax.swing.JPanel(); + m_jButtonCancel = new javax.swing.JButton(); + m_jButtonOK = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + jPanel5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel5.setLayout(new java.awt.BorderLayout()); + + jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.PAGE_AXIS)); + jPanel5.add(jPanel2, java.awt.BorderLayout.NORTH); + + getContentPane().add(jPanel5, java.awt.BorderLayout.CENTER); + + jPanel3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel3.setLayout(new java.awt.BorderLayout()); + + jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS)); + jPanel4.add(m_jKeys); + + jPanel3.add(jPanel4, java.awt.BorderLayout.NORTH); + + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + m_jButtonCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + m_jButtonCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N + m_jButtonCancel.setFocusPainted(false); + m_jButtonCancel.setFocusable(false); + m_jButtonCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jButtonCancel.setRequestFocusEnabled(false); + m_jButtonCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonCancelActionPerformed(evt); + } + }); + jPanel1.add(m_jButtonCancel); + + m_jButtonOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + m_jButtonOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + m_jButtonOK.setFocusPainted(false); + m_jButtonOK.setFocusable(false); + m_jButtonOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonOK.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jButtonOK.setRequestFocusEnabled(false); + m_jButtonOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonOKActionPerformed(evt); + } + }); + jPanel1.add(m_jButtonOK); + + jPanel3.add(jPanel1, java.awt.BorderLayout.PAGE_END); + + getContentPane().add(jPanel3, java.awt.BorderLayout.EAST); + + setSize(new java.awt.Dimension(658, 388)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void m_jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonOKActionPerformed + + StringBuilder description = new StringBuilder(); + for (JProductAttEditI item : itemslist) { + String value = item.getValue(); + if (value != null && value.length() > 0) { + if (description.length() > 0) { + description.append(", "); + } + description.append(value); + } + } + + + String id; + + if (description.length() == 0) { + // No values then id is null + id = null; + } else { + // Some values then an instance should exists. + try { + // Exist an attribute set instance with these values for the attributeset selected + id = (String) attsetinstExistsSent.find(attsetid, description.toString()); + } catch (BasicException ex) { + log.error(ex.getMessage()); + return; + } + + + if (id == null) { + // No, create a new ATTRIBUTESETINSTANCE and return the ID generated + // or return null... That means that that product does not exists.... + // Maybe these two modes must be supported one for selection and other for creation.... + id = UUID.randomUUID().toString(); + try { + attsetSave.exec(id, attsetid, description.toString()); + for (JProductAttEditI item : itemslist) { + attinstSave.exec(UUID.randomUUID().toString(), id, item.getAttribute(), item.getValue()); + } + + } catch (BasicException ex) { + log.error(ex.getMessage()); + return; + } + } + } + + ok = true; + attInstanceId = id; + attInstanceDescription = description.toString(); + + dispose(); + }//GEN-LAST:event_m_jButtonOKActionPerformed + + private void m_jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonCancelActionPerformed + + dispose(); + }//GEN-LAST:event_m_jButtonCancelActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JButton m_jButtonCancel; + private javax.swing.JButton m_jButtonOK; + private com.unicenta.editor.JEditorKeys m_jKeys; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/JProductAttEdit2.form b/src/main/java/com/unicenta/pos/sales/JProductAttEdit2.form new file mode 100644 index 0000000..c92e874 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductAttEdit2.form @@ -0,0 +1,152 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 250]"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-124,0,0,2,-112"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="3"/> + </Layout> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Last"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="2"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jButtonCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jButtonOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JProductAttEdit2.java b/src/main/java/com/unicenta/pos/sales/JProductAttEdit2.java new file mode 100644 index 0000000..39d5099 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductAttEdit2.java @@ -0,0 +1,426 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.PreparedSentence; +import com.unicenta.data.loader.SentenceExec; +import com.unicenta.data.loader.SentenceFind; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.SerializerRead; +import com.unicenta.data.loader.SerializerReadString; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.data.loader.SerializerWriteString; +import com.unicenta.data.loader.Session; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.inventory.AttributeSetInfo; +import lombok.extern.slf4j.Slf4j; + +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Window; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import javax.swing.SwingUtilities; + +/** + * @author adrianromero + */ +@Slf4j +public class JProductAttEdit2 extends javax.swing.JDialog { + + private SentenceFind attsetSent; + private SentenceList attvaluesSent; + private SentenceList attinstSent; + private SentenceList attinstSent2; + private SentenceFind attsetinstExistsSent; + + private SentenceExec attsetSave; + private SentenceExec attinstSave; + + private List<JProductAttEditI> itemslist; + private String attsetid; + private String attInstanceId; + private String attInstanceDescription; + + private boolean ok; + + /** + * Creates new form JProductAttEdit + */ + private JProductAttEdit2(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + + /** + * Creates new form JProductAttEdit + */ + private JProductAttEdit2(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + private void init(Session s) { + + initComponents(); + + attsetSave = new PreparedSentence(s, + "INSERT INTO attributesetinstance (ID, ATTRIBUTESET_ID, DESCRIPTION) VALUES (?, ?, ?)", + new SerializerWriteBasic(Datas.STRING, Datas.STRING, Datas.STRING)); + attinstSave = new PreparedSentence(s, + "INSERT INTO attributeinstance(ID, ATTRIBUTESETINSTANCE_ID, ATTRIBUTE_ID, VALUE) VALUES (?, ?, ?, ?)", + new SerializerWriteBasic(Datas.STRING, Datas.STRING, Datas.STRING, Datas.STRING)); + + attsetSent = new PreparedSentence(s, + "SELECT ID, NAME FROM attributeset WHERE ID = ?", + SerializerWriteString.INSTANCE, + (DataRead dr) -> new AttributeSetInfo(dr.getString(1), dr.getString(2))); + attsetinstExistsSent = new PreparedSentence(s, +// "SELECT ID FROM attributesetinstance WHERE ATTRIBUTESET_ID = ? AND DESCRIPTION = ?", + "SELECT ID, DESCRIPTION FROM attributesetinstance WHERE ATTRIBUTESET_ID = ? AND DESCRIPTION = ?", + new SerializerWriteBasic(Datas.STRING, Datas.STRING), + SerializerReadString.INSTANCE); + + attinstSent = new PreparedSentence(s, "SELECT A.ID, A.NAME, " + s.DB.CHAR_NULL() + ", " + s.DB.CHAR_NULL() + " " + + "FROM attributeuse AU JOIN attribute A ON AU.ATTRIBUTE_ID = A.ID " + + "WHERE AU.ATTRIBUTESET_ID = ? " + + "ORDER BY AU.LINENO", + SerializerWriteString.INSTANCE, + (DataRead dr) -> new AttributeInstInfo(dr.getString(1), dr.getString(2), dr.getString(3), dr.getString(4))); + attinstSent2 = new PreparedSentence(s, "SELECT A.ID, A.NAME, AI.ID, AI.VALUE " + + "FROM attributeuse AU JOIN attribute A ON AU.ATTRIBUTE_ID = A.ID LEFT OUTER JOIN attributeinstance AI ON AI.ATTRIBUTE_ID = A.ID " + + "WHERE AU.ATTRIBUTESET_ID = ? AND AI.ATTRIBUTESETINSTANCE_ID = ?" + + "ORDER BY AU.LINENO", + new SerializerWriteBasic(Datas.STRING, Datas.STRING), + (DataRead dr) -> new AttributeInstInfo(dr.getString(1), dr.getString(2), dr.getString(3), dr.getString(4))); + attvaluesSent = new PreparedSentence(s, "SELECT VALUE FROM attributevalue WHERE ATTRIBUTE_ID = ? ORDER BY VALUE", + SerializerWriteString.INSTANCE, + SerializerReadString.INSTANCE); + + getRootPane().setDefaultButton(m_jButtonOK); + } + + /** + * @param parent + * @param s + * @return + */ + public static JProductAttEdit2 getAttributesEditor(Component parent, Session s) { + + Window window = SwingUtilities.getWindowAncestor(parent); + + JProductAttEdit2 myMsg; + if (window instanceof Frame) { + myMsg = new JProductAttEdit2((Frame) window, true); + } else { + myMsg = new JProductAttEdit2((Dialog) window, true); + } + myMsg.init(s); + myMsg.applyComponentOrientation(parent.getComponentOrientation()); + return myMsg; + } + + /** + * @param attsetid + * @param attsetinstid + * @throws BasicException + */ + public void editAttributes(String attsetid, String attsetinstid) throws BasicException { + + if (attsetid == null) { +// throw new BasicException(AppLocal.getIntString("message.attsetnotexists")); + throw new BasicException(AppLocal.getIntString("message.cannotfindattributes")); + } else { + + this.attsetid = attsetid; + this.attInstanceId = null; + this.attInstanceDescription = null; + + this.ok = false; + + // get attsetinst values + AttributeSetInfo asi = (AttributeSetInfo) attsetSent.find(attsetid); + + if (asi == null) { +// throw new BasicException(AppLocal.getIntString("message.attsetnotexists")); + throw new BasicException(AppLocal.getIntString("message.cannotfindattributes")); + } + + setTitle(asi.getName()); + + List<AttributeInstInfo> attinstinfo = attsetinstid == null + ? attinstSent.list(attsetid) + : attinstSent2.list(attsetid, attsetinstid); + + itemslist = new ArrayList<>(); + + for (AttributeInstInfo aii : attinstinfo) { + + JProductAttEditI item; + + List<String> values = attvaluesSent.list(aii.getAttid()); + if (values.isEmpty()) { + // Does not exist a list of values then a textfield + item = new JProductAttEditItem(aii.getAttid(), aii.getAttname(), aii.getValue(), m_jKeys); + } else { + // Does exist a list with the values + item = new JProductAttListItem(aii.getAttid(), aii.getAttname(), aii.getValue(), values); + } + + itemslist.add(item); + jPanel2.add(item.getComponent()); + } + + if (itemslist.size() > 0) { + itemslist.get(0).assignSelection(); + } + } + } + + /** + * @return + */ + public boolean isOK() { + return ok; + } + + /** + * @return + */ + public String getAttributeSetInst() { + return attInstanceId; + } + + /** + * @return + */ + public String getAttributeSetInstDescription() { + return attInstanceDescription; + } + + private static class AttributeInstInfo { + + private final String attid; + private final String attname; + private String id; + private String value; + + public AttributeInstInfo(String attid, String attname, String id, String value) { + this.attid = attid; + this.attname = attname; + this.id = id; + this.value = value; + } + + /** + * @return the attid + */ + public String getAttid() { + return attid; + } + + /** + * @return the attname + */ + public String getAttname() { + return attname; + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return the value + */ + public String getValue() { + return value; + } + + /** + * @param value the value to set + */ + public void setValue(String value) { + this.value = value; + } + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel5 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + jPanel3 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel1 = new javax.swing.JPanel(); + m_jButtonCancel = new javax.swing.JButton(); + m_jButtonOK = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setPreferredSize(new java.awt.Dimension(300, 250)); + + jPanel5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel5.setLayout(new java.awt.BorderLayout()); + + jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.PAGE_AXIS)); + jPanel5.add(jPanel2, java.awt.BorderLayout.NORTH); + + getContentPane().add(jPanel5, java.awt.BorderLayout.CENTER); + + jPanel3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel3.setLayout(new java.awt.BorderLayout()); + + jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS)); + jPanel4.add(m_jKeys); + + jPanel3.add(jPanel4, java.awt.BorderLayout.NORTH); + + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + m_jButtonCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + m_jButtonCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N + m_jButtonCancel.setFocusPainted(false); + m_jButtonCancel.setFocusable(false); + m_jButtonCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jButtonCancel.setRequestFocusEnabled(false); + m_jButtonCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonCancelActionPerformed(evt); + } + }); + jPanel1.add(m_jButtonCancel); + + m_jButtonOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + m_jButtonOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + m_jButtonOK.setFocusPainted(false); + m_jButtonOK.setFocusable(false); + m_jButtonOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonOK.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jButtonOK.setRequestFocusEnabled(false); + m_jButtonOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonOKActionPerformed(evt); + } + }); + jPanel1.add(m_jButtonOK); + + jPanel3.add(jPanel1, java.awt.BorderLayout.PAGE_END); + + getContentPane().add(jPanel3, java.awt.BorderLayout.EAST); + + setSize(new java.awt.Dimension(656, 388)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void m_jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonOKActionPerformed + + StringBuilder description = new StringBuilder(); + itemslist.stream().map((item) -> item.getValue()) + .filter((value) -> (value != null && value.length() > 0)) + .forEach((value) -> { + if (description.length() > 0) { + description.append(", "); + } + description.append(value); + }); + + String id; + + if (description.length() == 0) { + id = null; + } else { + + try { + + id = (String) attsetinstExistsSent.find(attsetid, description.toString()); + + } catch (BasicException ex) { + return; + } + + if (id == null) { +// if (id == null ? (String.valueOf(description)) != null : !id.equals(String.valueOf(description))) { + // Now creates a new ATTRIBUTESETINSTANCE and returns the ID generated + // to allow for ad-hoc user input i.e.: Serial No + + id = UUID.randomUUID().toString(); + + try { + attsetSave.exec(id, attsetid, description.toString()); + + for (JProductAttEditI item : itemslist) { + attinstSave.exec(UUID.randomUUID().toString(), id, item.getAttribute(), item.getValue()); + } + + } catch (BasicException ex) { + log.error(ex.getMessage()); + return; + } + } + } + + ok = true; + attInstanceId = id; + attInstanceDescription = description.toString(); + + dispose(); + }//GEN-LAST:event_m_jButtonOKActionPerformed + + private void m_jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonCancelActionPerformed + + dispose(); + }//GEN-LAST:event_m_jButtonCancelActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JButton m_jButtonCancel; + private javax.swing.JButton m_jButtonOK; + private com.unicenta.editor.JEditorKeys m_jKeys; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/JProductAttEditI.java b/src/main/java/com/unicenta/pos/sales/JProductAttEditI.java new file mode 100644 index 0000000..9137942 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductAttEditI.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import java.awt.Component; + +/** + * + * @author adrianromero + */ +public interface JProductAttEditI { + + /** + * + * @return + */ + public String getAttribute(); + + /** + * + * @return + */ + public String getValue(); + + /** + * + * @return + */ + public Component getComponent(); + + /** + * + */ + public void assignSelection(); +} diff --git a/src/main/java/com/unicenta/pos/sales/JProductAttEditItem.form b/src/main/java/com/unicenta/pos/sales/JProductAttEditItem.form new file mode 100644 index 0000000..afe6b9f --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductAttEditItem.form @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jValue" min="-2" pref="224" max="-2" attributes="0"/> + <EmptySpace pref="56" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="jLabel1" alignment="1" max="32767" attributes="1"/> + <Component id="jValue" alignment="1" max="32767" attributes="1"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="jLabel1"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="jValue"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JProductAttEditItem.java b/src/main/java/com/unicenta/pos/sales/JProductAttEditItem.java new file mode 100644 index 0000000..ee953d3 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductAttEditItem.java @@ -0,0 +1,129 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.editor.JEditorKeys; +import java.awt.Component; + +/** + * + * @author adrian + */ +public class JProductAttEditItem extends javax.swing.JPanel implements JProductAttEditI { + + private String attid; + + /** Creates new form JProductAttEditItem + * @param attid + * @param label + * @param value + * @param keys */ + public JProductAttEditItem(String attid, String label, String value, JEditorKeys keys) { + + this.attid = attid; + + initComponents(); + + jLabel1.setText(label); + + jValue.addEditorKeys(keys); + jValue.setText(value); + } + + /** + * + */ + public void assignSelection() { + jValue.activate(); + } + + /** + * + * @return + */ + public String getAttribute() { + return attid; + } + + /** + * + * @return + */ + public String getValue() { + return jValue.getText(); + } + + /** + * + * @return + */ + public Component getComponent() { + return this; + } + + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jValue = new com.unicenta.editor.JEditorString(); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText("jLabel1"); + jLabel1.setPreferredSize(new java.awt.Dimension(110, 30)); + + jValue.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jValue.setPreferredSize(new java.awt.Dimension(0, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jValue, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(56, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jValue, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + ); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private com.unicenta.editor.JEditorString jValue; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/JProductAttListItem.form b/src/main/java/com/unicenta/pos/sales/JProductAttListItem.form new file mode 100644 index 0000000..5dcf4f3 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductAttListItem.form @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jValues" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="66" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="1"/> + <Component id="jValues" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="jLabel1"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jValues"> + <Properties> + <Property name="editable" type="boolean" value="true"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jValuesActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JProductAttListItem.java b/src/main/java/com/unicenta/pos/sales/JProductAttListItem.java new file mode 100644 index 0000000..9cf7a17 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductAttListItem.java @@ -0,0 +1,151 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.data.gui.ComboBoxValModel; +import java.awt.Component; +import java.util.List; + +/** + * @author JG + * @author adrian + */ +public class JProductAttListItem extends javax.swing.JPanel implements JProductAttEditI { + + private final String attid; + private ComboBoxValModel model; + + /** Creates new form JProductAttListItem + * @param attid + * @param label + * @param value + * @param values */ + public JProductAttListItem(String attid, String label, String value, List<String> values) { + + this.attid = attid; + + initComponents(); + + jLabel1.setText(label); + + values.stream().forEach((item) -> { + jValues.addItem(item); + }); + jValues.setSelectedItem(value); + } + + /** + * + */ + @Override + public void assignSelection() { + java.awt.EventQueue.invokeLater(() -> { + jValues.requestFocus(); + }); + } + + /** + * + * @return + */ + @Override + public String getAttribute() { + return attid; + } + + /** + * + * @return + */ + @Override + public String getValue() { + if (jValues.getSelectedItem() == null) { + return (String) jValues.getEditor().getItem(); + } else { + return (String) jValues.getSelectedItem(); + } + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jValues = new javax.swing.JComboBox(); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText("jLabel1"); + jLabel1.setPreferredSize(new java.awt.Dimension(110, 30)); + + jValues.setEditable(true); + jValues.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jValues.setPreferredSize(new java.awt.Dimension(200, 30)); + jValues.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jValuesActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jValues, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(66, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jValues, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jValuesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jValuesActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jValuesActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JComboBox jValues; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/JProductLineEdit.form b/src/main/java/com/unicenta/pos/sales/JProductLineEdit.form new file mode 100644 index 0000000..9bcfb02 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductLineEdit.form @@ -0,0 +1,492 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.editline" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[650, 350]"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-118,0,0,2,-60"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 230]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="10" pref="10" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jUnits" min="-2" pref="100" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jPriceTax" min="-2" pref="150" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jPrice" min="-2" pref="150" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel7" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jSubtotal" min="-2" pref="120" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="116" max="-2" attributes="0"/> + <Component id="m_jTaxrate" min="-2" pref="120" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jBtnPriceUpdate" min="-2" max="-2" attributes="0"/> + <Component id="m_jTotal" min="-2" pref="120" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jName" min="-2" pref="354" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace min="-2" pref="60" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jName" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <Component id="m_jUnits" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jPrice" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <Component id="m_jPriceTax" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" pref="9" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="1" pref="1" max="-2" attributes="0"/> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Component id="m_jTaxrate" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel7" min="-2" max="-2" attributes="0"/> + <Component id="m_jSubtotal" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jTotal" min="-2" max="-2" attributes="0"/> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace pref="19" max="32767" attributes="0"/> + <Component id="m_jBtnPriceUpdate" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.price" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.units" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.pricetax" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[132, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorDouble" name="m_jUnits"> + <Properties> + <Property name="enabled" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[132, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorCurrency" name="m_jPrice"> + <Properties> + <Property name="enabled" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[132, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorCurrency" name="m_jPriceTax"> + <Properties> + <Property name="enabled" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[132, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jTaxrate"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="e4" green="eb" id="TextField.disabledBackground" palette="3" red="eb" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 25]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.tax" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.totalcash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jTotal"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="e4" green="eb" id="TextField.disabledBackground" palette="3" red="eb" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 25]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.subtotalcash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jSubtotal"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="e4" green="eb" id="TextField.disabledBackground" palette="3" red="eb" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 25]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="m_jBtnPriceUpdate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/filesave.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.priceupdate" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBtnPriceUpdateActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jKeysActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="2"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jButtonCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jButtonOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JProductLineEdit.java b/src/main/java/com/unicenta/pos/sales/JProductLineEdit.java new file mode 100644 index 0000000..a009f59 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductLineEdit.java @@ -0,0 +1,566 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Session; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.ticket.TicketLineInfo; +import com.unicenta.pos.util.AltEncrypter; + +import javax.swing.*; +import java.awt.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +/** + * + * @author adrianromero + */ +public class JProductLineEdit extends javax.swing.JDialog { + + private TicketLineInfo returnLine; + private TicketLineInfo m_oLine; + private boolean m_bunitsok; + private boolean m_bpriceok; + private String productID; + private Session s; + private Connection con; + private String SQL; + private PreparedStatement pstmt; + + /** Creates new form JProductLineEdit */ + private JProductLineEdit(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + /** Creates new form JProductLineEdit */ + private JProductLineEdit(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + private TicketLineInfo init(AppView app, TicketLineInfo oLine) throws BasicException { + + initComponents(); + + productID = oLine.getProductID(); + + if (oLine.getTaxInfo() == null) { + throw new BasicException(AppLocal.getIntString("message.cannotcalculatetaxes")); + } + + if (!productID.equals("xxx999_999xxx_x9x9x9")) { + m_jBtnPriceUpdate.setVisible(AppConfig.getInstance().getBoolean("db.prodpriceupdate")); + }else{ + m_jBtnPriceUpdate.setVisible(false); + } + + m_jBtnPriceUpdate.setEnabled(false); + + m_oLine = new TicketLineInfo(oLine); + m_bunitsok = true; + m_bpriceok = true; + +// m_jName.setEnabled(app.getAppUserView().getUser().hasPermission("com.unicenta.pos.sales.JPanelTicketEdits")); + m_jUnits.setEnabled(app.getAppUserView().getUser().hasPermission("com.unicenta.pos.sales.JPanelTicketEdits")); + m_jPrice.setEnabled(app.getAppUserView().getUser().hasPermission("com.unicenta.pos.sales.JPanelTicketEdits")); + m_jPriceTax.setEnabled(app.getAppUserView().getUser().hasPermission("com.unicenta.pos.sales.JPanelTicketEdits")); + + m_jName.setText(oLine.getProductName()); + m_jUnits.setDoubleValue(oLine.getMultiply()); + m_jPrice.setDoubleValue(oLine.getPrice()); + m_jPriceTax.setDoubleValue(oLine.getPriceTax()); + m_jTaxrate.setText(oLine.getTaxInfo().getName()); + + m_jName.addPropertyChangeListener("Edition", new RecalculateName()); + m_jUnits.addPropertyChangeListener("Edition", new RecalculateUnits()); + m_jPrice.addPropertyChangeListener("Edition", new RecalculatePrice()); + m_jPriceTax.addPropertyChangeListener("Edition", new RecalculatePriceTax()); + + m_jName.addEditorKeys(m_jKeys); + m_jUnits.addEditorKeys(m_jKeys); + m_jPrice.addEditorKeys(m_jKeys); + m_jPriceTax.addEditorKeys(m_jKeys); + + if (m_jName.isEnabled()) { + m_jName.activate(); + } else { + m_jUnits.activate(); + } + + printTotals(); + + getRootPane().setDefaultButton(m_jButtonOK); + returnLine = null; + setVisible(true); + + return returnLine; + } + + private void printTotals() { + + if (m_bunitsok && m_bpriceok) { + m_jSubtotal.setText(m_oLine.printSubValue()); + m_jTotal.setText(m_oLine.printValue()); + m_jButtonOK.setEnabled(true); + } else { + m_jSubtotal.setText(null); + m_jTotal.setText(null); + m_jButtonOK.setEnabled(false); + } + } + + private class RecalculateUnits implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Double value = m_jUnits.getDoubleValue(); + if (value == null || value == 0.0) { + m_bunitsok = false; + } else { + m_oLine.setMultiply(value); + m_bunitsok = true; + } + + printTotals(); + } + } + + private class RecalculatePrice implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + + Double value = m_jPrice.getDoubleValue(); + if (value == null || value == 0.0) { + m_bpriceok = false; + } else { + m_oLine.setPrice(value); + m_jPriceTax.setDoubleValue(m_oLine.getPriceTax()); + m_bpriceok = true; + m_jBtnPriceUpdate.setEnabled(AppConfig.getInstance().getBoolean("db.prodpriceupdate")); + } + + printTotals(); + } + } + + private class RecalculatePriceTax implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + + Double value = m_jPriceTax.getDoubleValue(); + if (value == null || value == 0.0) { + m_bpriceok = false; + } else { + m_oLine.setPriceTax(value); + m_jPrice.setDoubleValue(m_oLine.getPrice()); + m_bpriceok = true; + m_jBtnPriceUpdate.setEnabled(AppConfig.getInstance().getBoolean("db.prodpriceupdate")); + } + + printTotals(); + } + } + + private class RecalculateName implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + m_oLine.setProperty("product.name", m_jName.getText()); + } + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window)parent; + } else { + return getWindow(parent.getParent()); + } + } + + /** + * + * @param parent + * @param app + * @param oLine + * @return + * @throws BasicException + */ + public static TicketLineInfo showMessage(Component parent + , AppView app + , TicketLineInfo oLine) throws BasicException { + + Window window = getWindow(parent); + + JProductLineEdit myMsg; + if (window instanceof Frame) { + myMsg = new JProductLineEdit((Frame) window, true); + } else { + myMsg = new JProductLineEdit((Dialog) window, true); + } + return myMsg.init(app, oLine); + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel5 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + m_jName = new com.unicenta.editor.JEditorString(); + m_jUnits = new com.unicenta.editor.JEditorDouble(); + m_jPrice = new com.unicenta.editor.JEditorCurrency(); + m_jPriceTax = new com.unicenta.editor.JEditorCurrency(); + m_jTaxrate = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + m_jTotal = new javax.swing.JLabel(); + jLabel7 = new javax.swing.JLabel(); + m_jSubtotal = new javax.swing.JLabel(); + m_jBtnPriceUpdate = new javax.swing.JButton(); + jPanel3 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel1 = new javax.swing.JPanel(); + m_jButtonCancel = new javax.swing.JButton(); + m_jButtonOK = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("label.editline")); // NOI18N + setPreferredSize(new java.awt.Dimension(650, 350)); + + jPanel5.setLayout(new java.awt.BorderLayout()); + + jPanel2.setPreferredSize(new java.awt.Dimension(400, 230)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.price")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.units")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.pricetax")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(132, 30)); + + m_jUnits.setEnabled(false); + m_jUnits.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jUnits.setPreferredSize(new java.awt.Dimension(132, 30)); + + m_jPrice.setEnabled(false); + m_jPrice.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPrice.setPreferredSize(new java.awt.Dimension(132, 30)); + + m_jPriceTax.setEnabled(false); + m_jPriceTax.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceTax.setPreferredSize(new java.awt.Dimension(132, 30)); + + m_jTaxrate.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.disabledBackground")); + m_jTaxrate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jTaxrate.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jTaxrate.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jTaxrate.setOpaque(true); + m_jTaxrate.setPreferredSize(new java.awt.Dimension(150, 25)); + m_jTaxrate.setRequestFocusEnabled(false); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.tax")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.totalcash")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jTotal.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.disabledBackground")); + m_jTotal.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jTotal.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jTotal.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jTotal.setOpaque(true); + m_jTotal.setPreferredSize(new java.awt.Dimension(150, 25)); + m_jTotal.setRequestFocusEnabled(false); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.subtotalcash")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jSubtotal.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.disabledBackground")); + m_jSubtotal.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jSubtotal.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jSubtotal.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jSubtotal.setOpaque(true); + m_jSubtotal.setPreferredSize(new java.awt.Dimension(150, 25)); + m_jSubtotal.setRequestFocusEnabled(false); + + m_jBtnPriceUpdate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jBtnPriceUpdate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/filesave.png"))); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + m_jBtnPriceUpdate.setText(bundle.getString("button.priceupdate")); // NOI18N + m_jBtnPriceUpdate.setFocusPainted(false); + m_jBtnPriceUpdate.setFocusable(false); + m_jBtnPriceUpdate.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jBtnPriceUpdate.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jBtnPriceUpdate.setRequestFocusEnabled(false); + m_jBtnPriceUpdate.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBtnPriceUpdateActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(10, 10, 10) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jUnits, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPriceTax, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPrice, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jSubtotal, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(116, 116, 116) + .addComponent(m_jTaxrate, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jBtnPriceUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, 354, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(60, 60, 60)) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jUnits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jPrice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jPriceTax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(9, 9, 9) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(1, 1, 1) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addComponent(m_jTaxrate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSubtotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE) + .addComponent(m_jBtnPriceUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + jPanel5.add(jPanel2, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel5, java.awt.BorderLayout.CENTER); + + jPanel3.setLayout(new java.awt.BorderLayout()); + + jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS)); + + m_jKeys.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jKeysActionPerformed(evt); + } + }); + jPanel4.add(m_jKeys); + + jPanel3.add(jPanel4, java.awt.BorderLayout.NORTH); + + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + m_jButtonCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + m_jButtonCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N + m_jButtonCancel.setFocusPainted(false); + m_jButtonCancel.setFocusable(false); + m_jButtonCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jButtonCancel.setRequestFocusEnabled(false); + m_jButtonCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonCancelActionPerformed(evt); + } + }); + jPanel1.add(m_jButtonCancel); + + m_jButtonOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + m_jButtonOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + m_jButtonOK.setFocusPainted(false); + m_jButtonOK.setFocusable(false); + m_jButtonOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonOK.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jButtonOK.setRequestFocusEnabled(false); + m_jButtonOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonOKActionPerformed(evt); + } + }); + jPanel1.add(m_jButtonOK); + + jPanel3.add(jPanel1, java.awt.BorderLayout.SOUTH); + + getContentPane().add(jPanel3, java.awt.BorderLayout.EAST); + + setSize(new java.awt.Dimension(708, 394)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void m_jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_m_jButtonCancelActionPerformed + + private void m_jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonOKActionPerformed + + returnLine = m_oLine; + + dispose(); + + }//GEN-LAST:event_m_jButtonOKActionPerformed + + private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_m_jKeysActionPerformed + + private void m_jBtnPriceUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBtnPriceUpdateActionPerformed + + String db_password = (AppConfig.getInstance().getProperty("db.password")); + + if (AppConfig.getInstance().getProperty("db.user") != null + && db_password != null + && db_password.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + + AppConfig.getInstance().getProperty("db.user")); + db_password = cypher.decrypt(db_password.substring(6)); + } + + try { + +// s = AppViewConnection.createSession(); + con = DriverManager.getConnection( + AppConfig.getInstance().getProperty("db.URL") + + AppConfig.getInstance().getProperty("db.schema") + , AppConfig.getInstance().getProperty("db.user") + , db_password); + + pstmt = con.prepareStatement( + "UPDATE PRODUCTS SET PRICESELL = ? WHERE ID = ?"); + pstmt.setDouble(1, m_jPrice.getDoubleValue()); + pstmt.setString(2, productID); + System.out.println(pstmt); + + pstmt.executeUpdate(); + + m_jBtnPriceUpdate.setEnabled(false); + + con.close(); + + } catch (SQLException e) { + System.out.println(e); + + return; + } + + m_oLine.setUpdated(true); + }//GEN-LAST:event_m_jBtnPriceUpdateActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JButton m_jBtnPriceUpdate; + private javax.swing.JButton m_jButtonCancel; + private javax.swing.JButton m_jButtonOK; + private com.unicenta.editor.JEditorKeys m_jKeys; + private com.unicenta.editor.JEditorString m_jName; + private com.unicenta.editor.JEditorCurrency m_jPrice; + private com.unicenta.editor.JEditorCurrency m_jPriceTax; + private javax.swing.JLabel m_jSubtotal; + private javax.swing.JLabel m_jTaxrate; + private javax.swing.JLabel m_jTotal; + private com.unicenta.editor.JEditorDouble m_jUnits; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/JProductLineEditTax.form b/src/main/java/com/unicenta/pos/sales/JProductLineEditTax.form new file mode 100644 index 0000000..f5d9bff --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductLineEditTax.form @@ -0,0 +1,525 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.editline" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-118,0,0,2,-60"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 230]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="10" pref="10" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jUnits" min="-2" pref="100" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jPriceTax" min="-2" pref="150" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jPrice" min="-2" pref="150" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jName" min="-2" pref="240" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel7" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jSubtotal" min="-2" pref="120" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jBtnPriceUpdate" min="-2" max="-2" attributes="0"/> + <Component id="m_jTotal" min="-2" pref="120" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="116" max="-2" attributes="0"/> + <Component id="m_jTaxrateOld" min="-2" pref="120" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="m_jTaxrate" min="-2" pref="100" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + <EmptySpace min="-2" pref="60" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jName" min="-2" max="-2" attributes="0"/> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <Component id="m_jUnits" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jPrice" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <Component id="m_jPriceTax" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Group type="103" alignment="1" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="1" pref="1" max="-2" attributes="0"/> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Component id="m_jTaxrateOld" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Component id="m_jTaxrate" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="11" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel7" min="-2" max="-2" attributes="0"/> + <Component id="m_jSubtotal" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jTotal" min="-2" max="-2" attributes="0"/> + <Component id="jLabel6" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="32767" attributes="0"/> + <Component id="m_jBtnPriceUpdate" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.price" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.units" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.pricetax" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.item" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[132, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorDouble" name="m_jUnits"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[132, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorCurrency" name="m_jPrice"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[132, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorCurrency" name="m_jPriceTax"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[132, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jTaxrateOld"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="e4" green="eb" id="TextField.disabledBackground" palette="3" red="eb" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 25]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.tax" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.totalcash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jTotal"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="e4" green="eb" id="TextField.disabledBackground" palette="3" red="eb" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 25]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.subtotalcash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="m_jSubtotal"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="e4" green="eb" id="TextField.disabledBackground" palette="3" red="eb" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 25]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="m_jBtnPriceUpdate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/filesave.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.priceupdate" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBtnPriceUpdateActionPerformed"/> + </Events> + </Component> + <Component class="com.unicenta.editor.JEditorDouble" name="m_jTaxrate"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[132, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jKeysActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="2"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jButtonCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jButtonOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JProductLineEditTax.java b/src/main/java/com/unicenta/pos/sales/JProductLineEditTax.java new file mode 100644 index 0000000..da7d8a5 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JProductLineEditTax.java @@ -0,0 +1,584 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.Session; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.ticket.TicketLineInfo; +import com.unicenta.pos.util.AltEncrypter; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import java.awt.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +/** + * + * @author adrianromero + */ +@Slf4j +public class JProductLineEditTax extends javax.swing.JDialog { + + private TicketLineInfo returnLine; + private TicketLineInfo m_oLine; + private boolean m_bunitsok; + private boolean m_bpriceok; + private String productID; + private Session s; + private Connection con; + private String SQL; + private PreparedStatement pstmt; + + /** Creates new form JProductLineEdit */ + private JProductLineEditTax(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + /** Creates new form JProductLineEdit */ + private JProductLineEditTax(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + private TicketLineInfo init(AppView app, TicketLineInfo oLine) throws BasicException { + + initComponents(); + + productID = oLine.getProductID(); + + if (oLine.getTaxInfo() == null) { + throw new BasicException(AppLocal.getIntString("message.cannotcalculatetaxes")); + } + + if (!productID.equals("xxx999_999xxx_x9x9x9")) { + m_jBtnPriceUpdate.setVisible(AppConfig.getInstance().getBoolean("db.prodpriceupdate")); + }else{ + m_jBtnPriceUpdate.setVisible(false); + } + + m_jBtnPriceUpdate.setEnabled(false); + + m_oLine = new TicketLineInfo(oLine); + m_bunitsok = true; + m_bpriceok = true; + + m_jName.setEnabled(app.getAppUserView().getUser().hasPermission("com.unicenta.pos.sales.JPanelTicketEdits")); + m_jPrice.setEnabled(app.getAppUserView().getUser().hasPermission("com.unicenta.pos.sales.JPanelTicketEdits")); + m_jPriceTax.setEnabled(app.getAppUserView().getUser().hasPermission("com.unicenta.pos.sales.JPanelTicketEdits")); + + m_jName.setText(oLine.getProductName()); + m_jUnits.setDoubleValue(oLine.getMultiply()); + m_jPrice.setDoubleValue(oLine.getPrice()); + m_jPriceTax.setDoubleValue(oLine.getPriceTax()); + m_jTaxrateOld.setText(oLine.getTaxInfo().getName()); + m_jTaxrate.setDoubleValue(oLine.getTaxRate()); + + m_jName.addPropertyChangeListener("Edition", new RecalculateName()); + m_jUnits.addPropertyChangeListener("Edition", new RecalculateUnits()); + m_jPrice.addPropertyChangeListener("Edition", new RecalculatePrice()); + m_jPriceTax.addPropertyChangeListener("Edition", new RecalculatePriceTax()); + + m_jName.addEditorKeys(m_jKeys); + m_jUnits.addEditorKeys(m_jKeys); + m_jPrice.addEditorKeys(m_jKeys); + m_jPriceTax.addEditorKeys(m_jKeys); + m_jTaxrate.addEditorKeys(m_jKeys); + + if (m_jName.isEnabled()) { + m_jName.activate(); + } else { + m_jUnits.activate(); + } + + printTotals(); + + getRootPane().setDefaultButton(m_jButtonOK); + returnLine = null; + setVisible(true); + + return returnLine; + } + + private void printTotals() { + + if (m_bunitsok && m_bpriceok) { + m_jSubtotal.setText(m_oLine.printSubValue()); + m_jTotal.setText(m_oLine.printValue()); + m_jButtonOK.setEnabled(true); + } else { + m_jSubtotal.setText(null); + m_jTotal.setText(null); + m_jButtonOK.setEnabled(false); + } + } + + private class RecalculateUnits implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + Double value = m_jUnits.getDoubleValue(); + if (value == null || value == 0.0) { + m_bunitsok = false; + } else { + m_oLine.setMultiply(value); + m_bunitsok = true; + } + + printTotals(); + } + } + + private class RecalculatePrice implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + + Double value = m_jPrice.getDoubleValue(); + if (value == null || value == 0.0) { + m_bpriceok = false; + } else { + m_oLine.setPrice(value); + m_jPriceTax.setDoubleValue(m_oLine.getPriceTax()); + m_bpriceok = true; + m_jBtnPriceUpdate.setEnabled(AppConfig.getInstance().getBoolean("db.prodpriceupdate")); + } + + printTotals(); + } + } + + private class RecalculatePriceTax implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + + Double value = m_jPriceTax.getDoubleValue(); + if (value == null || value == 0.0) { + m_bpriceok = false; + } else { + m_oLine.setPriceTax(value); + m_jPrice.setDoubleValue(m_oLine.getPrice()); + m_bpriceok = true; + m_jBtnPriceUpdate.setEnabled(AppConfig.getInstance().getBoolean("db.prodpriceupdate")); + } + + printTotals(); + } + } + + private class RecalculateName implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + m_oLine.setProperty("product.name", m_jName.getText()); + } + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window)parent; + } else { + return getWindow(parent.getParent()); + } + } + + /** + * + * @param parent + * @param app + * @param oLine + * @return + * @throws BasicException + */ + public static TicketLineInfo showMessage(Component parent + , AppView app + , TicketLineInfo oLine) throws BasicException { + + Window window = getWindow(parent); + + JProductLineEditTax myMsg; + if (window instanceof Frame) { + myMsg = new JProductLineEditTax((Frame) window, true); + } else { + myMsg = new JProductLineEditTax((Dialog) window, true); + } + return myMsg.init(app, oLine); + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel5 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + m_jName = new com.unicenta.editor.JEditorString(); + m_jUnits = new com.unicenta.editor.JEditorDouble(); + m_jPrice = new com.unicenta.editor.JEditorCurrency(); + m_jPriceTax = new com.unicenta.editor.JEditorCurrency(); + m_jTaxrateOld = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + m_jTotal = new javax.swing.JLabel(); + jLabel7 = new javax.swing.JLabel(); + m_jSubtotal = new javax.swing.JLabel(); + m_jBtnPriceUpdate = new javax.swing.JButton(); + m_jTaxrate = new com.unicenta.editor.JEditorDouble(); + jPanel3 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel1 = new javax.swing.JPanel(); + m_jButtonCancel = new javax.swing.JButton(); + m_jButtonOK = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("label.editline")); // NOI18N + + jPanel5.setLayout(new java.awt.BorderLayout()); + + jPanel2.setPreferredSize(new java.awt.Dimension(400, 230)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.price")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.units")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.pricetax")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.item")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(132, 30)); + + m_jUnits.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jUnits.setPreferredSize(new java.awt.Dimension(132, 30)); + + m_jPrice.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPrice.setPreferredSize(new java.awt.Dimension(132, 30)); + + m_jPriceTax.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceTax.setPreferredSize(new java.awt.Dimension(132, 30)); + + m_jTaxrateOld.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.disabledBackground")); + m_jTaxrateOld.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jTaxrateOld.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jTaxrateOld.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jTaxrateOld.setOpaque(true); + m_jTaxrateOld.setPreferredSize(new java.awt.Dimension(150, 25)); + m_jTaxrateOld.setRequestFocusEnabled(false); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.tax")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.totalcash")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jTotal.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.disabledBackground")); + m_jTotal.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jTotal.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jTotal.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jTotal.setOpaque(true); + m_jTotal.setPreferredSize(new java.awt.Dimension(150, 25)); + m_jTotal.setRequestFocusEnabled(false); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.subtotalcash")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jSubtotal.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.disabledBackground")); + m_jSubtotal.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jSubtotal.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jSubtotal.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jSubtotal.setOpaque(true); + m_jSubtotal.setPreferredSize(new java.awt.Dimension(150, 25)); + m_jSubtotal.setRequestFocusEnabled(false); + + m_jBtnPriceUpdate.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jBtnPriceUpdate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/filesave.png"))); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + m_jBtnPriceUpdate.setText(bundle.getString("button.priceupdate")); // NOI18N + m_jBtnPriceUpdate.setFocusPainted(false); + m_jBtnPriceUpdate.setFocusable(false); + m_jBtnPriceUpdate.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jBtnPriceUpdate.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jBtnPriceUpdate.setRequestFocusEnabled(false); + m_jBtnPriceUpdate.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBtnPriceUpdateActionPerformed(evt); + } + }); + + m_jTaxrate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTaxrate.setPreferredSize(new java.awt.Dimension(132, 30)); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(10, 10, 10) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jUnits, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPriceTax, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPrice, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jSubtotal, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jBtnPriceUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(116, 116, 116) + .addComponent(m_jTaxrateOld, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(18, 18, 18) + .addComponent(m_jTaxrate, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addGap(60, 60, 60)) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jUnits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jPrice, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jPriceTax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(1, 1, 1) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addComponent(m_jTaxrateOld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(m_jTaxrate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(11, 11, 11))) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSubtotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(m_jBtnPriceUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + jPanel5.add(jPanel2, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel5, java.awt.BorderLayout.CENTER); + + jPanel3.setLayout(new java.awt.BorderLayout()); + + jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS)); + + m_jKeys.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jKeysActionPerformed(evt); + } + }); + jPanel4.add(m_jKeys); + + jPanel3.add(jPanel4, java.awt.BorderLayout.NORTH); + + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + m_jButtonCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + m_jButtonCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N + m_jButtonCancel.setFocusPainted(false); + m_jButtonCancel.setFocusable(false); + m_jButtonCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jButtonCancel.setRequestFocusEnabled(false); + m_jButtonCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonCancelActionPerformed(evt); + } + }); + jPanel1.add(m_jButtonCancel); + + m_jButtonOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + m_jButtonOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + m_jButtonOK.setFocusPainted(false); + m_jButtonOK.setFocusable(false); + m_jButtonOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonOK.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jButtonOK.setRequestFocusEnabled(false); + m_jButtonOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonOKActionPerformed(evt); + } + }); + jPanel1.add(m_jButtonOK); + + jPanel3.add(jPanel1, java.awt.BorderLayout.SOUTH); + + getContentPane().add(jPanel3, java.awt.BorderLayout.EAST); + + setSize(new java.awt.Dimension(708, 394)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void m_jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_m_jButtonCancelActionPerformed + + private void m_jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonOKActionPerformed + + returnLine = m_oLine; + + dispose(); + + }//GEN-LAST:event_m_jButtonOKActionPerformed + + private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_m_jKeysActionPerformed + + private void m_jBtnPriceUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBtnPriceUpdateActionPerformed + + String db_password = (AppConfig.getInstance().getProperty("db.password")); + + if (AppConfig.getInstance().getProperty("db.user") != null + && db_password != null + && db_password.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + + AppConfig.getInstance().getProperty("db.user")); + db_password = cypher.decrypt(db_password.substring(6)); + } + + try { + +// s = AppViewConnection.createSession(); + con = DriverManager.getConnection( + AppConfig.getInstance().getProperty("db.URL") + + AppConfig.getInstance().getProperty("db.schema") + , AppConfig.getInstance().getProperty("db.user") + , db_password); + + pstmt = con.prepareStatement( + "UPDATE PRODUCTS SET PRICESELL = ? WHERE ID = ?"); + pstmt.setDouble(1, m_jPrice.getDoubleValue()); + pstmt.setString(2, productID); + pstmt.executeUpdate(); + + m_jBtnPriceUpdate.setEnabled(false); + + con.close(); + + } catch (SQLException e) { + + return; + } + + m_oLine.setUpdated(true); + }//GEN-LAST:event_m_jBtnPriceUpdateActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JButton m_jBtnPriceUpdate; + private javax.swing.JButton m_jButtonCancel; + private javax.swing.JButton m_jButtonOK; + private com.unicenta.editor.JEditorKeys m_jKeys; + private com.unicenta.editor.JEditorString m_jName; + private com.unicenta.editor.JEditorCurrency m_jPrice; + private com.unicenta.editor.JEditorCurrency m_jPriceTax; + private javax.swing.JLabel m_jSubtotal; + private com.unicenta.editor.JEditorDouble m_jTaxrate; + private javax.swing.JLabel m_jTaxrateOld; + private javax.swing.JLabel m_jTotal; + private com.unicenta.editor.JEditorDouble m_jUnits; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/JRefundLines.form b/src/main/java/com/unicenta/pos/sales/JRefundLines.form new file mode 100644 index 0000000..6992b01 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JRefundLines.form @@ -0,0 +1,177 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[15, 200]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-31,0,0,1,103"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="West"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="5" right="0" top="0"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="webLabel1" min="-2" pref="110" max="-2" attributes="0"/> + <Component id="m_jbtnAddOne" min="-2" max="-2" attributes="0"/> + <Component id="m_jbtnAddLine" min="-2" max="-2" attributes="0"/> + <Component id="m_jbtnAddAll" min="-2" max="-2" attributes="0"/> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="1" pref="1" max="-2" attributes="0"/> + <Component id="webLabel1" min="-2" pref="52" max="-2" attributes="0"/> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Component id="m_jbtnAddOne" min="-2" max="-2" attributes="0"/> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Component id="m_jbtnAddLine" min="-2" max="-2" attributes="0"/> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Component id="m_jbtnAddAll" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="com.alee.laf.label.WebLabel" name="webLabel1"> + <Properties> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.refunds" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="1"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="m_jbtnAddOne"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.refundone" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.refunditem" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnAddOneActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jbtnAddLine"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.refundline" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.refundline" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnAddLineActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jbtnAddAll"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.refundall" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.refundticket" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnAddAllActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JRefundLines.java b/src/main/java/com/unicenta/pos/sales/JRefundLines.java new file mode 100644 index 0000000..23b0b2d --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JRefundLines.java @@ -0,0 +1,216 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSystem; +import com.unicenta.pos.ticket.TicketLineInfo; +import java.awt.BorderLayout; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public class JRefundLines extends javax.swing.JPanel { + + private JTicketLines ticketlines; + private List m_aLines; + + private JPanelTicketEdits m_jTicketEdit; + +/** Creates new form JRefundLines +* @param dlSystem +* @param jTicketEdit +*/ +public JRefundLines(DataLogicSystem dlSystem, JPanelTicketEdits jTicketEdit) { + + m_jTicketEdit = jTicketEdit; + + initComponents(); + + ticketlines = new JTicketLines(dlSystem.getResourceAsXML("Ticket.Line")); + + jPanel3.add(ticketlines, BorderLayout.CENTER); + } + + /** + * + * @param aRefundLines + */ + public void setLines(List aRefundLines) { + + m_aLines = aRefundLines; + ticketlines.clearTicketLines(); + + if (m_aLines != null) { + for (int i = 0; i < m_aLines.size(); i++) { + ticketlines.addTicketLine((TicketLineInfo) m_aLines.get(i)); + } + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel3 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + webLabel1 = new com.alee.laf.label.WebLabel(); + m_jbtnAddOne = new javax.swing.JButton(); + m_jbtnAddLine = new javax.swing.JButton(); + m_jbtnAddAll = new javax.swing.JButton(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setPreferredSize(new java.awt.Dimension(15, 200)); + setLayout(new java.awt.BorderLayout()); + + jPanel3.setLayout(new java.awt.BorderLayout()); + + jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 0)); + jPanel1.setLayout(new java.awt.BorderLayout()); + + webLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + webLabel1.setText(bundle.getString("label.refunds")); // NOI18N + webLabel1.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + + m_jbtnAddOne.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jbtnAddOne.setText(AppLocal.getIntString("button.refundone")); // NOI18N + m_jbtnAddOne.setToolTipText(bundle.getString("tooltip.refunditem")); // NOI18N + m_jbtnAddOne.setFocusPainted(false); + m_jbtnAddOne.setFocusable(false); + m_jbtnAddOne.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jbtnAddOne.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jbtnAddOne.setRequestFocusEnabled(false); + m_jbtnAddOne.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnAddOneActionPerformed(evt); + } + }); + + m_jbtnAddLine.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jbtnAddLine.setText(AppLocal.getIntString("button.refundline")); // NOI18N + m_jbtnAddLine.setToolTipText(bundle.getString("tooltip.refundline")); // NOI18N + m_jbtnAddLine.setFocusPainted(false); + m_jbtnAddLine.setFocusable(false); + m_jbtnAddLine.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jbtnAddLine.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jbtnAddLine.setRequestFocusEnabled(false); + m_jbtnAddLine.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnAddLineActionPerformed(evt); + } + }); + + m_jbtnAddAll.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jbtnAddAll.setText(AppLocal.getIntString("button.refundall")); // NOI18N + m_jbtnAddAll.setToolTipText(bundle.getString("tooltip.refundticket")); // NOI18N + m_jbtnAddAll.setFocusPainted(false); + m_jbtnAddAll.setFocusable(false); + m_jbtnAddAll.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jbtnAddAll.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jbtnAddAll.setRequestFocusEnabled(false); + m_jbtnAddAll.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnAddAllActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(webLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jbtnAddOne, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jbtnAddLine, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jbtnAddAll, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGap(1, 1, 1) + .addComponent(webLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(5, 5, 5) + .addComponent(m_jbtnAddOne, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(5, 5, 5) + .addComponent(m_jbtnAddLine, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(5, 5, 5) + .addComponent(m_jbtnAddAll, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + + jPanel1.add(jPanel2, java.awt.BorderLayout.LINE_END); + + jPanel3.add(jPanel1, java.awt.BorderLayout.EAST); + + add(jPanel3, java.awt.BorderLayout.WEST); + }// </editor-fold>//GEN-END:initComponents + + private void m_jbtnAddAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnAddAllActionPerformed + + for (int i = 0; i < m_aLines.size(); i++) { + TicketLineInfo oLine = (TicketLineInfo) m_aLines.get(i); + TicketLineInfo oNewLine = new TicketLineInfo(oLine); + oNewLine.setMultiply(-oLine.getMultiply()); + m_jTicketEdit.addTicketLine(oNewLine); + } + + }//GEN-LAST:event_m_jbtnAddAllActionPerformed + + private void m_jbtnAddOneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnAddOneActionPerformed + + int index = ticketlines.getSelectedIndex(); + if (index >= 0) { + TicketLineInfo oLine = (TicketLineInfo) m_aLines.get(index); + TicketLineInfo oNewLine = new TicketLineInfo(oLine); + oNewLine.setMultiply(-1.0); + m_jTicketEdit.addTicketLine(oNewLine); + } + + }//GEN-LAST:event_m_jbtnAddOneActionPerformed + + private void m_jbtnAddLineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnAddLineActionPerformed + + int index = ticketlines.getSelectedIndex(); + if (index >= 0) { + TicketLineInfo oLine = (TicketLineInfo) m_aLines.get(index); + TicketLineInfo oNewLine = new TicketLineInfo(oLine); + oNewLine.setMultiply(-oLine.getMultiply()); + m_jTicketEdit.addTicketLine(oNewLine); + } + }//GEN-LAST:event_m_jbtnAddLineActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JButton m_jbtnAddAll; + private javax.swing.JButton m_jbtnAddLine; + private javax.swing.JButton m_jbtnAddOne; + private com.alee.laf.label.WebLabel webLabel1; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/JSalesLayoutManager.java b/src/main/java/com/unicenta/pos/sales/JSalesLayoutManager.java new file mode 100644 index 0000000..2b39f4b --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JSalesLayoutManager.java @@ -0,0 +1,10 @@ + +package com.unicenta.pos.sales; + +public class JSalesLayoutManager { + + public JSalesLayoutManager(){ } + + public static void createLayout(){ } + +} diff --git a/src/main/java/com/unicenta/pos/sales/JTicketCatalogLines.form b/src/main/java/com/unicenta/pos/sales/JTicketCatalogLines.form new file mode 100644 index 0000000..cd93fc2 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JTicketCatalogLines.form @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,18,0,0,1,-99"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JTicketCatalogLines.java b/src/main/java/com/unicenta/pos/sales/JTicketCatalogLines.java new file mode 100644 index 0000000..b1eb1b3 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JTicketCatalogLines.java @@ -0,0 +1,129 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.basic.BasicException; +import com.unicenta.pos.catalog.CatalogSelector; +import com.unicenta.pos.catalog.JCatalog; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.forms.DataLogicSystem; +import java.awt.CardLayout; +import java.awt.Dimension; +import java.awt.event.ActionListener; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public class JTicketCatalogLines extends javax.swing.JPanel { + + private JRefundLines m_reflines; + private CatalogSelector m_catalog; + + /** Creates new form JTicketCatalogLines + * @param app + * @param jTicketEdit + * @param pricevisible + * @param taxesincluded + * @param width + * @param height */ + public JTicketCatalogLines(AppView app, JPanelTicketEdits jTicketEdit, boolean pricevisible, boolean taxesincluded, int width, int height) { + + DataLogicSystem dlSystem = null; + DataLogicSales dlSales = null; + dlSystem = (DataLogicSystem) app.getBean("com.unicenta.pos.forms.DataLogicSystem"); + dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + initComponents(); + + m_reflines = new JRefundLines(dlSystem, jTicketEdit); + add(m_reflines, "reflines"); + + m_catalog = new JCatalog(dlSales, pricevisible, taxesincluded, width, height); + m_catalog.getComponent().setPreferredSize(new Dimension(0, 245)); + // m_catalog.addActionListener(new CatalogListener()); + add(m_catalog.getComponent(), "catalog"); + } + + /** + * + */ + public void showCatalog() { + showView("catalog"); + } + + /** + * + * @throws BasicException + */ + public void loadCatalog() throws BasicException { + m_catalog.loadCatalog(); + } + + /** + * + * @param l + */ + public void addActionListener(ActionListener l) { + m_catalog.addActionListener(l); + } + + /** + * + * @param l + */ + public void removeActionListener(ActionListener l) { + m_catalog.addActionListener(l); + } + + /** + * + * @param aRefundLines + */ + public void showRefundLines(List aRefundLines) { + // anado las lineas de refund + m_reflines.setLines(aRefundLines); + showView("reflines"); + } + + private void showView(String sView) { + CardLayout cl = (CardLayout)(this.getLayout()); + cl.show(this, sView); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setLayout(new java.awt.CardLayout()); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/JTicketLines.form b/src/main/java/com/unicenta/pos/sales/JTicketLines.form new file mode 100644 index 0000000..c200961 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JTicketLines.form @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-20,0,0,1,113"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="m_jScrollTableTicket"> + <Properties> + <Property name="horizontalScrollBarPolicy" type="int" value="31"/> + <Property name="verticalScrollBarPolicy" type="int" value="22"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="m_jTicketTable"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="intercellSpacing" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 1]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + <Property name="showVerticalLines" type="boolean" value="false"/> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JTicketLines.java b/src/main/java/com/unicenta/pos/sales/JTicketLines.java new file mode 100644 index 0000000..0e89b85 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JTicketLines.java @@ -0,0 +1,482 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.data.loader.LocalRes; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.scripting.ScriptEngine; +import com.unicenta.pos.scripting.ScriptException; +import com.unicenta.pos.scripting.ScriptFactory; +import com.unicenta.pos.ticket.TicketLineInfo; +import lombok.extern.slf4j.Slf4j; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +import javax.swing.*; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumnModel; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.awt.*; +import java.io.IOException; +import java.io.StringReader; +import java.util.ArrayList; + +/** + * + * @author JG uniCenta + */ +@Slf4j +public class JTicketLines extends javax.swing.JPanel { + + private static SAXParser m_sp = null; + + private final TicketTableModel m_jTableModel; + private Boolean sendStatus; + + /** Creates new form JLinesTicket + * @param ticketline */ + public JTicketLines(String ticketline) { + + initComponents(); + + ColumnTicket[] acolumns = new ColumnTicket[0]; + + if (ticketline != null) { + try { + if (m_sp == null) { + SAXParserFactory spf = SAXParserFactory.newInstance(); + m_sp = spf.newSAXParser(); + } + ColumnsHandler columnshandler = new ColumnsHandler(); + m_sp.parse(new InputSource(new StringReader(ticketline)), columnshandler); + acolumns = columnshandler.getColumns(); + + } catch (ParserConfigurationException ePC) { + log.error(LocalRes.getIntString("exception.parserconfig"), ePC.getMessage()); + } catch (SAXException eSAX) { + log.error(LocalRes.getIntString("exception.xmlfile"), eSAX.getMessage()); + } catch (IOException eIO) { + log.error(LocalRes.getIntString("exception.iofile"), eIO); + } + } + + m_jTableModel = new TicketTableModel(acolumns); + m_jTicketTable.setModel(m_jTableModel); + + TableColumnModel jColumns = m_jTicketTable.getColumnModel(); + for (int i = 0; i < acolumns.length; i++) { + jColumns.getColumn(i).setPreferredWidth(acolumns[i].width); + jColumns.getColumn(i).setResizable(false); + } + + m_jScrollTableTicket.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); + + // set font for headers + Font f = new Font("Arial", Font.BOLD, 14); + JTableHeader header = m_jTicketTable.getTableHeader(); + header.setFont(f); + +/* + * Starting point for SORTING the current table model & view + * m_aLines + TicketLineInfo also has to be considered BECAUSE.... + * where ticket is open on another terminal it won't reflect change from + * other session once placed and opened from sharedticket table + * + * m_jTicketTable.setRowSorter(new TableRowSorter(m_jTableModel)); + * m_jTicketTable.getTableHeader().setReorderingAllowed(true); + * m_jTicketTable.setAutoCreateRowSorter(true); + * m_jTicketTable.getTableHeader().addMouseListener(new MouseAdapter() { + * @Override + * public void mouseClicked(MouseEvent e) { + * int col = m_jTicketTable.columnAtPoint(e.getPoint()); + * String name = m_jTicketTable.getColumnName(col); + * System.out.println("Column index selected " + col + " " + name); + * } + * }); +*/ + + m_jTicketTable.setDefaultRenderer(Object.class, new TicketCellRenderer(acolumns)); + + m_jTicketTable.setRowHeight(40); + m_jTicketTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + m_jTableModel.clear(); + } + + /** + * + * @param l + */ + public void addListSelectionListener(ListSelectionListener l) { + m_jTicketTable.getSelectionModel().addListSelectionListener(l); + } + + /** + * + * @param l + */ + public void removeListSelectionListener(ListSelectionListener l) { + m_jTicketTable.getSelectionModel().removeListSelectionListener(l); + } + + /** + * + */ + public void clearTicketLines() { + m_jTableModel.clear(); + } + + /** + * + * @param index + * @param oLine + */ + public void setTicketLine(int index, TicketLineInfo oLine){ + m_jTableModel.setRow(index, oLine); + } + + /** + * + * @param oLine + */ + public void addTicketLine(TicketLineInfo oLine) { + m_jTableModel.addRow(oLine); + setSelectedIndex(m_jTableModel.getRowCount() - 1); + } + + /** + * + * @param index + * @param oLine + */ + public void insertTicketLine(int index, TicketLineInfo oLine) { + m_jTableModel.insertRow(index, oLine); + setSelectedIndex(index); + } + + /** + * + * @param i + */ + public void removeTicketLine(int i){ + m_jTableModel.removeRow(i); + + if (i >= m_jTableModel.getRowCount()) { + i = m_jTableModel.getRowCount() - 1; + } + + if ((i >= 0) && (i < m_jTableModel.getRowCount())) { + setSelectedIndex(i); + } + } + + /** + * + * @param i + */ + public void setSelectedIndex(int i){ + m_jTicketTable.getSelectionModel().setSelectionInterval(i, i); + Rectangle oRect = m_jTicketTable.getCellRect(i, 0, true); + m_jTicketTable.scrollRectToVisible(oRect); + + } + + /** + * + * @return + */ + public int getSelectedIndex() { + return m_jTicketTable.getSelectionModel().getMinSelectionIndex(); // solo sera uno, luego no importa... + } + + public int sortIndex(int i) { + int[] selection = m_jTicketTable.getSelectedRows(); + for (i = 0; i < selection.length; i++) { + selection[i] = m_jTicketTable.convertRowIndexToModel(selection[i]); + } + return m_jTicketTable.getRowSorter().convertRowIndexToView(i); + } + + /** + * + */ + public void selectionDown() { + int i = m_jTicketTable.getSelectionModel().getMaxSelectionIndex(); + if (i < 0){ + i = 0; + } else { + i ++; + if (i >= m_jTableModel.getRowCount()) { + i = m_jTableModel.getRowCount() - 1; + } + } + + if ((i >= 0) && (i < m_jTableModel.getRowCount())) { + setSelectedIndex(i); + } + } + + /** + * + */ + public void selectionUp() { + int i = m_jTicketTable.getSelectionModel().getMinSelectionIndex(); + if (i < 0){ + i = m_jTableModel.getRowCount() - 1; // No hay ninguna seleccionada + } else { + i --; + if (i < 0) { + i = 0; + } + } + + if ((i >= 0) && (i < m_jTableModel.getRowCount())) { + setSelectedIndex(i); + } + } + + + private static class TicketCellRenderer extends DefaultTableCellRenderer { + + private final ColumnTicket[] m_acolumns; + + public TicketCellRenderer(ColumnTicket[] acolumns) { + m_acolumns = acolumns; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column){ + + JLabel aux = (JLabel) super.getTableCellRendererComponent(table, value, + isSelected, hasFocus, row, column); + aux.setVerticalAlignment(javax.swing.SwingConstants.TOP); + aux.setHorizontalAlignment(m_acolumns[column].align); + Font fName =aux.getFont(); + aux.setFont(new Font(fName.getName(),Font.PLAIN,14)); + + return aux; + } + } + + private static class TicketCellRendererSent extends DefaultTableCellRenderer { + + private final ColumnTicket[] m_acolumns; + + public TicketCellRendererSent(ColumnTicket[] acolumns) { + m_acolumns = acolumns; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column){ + + JLabel aux = (JLabel) super.getTableCellRendererComponent(table, + value, isSelected, hasFocus, row, column); + + aux.setVerticalAlignment(javax.swing.SwingConstants.TOP); + aux.setHorizontalAlignment(m_acolumns[column].align); + Font fName =aux.getFont(); + aux.setFont(new Font(fName.getName(),Font.PLAIN,12)); + aux.setBackground(Color.yellow); + return aux; + } + } + + private static class TicketTableModel extends AbstractTableModel { + + private final ColumnTicket[] m_acolumns; + private final ArrayList m_rows = new ArrayList(); + + public TicketTableModel(ColumnTicket[] acolumns) { + m_acolumns = acolumns; + } + @Override + public int getRowCount() { + return m_rows.size(); + } + @Override + public int getColumnCount() { + return m_acolumns.length; + } + @Override + public String getColumnName(int column) { + return AppLocal.getIntString(m_acolumns[column].name); + // return m_acolumns[column].name; + } + @Override + public Object getValueAt(int row, int column) { + return ((String[]) m_rows.get(row))[column]; + } + + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + + public void clear() { + int old = getRowCount(); + if (old > 0) { + m_rows.clear(); + fireTableRowsDeleted(0, old - 1); + } + } + + public void setRow(int index, TicketLineInfo oLine){ + + String[] row = (String []) m_rows.get(index); + for (int i = 0; i < m_acolumns.length; i++) { + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); + script.put("ticketline", oLine); + row[i] = script.eval(m_acolumns[i].value).toString(); + } catch (ScriptException e) { + row[i] = null; + } + fireTableCellUpdated(index, i); + } + } + + public void addRow(TicketLineInfo oLine) { + + insertRow(m_rows.size(), oLine); + } + + public void insertRow(int index, TicketLineInfo oLine) { + + String[] row = new String[m_acolumns.length]; + for (int i = 0; i < m_acolumns.length; i++) { + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); + script.put("ticketline", oLine); + row[i] = script.eval(m_acolumns[i].value).toString(); + } catch (ScriptException e) { + row[i] = null; + } + } + + m_rows.add(index, row); + fireTableRowsInserted(index, index); + } + + public void removeRow(int row) { + m_rows.remove(row); + fireTableRowsDeleted(row, row); + } + } + + private static class ColumnsHandler extends DefaultHandler { + + private ArrayList m_columns = null; + + public ColumnTicket[] getColumns() { + return (ColumnTicket[]) m_columns.toArray(new ColumnTicket[m_columns.size()]); + } + @Override + public void startDocument() throws SAXException { + m_columns = new ArrayList(); + } + @Override + public void endDocument() throws SAXException {} + @Override + public void startElement(String uri, String localName, String qName, + Attributes attributes) throws SAXException{ + if ("column".equals(qName)){ + ColumnTicket c = new ColumnTicket(); + c.name = attributes.getValue("name"); + c.width = Integer.parseInt(attributes.getValue("width")); + String sAlign = attributes.getValue("align"); + switch (sAlign) { + case "right": + c.align = javax.swing.SwingConstants.RIGHT; + break; + case "center": + c.align = javax.swing.SwingConstants.CENTER; + break; + default: + c.align = javax.swing.SwingConstants.LEFT; + break; + } + c.value = attributes.getValue("value"); + m_columns.add(c); + } + } + @Override + public void endElement(String uri, String localName, String qName) throws SAXException {} + @Override + public void characters(char[] ch, int start, int length) throws SAXException {} + } + + /** + * + * @param state + */ + public void setSendStatus(Boolean state){ + sendStatus = state; + } + + private static class ColumnTicket { + public String name; + public int width; + public int align; + public String value; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jScrollTableTicket = new javax.swing.JScrollPane(); + m_jTicketTable = new javax.swing.JTable(); + + setLayout(new java.awt.BorderLayout()); + + m_jScrollTableTicket.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + m_jScrollTableTicket.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + m_jScrollTableTicket.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + m_jTicketTable.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTicketTable.setFocusable(false); + m_jTicketTable.setIntercellSpacing(new java.awt.Dimension(0, 1)); + m_jTicketTable.setRequestFocusEnabled(false); + m_jTicketTable.setShowVerticalLines(false); + m_jScrollTableTicket.setViewportView(m_jTicketTable); + + add(m_jScrollTableTicket, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JScrollPane m_jScrollTableTicket; + private javax.swing.JTable m_jTicketTable; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/JTicketsBag.java b/src/main/java/com/unicenta/pos/sales/JTicketsBag.java new file mode 100644 index 0000000..205b463 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JTicketsBag.java @@ -0,0 +1,86 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.sales.restaurant.JTicketsBagRestaurantMap; +import com.unicenta.pos.sales.restaurant.JTicketsBagRestaurant; +import com.unicenta.pos.sales.shared.JTicketsBagShared; +import com.unicenta.pos.sales.simple.JTicketsBagSimple; +import javax.swing.JComponent; +import javax.swing.JPanel; + +/** + * + * @author JG uniCenta + */ +public abstract class JTicketsBag extends JPanel { + + /** + * + */ + protected AppView m_App; + + /** + * + */ + protected DataLogicSales m_dlSales; + + /** + * + */ + protected TicketsEditor m_panelticket; + + /** Creates new form JTicketsBag + * @param oApp + * @param panelticket */ + public JTicketsBag(AppView oApp, TicketsEditor panelticket) { + m_App = oApp; + m_panelticket = panelticket; + m_dlSales = (DataLogicSales) m_App.getBean("com.unicenta.pos.forms.DataLogicSales"); + } + + public abstract void activate(); + public abstract boolean deactivate(); + public abstract void deleteTicket(); + protected abstract JComponent getBagComponent(); + protected abstract JComponent getNullComponent(); + + /** + * + * @param sName + * @param app + * @param panelticket + * @return + */ + public static JTicketsBag createTicketsBag(String sName, AppView app, TicketsEditor panelticket) { + switch (sName) { + case "standard": + // return new JTicketsBagMulti(oApp, user, panelticket); + return new JTicketsBagShared(app, panelticket); + case "restaurant": + return new JTicketsBagRestaurantMap(app, panelticket); + default: + // "simple" + return new JTicketsBagSimple(app, panelticket); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/sales/JTicketsBagTicket.form b/src/main/java/com/unicenta/pos/sales/JTicketsBagTicket.form new file mode 100644 index 0000000..3cb7c25 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JTicketsBagTicket.form @@ -0,0 +1,397 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <NonVisualComponents> + <Component class="javax.swing.ButtonGroup" name="buttonGroup1"> + </Component> + </NonVisualComponents> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-63,0,0,2,68"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jOptions"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jButtons"> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jTicketId" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="32767" attributes="0"/> + <Component id="jButton2" min="-2" max="-2" attributes="0"/> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Component id="m_jEdit" min="-2" max="-2" attributes="0"/> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Component id="m_jRefund" min="-2" max="-2" attributes="0"/> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Component id="m_jPrint" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jTicketId" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Component id="jButton2" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Component id="m_jEdit" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Component id="m_jRefund" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Component id="m_jPrint" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="m_jTicketId"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jButton2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="11" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/search24.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.ticketsearch" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jEdit"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="11" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/sale_editline.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.ticketedit" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jEditActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jRefund"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="11" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/inbox.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.ticketrefund" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jRefundActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jPrint"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="11" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/printer24.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.ticketreprint" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jPrintActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="0"/> + </Layout> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="m_jPanelTicket"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"> + <Property name="axis" type="int" value="1"/> + </Layout> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jKeysActionPerformed"/> + </Events> + </Component> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.edit.findticket" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="5" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="com.unicenta.editor.JEditorIntegerPositive" name="m_jTicketEditor"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JRadioButton" name="jrbSales"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="buttonGroup1"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.sales" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.edit.salesopt" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JRadioButton" name="jrbRefunds"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="buttonGroup1"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="1"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="ff" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.refunds" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.edit.refundopt" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JTicketsBagTicket.java b/src/main/java/com/unicenta/pos/sales/JTicketsBagTicket.java new file mode 100644 index 0000000..01ff78b --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JTicketsBagTicket.java @@ -0,0 +1,613 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.pos.customers.DataLogicCustomers; +import com.unicenta.pos.panels.JTicketsFinder; +import com.unicenta.pos.ticket.FindTicketsInfo; +import com.unicenta.pos.ticket.TicketTaxInfo; +import java.awt.*; +import java.util.ArrayList; +import javax.swing.*; +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.JMessageDialog; +import com.unicenta.data.gui.ListKeyed; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppProperties; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.forms.DataLogicSystem; +import com.unicenta.pos.printer.DeviceTicket; +import com.unicenta.pos.printer.TicketParser; +import com.unicenta.pos.printer.TicketPrinterException; +import com.unicenta.pos.scripting.ScriptEngine; +import com.unicenta.pos.scripting.ScriptException; +import com.unicenta.pos.scripting.ScriptFactory; +import com.unicenta.pos.ticket.TicketInfo; +import com.unicenta.pos.ticket.TicketLineInfo; + +/** + * + * @author JG uniCenta + */ +public class JTicketsBagTicket extends JTicketsBag { + + private DataLogicSystem m_dlSystem = null; + protected DataLogicCustomers dlCustomers = null; + private final DataLogicSales m_dlSales; + + private TaxesLogic taxeslogic; + private ListKeyed taxcollection; + + private final DeviceTicket m_TP; + private final TicketParser m_TTP; + private final TicketParser m_TTP2; + + private TicketInfo m_ticket; + private TicketInfo m_ticketCopy; + + private final JTicketsBagTicketBag m_TicketsBagTicketBag; + private final JPanelTicketEdits m_panelticketedit; + + private final AppView m_App; + + /** Creates new form JTicketsBagTicket + * @param app + * @param panelticket */ + public JTicketsBagTicket(AppView app, JPanelTicketEdits panelticket) { + + super(app, panelticket); + m_App = app; + + m_panelticketedit = panelticket; + m_dlSystem = (DataLogicSystem) m_App.getBean("com.unicenta.pos.forms.DataLogicSystem"); + m_dlSales = (DataLogicSales) m_App.getBean("com.unicenta.pos.forms.DataLogicSales"); + dlCustomers = (DataLogicCustomers) m_App.getBean("com.unicenta.pos.customers.DataLogicCustomers"); + AppProperties props = null; + + m_TP = new DeviceTicket(); + + m_TTP = new TicketParser(m_TP, m_dlSystem); // display ticket + m_TTP2 = new TicketParser(m_App.getDeviceTicket(), m_dlSystem); // print ticket + + initComponents(); + + m_TicketsBagTicketBag = new JTicketsBagTicketBag(this); + + m_jTicketEditor.addEditorKeys(m_jKeys); + + m_jPanelTicket.add(m_TP.getDevicePrinter("1").getPrinterComponent(), BorderLayout.CENTER); + + try { + taxeslogic = new TaxesLogic(m_dlSales.getTaxList().list()); + } catch (BasicException ex) { + } + } + + /** + * + */ + @Override + public void activate() { + + m_ticket = null; + m_ticketCopy = null; + + printTicket(); + + m_jTicketEditor.reset(); + m_jTicketEditor.activate(); + + m_panelticketedit.setActiveTicket(null, null); + + jrbSales.setSelected(true); + + m_jEdit.setVisible(m_App.getAppUserView().getUser().hasPermission("sales.EditTicket")); + m_jRefund.setVisible(m_App.getAppUserView().getUser().hasPermission("sales.RefundTicket")); + m_jPrint.setVisible(m_App.getAppUserView().getUser().hasPermission("sales.PrintTicket")); + + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + + m_ticket = null; + m_ticketCopy = null; + return true; + + } + + /** + * + */ + @Override + public void deleteTicket() { + + if (m_ticketCopy != null) { + try { + m_dlSales.deleteTicket(m_ticketCopy, m_App.getInventoryLocation()); + } catch (BasicException eData) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, + AppLocal.getIntString("message.nosaveticket"), + eData); + msg.show(this); + } + } + + m_ticket = null; + m_ticketCopy = null; + resetToTicket(); + } + + /** + * + */ + public void canceleditionTicket() { + + m_ticketCopy = null; + resetToTicket(); + } + + private void resetToTicket() { + printTicket(); + m_jTicketEditor.reset(); + m_jTicketEditor.activate(); + m_panelticketedit.setActiveTicket(null, null); + } + + /** + * + * @return + */ + @Override + protected JComponent getBagComponent() { + return m_TicketsBagTicketBag; + } + + /** + * + * @return + */ + @Override + protected JComponent getNullComponent() { + return this; + } + + private void readTicket(int iTicketid, int iTickettype) { + Integer findTicket=0; + try { + findTicket = m_jTicketEditor.getValueInteger(); + }catch (Exception e){ + } + + try { + + TicketInfo ticket = (iTicketid==-1) + ? m_dlSales.loadTicket(iTickettype, findTicket) + : m_dlSales.loadTicket(iTickettype, iTicketid) ; + + if (ticket == null) { + JFrame frame = new JFrame(); + JOptionPane.showMessageDialog(frame, + AppLocal.getIntString("message.notexiststicket"), + AppLocal.getIntString("message.notexiststickettitle"), + JOptionPane.WARNING_MESSAGE); + + } else { + m_ticket = ticket; + m_ticketCopy = null; + if(m_ticket.getTicketStatus()> 0) { + JFrame frame = new JFrame(); + JOptionPane.showMessageDialog(frame, + AppLocal.getIntString("message.ticketrefunded"), + AppLocal.getIntString("message.ticketrefundedtitle"), + JOptionPane.WARNING_MESSAGE); + m_jEdit.setEnabled(false); + m_jRefund.setEnabled(false); + }else{ + if (m_ticket.getTicketStatus() > 0) { + m_jEdit.setEnabled(false); + m_jRefund.setEnabled(false); + } else { + m_jEdit.setEnabled(true); + m_jRefund.setEnabled(true); + } + } + try { + taxeslogic.calculateTaxes(m_ticket); + TicketTaxInfo[] taxlist = m_ticket.getTaxLines(); + } catch (TaxesException ex) {} + + printTicket(); + } + + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotloadticket"), e); + msg.show(this); + } + + m_jTicketEditor.reset(); + m_jTicketEditor.activate(); + } + + private void printTicket() { + + try { + m_jEdit.setEnabled( + m_ticket != null + && (m_ticket.getTicketType() == TicketInfo.RECEIPT_NORMAL + && m_ticket.getTicketStatus() == 0) + && m_dlSales.isCashActive(m_ticket.getActiveCash())); + } catch (BasicException e) { + m_jEdit.setEnabled(false); + m_jRefund.setEnabled(false); + } + + if (m_ticket != null + && (m_ticket.getTicketType() == TicketInfo.RECEIPT_NORMAL + && m_ticket.getTicketStatus() == 0)) { + m_jRefund.setEnabled(true); + } + + m_jPrint.setEnabled(m_ticket != null); + + m_TP.getDevicePrinter("1").reset(); + + if (m_ticket == null) { + m_jTicketId.setText(null); + } else { + m_jTicketId.setText(m_ticket.getName()); + + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); + script.put("ticket", m_ticket); + script.put("taxes", m_ticket.getTaxLines()); + m_TTP.printTicket(script.eval(m_dlSystem.getResourceAsXML("Printer.TicketPreview")).toString()); + } catch ( ScriptException | TicketPrinterException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.cannotprintticket"), e); + msg.show(this); + } + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + buttonGroup1 = new javax.swing.ButtonGroup(); + m_jOptions = new javax.swing.JPanel(); + m_jButtons = new javax.swing.JPanel(); + m_jTicketId = new javax.swing.JLabel(); + jButton2 = new javax.swing.JButton(); + m_jEdit = new javax.swing.JButton(); + m_jRefund = new javax.swing.JButton(); + m_jPrint = new javax.swing.JButton(); + jPanel2 = new javax.swing.JPanel(); + m_jPanelTicket = new javax.swing.JPanel(); + jPanel3 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel5 = new javax.swing.JPanel(); + jButton1 = new javax.swing.JButton(); + m_jTicketEditor = new com.unicenta.editor.JEditorIntegerPositive(); + jPanel1 = new javax.swing.JPanel(); + jrbSales = new javax.swing.JRadioButton(); + jrbRefunds = new javax.swing.JRadioButton(); + + setLayout(new java.awt.BorderLayout()); + + m_jTicketId.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTicketId.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jTicketId.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jTicketId.setOpaque(true); + m_jTicketId.setPreferredSize(new java.awt.Dimension(200, 30)); + m_jTicketId.setRequestFocusEnabled(false); + + jButton2.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/search24.png"))); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jButton2.setToolTipText(bundle.getString("tooltip.ticketsearch")); // NOI18N + jButton2.setFocusPainted(false); + jButton2.setFocusable(false); + jButton2.setMargin(new java.awt.Insets(0, 4, 0, 4)); + jButton2.setMaximumSize(new java.awt.Dimension(50, 40)); + jButton2.setMinimumSize(new java.awt.Dimension(50, 40)); + jButton2.setPreferredSize(new java.awt.Dimension(80, 45)); + jButton2.setRequestFocusEnabled(false); + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); + + m_jEdit.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + m_jEdit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_editline.png"))); // NOI18N + m_jEdit.setToolTipText(bundle.getString("tooltip.ticketedit")); // NOI18N + m_jEdit.setFocusPainted(false); + m_jEdit.setFocusable(false); + m_jEdit.setMargin(new java.awt.Insets(0, 4, 0, 4)); + m_jEdit.setMaximumSize(new java.awt.Dimension(50, 40)); + m_jEdit.setMinimumSize(new java.awt.Dimension(50, 40)); + m_jEdit.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jEdit.setRequestFocusEnabled(false); + m_jEdit.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jEditActionPerformed(evt); + } + }); + + m_jRefund.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + m_jRefund.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/inbox.png"))); // NOI18N + m_jRefund.setToolTipText(bundle.getString("tooltip.ticketrefund")); // NOI18N + m_jRefund.setFocusPainted(false); + m_jRefund.setFocusable(false); + m_jRefund.setMargin(new java.awt.Insets(0, 4, 0, 4)); + m_jRefund.setMaximumSize(new java.awt.Dimension(50, 40)); + m_jRefund.setMinimumSize(new java.awt.Dimension(50, 40)); + m_jRefund.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jRefund.setRequestFocusEnabled(false); + m_jRefund.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jRefundActionPerformed(evt); + } + }); + + m_jPrint.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + m_jPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/printer24.png"))); // NOI18N + m_jPrint.setToolTipText(bundle.getString("tooltip.ticketreprint")); // NOI18N + m_jPrint.setFocusPainted(false); + m_jPrint.setFocusable(false); + m_jPrint.setMargin(new java.awt.Insets(0, 4, 0, 4)); + m_jPrint.setMaximumSize(new java.awt.Dimension(50, 40)); + m_jPrint.setMinimumSize(new java.awt.Dimension(50, 40)); + m_jPrint.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jPrint.setRequestFocusEnabled(false); + m_jPrint.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jPrintActionPerformed(evt); + } + }); + + org.jdesktop.layout.GroupLayout m_jButtonsLayout = new org.jdesktop.layout.GroupLayout(m_jButtons); + m_jButtons.setLayout(m_jButtonsLayout); + m_jButtonsLayout.setHorizontalGroup( + m_jButtonsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(m_jButtonsLayout.createSequentialGroup() + .addContainerGap() + .add(m_jTicketId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(5, 5, 5) + .add(m_jEdit, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(5, 5, 5) + .add(m_jRefund, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(5, 5, 5) + .add(m_jPrint, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + ); + m_jButtonsLayout.setVerticalGroup( + m_jButtonsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(m_jButtonsLayout.createSequentialGroup() + .addContainerGap() + .add(m_jTicketId, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(m_jButtonsLayout.createSequentialGroup() + .add(5, 5, 5) + .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(m_jButtonsLayout.createSequentialGroup() + .add(5, 5, 5) + .add(m_jEdit, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(m_jButtonsLayout.createSequentialGroup() + .add(5, 5, 5) + .add(m_jRefund, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(m_jButtonsLayout.createSequentialGroup() + .add(5, 5, 5) + .add(m_jPrint, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + ); + + m_jOptions.add(m_jButtons); + + jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); + m_jOptions.add(jPanel2); + + add(m_jOptions, java.awt.BorderLayout.NORTH); + + m_jPanelTicket.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + m_jPanelTicket.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + m_jPanelTicket.setLayout(new java.awt.BorderLayout()); + add(m_jPanelTicket, java.awt.BorderLayout.CENTER); + + jPanel3.setLayout(new java.awt.BorderLayout()); + + jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS)); + + m_jKeys.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jKeysActionPerformed(evt); + } + }); + jPanel4.add(m_jKeys); + + jPanel5.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel5.setLayout(new java.awt.GridBagLayout()); + + jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jButton1.setToolTipText(bundle.getString("tooltip.edit.findticket")); // NOI18N + jButton1.setFocusPainted(false); + jButton1.setFocusable(false); + jButton1.setMargin(new java.awt.Insets(8, 14, 8, 14)); + jButton1.setPreferredSize(new java.awt.Dimension(80, 45)); + jButton1.setRequestFocusEnabled(false); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); + jPanel5.add(jButton1, gridBagConstraints); + + m_jTicketEditor.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jTicketEditor.setPreferredSize(new java.awt.Dimension(130, 30)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + jPanel5.add(m_jTicketEditor, gridBagConstraints); + + jPanel4.add(jPanel5); + + jPanel3.add(jPanel4, java.awt.BorderLayout.NORTH); + + buttonGroup1.add(jrbSales); + jrbSales.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + jrbSales.setText(AppLocal.getIntString("label.sales")); // NOI18N + jrbSales.setToolTipText(bundle.getString("tooltip.edit.salesopt")); // NOI18N + jrbSales.setFocusPainted(false); + jrbSales.setFocusable(false); + jrbSales.setRequestFocusEnabled(false); + jPanel1.add(jrbSales); + + buttonGroup1.add(jrbRefunds); + jrbRefunds.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + jrbRefunds.setForeground(new java.awt.Color(255, 0, 0)); + jrbRefunds.setText(AppLocal.getIntString("label.refunds")); // NOI18N + jrbRefunds.setToolTipText(bundle.getString("tooltip.edit.refundopt")); // NOI18N + jrbRefunds.setFocusPainted(false); + jrbRefunds.setFocusable(false); + jrbRefunds.setRequestFocusEnabled(false); + jPanel1.add(jrbRefunds); + + jPanel3.add(jPanel1, java.awt.BorderLayout.CENTER); + + add(jPanel3, java.awt.BorderLayout.EAST); + }// </editor-fold>//GEN-END:initComponents + + private void m_jEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jEditActionPerformed + + m_ticketCopy = m_ticket; + m_TicketsBagTicketBag.showEdit(); + m_panelticketedit.showCatalog(); + m_ticketCopy.setOldTicket(true); + m_panelticketedit.setActiveTicket(m_ticket.copyTicket(), null); + + }//GEN-LAST:event_m_jEditActionPerformed + + private void m_jPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jPrintActionPerformed + + if (m_ticket != null) { + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); + script.put("ticket", m_ticket); + script.put("taxes", m_ticket.getTaxLines()); + m_TTP2.printTicket(script.eval(m_dlSystem.getResourceAsXML("Printer.TicketPreview")).toString()); + } catch (ScriptException | TicketPrinterException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_NOTICE, + AppLocal.getIntString("message.cannotprint"), e)); + } + } + + }//GEN-LAST:event_m_jPrintActionPerformed + + private void m_jRefundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jRefundActionPerformed + + java.util.List aRefundLines = new ArrayList(); + + for(int i = 0; i < m_ticket.getLinesCount(); i++) { + TicketLineInfo newline = new TicketLineInfo(m_ticket.getLine(i)); + aRefundLines.add(newline); + } + + m_ticketCopy = null; + m_TicketsBagTicketBag.showRefund(); + m_panelticketedit.showRefundLines(aRefundLines); + + TicketInfo refundticket = new TicketInfo(); + refundticket.setTicketType(TicketInfo.RECEIPT_REFUND); + refundticket.setTicketStatus(m_ticket.getTicketId()); + refundticket.setCustomer(m_ticket.getCustomer()); + refundticket.setPayments(m_ticket.getPayments()); + refundticket.setOldTicket(true); + m_panelticketedit.setActiveTicket(refundticket, null); + }//GEN-LAST:event_m_jRefundActionPerformed + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + + readTicket(-1, jrbSales.isSelected() ? 0 : 1); + + }//GEN-LAST:event_jButton1ActionPerformed + + private void m_jKeysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jKeysActionPerformed + + readTicket(-1, jrbSales.isSelected() ? 0 : 1); + + }//GEN-LAST:event_m_jKeysActionPerformed + +private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed + JTicketsFinder finder = JTicketsFinder.getReceiptFinder(this, m_dlSales, dlCustomers); + finder.setVisible(true); + FindTicketsInfo selectedTicket = finder.getSelectedCustomer(); + + if (selectedTicket == null) { + m_jTicketEditor.reset(); + m_jTicketEditor.activate(); + } else { + readTicket(selectedTicket.getTicketId(), selectedTicket.getTicketType()); + } +}//GEN-LAST:event_jButton2ActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.ButtonGroup buttonGroup1; + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JRadioButton jrbRefunds; + private javax.swing.JRadioButton jrbSales; + private javax.swing.JPanel m_jButtons; + private javax.swing.JButton m_jEdit; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JPanel m_jOptions; + private javax.swing.JPanel m_jPanelTicket; + private javax.swing.JButton m_jPrint; + private javax.swing.JButton m_jRefund; + private com.unicenta.editor.JEditorIntegerPositive m_jTicketEditor; + private javax.swing.JLabel m_jTicketId; + // End of variables declaration//GEN-END:variables + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/sales/JTicketsBagTicketBag.form b/src/main/java/com/unicenta/pos/sales/JTicketsBagTicketBag.form new file mode 100644 index 0000000..b112f2f --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JTicketsBagTicketBag.form @@ -0,0 +1,128 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,52,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanEdit"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription"> + <CardConstraints cardName="edit"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="0"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jBtnDelete"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/sale_delete.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.deleteticket" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Delete current Ticket"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBtnDeleteActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jBtnCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Cancel Action"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBtnCancelActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanRefund"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription"> + <CardConstraints cardName="refund"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="0"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jBtnCancel1"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/fileclose.png"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBtnCancel1ActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/JTicketsBagTicketBag.java b/src/main/java/com/unicenta/pos/sales/JTicketsBagTicketBag.java new file mode 100644 index 0000000..1fcea34 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/JTicketsBagTicketBag.java @@ -0,0 +1,170 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.pos.forms.AppLocal; +import java.awt.CardLayout; +import javax.swing.JOptionPane; + +/** + * + * @author JG uniCenta + */ +public class JTicketsBagTicketBag extends javax.swing.JPanel { + + private final JTicketsBagTicket m_ticketsbagticket; + + /** Creates new form JTicketsBagTicketBag + * @param ticketsbagticket */ + public JTicketsBagTicketBag(JTicketsBagTicket ticketsbagticket) { + m_ticketsbagticket = ticketsbagticket; + initComponents(); + } + + /** + * + */ + public void showEdit() { + showView("edit"); + } + + /** + * + */ + public void showRefund() { + showView("refund"); + } + + private void showView(String view) { + CardLayout cl = (CardLayout)(getLayout()); + cl.show(this, view); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanEdit = new javax.swing.JPanel(); + m_jBtnDelete = new javax.swing.JButton(); + m_jBtnCancel = new javax.swing.JButton(); + jPanRefund = new javax.swing.JPanel(); + m_jBtnCancel1 = new javax.swing.JButton(); + + setLayout(new java.awt.CardLayout()); + + jPanEdit.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); + + m_jBtnDelete.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jBtnDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_delete.png"))); // NOI18N + m_jBtnDelete.setText(AppLocal.getIntString("button.deleteticket")); // NOI18N + m_jBtnDelete.setToolTipText("Delete current Ticket"); + m_jBtnDelete.setFocusPainted(false); + m_jBtnDelete.setFocusable(false); + m_jBtnDelete.setMargin(new java.awt.Insets(0, 4, 0, 4)); + m_jBtnDelete.setMaximumSize(new java.awt.Dimension(50, 40)); + m_jBtnDelete.setMinimumSize(new java.awt.Dimension(50, 40)); + m_jBtnDelete.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jBtnDelete.setRequestFocusEnabled(false); + m_jBtnDelete.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBtnDeleteActionPerformed(evt); + } + }); + jPanEdit.add(m_jBtnDelete); + + m_jBtnCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jBtnCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + m_jBtnCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N + m_jBtnCancel.setToolTipText("Cancel Action"); + m_jBtnCancel.setFocusPainted(false); + m_jBtnCancel.setFocusable(false); + m_jBtnCancel.setMargin(new java.awt.Insets(0, 4, 0, 4)); + m_jBtnCancel.setMaximumSize(new java.awt.Dimension(50, 40)); + m_jBtnCancel.setMinimumSize(new java.awt.Dimension(50, 40)); + m_jBtnCancel.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jBtnCancel.setRequestFocusEnabled(false); + m_jBtnCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBtnCancelActionPerformed(evt); + } + }); + jPanEdit.add(m_jBtnCancel); + + add(jPanEdit, "edit"); + + jPanRefund.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); + + m_jBtnCancel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/fileclose.png"))); // NOI18N + m_jBtnCancel1.setFocusPainted(false); + m_jBtnCancel1.setFocusable(false); + m_jBtnCancel1.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jBtnCancel1.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jBtnCancel1.setRequestFocusEnabled(false); + m_jBtnCancel1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBtnCancel1ActionPerformed(evt); + } + }); + jPanRefund.add(m_jBtnCancel1); + + add(jPanRefund, "refund"); + }// </editor-fold>//GEN-END:initComponents + + private void m_jBtnCancel1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBtnCancel1ActionPerformed + + m_ticketsbagticket.canceleditionTicket(); + + }//GEN-LAST:event_m_jBtnCancel1ActionPerformed + + private void m_jBtnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBtnDeleteActionPerformed + + int res = JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.wannadelete"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + + if (res == JOptionPane.YES_OPTION) { + m_ticketsbagticket.deleteTicket(); + + } + + }//GEN-LAST:event_m_jBtnDeleteActionPerformed + + private void m_jBtnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBtnCancelActionPerformed + + m_ticketsbagticket.canceleditionTicket(); + + }//GEN-LAST:event_m_jBtnCancelActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanEdit; + private javax.swing.JPanel jPanRefund; + private javax.swing.JButton m_jBtnCancel; + private javax.swing.JButton m_jBtnCancel1; + private javax.swing.JButton m_jBtnDelete; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/KitchenDisplay.java b/src/main/java/com/unicenta/pos/sales/KitchenDisplay.java new file mode 100644 index 0000000..e32e3aa --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/KitchenDisplay.java @@ -0,0 +1,86 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.sales; + +import com.unicenta.data.loader.Session; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSystem; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * + * @author Administrator + */ +public class KitchenDisplay { + private Session s; + private Connection con; + private Statement stmt; + private PreparedStatement pstmt; + private String SQL; + private ResultSet rs; + private AppView m_App; + + /** + * + */ + protected DataLogicSystem dlSystem; + + /** + * + * @param oApp + */ + public KitchenDisplay(AppView oApp) { + m_App=oApp; + +//get database connection details + try{ + s=m_App.getSession(); + con=s.getConnection(); + } +// catch (Exception e){System.out.print("No session or connection"); + catch (Exception e){ } + } + + /** + * + * @param ID + * @param table + * @param pickupID + * @param product + * @param multiply + * @param attributes + */ + public void addRecord(String ID, String table, String pickupID, String product, String multiply, String attributes){ + DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); + Date date = new Date(); + + try{ + SQL = "INSERT INTO KITCHENDISPLAY (ID, ORDERTIME, PLACE, PICKUPID, PRODUCT, MULTIPLY, ATTRIBUTES) VALUES (?, ?, ?, ?, ?, ?, ?) "; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,ID); + pstmt.setString(2,dateFormat.format(date).toString()); + pstmt.setString(3,table); + pstmt.setString(4,pickupID); + pstmt.setString(5,product); + pstmt.setString(6,multiply); + pstmt.setString(7,attributes); + pstmt.executeUpdate(); + }catch(Exception e){ + } + + } + + +// stmt = (Statement) con.createStatement(); +// rs = stmt.executeQuery(SQL); + + +} diff --git a/src/main/java/com/unicenta/pos/sales/MenuActionListener.java b/src/main/java/com/unicenta/pos/sales/MenuActionListener.java new file mode 100644 index 0000000..dd891bf --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/MenuActionListener.java @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.sales; + +/** + * + * @author jack + */ +public class MenuActionListener { + +} diff --git a/src/main/java/com/unicenta/pos/sales/ReceiptSplit.form b/src/main/java/com/unicenta/pos/sales/ReceiptSplit.form new file mode 100644 index 0000000..2aa28a8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/ReceiptSplit.form @@ -0,0 +1,235 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="caption.split" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-42,0,0,2,-38"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="2"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jButtonCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jButtonOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jBtnToRightAll"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/2rightarrow.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Split All Line Items"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnToRightAllActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="jBtnToRightOne"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/1rightarrow.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Split only one of the Line Items"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnToRightOneActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="jBtnToLeftOne"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/1leftarrow.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Un-Split only one of the Line Items"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnToLeftOneActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="jBtnToLeftAll"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/2leftarrow.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Un-Split All Line Items"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnToLeftAllActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="3" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/ReceiptSplit.java b/src/main/java/com/unicenta/pos/sales/ReceiptSplit.java new file mode 100644 index 0000000..33652f2 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/ReceiptSplit.java @@ -0,0 +1,339 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.pos.customers.DataLogicCustomers; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.ticket.TicketInfo; +import com.unicenta.pos.ticket.TicketLineInfo; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Window; +import javax.swing.JFrame; + +/** + * + * @author adrianromero + */ +public class ReceiptSplit extends javax.swing.JDialog { + + private boolean accepted; + + SimpleReceipt receiptone; + SimpleReceipt receipttwo; + + /** Creates new form ReceiptSplit + * @param parent */ + protected ReceiptSplit(java.awt.Frame parent) { + super(parent, true); + } + /** Creates new form ReceiptSplit + * @param parent */ + protected ReceiptSplit(java.awt.Dialog parent) { + super(parent, true); + } + + private void init(String ticketline, DataLogicSales dlSales, DataLogicCustomers dlCustomers, TaxesLogic taxeslogic) { + + initComponents(); + getRootPane().setDefaultButton(m_jButtonOK); + + receiptone = new SimpleReceipt(ticketline, dlSales, dlCustomers, taxeslogic); + receiptone.setCustomerEnabled(false); + jPanel5.add(receiptone, BorderLayout.CENTER); + + receipttwo = new SimpleReceipt(ticketline, dlSales, dlCustomers, taxeslogic); + jPanel3.add(receipttwo, BorderLayout.CENTER); + } + + /** + * + * @param parent + * @param ticketline + * @param dlSales + * @param dlCustomers + * @param taxeslogic + * @return + */ + public static ReceiptSplit getDialog(Component parent, String ticketline, DataLogicSales dlSales, DataLogicCustomers dlCustomers, TaxesLogic taxeslogic) { + + Window window = getWindow(parent); + + ReceiptSplit myreceiptsplit; + + if (window instanceof Frame) { + myreceiptsplit = new ReceiptSplit((Frame) window); + } else { + myreceiptsplit = new ReceiptSplit((Dialog) window); + } + + myreceiptsplit.init(ticketline, dlSales, dlCustomers, taxeslogic); + + return myreceiptsplit; + } + + /** + * + * @param parent + * @return + */ + protected static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window)parent; + } else { + return getWindow(parent.getParent()); + } + } + + /** + * + * @param ticket + * @param ticket2 + * @param ticketext + * @return + */ + public boolean showDialog(TicketInfo ticket, TicketInfo ticket2, Object ticketext) { + + receiptone.setTicket(ticket, ticketext); + receipttwo.setTicket(ticket2, ticketext); + + setVisible(true); + return accepted; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + jPanel2 = new javax.swing.JPanel(); + m_jButtonCancel = new javax.swing.JButton(); + m_jButtonOK = new javax.swing.JButton(); + jPanel1 = new javax.swing.JPanel(); + jPanel5 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + jBtnToRightAll = new javax.swing.JButton(); + jBtnToRightOne = new javax.swing.JButton(); + jBtnToLeftOne = new javax.swing.JButton(); + jBtnToLeftAll = new javax.swing.JButton(); + jPanel3 = new javax.swing.JPanel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("caption.split")); // NOI18N + setResizable(false); + + jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + m_jButtonCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + m_jButtonCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N + m_jButtonCancel.setFocusPainted(false); + m_jButtonCancel.setFocusable(false); + m_jButtonCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jButtonCancel.setRequestFocusEnabled(false); + m_jButtonCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonCancelActionPerformed(evt); + } + }); + jPanel2.add(m_jButtonCancel); + + m_jButtonOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + m_jButtonOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + m_jButtonOK.setFocusPainted(false); + m_jButtonOK.setFocusable(false); + m_jButtonOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonOK.setPreferredSize(new java.awt.Dimension(110, 45)); + m_jButtonOK.setRequestFocusEnabled(false); + m_jButtonOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonOKActionPerformed(evt); + } + }); + jPanel2.add(m_jButtonOK); + + getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); + + jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.LINE_AXIS)); + + jPanel5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel5.setLayout(new java.awt.BorderLayout()); + jPanel1.add(jPanel5); + + jPanel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel4.setLayout(new java.awt.GridBagLayout()); + + jBtnToRightAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/2rightarrow.png"))); // NOI18N + jBtnToRightAll.setToolTipText("Split All Line Items"); + jBtnToRightAll.setFocusPainted(false); + jBtnToRightAll.setFocusable(false); + jBtnToRightAll.setMargin(new java.awt.Insets(8, 14, 8, 14)); + jBtnToRightAll.setPreferredSize(new java.awt.Dimension(80, 45)); + jBtnToRightAll.setRequestFocusEnabled(false); + jBtnToRightAll.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnToRightAllActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 0; + jPanel4.add(jBtnToRightAll, gridBagConstraints); + + jBtnToRightOne.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/1rightarrow.png"))); // NOI18N + jBtnToRightOne.setToolTipText("Split only one of the Line Items"); + jBtnToRightOne.setFocusPainted(false); + jBtnToRightOne.setFocusable(false); + jBtnToRightOne.setMargin(new java.awt.Insets(8, 14, 8, 14)); + jBtnToRightOne.setPreferredSize(new java.awt.Dimension(80, 45)); + jBtnToRightOne.setRequestFocusEnabled(false); + jBtnToRightOne.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnToRightOneActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 1; + gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); + jPanel4.add(jBtnToRightOne, gridBagConstraints); + + jBtnToLeftOne.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/1leftarrow.png"))); // NOI18N + jBtnToLeftOne.setToolTipText("Un-Split only one of the Line Items"); + jBtnToLeftOne.setFocusPainted(false); + jBtnToLeftOne.setFocusable(false); + jBtnToLeftOne.setMargin(new java.awt.Insets(8, 14, 8, 14)); + jBtnToLeftOne.setPreferredSize(new java.awt.Dimension(80, 45)); + jBtnToLeftOne.setRequestFocusEnabled(false); + jBtnToLeftOne.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnToLeftOneActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 2; + gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); + jPanel4.add(jBtnToLeftOne, gridBagConstraints); + + jBtnToLeftAll.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/2leftarrow.png"))); // NOI18N + jBtnToLeftAll.setToolTipText("Un-Split All Line Items"); + jBtnToLeftAll.setFocusPainted(false); + jBtnToLeftAll.setFocusable(false); + jBtnToLeftAll.setMargin(new java.awt.Insets(8, 14, 8, 14)); + jBtnToLeftAll.setPreferredSize(new java.awt.Dimension(80, 45)); + jBtnToLeftAll.setRequestFocusEnabled(false); + jBtnToLeftAll.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnToLeftAllActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 3; + gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); + jPanel4.add(jBtnToLeftAll, gridBagConstraints); + + jPanel1.add(jPanel4); + + jPanel3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel3.setLayout(new java.awt.BorderLayout()); + jPanel1.add(jPanel3); + + getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); + + setSize(new java.awt.Dimension(730, 470)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void m_jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonOKActionPerformed + + if (receipttwo.getTicket().getLinesCount() > 0) { + accepted = true; + dispose(); + } + + }//GEN-LAST:event_m_jButtonOKActionPerformed + + private void m_jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_m_jButtonCancelActionPerformed + + private void jBtnToRightAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnToRightAllActionPerformed + + TicketLineInfo[] lines = receiptone.getSelectedLines(); + if (lines != null) { + receipttwo.addSelectedLines(lines); + } + +}//GEN-LAST:event_jBtnToRightAllActionPerformed + + private void jBtnToRightOneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnToRightOneActionPerformed + + TicketLineInfo[] lines = receiptone.getSelectedLinesUnit(); + if (lines != null) { + receipttwo.addSelectedLines(lines); + } + +}//GEN-LAST:event_jBtnToRightOneActionPerformed + + private void jBtnToLeftOneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnToLeftOneActionPerformed + + TicketLineInfo[] lines = receipttwo.getSelectedLinesUnit(); + if (lines != null) { + receiptone.addSelectedLines(lines); + } + +}//GEN-LAST:event_jBtnToLeftOneActionPerformed + + private void jBtnToLeftAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnToLeftAllActionPerformed + + TicketLineInfo[] lines = receipttwo.getSelectedLines(); + if (lines != null) { + receiptone.addSelectedLines(lines); + } + +}//GEN-LAST:event_jBtnToLeftAllActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jBtnToLeftAll; + private javax.swing.JButton jBtnToLeftOne; + private javax.swing.JButton jBtnToRightAll; + private javax.swing.JButton jBtnToRightOne; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JButton m_jButtonCancel; + private javax.swing.JButton m_jButtonOK; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/ReprintTicketInfo.java b/src/main/java/com/unicenta/pos/sales/ReprintTicketInfo.java new file mode 100644 index 0000000..77a68f0 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/ReprintTicketInfo.java @@ -0,0 +1,93 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.DataWrite; +import com.unicenta.data.loader.SerializableRead; +import com.unicenta.data.loader.SerializableWrite; + +/** + * @author JG uniCenta + * Sept 2018 + * Recall + Reprint of last ticket + * Allows for reprint ticket from any terminal rather than only local +*/ +public class ReprintTicketInfo implements SerializableRead, SerializableWrite { + + private static final long serialVersionUID = 7640633837719L; + private String id; + private String total; + private String ticketDate; + private String UserName; + + + /** Creates a new instance of ReprintTicketInfo */ + public ReprintTicketInfo() { + } + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + id = dr.getString(1); + total = dr.getString(2); + ticketDate = dr.getString(3); + UserName = dr.getString(4); + + } + + /** + * + * @param dp + * @throws BasicException + */ + @Override + public void writeValues(DataWrite dp) throws BasicException { + dp.setString(1, id); + dp.setString(2, total); + dp.setString(3, ticketDate); + dp.setString(4, UserName); + } + + /** + * + * @return + */ + public String getId() { + return id; + } + + public String getTotal() { + return total; + } + + public String getTicketDate() { + return ticketDate; + } + + public String getUserName() { + return UserName; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/sales/SharedTicketInfo.java b/src/main/java/com/unicenta/pos/sales/SharedTicketInfo.java new file mode 100644 index 0000000..f25b28f --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/SharedTicketInfo.java @@ -0,0 +1,113 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.DataWrite; +import com.unicenta.data.loader.SerializableRead; +import com.unicenta.data.loader.SerializableWrite; + +public class SharedTicketInfo implements SerializableRead, SerializableWrite { + + private static final long serialVersionUID = 7640633837719L; + private String id; + private String name; + private String UserName; + private String status; +/* + * For : RickyO - display Customer Name | Phone | PickupId + * Change : JG uniCenta + * Date : May 2017 +*/ + private String phone; + private String pickupid; + + /** Creates a new instance of SharedTicketInfo */ + public SharedTicketInfo() { + } + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + id = dr.getString(1); + name = dr.getString(2); + UserName = dr.getString(3); + status = dr.getString(4); +/* + * For : RickyO - display Customer Name | Phone | PickupId + * Change : JG uniCenta + * Date : May 2017 +*/ + pickupid = dr.getString(5); + phone = dr.getString(6); + + } + + /** + * + * @param dp + * @throws BasicException + */ + @Override + public void writeValues(DataWrite dp) throws BasicException { + dp.setString(1, id); + dp.setString(2, name); + dp.setString(3, UserName); + dp.setString(4, status); + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getAppUser() { + return UserName; + } + + public String getStatus() { + return status; + } + +/* + * For : RickyO - display Customer Name | Phone | PickupId + * Change : JG uniCenta + * Date : May 2017 +*/ + public String getPhone() { + return phone; + } +/* + * For : RickyO - display Customer Name | Phone | PickupId + * Change : JG uniCenta + * Date : May 2017 +*/ + public String getPickupId() { + return pickupid; + } +} diff --git a/src/main/java/com/unicenta/pos/sales/SimpleReceipt.form b/src/main/java/com/unicenta/pos/sales/SimpleReceipt.form new file mode 100644 index 0000000..9389200 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/SimpleReceipt.form @@ -0,0 +1,296 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,84,0,0,1,98"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jPanTotals"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JLabel" name="m_jTotalEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="1" gridY="2" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="5" insetsBottom="0" insetsRight="0" anchor="23" weightX="1.0" weightY="1.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="m_jLblTotalEuros1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.totalcash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="23" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="m_jSubtotalEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="5" insetsBottom="0" insetsRight="0" anchor="23" weightX="1.0" weightY="1.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="m_jTaxesEuros"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="1" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="5" insetsBottom="0" insetsRight="0" anchor="23" weightX="1.0" weightY="1.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="m_jLblTotalEuros2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.taxcash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="23" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="m_jLblTotalEuros3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.subtotalcash" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="23" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="m_jButtons"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="0"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="m_jTicketId"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.CompoundBorderInfo"> + <CompoundBorder> + <Border PropertyName="outside" info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="64" green="6f" id="Button.darkShadow" palette="3" red="71" type="palette"/> + </LineBorder> + </Border> + <Border PropertyName="inside" info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="1" left="4" right="4" top="1"/> + </Border> + </CompoundBorder> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 25]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="btnCustomer"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/customer_sml.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Show Customers"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCustomerActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Tahoma" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/SimpleReceipt.java b/src/main/java/com/unicenta/pos/sales/SimpleReceipt.java new file mode 100644 index 0000000..df7d335 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/SimpleReceipt.java @@ -0,0 +1,450 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.pos.customers.DataLogicCustomers; +import com.unicenta.pos.customers.JCustomerFinder; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.ticket.TicketInfo; +import com.unicenta.pos.ticket.TicketLineInfo; +import java.awt.BorderLayout; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author adrian + */ +public class SimpleReceipt extends javax.swing.JPanel { + + /** + * + */ + protected DataLogicCustomers dlCustomers; + + /** + * + */ + protected DataLogicSales dlSales; + + /** + * + */ + protected TaxesLogic taxeslogic; + + private JTicketLines ticketlines; + private TicketInfo ticket; + private Object ticketext; + + /** Creates new form SimpleReceipt + * @param ticketline + * @param dlSales + * @param taxeslogic + * @param dlCustomers */ + public SimpleReceipt(String ticketline, DataLogicSales dlSales, DataLogicCustomers dlCustomers, TaxesLogic taxeslogic) { + + initComponents(); + + // dlSystem.getResourceAsXML("Ticket.Line") + ticketlines = new JTicketLines(ticketline); + this.dlCustomers = dlCustomers; + this.dlSales = dlSales; + this.taxeslogic = taxeslogic; + + jPanel2.add(ticketlines, BorderLayout.CENTER); + } + + /** + * + * @param value + */ + public void setCustomerEnabled(boolean value) { + btnCustomer.setEnabled(value); + } + + /** + * + * @param ticket + * @param ticketext + */ + public void setTicket(TicketInfo ticket, Object ticketext) { + + this.ticket = ticket; + this.ticketext = ticketext; + + // The ticket name + m_jTicketId.setText(ticket.getName(ticketext)); + + ticketlines.clearTicketLines(); + for (int i = 0; i < ticket.getLinesCount(); i++) { + ticketlines.addTicketLine(ticket.getLine(i)); + } + + if (ticket.getLinesCount() > 0) { + ticketlines.setSelectedIndex(0); + } + + printTotals(); + + } + + private void refreshTicketTaxes() { + + for (TicketLineInfo line : ticket.getLines()) { + line.setTaxInfo(taxeslogic.getTaxInfo(line.getProductTaxCategoryID(), ticket.getCustomer())); + } + } + + private void printTotals() { + + if (ticket.getLinesCount() == 0) { + m_jSubtotalEuros.setText(null); + m_jTaxesEuros.setText(null); + m_jTotalEuros.setText(null); + } else { + m_jSubtotalEuros.setText(ticket.printSubTotal()); + m_jTaxesEuros.setText(ticket.printTax()); + m_jTotalEuros.setText(ticket.printTotal()); + } + } + + /** + * + * @return + */ + public TicketInfo getTicket() { + return ticket; + } + + private int findFirstNonAuxiliarLine() { + + int i = ticketlines.getSelectedIndex(); + while (i >= 0 && ticket.getLine(i).isProductCom()) { + i--; + } + return i; + } + + /** + * + * @return + */ + public TicketLineInfo[] getSelectedLines() { + + // never returns an empty array, or null, or an array with at least one element. + + int i = findFirstNonAuxiliarLine(); + + if (i >= 0) { + + List<TicketLineInfo> l = new ArrayList<>(); + + TicketLineInfo line = ticket.getLine(i); + l.add(line); + ticket.removeLine(i); + ticketlines.removeTicketLine(i); + + // add also auxiliars + while (i < ticket.getLinesCount() && ticket.getLine(i).isProductCom()) { + l.add(ticket.getLine(i)); + ticket.removeLine(i); + ticketlines.removeTicketLine(i); + } + printTotals(); + return l.toArray(new TicketLineInfo[l.size()]); + } else { + return null; + } + } + + /** + * + * @return + */ + public TicketLineInfo[] getSelectedLinesUnit() { + + // never returns an empty array, or null, or an array with at least one element. + + int i = findFirstNonAuxiliarLine(); + + if (i >= 0) { + + TicketLineInfo line = ticket.getLine(i); + + if (line.getMultiply() >= 1.0) { + + List<TicketLineInfo> l = new ArrayList<>(); + + if (line.getMultiply() > 1.0) { + line.setMultiply(line.getMultiply() -1.0); + ticketlines.setTicketLine(i, line); + line = line.copyTicketLine(); + line.setMultiply(1.0); + l.add(line); + i++; + } else { // == 1.0 + l.add(line); + ticket.removeLine(i); + ticketlines.removeTicketLine(i); + } + + // add also auxiliars + while (i < ticket.getLinesCount() && ticket.getLine(i).isProductCom()) { + l.add(ticket.getLine(i)); + ticket.removeLine(i); + ticketlines.removeTicketLine(i); + } + printTotals(); + return l.toArray(new TicketLineInfo[l.size()]); + } else { // < 1.0 + return null; + } + } else { + return null; + } + } + + /** + * + * @param lines + */ + public void addSelectedLines(TicketLineInfo[] lines) { + + int i = findFirstNonAuxiliarLine(); + + TicketLineInfo firstline = lines[0]; + + if (i >= 0 + && ticket.getLine(i).getProductID() != null && firstline.getProductID() != null && ticket.getLine(i).getProductID().equals(firstline.getProductID()) + && ticket.getLine(i).getTaxInfo().getId().equals(firstline.getTaxInfo().getId()) + && ticket.getLine(i).getPrice() == firstline.getPrice()) { + + // add the auxiliars. + for (int j = 1; j < lines.length; j++) { + ticket.insertLine(i + 1, lines[j]); + ticketlines.insertTicketLine(i + 1, lines[j]); + } + + // inc the line + ticket.getLine(i).setMultiply(ticket.getLine(i).getMultiply() + firstline.getMultiply()); + ticketlines.setTicketLine(i, ticket.getLine(i)); + ticketlines.setSelectedIndex(i); + + } else { + // add all at the end in inverse order. + int insertpoint = ticket.getLinesCount(); + for (int j = lines.length - 1; j >= 0; j--) { + ticket.insertLine(insertpoint, lines[j]); + ticketlines.insertTicketLine(insertpoint, lines[j]); + } + } + + printTotals(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + jPanel1 = new javax.swing.JPanel(); + m_jPanTotals = new javax.swing.JPanel(); + m_jTotalEuros = new javax.swing.JLabel(); + m_jLblTotalEuros1 = new javax.swing.JLabel(); + m_jSubtotalEuros = new javax.swing.JLabel(); + m_jTaxesEuros = new javax.swing.JLabel(); + m_jLblTotalEuros2 = new javax.swing.JLabel(); + m_jLblTotalEuros3 = new javax.swing.JLabel(); + m_jButtons = new javax.swing.JPanel(); + m_jTicketId = new javax.swing.JLabel(); + btnCustomer = new javax.swing.JButton(); + jPanel2 = new javax.swing.JPanel(); + + setLayout(new java.awt.BorderLayout()); + + jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel1.setLayout(new java.awt.BorderLayout()); + + m_jPanTotals.setLayout(new java.awt.GridBagLayout()); + + m_jTotalEuros.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTotalEuros.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jTotalEuros.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jTotalEuros.setOpaque(true); + m_jTotalEuros.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jTotalEuros.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0); + m_jPanTotals.add(m_jTotalEuros, gridBagConstraints); + + m_jLblTotalEuros1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jLblTotalEuros1.setText(AppLocal.getIntString("label.totalcash")); // NOI18N + m_jLblTotalEuros1.setPreferredSize(new java.awt.Dimension(110, 30)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START; + gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); + m_jPanTotals.add(m_jLblTotalEuros1, gridBagConstraints); + + m_jSubtotalEuros.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSubtotalEuros.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jSubtotalEuros.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jSubtotalEuros.setOpaque(true); + m_jSubtotalEuros.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jSubtotalEuros.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0); + m_jPanTotals.add(m_jSubtotalEuros, gridBagConstraints); + + m_jTaxesEuros.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTaxesEuros.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + m_jTaxesEuros.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jTaxesEuros.setOpaque(true); + m_jTaxesEuros.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jTaxesEuros.setRequestFocusEnabled(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 0, 0); + m_jPanTotals.add(m_jTaxesEuros, gridBagConstraints); + + m_jLblTotalEuros2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jLblTotalEuros2.setText(AppLocal.getIntString("label.taxcash")); // NOI18N + m_jLblTotalEuros2.setPreferredSize(new java.awt.Dimension(110, 30)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START; + gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); + m_jPanTotals.add(m_jLblTotalEuros2, gridBagConstraints); + + m_jLblTotalEuros3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jLblTotalEuros3.setText(AppLocal.getIntString("label.subtotalcash")); // NOI18N + m_jLblTotalEuros3.setPreferredSize(new java.awt.Dimension(110, 30)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START; + m_jPanTotals.add(m_jLblTotalEuros3, gridBagConstraints); + + jPanel1.add(m_jPanTotals, java.awt.BorderLayout.EAST); + + add(jPanel1, java.awt.BorderLayout.SOUTH); + + m_jButtons.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); + + m_jTicketId.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jTicketId.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + m_jTicketId.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(javax.swing.UIManager.getDefaults().getColor("Button.darkShadow")), javax.swing.BorderFactory.createEmptyBorder(1, 4, 1, 4))); + m_jTicketId.setOpaque(true); + m_jTicketId.setPreferredSize(new java.awt.Dimension(160, 25)); + m_jTicketId.setRequestFocusEnabled(false); + m_jButtons.add(m_jTicketId); + + btnCustomer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer_sml.png"))); // NOI18N + btnCustomer.setToolTipText("Show Customers"); + btnCustomer.setFocusPainted(false); + btnCustomer.setFocusable(false); + btnCustomer.setMargin(new java.awt.Insets(8, 14, 8, 14)); + btnCustomer.setMaximumSize(new java.awt.Dimension(50, 40)); + btnCustomer.setMinimumSize(new java.awt.Dimension(50, 40)); + btnCustomer.setPreferredSize(new java.awt.Dimension(80, 45)); + btnCustomer.setRequestFocusEnabled(false); + btnCustomer.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCustomerActionPerformed(evt); + } + }); + m_jButtons.add(btnCustomer); + + add(m_jButtons, java.awt.BorderLayout.NORTH); + + jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N + jPanel2.setLayout(new java.awt.BorderLayout()); + add(jPanel2, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + + private void btnCustomerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCustomerActionPerformed + + JCustomerFinder finder = JCustomerFinder.getCustomerFinder(this, dlCustomers); + finder.search(ticket.getCustomer()); + finder.setVisible(true); + + try { + ticket.setCustomer(finder.getSelectedCustomer() == null + ? null + : dlSales.loadCustomerExt(finder.getSelectedCustomer().getId())); + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfindcustomer"), e); + msg.show(this); + } + + // The ticket name + m_jTicketId.setText(ticket.getName(ticketext)); + + refreshTicketTaxes(); + + // refresh the receipt.... + setTicket(ticket, ticketext); + + }//GEN-LAST:event_btnCustomerActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnCustomer; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel m_jButtons; + private javax.swing.JLabel m_jLblTotalEuros1; + private javax.swing.JLabel m_jLblTotalEuros2; + private javax.swing.JLabel m_jLblTotalEuros3; + private javax.swing.JPanel m_jPanTotals; + private javax.swing.JLabel m_jSubtotalEuros; + private javax.swing.JLabel m_jTaxesEuros; + private javax.swing.JLabel m_jTicketId; + private javax.swing.JLabel m_jTotalEuros; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/TaxesException.java b/src/main/java/com/unicenta/pos/sales/TaxesException.java new file mode 100644 index 0000000..c845260 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/TaxesException.java @@ -0,0 +1,51 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +/** + * + * @author adrianromero + */ +public class TaxesException extends Exception { + + /** + * Creates a new instance of <code>TaxesException</code> without detail message. + * @param t + */ + public TaxesException(Throwable t) { + super(t); + } + + /** + * + * @param msg + * @param t + */ + public TaxesException(String msg, Throwable t) { + super(msg, t); + } + /** + * Constructs an instance of <code>TaxesException</code> with the specified detail message. + * @param msg the detail message. + */ + public TaxesException(String msg) { + super(msg); + } +} diff --git a/src/main/java/com/unicenta/pos/sales/TaxesLogic.java b/src/main/java/com/unicenta/pos/sales/TaxesLogic.java new file mode 100644 index 0000000..80552c6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/TaxesLogic.java @@ -0,0 +1,314 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.inventory.TaxCategoryInfo; +import com.unicenta.pos.ticket.TaxInfo; +import com.unicenta.pos.ticket.TicketInfo; +import com.unicenta.pos.ticket.TicketLineInfo; +import com.unicenta.pos.ticket.TicketTaxInfo; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * + * @author adrianromero + */ +public class TaxesLogic { + + private List<TaxInfo> taxlist; + + private Map<String, TaxesLogicElement> taxtrees; + + /** + * + * @param taxlist + */ + public TaxesLogic(List<TaxInfo> taxlist) { + this.taxlist = taxlist; + +// JG June 2013 use diamond inference + taxtrees = new HashMap<>(); + + // Order the taxlist by Application Order... + // JG June 2013 use diamond inference + List<TaxInfo> taxlistordered = new ArrayList<>(); + taxlistordered.addAll(taxlist); + Collections.sort(taxlistordered, new Comparator<TaxInfo>() { + @Override + public int compare(TaxInfo o1, TaxInfo o2) { + if (o1.getApplicationOrder() < o2.getApplicationOrder()) { + return -1; + } else if (o1.getApplicationOrder() == o2.getApplicationOrder()) { + return 0; + } else { + return 1; + } + } + }); + + // Generate the taxtrees + // JG June 2013 use diamond inference + HashMap<String, TaxesLogicElement> taxorphans = new HashMap<>(); + + for (TaxInfo t : taxlistordered) { + + TaxesLogicElement te = new TaxesLogicElement(t); + + // get the parent + TaxesLogicElement teparent = taxtrees.get(t.getParentID()); + if (teparent == null) { + // orphan node + teparent = taxorphans.get(t.getParentID()); + if (teparent == null) { + teparent = new TaxesLogicElement(null); + taxorphans.put(t.getParentID(), teparent); + } + } + + teparent.getSons().add(te); + + // Does it have orphans ? + teparent = taxorphans.get(t.getId()); + if (teparent != null) { + // get all the sons + te.getSons().addAll(teparent.getSons()); + // remove the orphans + taxorphans.remove(t.getId()); + } + + // Add it to the tree... + taxtrees.put(t.getId(), te); + } + } + + /** + * + * @param ticket + * @throws TaxesException + */ + public void calculateTaxes(TicketInfo ticket) throws TaxesException { + + // JG June 2013 use diamond inference + List<TicketTaxInfo> tickettaxes = new ArrayList<>(); + + for (TicketLineInfo line: ticket.getLines()) { + tickettaxes = sumLineTaxes(tickettaxes, calculateTaxes(line)); + } + + ticket.setTaxes(tickettaxes); + } + + /** + * + * @param line + * @return + * @throws TaxesException + */ + public List<TicketTaxInfo> calculateTaxes(TicketLineInfo line) throws TaxesException { + + TaxesLogicElement taxesapplied = getTaxesApplied(line.getTaxInfo()); + return calculateLineTaxes(line.getSubValue(), taxesapplied); + } + + private List<TicketTaxInfo> calculateLineTaxes(double base, TaxesLogicElement taxesapplied) { + + // JG June 2013 use diamond inference + List<TicketTaxInfo> linetaxes = new ArrayList<>(); + + if (taxesapplied.getSons().isEmpty()) { + TicketTaxInfo tickettax = new TicketTaxInfo(taxesapplied.getTax()); + tickettax.add(base); + linetaxes.add(tickettax); + } else { + double acum = base; + + for (TaxesLogicElement te : taxesapplied.getSons()) { + + List<TicketTaxInfo> sublinetaxes = calculateLineTaxes( + te.getTax().isCascade() ? acum : base, + te); + linetaxes.addAll(sublinetaxes); + acum += sumTaxes(sublinetaxes); + } + } + + return linetaxes; + } + + private TaxesLogicElement getTaxesApplied(TaxInfo t) throws TaxesException { + + if (t == null) { + throw new TaxesException(new java.lang.NullPointerException()); + } + + return taxtrees.get(t.getId()); + } + + private double sumTaxes(List<TicketTaxInfo> linetaxes) { + + double taxtotal = 0.0; + + taxtotal = linetaxes.stream().map((tickettax) -> + tickettax.getTax()).reduce(taxtotal, (accumulator, _item) -> accumulator + _item); + return taxtotal; + } + + private List<TicketTaxInfo> sumLineTaxes(List<TicketTaxInfo> list1, List<TicketTaxInfo> list2) { + + list2.forEach((tickettax) -> { + TicketTaxInfo i = searchTicketTax(list1, tickettax.getTaxInfo().getId()); + if (i == null) { + list1.add(tickettax); + } else { + i.add(tickettax.getSubTotal()); + } + }); + return list1; + } + + private TicketTaxInfo searchTicketTax(List<TicketTaxInfo> l, String id) { + + for (TicketTaxInfo tickettax : l) { + if (id.equals(tickettax.getTaxInfo().getId())) { + return tickettax; + } + } + return null; + } + + /** + * + * @param tcid + * @return + */ + public double getTaxRate(String tcid) { + return getTaxRate(tcid, null); + } + + /** + * + * @param tc + * @return + */ + public double getTaxRate(TaxCategoryInfo tc) { + return getTaxRate(tc, null); + } + + /** + * + * @param tc + * @param customer + * @return + */ + public double getTaxRate(TaxCategoryInfo tc, CustomerInfoExt customer) { + + if (tc == null) { + return 0.0; + } else { + return getTaxRate(tc.getID(), customer); + } + } + + /** + * + * @param tcid + * @param customer + * @return + */ + public double getTaxRate(String tcid, CustomerInfoExt customer) { + + if (tcid == null) { + return 0.0; + } else { + TaxInfo tax = getTaxInfo(tcid, customer); + if (tax == null) { + return 0.0; + } else { + return tax.getRate(); + } + } + } + + /** + * + * @param tcid + * @return + */ + public TaxInfo getTaxInfo(String tcid) { + return getTaxInfo(tcid, null); + } + + /** + * + * @param tc + * @return + */ + public TaxInfo getTaxInfo(TaxCategoryInfo tc) { + return getTaxInfo(tc.getID(), null); + } + + /** + * + * @param tc + * @param customer + * @return + */ + public TaxInfo getTaxInfo(TaxCategoryInfo tc, CustomerInfoExt customer) { + return getTaxInfo(tc.getID(), customer); + } + + /** + * + * @param tcid + * @param customer + * @return + */ + public TaxInfo getTaxInfo(String tcid, CustomerInfoExt customer) { + + TaxInfo defaulttax = null; + + for (TaxInfo tax : taxlist) { + if (tax.getParentID() == null && tax.getTaxCategoryID().equals(tcid)) { + if ((customer == null + || customer.getTaxCustCategoryID() == null) + && tax.getTaxCustCategoryID() == null) { + return tax; + } else if (customer != null + && customer.getTaxCustCategoryID() != null + && customer.getTaxCustCategoryID().equals(tax.getTaxCustCategoryID())) { + return tax; + } + + if (tax.getTaxCustCategoryID() == null) { + defaulttax = tax; + } + } + } + + // No tax found + return defaulttax; + } +} diff --git a/src/main/java/com/unicenta/pos/sales/TaxesLogicElement.java b/src/main/java/com/unicenta/pos/sales/TaxesLogicElement.java new file mode 100644 index 0000000..c302def --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/TaxesLogicElement.java @@ -0,0 +1,61 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-20167 +// 2008-2013 Openbravo, S.L. +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.pos.ticket.TaxInfo; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author adrianromero + */ +public class TaxesLogicElement { + + private TaxInfo tax; + private List<TaxesLogicElement> taxsons; + + /** + * + * @param tax + */ + public TaxesLogicElement(TaxInfo tax) { + this.tax = tax; + // JG June 2013 use diamond inference + this.taxsons = new ArrayList<>(); + } + + /** + * + * @return + */ + public TaxInfo getTax() { + return tax; + } + + /** + * + * @return + */ + public List<TaxesLogicElement> getSons() { + return taxsons; + } +} diff --git a/src/main/java/com/unicenta/pos/sales/TicketsBagRestaurantMap.java b/src/main/java/com/unicenta/pos/sales/TicketsBagRestaurantMap.java new file mode 100644 index 0000000..da15edb --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/TicketsBagRestaurantMap.java @@ -0,0 +1,13 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.sales; + +/** + * + * @author Administrator + */ +class TicketsBagRestaurantMap { + +} diff --git a/src/main/java/com/unicenta/pos/sales/TicketsEditor.java b/src/main/java/com/unicenta/pos/sales/TicketsEditor.java new file mode 100644 index 0000000..b96b7dd --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/TicketsEditor.java @@ -0,0 +1,42 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales; + +import com.unicenta.pos.ticket.TicketInfo; + +/** + * + * @author JG uniCenta + */ +public interface TicketsEditor { + + /** + * + * @param oTicket + * @param oTicketExt + */ + public void setActiveTicket(TicketInfo oTicket, Object oTicketExt); // el ticket mas informacion extra... + + /** + * + * @return + */ + public TicketInfo getActiveTicket(); +} diff --git a/src/main/java/com/unicenta/pos/sales/dlSales.java b/src/main/java/com/unicenta/pos/sales/dlSales.java new file mode 100644 index 0000000..1f6e8b4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/dlSales.java @@ -0,0 +1,13 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.sales; + +/** + * + * @author JG uniCenta + */ +class dlSales { + +} diff --git a/src/main/java/com/unicenta/pos/sales/restaurant/Floor.java b/src/main/java/com/unicenta/pos/sales/restaurant/Floor.java new file mode 100644 index 0000000..3a215ad --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/restaurant/Floor.java @@ -0,0 +1,138 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales.restaurant; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.ImageUtils; +import com.unicenta.data.loader.SerializableRead; +import com.unicenta.pos.util.ThumbNailBuilder; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.image.BufferedImage; +import javax.imageio.ImageIO; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JPanel; + +/** + * + * @author JG uniCenta + */ +public class Floor implements SerializableRead { + + private static final long serialVersionUID = 8694154682897L; + private String m_sID; + private String m_sName; + private Container m_container; + private Icon m_icon; + + private static Image defimg = null; + + /** Creates a new instance of Floor */ + public Floor() { + try { + defimg = ImageIO.read(getClass().getClassLoader().getResourceAsStream("com/unicenta/images/floors.png")); + } catch (Exception fnfe) { + } + } + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_sID = dr.getString(1); + m_sName = dr.getString(2); + BufferedImage img = ImageUtils.readImage(dr.getBytes(3)); + ThumbNailBuilder tnbcat = new ThumbNailBuilder(32, 32, defimg); + m_container = new JPanelDrawing(img); + m_icon = new ImageIcon(tnbcat.getThumbNail(img)); + } + + /** + * + * @return + */ + public String getID() { + return m_sID; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + + /** + * + * @return + */ + public Icon getIcon() { + return m_icon; + } + + /** + * + * @return + */ + public Container getContainer() { + return m_container; + } + + private static class JPanelDrawing extends JPanel { + private Image img; + + public JPanelDrawing(Image img) { + this.img = img; + setLayout(null); + } + + @Override + protected void paintComponent (Graphics g) { + super.paintComponent(g); + if (img != null) { + g.drawImage(img, 0, 0, this); + } + } + + @Override + public Dimension getPreferredSize() { + return (img == null) +// ? new Dimension(640, 480) + ? new Dimension(950, 560) + : new Dimension(img.getWidth(this), img.getHeight(this)); + } + @Override + public Dimension getMinimumSize() { + return getPreferredSize(); + } + @Override + public Dimension getMaximumSize() { + return getPreferredSize(); + } + } +} diff --git a/src/main/java/com/unicenta/pos/sales/restaurant/JCalendarItemRenderer.form b/src/main/java/com/unicenta/pos/sales/restaurant/JCalendarItemRenderer.form new file mode 100644 index 0000000..6cbf3c9 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/restaurant/JCalendarItemRenderer.form @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="0"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,68,0,0,1,-113"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="javax.swing.JLabel" name="m_jDescription"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="<html>This is a test comment that shows how a long line is printed with this renderer."/> + <Property name="verticalAlignment" type="int" value="1"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="20" right="20" top="5"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="opaque" type="boolean" value="false"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="javax.swing.JLabel" name="m_jTime"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="0" red="0" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" value="10:20"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="West"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="m_jTitle"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value=" This is a test"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="5" right="0" top="0"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="m_jChairs"> + <Properties> + <Property name="text" type="java.lang.String" value="5"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="East"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/restaurant/JCalendarItemRenderer.java b/src/main/java/com/unicenta/pos/sales/restaurant/JCalendarItemRenderer.java new file mode 100644 index 0000000..b401eff --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/restaurant/JCalendarItemRenderer.java @@ -0,0 +1,186 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales.restaurant; + +import javax.swing.*; +import javax.swing.border.*; + +import java.awt.Component; +import java.awt.Font; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Insets; + +import java.io.Serializable; +import com.unicenta.format.Formats; + +/** + * + * @author JG uniCenta + */ +public class JCalendarItemRenderer extends javax.swing.JPanel implements ListCellRenderer, Serializable { + + /** + * + */ + protected static Border noFocusBorder; + + private boolean m_bDone = false; + + /** Creates new form JCalendarItemRenderer */ + public JCalendarItemRenderer() { + + super(); + if (noFocusBorder == null) { + noFocusBorder = new EmptyBorder(1, 1, 1, 1); + } + + initComponents(); + + m_jTime.setFont(new Font("SansSerif", Font.BOLD, 14)); // HORA + m_jTitle.setFont(new Font("SansSerif", Font.BOLD, 14)); // TITULO + m_jDescription.setFont(new Font("SansSerif", Font.ITALIC, 14)); // TEXTO EXPLICATIVO + + setOpaque(true); + setBorder(noFocusBorder); + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + applyComponentOrientation(list.getComponentOrientation()); + + if (isSelected) { + setBackground(list.getSelectionBackground()); + m_jTime.setForeground(list.getSelectionForeground()); + m_jTitle.setForeground(list.getSelectionForeground()); + m_jDescription.setForeground(list.getSelectionForeground()); + } else { + setBackground(list.getBackground()); + m_jTime.setForeground(Color.BLUE); + m_jTitle.setForeground(list.getForeground()); + m_jDescription.setForeground(list.getForeground()); + } + + if (value == null) { + m_jTime.setText(""); + m_jTitle.setText(""); + m_jChairs.setText(""); + m_bDone = false; + m_jDescription.setText(""); + } else { + Object[] avalue = (Object []) value; + m_jTime.setText(Formats.TIME.formatValue(avalue[2])); + m_jTitle.setText(Formats.STRING.formatValue(avalue[6])); + m_jChairs.setText(Formats.INT.formatValue(avalue[7])); + m_bDone = ((Boolean) avalue[8]).booleanValue(); + m_jDescription.setText(Formats.STRING.formatValue(avalue[9])); + } + + setEnabled(list.isEnabled()); + setFont(list.getFont()); + setBorder((cellHasFocus) ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder); + + return this; + } + + public void paintComponent(Graphics g) { + super.paintComponent(g); + + if (m_bDone) { + Insets in = getInsets(); + g.drawLine(in.left, 10, getWidth() - in.right, 10); + } + } + + + /** + * Overridden for performance reasons. + */ + @Override + protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {} + @Override + public void firePropertyChange(String propertyName, byte oldValue, byte newValue) {} + @Override + public void firePropertyChange(String propertyName, char oldValue, char newValue) {} + @Override + public void firePropertyChange(String propertyName, short oldValue, short newValue) {} + @Override + public void firePropertyChange(String propertyName, int oldValue, int newValue) {} + @Override + public void firePropertyChange(String propertyName, long oldValue, long newValue) {} + @Override + public void firePropertyChange(String propertyName, float oldValue, float newValue) {} + @Override + public void firePropertyChange(String propertyName, double oldValue, double newValue) {} + @Override + public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) {} + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jDescription = new javax.swing.JLabel(); + jPanel1 = new javax.swing.JPanel(); + m_jTime = new javax.swing.JLabel(); + m_jTitle = new javax.swing.JLabel(); + m_jChairs = new javax.swing.JLabel(); + + setLayout(new java.awt.BorderLayout()); + + m_jDescription.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jDescription.setText("<html>This is a test comment that shows how a long line is printed with this renderer."); + m_jDescription.setVerticalAlignment(javax.swing.SwingConstants.TOP); + m_jDescription.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 20, 5, 20)); + add(m_jDescription, java.awt.BorderLayout.CENTER); + + jPanel1.setOpaque(false); + jPanel1.setLayout(new java.awt.BorderLayout()); + + m_jTime.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jTime.setForeground(new java.awt.Color(0, 0, 255)); + m_jTime.setText("10:20"); + jPanel1.add(m_jTime, java.awt.BorderLayout.WEST); + + m_jTitle.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jTitle.setText(" This is a test"); + m_jTitle.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 5, 0, 0)); + jPanel1.add(m_jTitle, java.awt.BorderLayout.CENTER); + + m_jChairs.setText("5"); + jPanel1.add(m_jChairs, java.awt.BorderLayout.EAST); + + add(jPanel1, java.awt.BorderLayout.NORTH); + }// </editor-fold>//GEN-END:initComponents + + // Variables declaration - do not modify//GEN-BEGIN:variables + javax.swing.JPanel jPanel1; + javax.swing.JLabel m_jChairs; + javax.swing.JLabel m_jDescription; + javax.swing.JLabel m_jTime; + javax.swing.JLabel m_jTitle; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurant.form b/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurant.form new file mode 100644 index 0000000..8e534d4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurant.form @@ -0,0 +1,174 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 50]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[430, 50]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,54,0,0,1,-72"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="0"/> + <Property name="horizontalGap" type="int" value="4"/> + <Property name="verticalGap" type="int" value="3"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="j_btnGuests"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="1"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="99" green="0" red="ff" type="rgb"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/customer_add_sml.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.guests" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="horizontalTextPosition" type="int" value="4"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="j_btnGuestsActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JTicketsBagRestaurant_j_btnGuests"/> + </AuxValues> + </Component> + <Component class="javax.swing.JButton" name="m_TablePlan"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/tables.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Go to Table Plan"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_TablePlanActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_MoveTable"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/movetable.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Move Table"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_MoveTableActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_DelTicket"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/sale_delete.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Delete Current Order"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_DelTicketActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="j_btnKitchen"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/printer24.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Send to Kichen Printer"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" value="Send to Remote Printer"/> + </AccessibilityProperties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="j_btnKitchenActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurant.java b/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurant.java new file mode 100644 index 0000000..e0b6baf --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurant.java @@ -0,0 +1,440 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// + +package com.unicenta.pos.sales.restaurant; + +import bsh.EvalError; +import bsh.Interpreter; +import com.alee.extended.time.ClockType; +import com.alee.extended.time.WebClock; +import com.alee.managers.notification.NotificationIcon; +import com.alee.managers.notification.NotificationManager; +import com.alee.managers.notification.WebNotification; +import com.unicenta.basic.BasicException; +import com.unicenta.beans.JGuestsPop; +import com.unicenta.beans.JNumberPop; +import com.unicenta.data.gui.JMessageDialog; +import com.unicenta.data.gui.ListKeyed; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.pos.forms.*; +import com.unicenta.pos.printer.DeviceTicket; +import com.unicenta.pos.printer.TicketParser; +import com.unicenta.pos.printer.TicketPrinterException; +import com.unicenta.pos.sales.DataLogicReceipts; +import com.unicenta.pos.sales.TaxesLogic; +import com.unicenta.pos.scripting.ScriptEngine; +import com.unicenta.pos.scripting.ScriptException; +import com.unicenta.pos.scripting.ScriptFactory; +import com.unicenta.pos.ticket.TicketInfo; +import com.unicenta.pos.ticket.TicketLineInfo; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +@Slf4j +public class JTicketsBagRestaurant extends javax.swing.JPanel { + + private final AppView m_App; + private final JTicketsBagRestaurantMap m_restaurant; + private List<TicketLineInfo> m_aLines; + private TicketLineInfo line; + private TicketInfo ticket; + private final Object ticketExt; + private DataLogicSystem m_dlSystem = null; + private final DeviceTicket m_TP; + private final TicketParser m_TTP2; + private final RestaurantDBUtils restDB; + + private final DataLogicSystem dlSystem = null; + private final DataLogicReceipts dlReceipts = null; + private DataLogicSales dlSales = null; + + private TicketParser m_TTP; + + private SentenceList senttax; + private ListKeyed taxcollection; + private TaxesLogic taxeslogic; + + private Interpreter i; + + + /** Creates new form JTicketsBagRestaurantMap + * @param app + * @param restaurant */ + public JTicketsBagRestaurant(AppView app, JTicketsBagRestaurantMap restaurant) { + super(); + m_App = app; + m_restaurant = restaurant; + + initComponents(); + + ticketExt = null; + + restDB = new RestaurantDBUtils(m_App); + + m_dlSystem = (DataLogicSystem) m_App.getBean("com.unicenta.pos.forms.DataLogicSystem"); + dlSales = (DataLogicSales) m_App.getBean("com.unicenta.pos.forms.DataLogicSales"); + DataLogicReceipts m_dlReceipts = (DataLogicReceipts) m_App.getBean("com.unicenta.pos.sales.DataLogicReceipts"); + + m_TP = new DeviceTicket(); + m_TTP2 = new TicketParser(m_App.getDeviceTicket(), m_dlSystem); + + j_btnKitchen.setVisible(false); + + m_TablePlan.setVisible(m_App.getAppUserView().getUser(). + hasPermission("sales.TablePlan")); + +// j_btnGuests.setText(null); + + } + + /** + * + */ + public void activate() { + + m_DelTicket.setEnabled(m_App.getAppUserView().getUser() + .hasPermission("com.unicenta.pos.sales.JPanelTicketEdits")); + + m_TablePlan.setEnabled(m_App.getAppUserView().getUser() + .hasPermission("com.unicenta.pos.sales.JPanelTicketEdits")); + + m_TablePlan.setVisible(true); + + } + + /** + * + * @param pTicket + * @return + */ + public String getPickupString(TicketInfo pTicket){ + if (pTicket == null){ + return("0"); + } + String tmpPickupId=Integer.toString(pTicket.getPickupId()); + String pickupSize =(m_App.getProperties().getProperty("till.pickupsize")); + + if (pickupSize!=null && (Integer.parseInt(pickupSize) >= tmpPickupId.length())){ + while (tmpPickupId.length()< (Integer.parseInt(pickupSize))){ + tmpPickupId="0"+tmpPickupId; + } + } + return (tmpPickupId); + } + + /** + * + * @param resource + */ + public void printTicket(String resource) { + printTicket(resource, ticket, m_restaurant.getTable()); + printNotify(); +// j_btnKitchen.setEnabled(false); + } + + private void printTicket(String sresourcename, TicketInfo ticket, String table) { + if (ticket != null) { + + if (ticket.getPickupId()== 0){ + try{ + ticket.setPickupId(dlSales.getNextPickupIndex()); + }catch (BasicException e){ + ticket.setPickupId(0); + } + } + + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); + + script.put("ticket", ticket); + script.put("place",m_restaurant.getTableName()); + script.put("pickupid",getPickupString(ticket)); + + m_TTP2.printTicket(script.eval(m_dlSystem.getResourceAsXML(sresourcename)).toString()); + + } catch ( ScriptException | TicketPrinterException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_NOTICE, + AppLocal.getIntString("message.cannotprint"), e)); + } + } + } + + public void printNotify(){ + final WebNotification notificationPopup = new WebNotification (); + notificationPopup.setIcon ( NotificationIcon.information ); + notificationPopup.setDisplayTime ( 4000 ); + + final WebClock clock = new WebClock (); + clock.setClockType ( ClockType.timer ); + clock.setTimeLeft ( 5000 ); + clock.setTimePattern ( "'Printed successfully'" ); + notificationPopup.setContent ( clock ); + + NotificationManager.showNotification ( notificationPopup ); + clock.start (); + } + + public void updateGuestCount() { + Integer count = restDB.getGuestsInTable(m_restaurant.getTable()); + + if (count > 0) { + j_btnGuests.setText(Integer.toString(count)); + + } else { + j_btnGuests.setText(""); + } + System.out.println("Table : " + m_restaurant.getTable() + " GuestsCount :" + count); + + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + j_btnGuests = new javax.swing.JButton(); + m_TablePlan = new javax.swing.JButton(); + m_MoveTable = new javax.swing.JButton(); + m_DelTicket = new javax.swing.JButton(); + j_btnKitchen = new javax.swing.JButton(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setMinimumSize(new java.awt.Dimension(250, 50)); + setPreferredSize(new java.awt.Dimension(430, 50)); + setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 4, 3)); + + j_btnGuests.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + j_btnGuests.setForeground(new java.awt.Color(255, 0, 153)); + j_btnGuests.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer_add_sml.png"))); // NOI18N + j_btnGuests.setToolTipText(AppLocal.getIntString("tooltip.guests")); // NOI18N + j_btnGuests.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + j_btnGuests.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + j_btnGuests.setMargin(new java.awt.Insets(0, 4, 0, 4)); + j_btnGuests.setMaximumSize(new java.awt.Dimension(50, 40)); + j_btnGuests.setMinimumSize(new java.awt.Dimension(50, 40)); + j_btnGuests.setPreferredSize(new java.awt.Dimension(80, 45)); + j_btnGuests.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + j_btnGuestsActionPerformed(evt); + } + }); + add(j_btnGuests); + + m_TablePlan.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/tables.png"))); // NOI18N + m_TablePlan.setToolTipText("Go to Table Plan"); + m_TablePlan.setFocusPainted(false); + m_TablePlan.setFocusable(false); + m_TablePlan.setMargin(new java.awt.Insets(0, 4, 0, 4)); + m_TablePlan.setMaximumSize(new java.awt.Dimension(50, 40)); + m_TablePlan.setMinimumSize(new java.awt.Dimension(50, 40)); + m_TablePlan.setPreferredSize(new java.awt.Dimension(80, 45)); + m_TablePlan.setRequestFocusEnabled(false); + m_TablePlan.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_TablePlanActionPerformed(evt); + } + }); + add(m_TablePlan); + + m_MoveTable.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/movetable.png"))); // NOI18N + m_MoveTable.setToolTipText("Move Table"); + m_MoveTable.setFocusPainted(false); + m_MoveTable.setFocusable(false); + m_MoveTable.setMargin(new java.awt.Insets(0, 4, 0, 4)); + m_MoveTable.setMaximumSize(new java.awt.Dimension(50, 40)); + m_MoveTable.setMinimumSize(new java.awt.Dimension(50, 40)); + m_MoveTable.setPreferredSize(new java.awt.Dimension(80, 45)); + m_MoveTable.setRequestFocusEnabled(false); + m_MoveTable.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_MoveTableActionPerformed(evt); + } + }); + add(m_MoveTable); + + m_DelTicket.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_delete.png"))); // NOI18N + m_DelTicket.setToolTipText("Delete Current Order"); + m_DelTicket.setFocusPainted(false); + m_DelTicket.setFocusable(false); + m_DelTicket.setMargin(new java.awt.Insets(0, 4, 0, 4)); + m_DelTicket.setMaximumSize(new java.awt.Dimension(50, 40)); + m_DelTicket.setMinimumSize(new java.awt.Dimension(50, 40)); + m_DelTicket.setPreferredSize(new java.awt.Dimension(80, 45)); + m_DelTicket.setRequestFocusEnabled(false); + m_DelTicket.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_DelTicketActionPerformed(evt); + } + }); + add(m_DelTicket); + + j_btnKitchen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/printer24.png"))); // NOI18N + j_btnKitchen.setToolTipText("Send to Kichen Printer"); + j_btnKitchen.setMargin(new java.awt.Insets(0, 4, 0, 4)); + j_btnKitchen.setMaximumSize(new java.awt.Dimension(50, 40)); + j_btnKitchen.setMinimumSize(new java.awt.Dimension(50, 40)); + j_btnKitchen.setPreferredSize(new java.awt.Dimension(80, 45)); + j_btnKitchen.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + j_btnKitchenActionPerformed(evt); + } + }); + add(j_btnKitchen); + j_btnKitchen.getAccessibleContext().setAccessibleDescription("Send to Remote Printer"); + }// </editor-fold>//GEN-END:initComponents + + private void m_MoveTableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_MoveTableActionPerformed + +// JG 6 Nov 13 - clear Customer from orignal table - Thanks David Kurniawan + restDB.clearCustomerNameInTableById(m_restaurant.getTable()); + restDB.clearWaiterNameInTableById(m_restaurant.getTable()); + restDB.clearTicketIdInTableById(m_restaurant.getTable()); + restDB.clearGuestsInTable(m_restaurant.getTable()); + restDB.clearOccupied(m_restaurant.getTable()); + restDB.setTableMovedFlag(m_restaurant.getTable()); + + m_restaurant.moveTicket(); + + }//GEN-LAST:event_m_MoveTableActionPerformed + + @SuppressWarnings("empty-statement") + private void m_DelTicketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_DelTicketActionPerformed + boolean pinOK = false; + + if (m_App.getProperties().getProperty("override.check").equals("true")) { + Integer secret = Integer.parseInt(m_App.getProperties().getProperty("override.pin")); + Integer iValue = JNumberPop.showEditNumber(this, AppLocal.getIntString("title.override.enterpin")); + + if (iValue == null ? secret == null : iValue.equals(secret)) { + pinOK = true; + int res = JOptionPane.showConfirmDialog(this + , AppLocal.getIntString("message.wannadelete") + , AppLocal.getIntString("title.editor") + , JOptionPane.YES_NO_OPTION + , JOptionPane.QUESTION_MESSAGE); + if (res == JOptionPane.YES_OPTION) { + restDB.clearCustomerNameInTableById(m_restaurant.getTable()); + restDB.clearWaiterNameInTableById(m_restaurant.getTable()); + restDB.clearTicketIdInTableById(m_restaurant.getTable()); + restDB.clearGuestsInTable(m_restaurant.getTable()); + restDB.clearOccupied(m_restaurant.getTable()); + + m_restaurant.deleteTicket(); + } + } else { + pinOK = false; + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.override.badpin")); + } + } else { + int res = JOptionPane.showConfirmDialog(this + , AppLocal.getIntString("message.wannadelete") + , AppLocal.getIntString("title.editor") + , JOptionPane.YES_NO_OPTION + , JOptionPane.QUESTION_MESSAGE); + if (res == JOptionPane.YES_OPTION) { + restDB.clearCustomerNameInTableById(m_restaurant.getTable()); + restDB.clearWaiterNameInTableById(m_restaurant.getTable()); + restDB.clearTicketIdInTableById(m_restaurant.getTable()); + restDB.clearGuestsInTable(m_restaurant.getTable()); + restDB.clearOccupied(m_restaurant.getTable()); + + m_restaurant.deleteTicket(); + } + } + }//GEN-LAST:event_m_DelTicketActionPerformed + + private void m_TablePlanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_TablePlanActionPerformed + // outta here back to TableMap + m_restaurant.newTicket(); + + }//GEN-LAST:event_m_TablePlanActionPerformed + + private void j_btnGuestsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_j_btnGuestsActionPerformed + + Integer iValue = JGuestsPop.showEditNumber(this, + AppLocal.getIntString("title.guestspop.enterguests")); + restDB.setGuestsInTable(iValue, m_restaurant.getTable()); + j_btnGuests.setText(iValue.toString()); + + }//GEN-LAST:event_j_btnGuestsActionPerformed + + @SuppressWarnings("empty-statement") + private void j_btnKitchenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_j_btnKitchenActionPerformed + /* + * This is legacy and deprecated and should use RemotePrinter which covers + * all sales screens for i.e.: Kitchen Print + Click & Collect & etc + * It may be removed from future version + */ + ticket = m_restaurant.getActiveTicket(); + String rScript = (m_dlSystem.getResourceAsText("script.SendOrder")); + + Interpreter i = new Interpreter(); + try { + i.set("ticket", ticket); + i.set("place",m_restaurant.getTableName()); + i.set("user", m_App.getAppUserView().getUser()); + i.set("sales", this); + i.set("pickupid", ticket.getPickupId()); + Object result = i.eval(rScript); + } catch (EvalError ex) { + log.error(ex.getMessage()); + } + // Autologoff after sales + String autoLogoff = (m_App.getProperties().getProperty("till.autoLogoff")); + String autoLogoffRestaurant =(m_App.getProperties().getProperty("till.autoLogoffrestaurant")); + if (autoLogoff != null){ + if (autoLogoff.equals("true")){ + if (autoLogoffRestaurant == null){ + ((JRootApp)m_App).closeAppView(); + }else if (autoLogoffRestaurant.equals("true")){ + m_restaurant.newTicket(); + }else{ + ((JRootApp)m_App).closeAppView(); + } + } + } + }//GEN-LAST:event_j_btnKitchenActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton j_btnGuests; + private javax.swing.JButton j_btnKitchen; + private javax.swing.JButton m_DelTicket; + private javax.swing.JButton m_MoveTable; + private javax.swing.JButton m_TablePlan; + // End of variables declaration//GEN-END:variables + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantMap.form b/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantMap.form new file mode 100644 index 0000000..98aa321 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantMap.form @@ -0,0 +1,225 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-83,0,0,3,27"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jPanelMap"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription"> + <CardConstraints cardName="map"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Before"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="0"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jbtnReservations"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/date.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.reservations" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Open Reservations screen"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[133, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[133, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[133, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnReservationsActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jbtnRefresh"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.reloadticket" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Reload table information"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnRefreshActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jbtnLayout"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/movetable.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.layout" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnLayoutActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jbtnSave"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/filesave.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.save" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnSaveActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="m_jText"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="99" red="0" type="rgb"/> + </Property> + <Property name="opaque" type="boolean" value="true"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="com.alee.laf.label.WebLabel" name="webLblautoRefresh"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="33" red="ff" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.autoRefreshTableMapTimerON" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantMap.java b/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantMap.java new file mode 100644 index 0000000..67d3a66 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantMap.java @@ -0,0 +1,1085 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales.restaurant; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.gui.NullIcon; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.SerializerReadClass; +import com.unicenta.data.loader.StaticSentence; +import com.unicenta.pos.customers.CustomerInfo; +import com.unicenta.pos.forms.*; +import com.unicenta.pos.sales.DataLogicReceipts; +import com.unicenta.pos.sales.JTicketsBag; +import com.unicenta.pos.sales.SharedTicketInfo; +import com.unicenta.pos.sales.TicketsEditor; +import com.unicenta.pos.ticket.TicketInfo; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + +/** + * + * @author JG uniCenta + */ +@Slf4j +public class JTicketsBagRestaurantMap extends JTicketsBag { + + private static class ServerCurrent { + + public ServerCurrent() { + } + } + + private java.util.List<Place> m_aplaces; + private java.util.List<Floor> m_afloors; + + private JTicketsBagRestaurant m_restaurantmap; + + private final JTicketsBagRestaurantRes m_jreservations; + private Place m_PlaceCurrent; + private ServerCurrent m_ServerCurrent; + private Place m_PlaceClipboard; + private CustomerInfo customer; + + private DataLogicReceipts dlReceipts = null; + private DataLogicSales dlSales = null; + private DataLogicSystem dlSystem = null; + private final RestaurantDBUtils restDB; + private static final Icon ICO_OCU_SM = new ImageIcon(Place.class.getResource("/com/unicenta/images/edit_group_sm.png")); + private static final Icon ICO_WAITER = new NullIcon(1, 1); + private static final Icon ICO_FRE = new NullIcon(22, 22); + private String waiterDetails; + private String customerDetails; + private String tableName; + private Boolean transBtns; + private Boolean actionEnabled = true; + private int newX; + private int newY; + private AppView m_app; + private Boolean showLayout = false; + + + /** Creates new form JTicketsBagRestaurant + * @param app + * @param panelticket */ + + public JTicketsBagRestaurantMap(AppView app, TicketsEditor panelticket) { + + super(app, panelticket); + + restDB = new RestaurantDBUtils(app); + transBtns = AppConfig.getInstance().getBoolean("table.transbtn"); + + dlReceipts = (DataLogicReceipts) app.getBean("com.unicenta.pos.sales.DataLogicReceipts"); + dlSales = (DataLogicSales) m_App.getBean("com.unicenta.pos.forms.DataLogicSales"); + dlSystem = (DataLogicSystem) m_App.getBean("com.unicenta.pos.forms.DataLogicSystem"); + + m_restaurantmap = new JTicketsBagRestaurant(app, this); + m_PlaceCurrent = null; + m_PlaceClipboard = null; + customer = null; + + try { + SentenceList sent = new StaticSentence( + app.getSession(), + "SELECT ID, NAME, IMAGE FROM floors ORDER BY NAME", + null, + new SerializerReadClass(Floor.class)); + m_afloors = sent.list(); + + } catch (BasicException eD) { + m_afloors = new ArrayList<>(); + } + try { + SentenceList sent = new StaticSentence( + app.getSession(), + "SELECT ID, NAME, SEATS, X, Y, FLOOR, CUSTOMER, WAITER, " + + "TICKETID, TABLEMOVED, WIDTH, HEIGHT, GUESTS, OCCUPIED " + + "FROM places " + + "ORDER BY FLOOR ", + null, + new SerializerReadClass(Place.class)); + m_aplaces = sent.list(); + } catch (BasicException eD) { + m_aplaces = new ArrayList<>(); + } + + initComponents(); + + m_jbtnSave.setVisible(false); + + if (m_afloors.size() > 1) { + JTabbedPane jTabFloors = new JTabbedPane(); + jTabFloors.applyComponentOrientation(getComponentOrientation()); + jTabFloors.setBorder(new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5))); + jTabFloors.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); + jTabFloors.setFocusable(false); + jTabFloors.setRequestFocusEnabled(false); + m_jPanelMap.add(jTabFloors, BorderLayout.CENTER); + + m_afloors.stream().map((f) -> { + f.getContainer().applyComponentOrientation(getComponentOrientation()); + return f; + }).forEach((f) -> { + JScrollPane jScrCont = new JScrollPane(); + jScrCont.applyComponentOrientation(getComponentOrientation()); + JPanel jPanCont = new JPanel(); + jPanCont.applyComponentOrientation(getComponentOrientation()); + + jTabFloors.addTab(f.getName(), f.getIcon(), jScrCont); + jScrCont.setViewportView(jPanCont); + jPanCont.add(f.getContainer()); + }); + } else if (m_afloors.size() == 1) { + Floor f = m_afloors.get(0); + f.getContainer().applyComponentOrientation(getComponentOrientation()); + + JPanel jPlaces = new JPanel(); + jPlaces.applyComponentOrientation(getComponentOrientation()); + jPlaces.setLayout(new BorderLayout()); + jPlaces.setBorder(new javax.swing.border.CompoundBorder( + new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5)), + new javax.swing.border.TitledBorder(f.getName()))); + + JScrollPane jScrCont = new JScrollPane(); + jScrCont.applyComponentOrientation(getComponentOrientation()); + JPanel jPanCont = new JPanel(); + jPanCont.applyComponentOrientation(getComponentOrientation()); + + m_jPanelMap.add(jPlaces, BorderLayout.CENTER); + jPlaces.add(jScrCont, BorderLayout.CENTER); + jScrCont.setViewportView(jPanCont); + jPanCont.add(f.getContainer()); + } + + Floor currfloor = null; + + for (Place pl : m_aplaces) { + int iFloor = 0; + + if (currfloor == null || !currfloor.getID().equals(pl.getFloor())) { + do { + currfloor = m_afloors.get(iFloor++); + } while (!currfloor.getID().equals(pl.getFloor())); + } + + currfloor.getContainer().add(pl.getButton()); + pl.setButtonBounds(); + + if (transBtns) { + pl.getButton().setOpaque(false); + pl.getButton().setContentAreaFilled(false); + pl.getButton().setBorderPainted(false); + } + + pl.getButton().addMouseMotionListener(new MouseAdapter() { + @Override + public void mouseDragged(MouseEvent E) { + if (!actionEnabled) { + if (pl.getDiffX() == 0) { + pl.setDiffX(pl.getButton().getX() - pl.getX()); + pl.setDiffY(pl.getButton().getY() - pl.getY()); + } + newX = E.getX() + pl.getButton().getX(); + newY = E.getY() + pl.getButton().getY(); + pl.getButton().setBounds(newX + pl.getDiffX(), newY + pl.getDiffY(), + pl.getButton().getWidth(), pl.getButton().getHeight()); + pl.setX(newX); + pl.setY(newY); + } + } + } + ); + + pl.getButton().addActionListener(new MyActionListener(pl)); + } + + m_jreservations = new JTicketsBagRestaurantRes(app, this); + add(m_jreservations, "res"); + + showLayout = m_App.getAppUserView().getUser().hasPermission("sales.Layout"); + if (showLayout) { + m_jbtnLayout.setVisible(true); + m_jbtnSave.setVisible(false); + } else { + m_jbtnLayout.setVisible(false); + m_jbtnSave.setVisible(false); + } + + if (m_App.getProperties().getProperty("till.autoRefreshTableMap").equals("true")) { + webLblautoRefresh.setText(java.util.ResourceBundle.getBundle("pos_messages") + .getString("label.autoRefreshTableMapTimerON")); + + Timer autoRefreshTimer = new Timer(Integer.parseInt(m_App.getProperties() + .getProperty("till.autoRefreshTimer"))*1000, new tableMapRefresh()); + + autoRefreshTimer.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + autoRefreshTimer.stop(); + } + } else { + webLblautoRefresh.setText(java.util.ResourceBundle.getBundle("pos_messages") + .getString("label.autoRefreshTableMapTimerOFF")); + } + +} + + class tableMapRefresh implements ActionListener { + + @Override + public void actionPerformed(ActionEvent e) { + loadTickets(); + printState(); + } + } + + /** + * + */ + @Override + public void activate() { + + showLayout = m_App.getAppUserView().getUser().hasPermission("sales.Layout"); + if (showLayout) { + m_jbtnLayout.setVisible(true); + m_jbtnSave.setVisible(false); + } else { + m_jbtnLayout.setVisible(false); + m_jbtnSave.setVisible(false); + } + + m_PlaceClipboard = null; + customer = null; + loadTickets(); + printState(); + + m_panelticket.setActiveTicket(null, null); + m_restaurantmap.activate(); + + showView("map"); + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + + if (viewTables()) { + m_PlaceClipboard = null; + customer = null; + + if (m_PlaceCurrent != null) { + + try { + dlReceipts.updateSharedTicket(m_PlaceCurrent.getId(), + m_panelticket.getActiveTicket(), + m_panelticket.getActiveTicket().getPickupId()); + dlReceipts.unlockSharedTicket(m_PlaceCurrent.getId(),null); + } catch (BasicException e) { + new MessageInf(e).show(this); + } + + m_PlaceCurrent = null; + + } + printState(); + m_panelticket.setActiveTicket(null, null); + + return true; + } else { + return false; + } + } + + /** + * + * @return + */ + @Override + protected JComponent getBagComponent() { + return m_restaurantmap; + } + + /** + * + * @return + */ + @Override + protected JComponent getNullComponent() { + return this; + } + + /** + * + * @return + */ + public TicketInfo getActiveTicket() { + return m_panelticket.getActiveTicket(); + } + + /** + * + */ + public void moveTicket() { + if (m_PlaceCurrent != null) { + try { + dlReceipts.updateRSharedTicket(m_PlaceCurrent.getId(), + m_panelticket.getActiveTicket(),m_panelticket.getActiveTicket().getPickupId()); + } catch (BasicException e) { + new MessageInf(e).show(this); + } + + m_PlaceClipboard = m_PlaceCurrent; // put FROM table to TO table + + customer = null; +// m_PlaceCurrent = null; // Hang on we'll clear later after we're done + } + + printState(); + m_panelticket.setActiveTicket(null, null); + } + + /** + * + * @param c + * @return + */ + public boolean viewTables(CustomerInfo c) { + if (m_jreservations.deactivate()) { + showView("map"); + m_PlaceClipboard = null; + customer = c; + printState(); + return true; + } else { + return false; + } + } + + /** + * + * @return + */ + public boolean viewTables() { + return viewTables(null); + } + + /** + * + */ + public void newTicket() { + + if (m_PlaceCurrent != null) { + + try { + String m_lockState = null; + m_lockState = dlReceipts.getLockState(m_PlaceCurrent.getId(), m_lockState); + dlReceipts.getSharedTicket(m_PlaceCurrent.getId()); + + if ("override".equals(m_lockState) + || "locked".equals(m_lockState)) { + dlReceipts.updateSharedTicket(m_PlaceCurrent.getId(), + m_panelticket.getActiveTicket(), + m_panelticket.getActiveTicket().getPickupId()); + dlReceipts.unlockSharedTicket(m_PlaceCurrent.getId(), null); + m_PlaceCurrent = null; + + } else { + JOptionPane.showMessageDialog(null + , AppLocal.getIntString("message.sharedticketlockoverriden") + , AppLocal.getIntString("title.editor") + , JOptionPane.INFORMATION_MESSAGE); + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + printState(); + m_panelticket.setActiveTicket(null, null); + } + + /** + * + * @return + */ + public String getTable() { + String id = null; + if (m_PlaceCurrent != null) { + id = m_PlaceCurrent.getId(); + } + return(id); + } + + /** + * + * @return + */ + public String getTableName() { + String stableName = null; + if (m_PlaceCurrent != null) { + stableName = m_PlaceCurrent.getName(); + } + return(stableName); + } + + /** + * + */ + @Override + public void deleteTicket() { + + if (m_PlaceCurrent != null) { + String id = m_PlaceCurrent.getId(); + try { + dlReceipts.deleteSharedTicket(id); + dlSystem.execTicketRemoved( + new Object[] { + m_App.getAppUserView().getUser().getName(), + "Void", + "Ticket Deleted", + 0.0 + }); + + } catch (BasicException e) { + new MessageInf(e).show(this); + } + + m_PlaceCurrent.setPeople(false); + m_PlaceCurrent = null; + } + + printState(); + m_panelticket.setActiveTicket(null, null); + } + + /** + * + */ + public void changeServer() { + + if (m_ServerCurrent != null) { + } + } + + /** + * + */ + public void loadTickets() { + + Set<String> atickets = new HashSet<>(); + + try { + java.util.List<SharedTicketInfo> l = dlReceipts.getSharedTicketList(); + l.stream().forEach((ticket) -> { + atickets.add(ticket.getId()); + }); + } catch (BasicException e) { + new MessageInf(e).show(this); + } + + m_aplaces.stream().forEach((table) -> { + table.setPeople(atickets.contains(table.getId())); + }); + } + +/* + * Populate the floor plans and tables +*/ + private void printState() { + String sDB; + sDB = m_App.getProperties().getProperty("db.engine"); + + if (m_PlaceClipboard == null) { + if (customer == null) { + m_jText.setText(null); + + m_aplaces.stream() + .map((place) -> { + place.getButton().setEnabled(true); + Integer guests = restDB.getGuestsInTable(place.getId()); + place.setGuests(guests); + Date occupied = restDB.getOccupied(place.getId()); + place.setOccupied(occupied); + return place; + }) + + .map((place) -> { + if (m_App.getProperties().getProperty("table.tablecolour")== null){ + tableName="<style=font-size:9px;font-weight:bold;><font color = black>" + + place.getName()+"</font></style>"; + }else{ + if (place.getOccupied() != null) { + Date date = new java.util.Date(); + Timestamp t1 = new Timestamp(date.getTime()); + Timestamp t2 = new Timestamp(place.getOccupied().getTime()); + + long milliseconds = t1.getTime() - t2.getTime(); + int seconds = (int) milliseconds / 1000; + int hours = seconds / 3600; + int minutes = (seconds % 3600) / 60; + +Integer count = restDB.getGuestsInTable(place.getId()); + + tableName="<style=font-size:9px;font-weight:bold;><font color =" + + m_App.getProperties().getProperty("table.tablecolour")+ ">" + + place.getName() + " / " + place.getSeats() + "<br>" +// + AppLocal.getIntString("button.guest") + place.getGuests() + "<br>" + + AppLocal.getIntString("button.guest") + count + "<br>" + + AppLocal.getIntString("button.occupied") + + hours + "h" + ":" + minutes + "m" + + "<br>" + + "</font></style>"; + } else { + tableName="<style=font-size:9px;font-weight:bold;><font color =" + + m_App.getProperties().getProperty("table.tablecolour")+ ">" + + place.getName() + " / " + place.getSeats() + "<br>" + + "</font></style>"; + } + } + return place; + }) + + .map((place) -> { + if (Boolean.parseBoolean(m_App.getProperties().getProperty("table.showwaiterdetails"))){ + if (m_App.getProperties().getProperty("table.waitercolour")== null){ + waiterDetails = (restDB.getWaiterNameInTable(place.getName()) ==null)? "" + :"<style=font-size:9px;font-weight:bold;><font color = red>" + + restDB.getWaiterNameInTableById(place.getId())+"</font></style><br>"; + }else{ + waiterDetails = (restDB.getWaiterNameInTable(place.getName()) ==null)? "" + :"<style=font-size:9px;font-weight:bold;><font color =" + + m_App.getProperties().getProperty("table.waitercolour")+ ">" + + restDB.getWaiterNameInTableById(place.getId())+"</font></style><br>"; + } + place.getButton().setIcon(ICO_OCU_SM); + } else { + waiterDetails = ""; + } + return place; + }) + + .map((place) -> { + if (Boolean.parseBoolean( + m_App.getProperties().getProperty("table.showcustomerdetails"))){ + place.getButton().setIcon((Boolean.parseBoolean( + m_App.getProperties().getProperty("table.showwaiterdetails")) + && (restDB.getCustomerNameInTable(place.getName()) !=null)) + ? ICO_WAITER:ICO_OCU_SM); + if (m_App.getProperties().getProperty("table.customercolour")== null){ + customerDetails = (restDB.getCustomerNameInTable(place.getName()) ==null)? "" + :"<style=font-size:9px;font-weight:bold;><font color = blue>" + + restDB.getCustomerNameInTableById(place.getId())+"</font></style><br>"; + }else{ + customerDetails = (restDB.getCustomerNameInTable(place.getName()) ==null)? "" + :"<style=font-size:9px;font-weight:bold;><font color =" + + m_App.getProperties().getProperty("table.customercolour")+ ">" + + restDB.getCustomerNameInTableById(place.getId())+"</font></style><br>"; + } + } else { + customerDetails = ""; + } + return place; + }) + + .map((place) -> { + if ((Boolean.parseBoolean( + m_App.getProperties().getProperty("table.showwaiterdetails"))) + || (Boolean.parseBoolean( + m_App.getProperties().getProperty("table.showcustomerdetails")))) { + place.getButton().setText("<html><center>" + + customerDetails + waiterDetails +tableName+"</html>" ); + }else{ + if (m_App.getProperties().getProperty("table.tablecolour")== null){ + tableName="<style=font-size:10px;font-weight:bold;><font color = black>" + + place.getName()+"</font></style>"; + }else{ + tableName="<style=font-size:10px;font-weight:bold;><font color =" + + m_App.getProperties().getProperty("table.tablecolour")+ ">" + + place.getName()+"</font></style>"; + } + place.getButton().setText("<html><center>"+tableName+"</html>"); + } + return place; + }) + + .filter((place) -> (!place.hasPeople())) + + .forEach((place) -> { + place.getButton().setIcon(ICO_FRE); + }); + + m_jbtnReservations.setEnabled(true); +// places here + + } else { + m_jText.setText(AppLocal.getIntString("label.restaurantcustomer" + , new Object[] { + customer.getName() + } + ) + ); + + m_aplaces.stream() + .forEach((place) -> { + place.getButton().setEnabled(!place.hasPeople()); + }); + m_jbtnReservations.setEnabled(false); + } + } else { + m_jText.setText(AppLocal.getIntString("label.restaurantmove" + , new Object[] { + m_PlaceClipboard.getName() + } + )); + + m_aplaces.stream() + .forEach((place) -> { + Integer guests = restDB.getGuestsInTable(place.getId()); + place.setGuests(guests); + Date occupied = restDB.getOccupied(place.getId()); + place.setOccupied(occupied); + place.getButton().setEnabled(true); + }); + + m_jbtnReservations.setEnabled(false); + } + } + + private TicketInfo getTicketInfo(Place place) { + + try { + return dlReceipts.getSharedTicket(place.getId()); + } catch (BasicException e) { + new MessageInf(e).show(JTicketsBagRestaurantMap.this); + return null; + } + } + + private void setActivePlace(Place place, TicketInfo ticket) { + m_PlaceCurrent = place; + m_panelticket.setActiveTicket(ticket, m_PlaceCurrent.getName()); + m_restaurantmap.updateGuestCount(); + + try { + dlReceipts.lockSharedTicket(m_PlaceCurrent.getId(),"locked"); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + } + + private void showView(String view) { + CardLayout cl = (CardLayout)(getLayout()); + cl.show(this, view); + } + + private class MyActionListener implements ActionListener { + + private final Place m_place; + public MyActionListener(Place place) { + m_place = place; + } + @Override + public void actionPerformed(ActionEvent evt) { + m_App.getAppUserView().getUser(); + + if (!actionEnabled) { + m_place.setDiffX(0); + } else { + if (m_PlaceClipboard == null) { + TicketInfo ticket = getTicketInfo(m_place); + if (ticket == null) { // It's an empty table + ticket = new TicketInfo(); + ticket.setUser(m_App.getAppUserView().getUser().getUserInfo()); + try { + dlReceipts.insertSharedTicket(m_place.getId(), ticket, ticket.getPickupId()); + } catch (BasicException e) { + new MessageInf(e).show(JTicketsBagRestaurantMap.this); + } + m_place.setPeople(true); + m_place.setGuests(restDB.updateGuestsInTable(m_place.getId())); + setActivePlace(m_place, ticket); + } else { // Table not empty + String m_lockState = null; + try { + m_lockState = dlReceipts.getLockState(m_place.getId(), m_lockState); //check lockstate + + if ("locked".equals(m_lockState)) { // It's locked + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.sharedticketlock")); + + if (m_App.getAppUserView().getUser().hasPermission("sales.Override")) { // Override it + int res = JOptionPane.showConfirmDialog(null + , AppLocal.getIntString("message.sharedticketlockoverride") + , AppLocal.getIntString("title.editor") + , JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); + + if (res == JOptionPane.YES_OPTION) { + m_place.setPeople(true); + m_PlaceClipboard = null; + setActivePlace(m_place, ticket); + dlReceipts.lockSharedTicket(m_PlaceCurrent.getId(),"locked"); + } + } + } else { // It's not locked + String m_user = m_App.getAppUserView().getUser().getId(); + String ticketuser = dlReceipts.getServer(m_place.getId(),m_user); + + if (m_App.getAppUserView().getUser().hasPermission("sales.Override") //Check User permission + || m_user.equals(ticketuser)) { + m_place.setPeople(true); + + m_PlaceClipboard = null; + m_lockState = "locked"; + setActivePlace(m_place, ticket); + } else { + JOptionPane.showMessageDialog(null + , AppLocal.getIntString("message.sharedticket") + , AppLocal.getIntString("title.editor") + , JOptionPane.OK_OPTION); + } + } + } catch (BasicException ex) { + log.error(ex.getMessage()); + } +// printState(); // show table map. Why here? + } + } +// This block handles Merge +// at this stage m_PlaceClipboard is FROM table +// at this point m_place is TO table + + if (m_PlaceClipboard != null) { // Anything in the Clipboard? + TicketInfo ticketclip = getTicketInfo(m_PlaceClipboard); // add ticket object from clipboard + + if (ticketclip != null) { + + if (m_PlaceClipboard == m_place) { // check if FROM same as TO + Place placeclip = m_PlaceClipboard; + m_PlaceClipboard = null; + customer = null; + printState(); + setActivePlace(placeclip, ticketclip); + } + + if (m_place.hasPeople()) { // check if TO table already occupied + TicketInfo ticket = getTicketInfo(m_place); // add TO ticket object + + if (ticket != null) { // It does, so... + + if (JOptionPane.showConfirmDialog(JTicketsBagRestaurantMap.this, + AppLocal.getIntString("message.mergetablequestion"), + AppLocal.getIntString("message.mergetable"), + JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { + try { + m_PlaceClipboard.setPeople(false); + + if (ticket.getCustomer() == null) { + ticket.setCustomer(ticketclip.getCustomer()); + } + ticketclip.getLines().stream().forEach((line) -> { + ticket.addLine(line); + }); + dlReceipts.updateRSharedTicket(m_place.getId(), + ticket, ticket.getPickupId()); + dlReceipts.deleteSharedTicket(m_PlaceClipboard.getId()); + m_place.setGuests(m_PlaceClipboard.getGuests()); // Add Guests from Clipboard + + } catch (BasicException e) { + new MessageInf(e).show(JTicketsBagRestaurantMap.this); + } + m_PlaceClipboard = null; + customer = null; + + restDB.clearCustomerNameInTable(restDB.getTableDetails(ticketclip.getId())); + restDB.clearWaiterNameInTable(restDB.getTableDetails(ticketclip.getId())); + restDB.clearTableMovedFlag(restDB.getTableDetails(ticketclip.getId())); + restDB.clearTicketIdInTable(restDB.getTableDetails(ticketclip.getId())); + restDB.clearOccupiedTable(restDB.getTableDetails(ticketclip.getId())); + + printState(); + setActivePlace(m_place, ticket); + } else { + Place placeclip = m_PlaceClipboard; // don't want to merge so clear clipboard + m_PlaceClipboard = null; + customer = null; + printState(); + setActivePlace(placeclip, ticketclip); + } + } else { + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.tableempty")) + .show(JTicketsBagRestaurantMap.this); + m_place.setPeople(false); + } + } else { // The TO table is empty + TicketInfo ticket = getTicketInfo(m_place); // fill ticket object with TO table + + if (ticket == null) { + try { + dlReceipts.insertRSharedTicket(m_place.getId(), ticketclip, ticketclip.getPickupId()); + m_place.setPeople(true); + m_place.setGuests(m_PlaceClipboard.getGuests()); // Add Guests from Clipboard + dlReceipts.deleteSharedTicket(m_PlaceClipboard.getId()); + m_PlaceClipboard.setPeople(false); + } catch (BasicException e) { + new MessageInf(e).show(JTicketsBagRestaurantMap.this); + } + printState(); + setActivePlace(m_place, ticketclip); + m_PlaceClipboard = null; + customer = null; + } else { + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.tablefull")) + .show(JTicketsBagRestaurantMap.this); + m_PlaceClipboard.setPeople(true); + printState(); + } + } + } else { // table empty! Do we need it here? + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.tableempty")).show(JTicketsBagRestaurantMap.this); + m_PlaceClipboard.setPeople(false); + m_PlaceClipboard = null; + customer = null; + printState(); + } + } // end of Merge + } // end of !actionEnabled + } // end of actionPerformed + } // end of Action Listener + + /** + * + * @param btnText + */ + public void setButtonTextBags(String btnText){ + m_PlaceClipboard.setButtonText(btnText); + } + + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jPanelMap = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + m_jbtnReservations = new javax.swing.JButton(); + m_jbtnRefresh = new javax.swing.JButton(); + m_jbtnLayout = new javax.swing.JButton(); + m_jbtnSave = new javax.swing.JButton(); + m_jText = new javax.swing.JLabel(); + webLblautoRefresh = new com.alee.laf.label.WebLabel(); + + setLayout(new java.awt.CardLayout()); + + m_jPanelMap.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jPanelMap.setLayout(new java.awt.BorderLayout()); + + jPanel1.setLayout(new java.awt.BorderLayout()); + + jPanel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); + + m_jbtnReservations.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jbtnReservations.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/date.png"))); // NOI18N + m_jbtnReservations.setText(AppLocal.getIntString("button.reservations")); // NOI18N + m_jbtnReservations.setToolTipText("Open Reservations screen"); + m_jbtnReservations.setFocusPainted(false); + m_jbtnReservations.setFocusable(false); + m_jbtnReservations.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jbtnReservations.setMaximumSize(new java.awt.Dimension(133, 40)); + m_jbtnReservations.setMinimumSize(new java.awt.Dimension(133, 40)); + m_jbtnReservations.setPreferredSize(new java.awt.Dimension(133, 45)); + m_jbtnReservations.setRequestFocusEnabled(false); + m_jbtnReservations.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnReservationsActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnReservations); + + m_jbtnRefresh.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jbtnRefresh.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + m_jbtnRefresh.setText(AppLocal.getIntString("button.reloadticket")); // NOI18N + m_jbtnRefresh.setToolTipText("Reload table information"); + m_jbtnRefresh.setFocusPainted(false); + m_jbtnRefresh.setFocusable(false); + m_jbtnRefresh.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jbtnRefresh.setMaximumSize(new java.awt.Dimension(100, 40)); + m_jbtnRefresh.setMinimumSize(new java.awt.Dimension(100, 40)); + m_jbtnRefresh.setPreferredSize(new java.awt.Dimension(100, 45)); + m_jbtnRefresh.setRequestFocusEnabled(false); + m_jbtnRefresh.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnRefreshActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnRefresh); + + m_jbtnLayout.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jbtnLayout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/movetable.png"))); // NOI18N + m_jbtnLayout.setText(AppLocal.getIntString("button.layout")); // NOI18N + m_jbtnLayout.setToolTipText(""); + m_jbtnLayout.setFocusPainted(false); + m_jbtnLayout.setFocusable(false); + m_jbtnLayout.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jbtnLayout.setMaximumSize(new java.awt.Dimension(100, 40)); + m_jbtnLayout.setMinimumSize(new java.awt.Dimension(100, 40)); + m_jbtnLayout.setPreferredSize(new java.awt.Dimension(100, 45)); + m_jbtnLayout.setRequestFocusEnabled(false); + m_jbtnLayout.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnLayoutActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnLayout); + + m_jbtnSave.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jbtnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/filesave.png"))); // NOI18N + m_jbtnSave.setText(AppLocal.getIntString("button.save")); // NOI18N + m_jbtnSave.setToolTipText(""); + m_jbtnSave.setFocusPainted(false); + m_jbtnSave.setFocusable(false); + m_jbtnSave.setMargin(new java.awt.Insets(8, 14, 8, 14)); + m_jbtnSave.setMaximumSize(new java.awt.Dimension(100, 40)); + m_jbtnSave.setMinimumSize(new java.awt.Dimension(100, 40)); + m_jbtnSave.setPreferredSize(new java.awt.Dimension(100, 45)); + m_jbtnSave.setRequestFocusEnabled(false); + m_jbtnSave.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnSaveActionPerformed(evt); + } + }); + jPanel2.add(m_jbtnSave); + + m_jText.setBackground(new java.awt.Color(255, 255, 255)); + m_jText.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jText.setForeground(new java.awt.Color(0, 153, 255)); + m_jText.setOpaque(true); + jPanel2.add(m_jText); + + jPanel1.add(jPanel2, java.awt.BorderLayout.LINE_START); + + webLblautoRefresh.setBackground(new java.awt.Color(255, 51, 51)); + webLblautoRefresh.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + webLblautoRefresh.setText(bundle.getString("label.autoRefreshTableMapTimerON")); // NOI18N + webLblautoRefresh.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel1.add(webLblautoRefresh, java.awt.BorderLayout.CENTER); + + m_jPanelMap.add(jPanel1, java.awt.BorderLayout.NORTH); + + add(m_jPanelMap, "map"); + }// </editor-fold>//GEN-END:initComponents + + private void m_jbtnRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnRefreshActionPerformed + + loadTickets(); + printState(); + }//GEN-LAST:event_m_jbtnRefreshActionPerformed + + private void m_jbtnReservationsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnReservationsActionPerformed + showView("res"); + m_jreservations.activate(); + }//GEN-LAST:event_m_jbtnReservationsActionPerformed + + private void m_jbtnLayoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnLayoutActionPerformed + if (java.util.ResourceBundle.getBundle("pos_messages") + .getString("button.layout").equals(m_jbtnLayout.getText())) { + actionEnabled = false; + m_jbtnSave.setVisible(true); + m_jbtnLayout.setText(java.util.ResourceBundle + .getBundle("pos_messages").getString("button.disablelayout")); + + m_aplaces.stream().filter((pl) -> (transBtns)).map((pl) -> { + pl.getButton().setOpaque(true); + return pl; + }).map((pl) -> { + pl.getButton().setContentAreaFilled(true); + return pl; + }).forEachOrdered((pl) -> { + pl.getButton().setBorderPainted(true); + }); + } else { + actionEnabled = true; + m_jbtnSave.setVisible(false); + m_jbtnLayout.setText(java.util.ResourceBundle + .getBundle("pos_messages").getString("button.layout")); + + m_aplaces.stream().filter((pl) -> (transBtns)).map((pl) -> { + pl.getButton().setOpaque(false); + return pl; + }).map((pl) -> { + pl.getButton().setContentAreaFilled(false); + return pl; + }).forEachOrdered((pl) -> { + pl.getButton().setBorderPainted(false); + }); + } + }//GEN-LAST:event_m_jbtnLayoutActionPerformed + + private void m_jbtnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnSaveActionPerformed + m_aplaces.forEach((pl) -> { + try { + dlSystem.updatePlaces(pl.getX(), pl.getY(), pl.getId()); + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + }); + }//GEN-LAST:event_m_jbtnSaveActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel m_jPanelMap; + private javax.swing.JLabel m_jText; + private javax.swing.JButton m_jbtnLayout; + private javax.swing.JButton m_jbtnRefresh; + private javax.swing.JButton m_jbtnReservations; + private javax.swing.JButton m_jbtnSave; + private com.alee.laf.label.WebLabel webLblautoRefresh; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantRes.form b/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantRes.form new file mode 100644 index 0000000..378721d --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantRes.form @@ -0,0 +1,480 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1000, 750]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-18,0,0,3,-12"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanNorth"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1000, 350]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="10" pref="10" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <EmptySpace min="10" pref="10" max="-2" attributes="0"/> + <Component id="jButton1" min="-2" pref="70" max="-2" attributes="0"/> + <EmptySpace min="6" pref="6" max="-2" attributes="0"/> + <Component id="txtCustomer" min="-2" max="-2" attributes="0"/> + <EmptySpace min="4" pref="4" max="-2" attributes="0"/> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace min="4" pref="4" max="-2" attributes="0"/> + <Component id="m_jtxtChairs" min="-2" pref="90" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="m_jPanelTime" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jbtnShowCalendar" min="-2" pref="200" max="-2" attributes="0"/> + <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + <EmptySpace min="4" pref="4" max="-2" attributes="0"/> + <Component id="m_jtxtDescription" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="22" max="-2" attributes="0"/> + <Component id="m_jPanelList" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="m_jToolbar" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jKeys" min="-2" pref="1" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="m_jbtnReceive" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jbtnTables" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="42" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jToolbar" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="24" max="-2" attributes="0"/> + <Component id="m_jKeys" min="-2" pref="32" max="-2" attributes="0"/> + </Group> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jbtnTables" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jbtnReceive" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Component id="jLabel5" min="-2" pref="40" max="-2" attributes="0"/> + </Group> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + <Group type="102" attributes="0"> + <EmptySpace min="7" pref="7" max="-2" attributes="0"/> + <Component id="txtCustomer" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace min="7" pref="7" max="-2" attributes="0"/> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace min="7" pref="7" max="-2" attributes="0"/> + <Component id="m_jtxtChairs" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace min="7" pref="7" max="-2" attributes="0"/> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace min="7" pref="7" max="-2" attributes="0"/> + <Component id="m_jtxtDescription" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="2" attributes="0"> + <EmptySpace min="-2" pref="31" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="42" max="-2" attributes="0"/> + <Component id="jbtnShowCalendar" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="2" attributes="0"> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jPanelTime" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jPanelList" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jToolbar"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 55]"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + <Component class="javax.swing.JButton" name="m_jbtnReceive"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/receive.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.receive" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Receive pre-Booked Customer"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnReceiveActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jbtnTables"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/tables.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.tables" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Go to Table Plan"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[130, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jbtnTablesActionPerformed"/> + </Events> + </Component> + <Container class="javax.swing.JPanel" name="m_jPanelList"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[300, 200]"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="rest.label.selectcustomer" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 45]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleName" type="java.lang.String" value="Select Person"/> + </AccessibilityProperties> + </Component> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/customer_add_sml.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Show Customers"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/> + </Events> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="txtCustomer"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="rest.label.chairs" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorIntegerPositive" name="m_jtxtChairs"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="rest.label.notes" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtDescription"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[180, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="rest.label.date" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="verticalAlignment" type="int" value="1"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Container class="javax.swing.JPanel" name="m_jPanelTime"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 200]"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + <Component class="javax.swing.JButton" name="jbtnShowCalendar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/date.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="rest.label.showcalendar" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="rest.label.showcalendar" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[129, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnShowCalendarActionPerformed"/> + </Events> + </Component> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 5]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanSouth"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1000, 350]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="1012" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jCalendar" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <EmptySpace min="0" pref="350" max="32767" attributes="0"/> + <Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jCalendar" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jCalendar"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1000, 350]"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="false"/> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanelTime"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 250]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="0" y="50" width="-1" height="-1"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + <Container class="javax.swing.JPanel" name="jPanelDate"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 345]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> + <AbsoluteConstraints x="270" y="5" width="-1" height="-1"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantRes.java b/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantRes.java new file mode 100644 index 0000000..f6abccc --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/restaurant/JTicketsBagRestaurantRes.java @@ -0,0 +1,710 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales.restaurant; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.beans.*; +import java.util.*; + +import com.unicenta.beans.*; +import com.unicenta.data.gui.*; +import com.unicenta.data.loader.*; +import com.unicenta.data.user.*; + +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.format.Formats; +import com.unicenta.basic.BasicException; +import com.unicenta.pos.customers.DataLogicCustomers; +import com.unicenta.pos.customers.JCustomerFinder; +import com.unicenta.pos.customers.CustomerInfo; + +/** + * + * @author JG uniCenta + */ +public class JTicketsBagRestaurantRes extends javax.swing.JPanel implements EditorRecord { + + private final JTicketsBagRestaurantMap m_restaurantmap; + + private DataLogicCustomers dlCustomers = null; + + private final DirtyManager m_Dirty; + private Object m_sID; + private CustomerInfo customer; + private Date m_dCreated; + private final JTimePanel m_timereservation; + private boolean m_bReceived; + private final BrowsableEditableData m_bd; + + private Date m_dcurrentday; + + private final JCalendarPanel m_datepanel; + private final JTimePanel m_timepanel; + private boolean m_bpaintlock = false; + + + /** Creates new form JPanelReservations + * @param oApp + * @param restaurantmap */ + public JTicketsBagRestaurantRes(AppView oApp, JTicketsBagRestaurantMap restaurantmap) { + + m_restaurantmap = restaurantmap; + + dlCustomers = (DataLogicCustomers) oApp.getBean("com.unicenta.pos.customers.DataLogicCustomers"); + + m_dcurrentday = null; + + initComponents(); + jCalendar.setVisible(false); + + m_datepanel = new JCalendarPanel(); + jPanelDate.add(m_datepanel, BorderLayout.CENTER); + m_datepanel.addPropertyChangeListener("Date", new DateChangeCalendarListener()); + + m_timepanel = new JTimePanel(null, JTimePanel.BUTTONS_HOUR); + m_timepanel.setPeriod(3600000L); + jPanelTime.add(m_timepanel, BorderLayout.CENTER); + m_timepanel.addPropertyChangeListener("Date", new DateChangeTimeListener()); + + m_timereservation = new JTimePanel(null, JTimePanel.BUTTONS_MINUTE); + m_jPanelTime.add(m_timereservation, BorderLayout.CENTER); + + txtCustomer.addEditorKeys(m_jKeys); + m_jtxtChairs.addEditorKeys(m_jKeys); + m_jtxtDescription.addEditorKeys(m_jKeys); + + m_Dirty = new DirtyManager(); + m_timereservation.addPropertyChangeListener("Date", m_Dirty); + txtCustomer.addPropertyChangeListener("Text", m_Dirty); + txtCustomer.addPropertyChangeListener("Text", new PropertyChangeListener(){ + @Override + public void propertyChange(PropertyChangeEvent evt) { + customer = new CustomerInfo(null); + customer.setTaxid(null); + customer.setSearchkey(null); + customer.setName(txtCustomer.getText()); + } + }); + m_jtxtChairs.addPropertyChangeListener("Text", m_Dirty); + m_jtxtDescription.addPropertyChangeListener("Text", m_Dirty); + + writeValueEOF(); + + ListProvider lpr = new ListProviderCreator(dlCustomers.getReservationsList(), new MyDateFilter()); + SaveProvider spr = new SaveProvider(dlCustomers.getReservationsUpdate(), + dlCustomers.getReservationsInsert(), dlCustomers.getReservationsDelete()); + + m_bd = new BrowsableEditableData(lpr, spr, new CompareReservations(), this, m_Dirty); + + JListNavigator nl = new JListNavigator(m_bd, true); + nl.setCellRenderer(new JCalendarItemRenderer()); + m_jPanelList.add(nl, BorderLayout.CENTER); + + m_jToolbar.add(new JLabelDirty(m_Dirty)); + m_jToolbar.add(new JCounter(m_bd)); + m_jToolbar.add(new JNavigator(m_bd)); + m_jToolbar.add(new JSaver(m_bd)); + } + + private class MyDateFilter implements EditorCreator { + @Override + public Object createValue() throws BasicException { + return new Object[] {m_dcurrentday, new Date(m_dcurrentday.getTime() + 3600000L)}; + } + } + + /** + * + */ + public void activate() { + reload(DateUtils.getTodayHours(new Date())); + } + + /** + * + */ + @Override + public void refresh() { + } + + /** + * + * @return + */ + public boolean deactivate() { + try { + return m_bd.actionClosingForm(this); + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, + AppLocal.getIntString("message.CannotMove"), eD); + msg.show(this); + return false; + } + } + + /** + * + */ + @Override + public void writeValueEOF() { + m_sID = null; + m_dCreated = null; + m_timereservation.setDate(null); + assignCustomer(new CustomerInfo(null)); + m_jtxtChairs.reset(); + m_bReceived = false; + m_jtxtDescription.reset(); + m_timereservation.setEnabled(false); + txtCustomer.setEnabled(false); + m_jtxtChairs.setEnabled(false); + m_jtxtDescription.setEnabled(false); + m_jKeys.setEnabled(false); + + m_jbtnReceive.setEnabled(false); + } + + /** + * + */ + @Override + public void writeValueInsert() { + m_sID = null; + m_dCreated = null; + m_timereservation.setCheckDates(m_dcurrentday, new Date(m_dcurrentday.getTime() + 3600000L)); + m_timereservation.setDate(m_dcurrentday); + assignCustomer(new CustomerInfo(null)); + m_jtxtChairs.setValueInteger(2); + m_bReceived = false; + m_jtxtDescription.reset(); + m_timereservation.setEnabled(true); + txtCustomer.setEnabled(true); + m_jtxtChairs.setEnabled(true); + m_jtxtDescription.setEnabled(true); + m_jKeys.setEnabled(true); + + m_jbtnReceive.setEnabled(true); + + txtCustomer.activate(); + } + + /** + * + * @param value + */ + @Override + public void writeValueDelete(Object value) { + Object[] res = (Object[]) value; + m_sID = res[0]; + m_dCreated = (Date) res[1]; + m_timereservation.setCheckDates(m_dcurrentday, new Date(m_dcurrentday.getTime() + 3600000L)); + m_timereservation.setDate((Date) res[2]); + CustomerInfo c = new CustomerInfo((String) res[3]); + c.setTaxid((String) res[4]); + c.setSearchkey((String) res[5]); + c.setName((String) res[6]); + assignCustomer(c); + m_jtxtChairs.setValueInteger(((Integer)res[7]).intValue()); + m_bReceived = ((Boolean)res[8]).booleanValue(); + m_jtxtDescription.setText(Formats.STRING.formatValue(res[9])); + m_timereservation.setEnabled(false); + txtCustomer.setEnabled(false); + m_jtxtChairs.setEnabled(false); + m_jtxtDescription.setEnabled(false); + m_jKeys.setEnabled(false); + + m_jbtnReceive.setEnabled(false); + } + + /** + * + * @param value + */ + @Override + public void writeValueEdit(Object value) { + Object[] res = (Object[]) value; + m_sID = res[0]; + m_dCreated = (Date) res[1]; + m_timereservation.setCheckDates(m_dcurrentday, new Date(m_dcurrentday.getTime() + 3600000L)); + m_timereservation.setDate((Date) res[2]); + CustomerInfo c = new CustomerInfo((String) res[3]); + c.setTaxid((String) res[4]); + c.setSearchkey((String) res[5]); + c.setName((String) res[6]); + assignCustomer(c); + m_jtxtChairs.setValueInteger(((Integer)res[7]).intValue()); + m_bReceived = ((Boolean)res[8]).booleanValue(); + m_jtxtDescription.setText(Formats.STRING.formatValue(res[9])); + m_timereservation.setEnabled(true); + txtCustomer.setEnabled(true); + m_jtxtChairs.setEnabled(true); + m_jtxtDescription.setEnabled(true); + m_jKeys.setEnabled(true); + + m_jbtnReceive.setEnabled(!m_bReceived); // se habilita si no se ha recibido al cliente + + txtCustomer.activate(); + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] res = new Object[10]; + + res[0] = m_sID == null ? UUID.randomUUID().toString() : m_sID; + res[1] = m_dCreated == null ? new Date() : m_dCreated; + res[2] = m_timereservation.getDate(); + res[3] = customer.getId(); + res[4] = customer.getTaxid(); + res[5] = customer.getSearchkey(); + res[6] = customer.getName(); + res[7] = m_jtxtChairs.getValueInteger(); + res[8] = m_bReceived; + res[9] = m_jtxtDescription.getText(); + + return res; + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + private static class CompareReservations implements Comparator { + @Override + public int compare(Object o1, Object o2) { + Object[] a1 = (Object[]) o1; + Object[] a2 = (Object[]) o2; + Date d1 = (Date) a1[2]; + Date d2 = (Date) a2[2]; + int c = d1.compareTo(d2); + if (c == 0) { + d1 = (Date) a1[1]; + d2 = (Date) a2[1]; + return d1.compareTo(d2); + } else { + return c; + } + } + } + + private void reload(Date dDate) { + + if (!dDate.equals(m_dcurrentday)) { + + Date doldcurrentday = m_dcurrentday; + m_dcurrentday = dDate; + try { + m_bd.actionLoad(); + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, + LocalRes.getIntString("message.noreload"), eD); + msg.show(this); + m_dcurrentday = doldcurrentday; // nos retractamos... + } + } + + paintDate(); + } + + private void paintDate() { + + m_bpaintlock = true; + m_datepanel.setDate(m_dcurrentday); + m_timepanel.setDate(m_dcurrentday); + m_bpaintlock = false; + } + + private void assignCustomer(CustomerInfo c) { + + txtCustomer.setText(c.getName()); + customer = c; + } + + private class DateChangeCalendarListener implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (!m_bpaintlock) { + reload(DateUtils.getTodayHours(DateUtils.getDate(m_datepanel.getDate(), + m_timepanel.getDate()))); + } + } + } + + private class DateChangeTimeListener implements PropertyChangeListener { + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (!m_bpaintlock) { + reload(DateUtils.getTodayHours(DateUtils.getDate(m_datepanel.getDate(), + m_timepanel.getDate()))); + } + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanNorth = new javax.swing.JPanel(); + m_jToolbar = new javax.swing.JPanel(); + m_jbtnReceive = new javax.swing.JButton(); + m_jbtnTables = new javax.swing.JButton(); + m_jPanelList = new javax.swing.JPanel(); + jLabel5 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); + txtCustomer = new com.unicenta.editor.JEditorString(); + jLabel3 = new javax.swing.JLabel(); + m_jtxtChairs = new com.unicenta.editor.JEditorIntegerPositive(); + jLabel4 = new javax.swing.JLabel(); + m_jtxtDescription = new com.unicenta.editor.JEditorString(); + jLabel1 = new javax.swing.JLabel(); + m_jPanelTime = new javax.swing.JPanel(); + jbtnShowCalendar = new javax.swing.JButton(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanSouth = new javax.swing.JPanel(); + jCalendar = new javax.swing.JPanel(); + jPanelTime = new javax.swing.JPanel(); + jPanelDate = new javax.swing.JPanel(); + + setPreferredSize(new java.awt.Dimension(1000, 750)); + setLayout(new java.awt.BorderLayout()); + + jPanNorth.setPreferredSize(new java.awt.Dimension(1000, 350)); + + m_jToolbar.setPreferredSize(new java.awt.Dimension(500, 55)); + m_jToolbar.setLayout(new java.awt.BorderLayout()); + + m_jbtnReceive.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jbtnReceive.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/receive.png"))); // NOI18N + m_jbtnReceive.setText(AppLocal.getIntString("button.receive")); // NOI18N + m_jbtnReceive.setToolTipText("Receive pre-Booked Customer"); + m_jbtnReceive.setFocusPainted(false); + m_jbtnReceive.setFocusable(false); + m_jbtnReceive.setPreferredSize(new java.awt.Dimension(130, 45)); + m_jbtnReceive.setRequestFocusEnabled(false); + m_jbtnReceive.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnReceiveActionPerformed(evt); + } + }); + + m_jbtnTables.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jbtnTables.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/tables.png"))); // NOI18N + m_jbtnTables.setText(AppLocal.getIntString("button.tables")); // NOI18N + m_jbtnTables.setToolTipText("Go to Table Plan"); + m_jbtnTables.setFocusPainted(false); + m_jbtnTables.setFocusable(false); + m_jbtnTables.setPreferredSize(new java.awt.Dimension(130, 45)); + m_jbtnTables.setRequestFocusEnabled(false); + m_jbtnTables.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jbtnTablesActionPerformed(evt); + } + }); + + m_jPanelList.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + m_jPanelList.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPanelList.setPreferredSize(new java.awt.Dimension(300, 200)); + m_jPanelList.setLayout(new java.awt.BorderLayout()); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("rest.label.selectcustomer")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(100, 45)); + + jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/customer_add_sml.png"))); // NOI18N + jButton1.setToolTipText("Show Customers"); + jButton1.setFocusPainted(false); + jButton1.setFocusable(false); + jButton1.setMaximumSize(new java.awt.Dimension(40, 33)); + jButton1.setMinimumSize(new java.awt.Dimension(40, 33)); + jButton1.setPreferredSize(new java.awt.Dimension(80, 45)); + jButton1.setRequestFocusEnabled(false); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + txtCustomer.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCustomer.setMaximumSize(new java.awt.Dimension(250, 30)); + txtCustomer.setMinimumSize(new java.awt.Dimension(200, 25)); + txtCustomer.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("rest.label.chairs")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jtxtChairs.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtChairs.setMaximumSize(new java.awt.Dimension(50, 25)); + m_jtxtChairs.setMinimumSize(new java.awt.Dimension(50, 25)); + m_jtxtChairs.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("rest.label.notes")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jtxtDescription.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtDescription.setMaximumSize(new java.awt.Dimension(180, 25)); + m_jtxtDescription.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("rest.label.date")); // NOI18N + jLabel1.setVerticalAlignment(javax.swing.SwingConstants.TOP); + jLabel1.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jPanelTime.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPanelTime.setPreferredSize(new java.awt.Dimension(200, 200)); + m_jPanelTime.setLayout(new java.awt.BorderLayout()); + + jbtnShowCalendar.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jbtnShowCalendar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/date.png"))); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jbtnShowCalendar.setText(bundle.getString("rest.label.showcalendar")); // NOI18N + jbtnShowCalendar.setToolTipText(bundle.getString("rest.label.showcalendar")); // NOI18N + jbtnShowCalendar.setPreferredSize(new java.awt.Dimension(129, 45)); + jbtnShowCalendar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnShowCalendarActionPerformed(evt); + } + }); + + m_jKeys.setPreferredSize(new java.awt.Dimension(5, 5)); + + javax.swing.GroupLayout jPanNorthLayout = new javax.swing.GroupLayout(jPanNorth); + jPanNorth.setLayout(jPanNorthLayout); + jPanNorthLayout.setHorizontalGroup( + jPanNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addGap(10, 10, 10) + .addGroup(jPanNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addGroup(jPanNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(10, 10, 10) + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(6, 6, 6) + .addComponent(txtCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(4, 4, 4) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(4, 4, 4) + .addComponent(m_jtxtChairs, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addComponent(m_jPanelTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jbtnShowCalendar, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(4, 4, 4) + .addComponent(m_jtxtDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addGap(22, 22, 22) + .addComponent(m_jPanelList, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addComponent(m_jToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jKeys, javax.swing.GroupLayout.PREFERRED_SIZE, 1, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(m_jbtnReceive, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jbtnTables, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(42, 42, 42)))) + ); + jPanNorthLayout.setVerticalGroup( + jPanNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addGroup(jPanNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addGap(24, 24, 24) + .addComponent(m_jKeys, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jbtnTables, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jbtnReceive, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addGap(5, 5, 5) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addGap(7, 7, 7) + .addComponent(txtCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addGap(7, 7, 7) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addGap(7, 7, 7) + .addComponent(m_jtxtChairs, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addGap(7, 7, 7) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addGap(7, 7, 7) + .addComponent(m_jtxtDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanNorthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.CENTER, jPanNorthLayout.createSequentialGroup() + .addGap(31, 31, 31) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(42, 42, 42) + .addComponent(jbtnShowCalendar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.CENTER, jPanNorthLayout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jPanelTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanNorthLayout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jPanelList, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + + jLabel5.getAccessibleContext().setAccessibleName("Select Person"); + + add(jPanNorth, java.awt.BorderLayout.CENTER); + + jPanSouth.setPreferredSize(new java.awt.Dimension(1000, 350)); + + jCalendar.setPreferredSize(new java.awt.Dimension(1000, 350)); + jCalendar.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jPanelTime.setPreferredSize(new java.awt.Dimension(250, 250)); + jPanelTime.setLayout(new java.awt.BorderLayout()); + jCalendar.add(jPanelTime, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 50, -1, -1)); + + jPanelDate.setPreferredSize(new java.awt.Dimension(700, 345)); + jPanelDate.setLayout(new java.awt.BorderLayout()); + jCalendar.add(jPanelDate, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 5, -1, -1)); + + javax.swing.GroupLayout jPanSouthLayout = new javax.swing.GroupLayout(jPanSouth); + jPanSouth.setLayout(jPanSouthLayout); + jPanSouthLayout.setHorizontalGroup( + jPanSouthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 1012, Short.MAX_VALUE) + .addGroup(jPanSouthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanSouthLayout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jCalendar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + jPanSouthLayout.setVerticalGroup( + jPanSouthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 350, Short.MAX_VALUE) + .addGroup(jPanSouthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanSouthLayout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jCalendar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE))) + ); + + add(jPanSouth, java.awt.BorderLayout.SOUTH); + }// </editor-fold>//GEN-END:initComponents + + private void m_jbtnReceiveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnReceiveActionPerformed + + m_bReceived = true; + m_Dirty.setDirty(true); + + try { + m_bd.saveData(); + m_restaurantmap.viewTables(customer); + } catch (BasicException eD) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, + LocalRes.getIntString("message.nosaveticket"), eD); + msg.show(this); + } + + }//GEN-LAST:event_m_jbtnReceiveActionPerformed + + private void m_jbtnTablesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jbtnTablesActionPerformed + + m_restaurantmap.viewTables(); + + }//GEN-LAST:event_m_jbtnTablesActionPerformed + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + + JCustomerFinder finder = JCustomerFinder.getCustomerFinder(this, dlCustomers); + finder.search(customer); + finder.setVisible(true); + + CustomerInfo c = finder.getSelectedCustomer(); + + if (c == null) { + assignCustomer(new CustomerInfo(null)); + } else { + assignCustomer(c); + } + + }//GEN-LAST:event_jButton1ActionPerformed + + private void jbtnShowCalendarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnShowCalendarActionPerformed + if (jCalendar.isShowing()) { + jCalendar.setVisible(false); + jbtnShowCalendar.setText("Show Calendar"); + }else{ + jbtnShowCalendar.setText("Hide Calendar"); + jCalendar.setVisible(true); + } + }//GEN-LAST:event_jbtnShowCalendarActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JPanel jCalendar; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JPanel jPanNorth; + private javax.swing.JPanel jPanSouth; + private javax.swing.JPanel jPanelDate; + private javax.swing.JPanel jPanelTime; + private javax.swing.JButton jbtnShowCalendar; + private com.unicenta.editor.JEditorKeys m_jKeys; + private javax.swing.JPanel m_jPanelList; + private javax.swing.JPanel m_jPanelTime; + private javax.swing.JPanel m_jToolbar; + private javax.swing.JButton m_jbtnReceive; + private javax.swing.JButton m_jbtnTables; + private com.unicenta.editor.JEditorIntegerPositive m_jtxtChairs; + private com.unicenta.editor.JEditorString m_jtxtDescription; + private com.unicenta.editor.JEditorString txtCustomer; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/restaurant/Place.java b/src/main/java/com/unicenta/pos/sales/restaurant/Place.java new file mode 100644 index 0000000..d7a6422 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/restaurant/Place.java @@ -0,0 +1,233 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales.restaurant; + +import java.awt.Dimension; +import java.awt.Insets; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.SwingConstants; +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.NullIcon; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.SerializableRead; +import java.util.Date; + +/** + * + * @author JG uniCenta + */ +public class Place implements SerializableRead, java.io.Serializable { + + private static final long serialVersionUID = 8652254694281L; + private static final Icon ICO_OCU = new ImageIcon(Place.class.getResource("/com/unicenta/images/edit_group.png")); + private static final Icon ICO_FRE = new NullIcon(22, 22); + + private String m_sId; + private String m_sName; + private String m_sSeats; + private int m_ix; + private int m_iy; + private int m_diffx; + private int m_diffy; + private String m_sfloor; + private String m_customer; + private String m_waiter; + private String m_ticketId; + private Boolean m_tableMoved; + private Boolean m_changed = false; + + private boolean m_bPeople; + private JButton m_btn; + + private int m_theight; + private int m_twidth; + private int m_guests; + private Date m_occupied; + + + /** + * Creates a new instance of TablePlace + */ + public Place() { + } + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_sId = dr.getString(1); + m_sName = dr.getString(2); + m_sSeats = dr.getString(3); + m_ix = dr.getInt(4); + m_iy = dr.getInt(5); + m_sfloor = dr.getString(6); + m_customer = dr.getString(7); + m_waiter = dr.getString(8); + m_ticketId = dr.getString(9); + m_tableMoved = dr.getBoolean(10); + m_twidth = dr.getInt(11); + m_theight = dr.getInt(12); + m_guests = dr.getInt(13); + m_occupied = dr.getTimestamp(14); + + m_bPeople = false; + m_btn = new JButton(); + m_btn.setFocusPainted(false); + m_btn.setFocusable(false); + m_btn.setRequestFocusEnabled(false); + m_btn.setHorizontalTextPosition(SwingConstants.CENTER); + m_btn.setVerticalTextPosition(SwingConstants.BOTTOM); + m_btn.setIcon(ICO_FRE); + m_btn.setText(m_sName); + m_btn.setMargin(new Insets(2,5,2,5)); + m_diffx=0; + m_diffy=0; + + } + + public String getId() { + return m_sId; + } + + public String getTicketID(){ + return m_ticketId; + } + public String getName() { + return m_sName; + } + + public String getSeats() { + return m_sSeats; + } + + public int getX() { + return m_ix; + } + + public int getY() { + return m_iy; + } + + public void setX(int x) { + this.m_ix = x; + } + + public void setY(int y) { + this.m_iy = y; + } + + public int gettWidth() { + return m_twidth; + } + + public int gettHeight() { + return m_theight; + } + + public void settWidth(int twidth) { + this.m_twidth = twidth; + } + + public void settHeight(int theight) { + this.m_theight = theight; + } + + public int getDiffX() { + return m_diffx; + } + + public int getDiffY() { + return m_diffy; + } + + public void setDiffX(int x) { + this.m_diffx = x; + } + + public void setDiffY(int y) { + this.m_diffy = y; + } + + public Boolean getChanged() { + return m_changed; + } + + public void setChanged(Boolean changed) { + this.m_changed = changed; + } + + + public String getFloor() { + return m_sfloor; + } + + public JButton getButton() { + return m_btn; + } + + public String getCustomer() { + return m_customer; + } + + public String getWaiter() { + return m_waiter; + } + + public boolean hasPeople() { + return m_bPeople; + } + + public void setPeople(boolean bValue) { + m_bPeople = bValue; + m_btn.setIcon(bValue ? ICO_OCU : ICO_FRE); + } + + public int getGuests() { + return m_guests; + } + + public void setGuests(int guests) { + this.m_guests = guests; + } + + public Date getOccupied() { + return m_occupied; + } + + public void setOccupied(Date occupied) { + this.m_occupied = occupied; + } + + public void setButtonBounds() { + Dimension d = m_btn.getPreferredSize(); + m_btn.setPreferredSize(new Dimension(d.width + m_twidth, d.height + m_theight)); + d = m_btn.getPreferredSize(); + m_btn.setBounds(m_ix - d.width / 2, m_iy - d.height / 2, d.width, d.height); + } + + public void setButtonText(String btnText) { + m_btn.setText(btnText); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/sales/restaurant/RestaurantDBUtils.java b/src/main/java/com/unicenta/pos/sales/restaurant/RestaurantDBUtils.java new file mode 100644 index 0000000..feba2ac --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/restaurant/RestaurantDBUtils.java @@ -0,0 +1,624 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.sales.restaurant; + +import com.unicenta.data.loader.Session; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSystem; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Timestamp; + +/** + * + * @author JDL + */ + +public class RestaurantDBUtils { + private Session s; + private Connection con; + private Statement stmt; + private PreparedStatement pstmt; + private String SQL; + private ResultSet rs; + private AppView m_App; + + protected DataLogicSystem dlSystem; + + /** + * + * @param oApp + */ + public RestaurantDBUtils(AppView oApp) { + m_App=oApp; + + try{ + s=m_App.getSession(); + con=s.getConnection(); + } catch (SQLException e){ + } + } + + /** + * + * @param newTable + * @param ticketID + */ + public void moveCustomer(String newTable, String ticketID){ + String oldTable=getTableDetails(ticketID); + + if (countTicketIdInTable(ticketID)>1){ + setCustomerNameInTable(getCustomerNameInTable(oldTable),newTable); + setWaiterNameInTable(getWaiterNameInTable(oldTable),newTable); + setTicketIdInTable(ticketID,newTable); + setGuestsInTable(getGuestsInTable(oldTable),newTable); + + + + oldTable = getTableMovedName(ticketID); + if ((oldTable != null) && (oldTable != newTable)){ + clearCustomerNameInTable(oldTable); + clearWaiterNameInTable(oldTable); + clearTicketIdInTable(oldTable); + clearTableMovedFlag(oldTable); + } else { + oldTable = getTableMovedName(ticketID); + clearTableMovedFlag(oldTable); + } + } + } + + /** + * + * @param custName + * @param tableName + */ + public void setCustomerNameInTable(String custName, String tableName){ + try{ + SQL = "UPDATE places SET CUSTOMER=? WHERE NAME=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,custName); + pstmt.setString(2,tableName); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + } + + /** + * + * @param custName + * @param tableID + */ + public void setCustomerNameInTableById(String custName, String tableID){ + try{ + SQL = "UPDATE places SET CUSTOMER=? WHERE ID=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,custName); + pstmt.setString(2,tableID); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + } + + /** + * + * @param custName + * @param ticketID + */ + public void setCustomerNameInTableByTicketId(String custName, String ticketID){ + try{ + SQL = "UPDATE places SET CUSTOMER=? WHERE TICKETID=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,custName); + pstmt.setString(2,ticketID); + pstmt.executeUpdate(); + }catch(SQLException e){ + } +} + + /** + * + * @param tableName + * @return + */ + public String getCustomerNameInTable(String tableName){ + try{ + SQL = "SELECT customer FROM places WHERE NAME='"+ tableName + "'"; + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + + if (rs.next()){ + String customer =rs.getString("CUSTOMER"); + return(customer); + } + }catch(SQLException e){ + } + + return ""; + } + + /** + * + * @param tableId + * @return + */ + public String getCustomerNameInTableById(String tableId){ + try{ + SQL = "SELECT customer FROM places WHERE ID='"+ tableId + "'"; + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + if (rs.next()){ + String customer =rs.getString("CUSTOMER"); + return(customer); } + }catch(SQLException e){ + } + + return ""; + } + + /** + * + * @param tableName + */ + public void clearCustomerNameInTable(String tableName){ + try{ + SQL = "UPDATE places SET CUSTOMER=null WHERE NAME=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,tableName); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + } + + /** + * + * @param tableID + */ + public void clearCustomerNameInTableById(String tableID){ + try{ + SQL = "UPDATE places SET CUSTOMER=null WHERE ID=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,tableID); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + } + + /** + * + * @param waiterName + * @param tableName + */ + public void setWaiterNameInTable(String waiterName, String tableName){ + try{ + SQL = "UPDATE places SET WAITER=? WHERE NAME=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,waiterName); + pstmt.setString(2,tableName); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + } + + /** + * + * @param waiterName + * @param tableID + */ + public void setWaiterNameInTableById(String waiterName, String tableID){ + try{ + SQL = "UPDATE places SET WAITER=? WHERE ID=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,waiterName); + pstmt.setString(2,tableID); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + } + + /** + * + * @param tableName + * @return + */ + public String getWaiterNameInTable(String tableName){ + try{ + SQL = "SELECT waiter FROM places WHERE NAME='"+ tableName + "'"; + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + + if (rs.next()){ + String waiter =rs.getString("WAITER"); + return(waiter); + } + }catch(SQLException e){ + } + + return ""; + } + + /** + * + * @param tableID + * @return + */ + public String getWaiterNameInTableById(String tableID){ + try{ + SQL = "SELECT waiter FROM places WHERE ID='"+ tableID + "'"; + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + + if (rs.next()){ + String waiter =rs.getString("WAITER"); + return(waiter); + } + }catch(SQLException e){ + } + + return ""; + } + + /** + * + * @param tableName + */ + public void clearWaiterNameInTable(String tableName){ + try{ + SQL = "UPDATE places SET WAITER=null WHERE NAME=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,tableName); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + } + + /** + * + * @param tableID + */ + public void clearWaiterNameInTableById(String tableID){ + try{ + SQL = "UPDATE places SET WAITER=null WHERE ID=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,tableID); + pstmt.executeUpdate(); + + }catch(SQLException e){ + } + } + + /** + * + * @param ID + * @return + */ + public String getTicketIdInTable(String ID){ + try{ + SQL = "SELECT TICKETID FROM places WHERE ID='"+ ID + "'"; + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + + if (rs.next()){ + String customer =rs.getString("TICKETID"); + return(customer); + } + }catch(SQLException e){ + } + + return ""; + } + + /** + * + * @param TicketID + * @param tableName + */ + public void setTicketIdInTable(String TicketID, String tableName){ + try{ +// SQL = "UPDATE places SET TICKETID=?, GUESTS=SEATS WHERE NAME=?"; + SQL = "UPDATE places SET TICKETID=? WHERE NAME=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,TicketID); + pstmt.setString(2,tableName); + pstmt.executeUpdate(); + + }catch(SQLException e){ + } + } + + /** + * + * @param tableName + */ + public void clearTicketIdInTable(String tableName){ + try{ +// SQL = "UPDATE places SET TICKETID=null WHERE NAME=?"; + SQL = "UPDATE places SET TICKETID=null, OCCUPIED=null WHERE NAME=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,tableName); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + + clearGuestsInTable(tableName); + + } + + /** + * + * @param tableID + */ + public void clearTicketIdInTableById(String tableID){ + try{ + SQL = "UPDATE places SET TICKETID=null WHERE ID=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,tableID); + pstmt.executeUpdate(); + + }catch(SQLException e){ + } + } + + /** + * + * @param tableID + * @return + */ + public Integer getGuestsInTable(String tableID){ + try{ + SQL = "SELECT guests FROM places WHERE ID='"+ tableID + "'"; + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + + if (rs.next()){ + Integer guests =rs.getInt("GUESTS"); + return(guests); + } + }catch(SQLException e){ + } + + return 0; + } + + /** + * + * @param guests + * @param tableID + */ + public void setGuestsInTable(Integer guests, String tableID){ + try{ + SQL = "UPDATE places SET GUESTS=? WHERE ID=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setInt(1,guests); + pstmt.setString(2,tableID); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + } + + /** + * + * @param tableID + * @return + */ + public Integer updateGuestsInTable(String tableID){ + try{ + SQL = "SELECT guests FROM places WHERE ID='"+ tableID + "'"; + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + + if (rs.next()){ + Integer guests =rs.getInt("GUESTS"); + return(guests); + } + }catch(SQLException e){ + } + + return 0; + } + + /** + * + * @param tableID + */ + public void clearGuestsInTable(String tableID){ + try{ + SQL = "UPDATE places SET guests=0 WHERE ID=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,tableID); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + } + /** + * + * @param table + */ + public void clearGuestsTable(String table){ + try{ + SQL = "UPDATE places SET guests=0 WHERE NAME=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,table); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + } + + /** + * + * @param tableID + */ + public void clearOccupied(String tableID){ + try{ + SQL = "UPDATE places SET occupied=null WHERE ID=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,tableID); + pstmt.executeUpdate(); + }catch(SQLException e){ + + } + } + /** + * + * @param table + */ + public void clearOccupiedTable(String table){ + try{ + SQL = "UPDATE places SET occupied=null WHERE NAME=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,table); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + } + /** + * + * @param tableID + * @return + */ + public Timestamp getOccupied(String tableID){ + try{ + SQL = "SELECT occupied FROM places WHERE ID='"+ tableID + "'"; + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + + if (rs.next()){ + Timestamp occupied =rs.getTimestamp("OCCUPIED"); + return(occupied); + } + }catch(SQLException e){ + } + + return null; + } + + /** + * + * @param ticketID + */ + public void setOccupied(String ticketID){ + try{ + SQL = "UPDATE places SET occupied=NOW() WHERE TICKETID=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,ticketID); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + } + + /** + * + * @param ticketID + * @return + */ + public Integer countTicketIdInTable(String ticketID){ + try{ + SQL = "SELECT COUNT(*) AS RECORDCOUNT FROM places WHERE TICKETID='"+ ticketID + "'"; + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + + if (rs.next()){ + Integer count =rs.getInt("RECORDCOUNT"); + return(count); + } + }catch(SQLException e){ + } + + return 0; + } + + /** + * + * @param ticketID + * @return + */ + public String getTableDetails (String ticketID){ + try{ + SQL = "SELECT NAME FROM places WHERE TICKETID='"+ ticketID + "'"; + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + + if (rs.next()){ + String name =rs.getString("NAME"); + return(name); + } + }catch(SQLException e){ + } + + return ""; + } + + /** + * + * @param tableID + */ + public void setTableMovedFlag (String tableID){ + try{ + SQL = "UPDATE places SET TABLEMOVED='true' WHERE ID=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,tableID); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + } + + /** + * + * @param ticketID + * @return + */ + public String getTableMovedName (String ticketID){ + try{ + SQL = "SELECT NAME FROM places WHERE TICKETID='"+ ticketID + "' AND TABLEMOVED ='true'"; + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + + if (rs.next()){ + String name =rs.getString("NAME"); + return(name); + } + }catch(SQLException e){ + } + + return null; + } + + /** + * + * @param ticketID + * @return + */ + public Boolean getTableMovedFlag (String ticketID){ + try{ + SQL = "SELECT TABLEMOVED FROM places WHERE TICKETID='"+ ticketID + "'"; + stmt = (Statement) con.createStatement(); + rs = stmt.executeQuery(SQL); + + if (rs.next()){ + return(rs.getBoolean("TABLEMOVED")); + } + }catch(SQLException e){ + } + + return (false); + } + + /** + * + * @param tableID + */ + public void clearTableMovedFlag (String tableID){ + try{ + SQL = "UPDATE places SET TABLEMOVED='false' WHERE NAME=?"; + pstmt=con.prepareStatement(SQL); + pstmt.setString(1,tableID); + pstmt.executeUpdate(); + }catch(SQLException e){ + } + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/sales/shared/JTicketsBagShared.form b/src/main/java/com/unicenta/pos/sales/shared/JTicketsBagShared.form new file mode 100644 index 0000000..9bef47e --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/shared/JTicketsBagShared.form @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,51,0,0,1,-53"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="West"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jNewTicket"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="11" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/sale_new.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.addnewticket" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jNewTicketActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jListTickets"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="1"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="99" green="0" red="ff" type="rgb"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/sale_pending.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.layaway" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="horizontalTextPosition" type="int" value="4"/> + <Property name="iconTextGap" type="int" value="1"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 2, 0, 2]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + <Property name="verticalTextPosition" type="int" value="1"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jListTicketsActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jDelTicket"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="11" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/sale_delete.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.delete" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jDelTicketActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jReprintTickets"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="1"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="99" green="0" red="ff" type="rgb"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reprint24.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.reprint" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="iconTextGap" type="int" value="1"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 2, 0, 2]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + <Property name="verticalTextPosition" type="int" value="1"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jReprintTicketsActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jHold"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="11" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/logout.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.quicklogoff" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jHoldActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/shared/JTicketsBagShared.java b/src/main/java/com/unicenta/pos/sales/shared/JTicketsBagShared.java new file mode 100644 index 0000000..21be4aa --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/shared/JTicketsBagShared.java @@ -0,0 +1,504 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales.shared; + +import com.unicenta.basic.BasicException; +import com.unicenta.beans.JNumberPop; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.JRootApp; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.forms.DataLogicSystem; +import com.unicenta.pos.sales.DataLogicReceipts; +import com.unicenta.pos.sales.JTicketsBag; +import com.unicenta.pos.sales.ReprintTicketInfo; +import com.unicenta.pos.sales.SharedTicketInfo; +import com.unicenta.pos.sales.TicketsEditor; +import com.unicenta.pos.ticket.TicketInfo; +import java.util.List; +import java.util.UUID; +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +/** + * + * @author JG uniCenta + */ +public class JTicketsBagShared extends JTicketsBag { + + private String m_sCurrentTicket = null; + private DataLogicReceipts dlReceipts = null; + private DataLogicSales dlSales = null; + private final DataLogicSystem dlSystem; + private Boolean showList; + + + /** Creates new form JTicketsBagShared + * @param app + * @param panelticket */ + public JTicketsBagShared(AppView app, TicketsEditor panelticket) { + + super(app, panelticket); + + dlReceipts = (DataLogicReceipts) app.getBean("com.unicenta.pos.sales.DataLogicReceipts"); + dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + dlSystem = (DataLogicSystem) m_App.getBean("com.unicenta.pos.forms.DataLogicSystem"); + + initComponents(); + + m_jReprintTickets.setVisible(false); + + } + + /** + * + */ + @Override + public void activate() { + + m_sCurrentTicket = null; + selectValidTicket(); + + m_jDelTicket.setEnabled(m_App.getAppUserView().getUser().hasPermission( + "com.unicenta.pos.sales.JPanelTicketEdits")); + m_jDelTicket.setEnabled(m_App.getAppUserView().getUser().hasPermission("sales.DeleteTicket")); + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + + saveCurrentTicket(); + + m_sCurrentTicket = null; + m_panelticket.setActiveTicket(null, null); + + return true; + } + + /** + * + */ + @Override + public void deleteTicket() { + + dlSystem.execTicketRemoved( + new Object[] { + m_App.getAppUserView().getUser().getName(), + "Void", + "Ticket Deleted", + 0.0 + }); + + m_sCurrentTicket = null; + selectValidTicket(); + } + + public void updateCount() { + try { + List<SharedTicketInfo> l = dlReceipts.getSharedTicketList(); + int count = l.size(); + + if (count > 0) { + m_jListTickets.setText(Integer.toString(count)); + } else { + m_jListTickets.setText(""); + } + } catch (BasicException ex) { + new MessageInf(ex).show(this); + m_jListTickets.setText(""); + } + } + + + /** + * + * @return + */ + @Override + protected JComponent getBagComponent() { + return this; + } + + /** + * + * @return + */ + @Override + protected JComponent getNullComponent() { + return new JPanel(); + } + + private void saveCurrentTicket() { + + if (m_sCurrentTicket != null) { + try { + dlReceipts.insertSharedTicket(m_sCurrentTicket, + m_panelticket.getActiveTicket(), + m_panelticket.getActiveTicket().getPickupId()); + m_jListTickets.setText("*"); + TicketInfo l = dlReceipts.getSharedTicket(m_sCurrentTicket); + if(l.getLinesCount() == 0) { + dlReceipts.deleteSharedTicket(m_sCurrentTicket); + } + } catch (BasicException e) { + new MessageInf(e).show(this); + } + } + + updateCount(); + } + + private void setActiveTicket(String id) throws BasicException{ + + TicketInfo ticket = dlReceipts.getSharedTicket(id); + if (ticket == null) { + m_jListTickets.setText(""); + throw new BasicException(AppLocal.getIntString("message.noticket")); + } else { + dlReceipts.getPickupId(id); + Integer pickUp = dlReceipts.getPickupId(id); + dlReceipts.deleteSharedTicket(id); + m_sCurrentTicket = id; + m_panelticket.setActiveTicket(ticket, null); + ticket.setPickupId(pickUp); + } + + updateCount(); + } + + private void setActiveReprintTicket(String id) throws BasicException{ + + + TicketInfo ticket = dlSales.getReprintTicket(id); + m_sCurrentTicket = id; + } + + private void selectValidTicket() { + + newTicket(); + updateCount(); + + try { + List<SharedTicketInfo> l = dlReceipts.getSharedTicketList(); + if (l.isEmpty()) { + m_jListTickets.setText(""); + newTicket(); + } else { + showList = m_App.getAppUserView().getUser().hasPermission("sales.ShowList"); + if (showList) { + m_jListTickets.doClick(); + } + } + } catch (BasicException e) { + new MessageInf(e).show(this); + newTicket(); + } + } + + private void newTicket() { + + saveCurrentTicket(); + + TicketInfo ticket = new TicketInfo(); + m_sCurrentTicket = UUID.randomUUID().toString(); + m_panelticket.setActiveTicket(ticket, null); + + updateCount(); + + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + m_jNewTicket = new javax.swing.JButton(); + m_jListTickets = new javax.swing.JButton(); + m_jDelTicket = new javax.swing.JButton(); + m_jReprintTickets = new javax.swing.JButton(); + m_jHold = new javax.swing.JButton(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setLayout(new java.awt.BorderLayout()); + + m_jNewTicket.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + m_jNewTicket.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_new.png"))); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + m_jNewTicket.setToolTipText(bundle.getString("tooltip.addnewticket")); // NOI18N + m_jNewTicket.setFocusPainted(false); + m_jNewTicket.setFocusable(false); + m_jNewTicket.setMargin(new java.awt.Insets(0, 4, 0, 4)); + m_jNewTicket.setMaximumSize(new java.awt.Dimension(50, 40)); + m_jNewTicket.setMinimumSize(new java.awt.Dimension(50, 40)); + m_jNewTicket.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jNewTicket.setRequestFocusEnabled(false); + m_jNewTicket.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jNewTicketActionPerformed(evt); + } + }); + jPanel1.add(m_jNewTicket); + + m_jListTickets.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + m_jListTickets.setForeground(new java.awt.Color(255, 0, 153)); + m_jListTickets.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_pending.png"))); // NOI18N + m_jListTickets.setToolTipText(bundle.getString("tooltip.layaway")); // NOI18N + m_jListTickets.setFocusPainted(false); + m_jListTickets.setFocusable(false); + m_jListTickets.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + m_jListTickets.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + m_jListTickets.setIconTextGap(1); + m_jListTickets.setMargin(new java.awt.Insets(0, 2, 0, 2)); + m_jListTickets.setMaximumSize(new java.awt.Dimension(50, 40)); + m_jListTickets.setMinimumSize(new java.awt.Dimension(50, 40)); + m_jListTickets.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jListTickets.setRequestFocusEnabled(false); + m_jListTickets.setVerticalTextPosition(javax.swing.SwingConstants.TOP); + m_jListTickets.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jListTicketsActionPerformed(evt); + } + }); + jPanel1.add(m_jListTickets); + + m_jDelTicket.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + m_jDelTicket.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_delete.png"))); // NOI18N + m_jDelTicket.setToolTipText(bundle.getString("tooltip.delete")); // NOI18N + m_jDelTicket.setFocusPainted(false); + m_jDelTicket.setFocusable(false); + m_jDelTicket.setMargin(new java.awt.Insets(0, 4, 0, 4)); + m_jDelTicket.setMaximumSize(new java.awt.Dimension(50, 40)); + m_jDelTicket.setMinimumSize(new java.awt.Dimension(50, 40)); + m_jDelTicket.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jDelTicket.setRequestFocusEnabled(false); + m_jDelTicket.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jDelTicketActionPerformed(evt); + } + }); + jPanel1.add(m_jDelTicket); + + m_jReprintTickets.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N + m_jReprintTickets.setForeground(new java.awt.Color(255, 0, 153)); + m_jReprintTickets.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reprint24.png"))); // NOI18N + m_jReprintTickets.setToolTipText(bundle.getString("tooltip.reprint")); // NOI18N + m_jReprintTickets.setFocusPainted(false); + m_jReprintTickets.setFocusable(false); + m_jReprintTickets.setIconTextGap(1); + m_jReprintTickets.setMargin(new java.awt.Insets(0, 2, 0, 2)); + m_jReprintTickets.setMaximumSize(new java.awt.Dimension(50, 40)); + m_jReprintTickets.setMinimumSize(new java.awt.Dimension(50, 40)); + m_jReprintTickets.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jReprintTickets.setRequestFocusEnabled(false); + m_jReprintTickets.setVerticalTextPosition(javax.swing.SwingConstants.TOP); + m_jReprintTickets.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jReprintTicketsActionPerformed(evt); + } + }); + jPanel1.add(m_jReprintTickets); + + m_jHold.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N + m_jHold.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/logout.png"))); // NOI18N + m_jHold.setToolTipText(bundle.getString("tooltip.quicklogoff")); // NOI18N + m_jHold.setFocusPainted(false); + m_jHold.setFocusable(false); + m_jHold.setMargin(new java.awt.Insets(0, 4, 0, 4)); + m_jHold.setMaximumSize(new java.awt.Dimension(50, 40)); + m_jHold.setMinimumSize(new java.awt.Dimension(50, 40)); + m_jHold.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jHold.setRequestFocusEnabled(false); + m_jHold.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jHoldActionPerformed(evt); + } + }); + jPanel1.add(m_jHold); + + add(jPanel1, java.awt.BorderLayout.WEST); + }// </editor-fold>//GEN-END:initComponents + + private void m_jListTicketsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jListTicketsActionPerformed + + SwingUtilities.invokeLater(() -> { + try { + if (!m_App.getAppUserView().getUser().hasPermission("sales.ViewSharedTicket")){ + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.sharedticket"), + AppLocal.getIntString("message.sharedtickettitle"), + JOptionPane.INFORMATION_MESSAGE); + }else{ + + if("0".equals(m_App.getAppUserView().getUser().getRole()) + || "1".equals(m_App.getAppUserView().getUser().getRole()) + || m_App.getAppUserView().getUser().hasPermission("sales.ViewSharedTicket") + || m_App.getAppUserView().getUser().hasPermission("sales.Override")) + { + List<SharedTicketInfo> l = dlReceipts.getSharedTicketList(); + JTicketsBagSharedList listDialog = JTicketsBagSharedList.newJDialog(JTicketsBagShared.this); + String id = listDialog.showTicketsList(l, dlReceipts); + + if (id != null) { + saveCurrentTicket(); + setActiveTicket(id); + } + }else{ + + String appuser = m_App.getAppUserView().getUser().getId(); + List<SharedTicketInfo> l = dlReceipts.getUserSharedTicketList( + appuser); + + JTicketsBagSharedList listDialog = JTicketsBagSharedList.newJDialog(JTicketsBagShared.this); + + String id = listDialog.showTicketsList(l, dlReceipts); + + if (id != null) { + saveCurrentTicket(); + setActiveTicket(id); + } + } + } + }catch (BasicException e) { + new MessageInf(e).show(JTicketsBagShared.this); + newTicket(); + } + }); + + }//GEN-LAST:event_m_jListTicketsActionPerformed + + private void m_jNewTicketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jNewTicketActionPerformed + + newTicket(); + + }//GEN-LAST:event_m_jNewTicketActionPerformed + + private void m_jHoldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jHoldActionPerformed + deactivate(); + ((JRootApp)m_App).closeAppView(); + }//GEN-LAST:event_m_jHoldActionPerformed + + private void m_jReprintTicketsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jReprintTicketsActionPerformed + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + + try { + if (!m_App.getAppUserView().getUser().hasPermission("sales.ReprintTicket")){ + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.reprintticket"), + AppLocal.getIntString("message.reprinttickettitle"), + JOptionPane.INFORMATION_MESSAGE); + }else{ + + if("0".equals(m_App.getAppUserView().getUser().getRole()) + || "1".equals(m_App.getAppUserView().getUser().getRole()) + || m_App.getAppUserView().getUser().hasPermission("sales.ViewSharedTicket") + || m_App.getAppUserView().getUser().hasPermission("sales.Override")) + { + List<ReprintTicketInfo> l = dlSales.getReprintTicketList(); + JTicketsReprintList listDialog = JTicketsReprintList.newJDialog(JTicketsBagShared.this); + String id = listDialog.showTicketsList(l, dlSales); + + }else{ + + String appuser = m_App.getAppUserView().getUser().getId(); + List<ReprintTicketInfo> l = dlSales.getReprintTicketList(); + + JTicketsReprintList listDialog = JTicketsReprintList.newJDialog(JTicketsBagShared.this); + + String id = listDialog.showTicketsList(l, dlSales); + + if (id != null) { + saveCurrentTicket(); + setActiveReprintTicket(id); + } + } + } + }catch (BasicException e) { + new MessageInf(e).show(JTicketsBagShared.this); + newTicket(); + } + } + }); + }//GEN-LAST:event_m_jReprintTicketsActionPerformed + + private void m_jDelTicketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jDelTicketActionPerformed +// Only called in simple & standard NOT RESTAURANT +// For Restaurant-mode see JTicketsBagRestaurant + + boolean pinOK = false; + + if (m_sCurrentTicket != null) { + + if (m_App.getProperties().getProperty("override.check").equals("true")) { + Integer secret = Integer.parseInt(m_App.getProperties().getProperty("override.pin")); + Integer iValue = JNumberPop.showEditNumber(this, AppLocal.getIntString("title.override.enterpin")); + + if (iValue == null ? secret == null : iValue.equals(secret)) { + pinOK = true; + int res = JOptionPane.showConfirmDialog(this + , AppLocal.getIntString("message.wannadelete") + , AppLocal.getIntString("title.editor") + , JOptionPane.YES_NO_OPTION + , JOptionPane.QUESTION_MESSAGE); + + if (res == JOptionPane.YES_OPTION) { + deleteTicket(); + } + } else { + pinOK = false; + JOptionPane.showMessageDialog(this, AppLocal.getIntString("message.override.badpin")); + } + } else { + int res = JOptionPane.showConfirmDialog(this + , AppLocal.getIntString("message.wannadelete") + , AppLocal.getIntString("title.editor") + , JOptionPane.YES_NO_OPTION + , JOptionPane.QUESTION_MESSAGE); + + if (res == JOptionPane.YES_OPTION) { + deleteTicket(); + } + } + } + }//GEN-LAST:event_m_jDelTicketActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JButton m_jDelTicket; + private javax.swing.JButton m_jHold; + private javax.swing.JButton m_jListTickets; + private javax.swing.JButton m_jNewTicket; + private javax.swing.JButton m_jReprintTickets; + // End of variables declaration//GEN-END:variables + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/sales/shared/JTicketsBagSharedList.form b/src/main/java/com/unicenta/pos/sales/shared/JTicketsBagSharedList.form new file mode 100644 index 0000000..c9dec8a --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/shared/JTicketsBagSharedList.form @@ -0,0 +1,133 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="caption.tickets" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,21,0,0,2,6"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jtickets"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout"> + <Property name="columns" type="int" value="1"/> + <Property name="horizontalGap" type="int" value="5"/> + <Property name="rows" type="int" value="0"/> + <Property name="verticalGap" type="int" value="5"/> + </Layout> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="2"/> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + </Container> + <Component class="javax.swing.JButton" name="m_jButtonCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.close" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonCancelActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/shared/JTicketsBagSharedList.java b/src/main/java/com/unicenta/pos/sales/shared/JTicketsBagSharedList.java new file mode 100644 index 0000000..3692d67 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/shared/JTicketsBagSharedList.java @@ -0,0 +1,236 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales.shared; + + +import com.unicenta.pos.sales.SharedTicketInfo; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JFrame; +import com.unicenta.basic.BasicException; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.ticket.TicketInfo; +import com.unicenta.pos.sales.DataLogicReceipts; +import javax.swing.JOptionPane; + + +/** + * + * @author JG uniCenta + */ +public class JTicketsBagSharedList extends javax.swing.JDialog { + + private String m_sDialogTicket; + + /** Creates new form JTicketsBagSharedList */ + private JTicketsBagSharedList(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + /** Creates new form JTicketsBagSharedList */ + private JTicketsBagSharedList(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + /** + * + * @param atickets + * @param dlReceipts + * @return + */ + public String showTicketsList(java.util.List<SharedTicketInfo> atickets, DataLogicReceipts dlReceipts) { +// JG Dec 2014 + SharedTicketInfo m_Ticket = null; + + for (SharedTicketInfo aticket : atickets) { + m_jtickets.add(new JButtonTicket(aticket, dlReceipts)); + } + + m_sDialogTicket = null; + + int lsize = atickets.size(); + if (lsize > 0) { + setVisible(true); + }else{ + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.nosharedtickets"), + AppLocal.getIntString("message.sharedtickettitle"), + JOptionPane.OK_OPTION); + } + + return m_sDialogTicket; + } + + /** + * + * @param ticketsbagshared + * @return + */ + public static JTicketsBagSharedList newJDialog(JTicketsBagShared ticketsbagshared) { + + Window window = getWindow(ticketsbagshared); + JTicketsBagSharedList mydialog; + if (window instanceof Frame) { + mydialog = new JTicketsBagSharedList((Frame) window, true); + } else { + mydialog = new JTicketsBagSharedList((Dialog) window, true); + } + + mydialog.initComponents(); + + mydialog.jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); + mydialog.jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(25, 25)); + + return mydialog; + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window) parent; + } else { + return getWindow(parent.getParent()); + } + } + + private class JButtonTicket extends JButton { + + private final SharedTicketInfo m_Ticket; + + public JButtonTicket(SharedTicketInfo ticket, DataLogicReceipts dlReceipts){ + + super(); + + m_Ticket = ticket; + setFocusPainted(false); + setFocusable(false); + setRequestFocusEnabled(false); + setMargin(new Insets(8, 14, 8, 14)); + setFont(new java.awt.Font ("Dialog", 0, 14)); + setBackground(new java.awt.Color (220, 220, 220)); + addActionListener(new ActionListenerImpl()); + +// JG Nov 2014 + String total; + try { + TicketInfo ticket2 = dlReceipts.getSharedTicket(ticket.getId()); + total = " - " + ticket2.printTotal(); + } catch (BasicException ex) { + total = ""; + } + + setText(ticket.getPickupId() + " - " + + ticket.getName() + + total); + } + + private class ActionListenerImpl implements ActionListener { + + public ActionListenerImpl() { + } + + @Override + public void actionPerformed(ActionEvent evt) { + + m_sDialogTicket = m_Ticket.getId(); + JTicketsBagSharedList.this.setVisible(false); + + } + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jPanel2 = new javax.swing.JPanel(); + m_jtickets = new javax.swing.JPanel(); + jPanel3 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + m_jButtonCancel = new javax.swing.JButton(); + + setTitle(AppLocal.getIntString("caption.tickets")); // NOI18N + setResizable(false); + + jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel1.setLayout(new java.awt.BorderLayout()); + + jPanel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel2.setLayout(new java.awt.BorderLayout()); + + m_jtickets.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + m_jtickets.setLayout(new java.awt.GridLayout(0, 1, 5, 5)); + jPanel2.add(m_jtickets, java.awt.BorderLayout.NORTH); + + jScrollPane1.setViewportView(jPanel2); + + jPanel1.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); + + jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + jPanel3.add(jPanel4); + + m_jButtonCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + m_jButtonCancel.setText(AppLocal.getIntString("button.close")); // NOI18N + m_jButtonCancel.setFocusPainted(false); + m_jButtonCancel.setFocusable(false); + m_jButtonCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonCancel.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jButtonCancel.setRequestFocusEnabled(false); + m_jButtonCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonCancelActionPerformed(evt); + } + }); + jPanel3.add(m_jButtonCancel); + + getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH); + + setSize(new java.awt.Dimension(518, 533)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void m_jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_m_jButtonCancelActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton m_jButtonCancel; + private javax.swing.JPanel m_jtickets; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/shared/JTicketsReprintList.form b/src/main/java/com/unicenta/pos/sales/shared/JTicketsReprintList.form new file mode 100644 index 0000000..590d08d --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/shared/JTicketsReprintList.form @@ -0,0 +1,134 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="caption.tickets" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-113,0,0,2,7"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="m_jtickets"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout"> + <Property name="columns" type="int" value="1"/> + <Property name="horizontalGap" type="int" value="5"/> + <Property name="rows" type="int" value="0"/> + <Property name="verticalGap" type="int" value="5"/> + </Layout> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="2"/> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + </Container> + <Component class="javax.swing.JButton" name="m_jButtonCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.close" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jButtonCancelActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/shared/JTicketsReprintList.java b/src/main/java/com/unicenta/pos/sales/shared/JTicketsReprintList.java new file mode 100644 index 0000000..f9defc1 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/shared/JTicketsReprintList.java @@ -0,0 +1,415 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales.shared; + + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ListKeyed; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.pos.forms.*; +import com.unicenta.pos.printer.DeviceTicket; +import com.unicenta.pos.printer.TicketParser; +import com.unicenta.pos.printer.TicketPrinterException; +import com.unicenta.pos.sales.ReprintTicketInfo; +import com.unicenta.pos.sales.TaxesException; +import com.unicenta.pos.sales.TaxesLogic; +import com.unicenta.pos.scripting.ScriptEngine; +import com.unicenta.pos.scripting.ScriptException; +import com.unicenta.pos.scripting.ScriptFactory; +import com.unicenta.pos.ticket.TicketInfo; +import com.unicenta.pos.ticket.TicketTaxInfo; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + + +/** + * + * @author JG uniCenta + */ +@Slf4j +public class JTicketsReprintList extends javax.swing.JDialog { + + private String m_sDialogTicket; + private final DeviceTicket m_TP; + private final TicketParser m_TTP; +// private final TicketParser m_TTP2; + private TaxesLogic taxeslogic; + private ListKeyed taxcollection; + + private TicketInfo m_ticket; + private TicketInfo m_ticketCopy; + private AppView m_App; + + private DataLogicSystem dlSystem = null; + private DataLogicSales dlSales = null; + + /** Creates new form JTicketsReprintList */ + private JTicketsReprintList(java.awt.Frame parent, boolean modal) { + super(parent, modal); + AppView app = null; + m_App = app; + AppProperties props = null; + + m_TP = new DeviceTicket(); + + m_TTP = new TicketParser(m_TP, dlSystem); +// m_TTP2 = new TicketParser(m_App.getDeviceTicket(), dlSystem); + } + /** Creates new form JTicketsReprintList */ + private JTicketsReprintList(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + AppProperties props = null; + + m_TP = new DeviceTicket(); + m_TTP = new TicketParser(m_TP, dlSystem); + } + + /** + * + * @param atickets + * @param dlSales + * @return + */ + public String showTicketsList(java.util.List<ReprintTicketInfo> atickets, DataLogicSales dlSales) { + + m_ticket = null; + m_ticketCopy = null; + +ReprintTicketInfo m_Ticket = null; + + for (ReprintTicketInfo aticket : atickets) { + m_jtickets.add(new JButtonTicket(aticket, dlSales)); + } + + m_sDialogTicket = null; + + int lsize = atickets.size(); + if (lsize > 0) { + setVisible(true); + }else{ + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.nosharedtickets"), + AppLocal.getIntString("message.sharedtickettitle"), + JOptionPane.OK_OPTION); + } + + return m_sDialogTicket; + } + + /** + * + * @param ticketsbagshared + * @return + */ + public static JTicketsReprintList newJDialog(JTicketsBagShared ticketsbagshared) { + + Window window = getWindow(ticketsbagshared); + JTicketsReprintList mydialog; + if (window instanceof Frame) { + mydialog = new JTicketsReprintList((Frame) window, true); + } else { + mydialog = new JTicketsReprintList((Dialog) window, true); + } + + mydialog.initComponents(); + + mydialog.jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); + mydialog.jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(25, 25)); + + return mydialog; + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window) parent; + } else { + return getWindow(parent.getParent()); + } + } + + private class JButtonTicket extends JButton { + + private final ReprintTicketInfo m_Ticket; + + public JButtonTicket(ReprintTicketInfo ticket, DataLogicSales dlSales){ + + super(); + + m_Ticket = ticket; + setFocusPainted(false); + setFocusable(false); + setRequestFocusEnabled(false); + setMargin(new Insets(8, 14, 8, 14)); + setFont(new java.awt.Font ("Dialog", 0, 14)); + setBackground(new java.awt.Color (220, 220, 220)); + addActionListener(new ActionListenerImpl()); + + setText(ticket.getId() + " - " + + ticket.getTicketDate() + " - " + + ticket.getUserName()); + } + + private class ActionListenerImpl implements ActionListener { + + public ActionListenerImpl() { + } + + @Override + public void actionPerformed(ActionEvent evt) { + + try { + m_sDialogTicket = m_Ticket.getId(); + + JTicketsReprintList.this.setVisible(false); + int iTkt=Integer.valueOf(m_sDialogTicket); + int iTt = 0; +// readTicket(iTkt, iTt); +// readTicket(m_sDialogTicket); + + TicketInfo ticket = dlSales.loadTicket(iTt, iTkt); + + if (ticket == null) { + JFrame frame = new JFrame(); + JOptionPane.showMessageDialog(frame, AppLocal.getIntString("message.notexiststicket"), AppLocal.getIntString("message.notexiststickettitle"), JOptionPane.WARNING_MESSAGE); + } else { + m_ticket = ticket; + m_ticketCopy = null; + try { + taxeslogic.calculateTaxes(m_ticket); + TicketTaxInfo[] taxlist = m_ticket.getTaxLines(); + } catch (TaxesException ex) { + } + printTicket("Printer.ReprintLastTicket", m_ticket, null); + } +// } catch (BasicException e) { +// MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadticket"), e); +// msg.show(this); +// } +// } + } catch (BasicException ex) { + log.error(ex.getMessage()); + + } + + + } + } + } + +// private void readTicket(int iTicketid, int iTickettype) { + private void readTicket(String Id) { +// Integer findTicket=Integer.valueOf(m_sDialogTicket); + + try { + //TicketInfo ticket = new TicketInfo(); + +// TicketInfo ticket = dlSales.loadTicket(iTickettype, iTicketid); + +TicketInfo ticket = dlSales.getReprintTicket(Id); + if (ticket == null) { + JFrame frame = new JFrame(); + JOptionPane.showMessageDialog(frame, + AppLocal.getIntString("message.notexiststicket"), + AppLocal.getIntString("message.notexiststickettitle"), + JOptionPane.WARNING_MESSAGE); + + } else { + m_ticket = ticket; + m_ticketCopy = null; + + if(m_ticket.getTicketType()== 1 + || m_ticket.getTicketStatus()> 0) { + JFrame frame = new JFrame(); + JOptionPane.showMessageDialog(frame, + AppLocal.getIntString("message.ticketrefunded"), + AppLocal.getIntString("message.ticketrefundedtitle"), + JOptionPane.WARNING_MESSAGE); +// m_jEdit.setEnabled(false); +// m_jRefund.setEnabled(false); + }else{ +// m_jEdit.setEnabled(true); +// m_jRefund.setEnabled(true); + } + try { + taxeslogic.calculateTaxes(m_ticket); + TicketTaxInfo[] taxlist = m_ticket.getTaxLines(); + } catch (TaxesException ex) {} + +// printTicket(); + } + + } catch (BasicException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadticket"), e); + msg.show(this); + } + + } + +/* private void printTicket() { + + if (m_ticket != null + && (m_ticket.getTicketType() == TicketInfo.RECEIPT_NORMAL + && m_ticket.getTicketStatus() == 0)) { + } + + m_TP.getDevicePrinter("1").reset(); + + if (m_ticket == null) { +// m_jTicketId.setText(m_ticket.getName()); + + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); + script.put("ticket", m_ticket); + script.put("taxes", m_ticket.getTaxLines()); + m_TTP.printTicket(script.eval(dlSystem.getResourceAsXML("Printer.TicketPreview")).toString()); + } catch ( ScriptException | TicketPrinterException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), e); + msg.show(this); + } + } + } +*/ + + private void printTicket(String sresourcename, TicketInfo ticket, Object ticketext) { + + String sresource = dlSystem.getResourceAsXML(sresourcename); + if (sresource == null) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket")); +// msg.show(JPanelTicket.this); + } else { + +// if this is ticket does not have a pickup code assign on now + if (ticket.getPickupId() == 0) { + try { + ticket.setPickupId(dlSales.getNextPickupIndex()); + } catch (BasicException e) { + ticket.setPickupId(0); + } + } + try { + ScriptEngine script = ScriptFactory.getScriptEngine(ScriptFactory.VELOCITY); +// JG 19 Feb 14 unnecessary boolean parse - if (Boolean.valueOf(m_App.getProperties().getProperty("receipt.newlayout")).booleanValue()){ + if (Boolean.parseBoolean(m_App.getProperties().getProperty("receipt.newlayout"))) { + script.put("taxes", ticket.getTaxLines()); + } else { + script.put("taxes", taxcollection); + } + script.put("taxeslogic", taxeslogic); + script.put("ticket", ticket); + script.put("place", ticketext); + Object warrantyPrint; +// script.put("warranty", warrantyPrint); +// script.put("pickupid", getPickupString(ticket)); + +// JG Aug 2014 +// refreshTicket(); + + m_TTP.printTicket(script.eval(sresource).toString(), ticket); + +// JG May 2013 replaced with Multicatch + } catch (ScriptException | TicketPrinterException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotprintticket"), e); +// msg.show(JPanelTicket.this); + } + } + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel1 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jPanel2 = new javax.swing.JPanel(); + m_jtickets = new javax.swing.JPanel(); + jPanel3 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + m_jButtonCancel = new javax.swing.JButton(); + + setTitle(AppLocal.getIntString("caption.tickets")); // NOI18N + setResizable(false); + + jPanel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel1.setLayout(new java.awt.BorderLayout()); + + jPanel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanel2.setLayout(new java.awt.BorderLayout()); + + m_jtickets.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + m_jtickets.setLayout(new java.awt.GridLayout(0, 1, 5, 5)); + jPanel2.add(m_jtickets, java.awt.BorderLayout.NORTH); + + jScrollPane1.setViewportView(jPanel2); + + jPanel1.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); + + jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + jPanel3.add(jPanel4); + + m_jButtonCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + m_jButtonCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + m_jButtonCancel.setText(AppLocal.getIntString("button.close")); // NOI18N + m_jButtonCancel.setFocusPainted(false); + m_jButtonCancel.setFocusable(false); + m_jButtonCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jButtonCancel.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jButtonCancel.setRequestFocusEnabled(false); + m_jButtonCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jButtonCancelActionPerformed(evt); + } + }); + jPanel3.add(m_jButtonCancel); + + getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH); + + setSize(new java.awt.Dimension(519, 399)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void m_jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jButtonCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_m_jButtonCancelActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton m_jButtonCancel; + private javax.swing.JPanel m_jtickets; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/sales/simple/JTicketsBagSimple.form b/src/main/java/com/unicenta/pos/sales/simple/JTicketsBagSimple.form new file mode 100644 index 0000000..ed1408b --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/simple/JTicketsBagSimple.form @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,49,0,0,0,-47"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="0"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jDelTicket"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/sale_delete.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.delete" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 4, 0, 4]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 40]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jDelTicketActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/sales/simple/JTicketsBagSimple.java b/src/main/java/com/unicenta/pos/sales/simple/JTicketsBagSimple.java new file mode 100644 index 0000000..8d4c6a2 --- /dev/null +++ b/src/main/java/com/unicenta/pos/sales/simple/JTicketsBagSimple.java @@ -0,0 +1,142 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.sales.simple; + +import com.unicenta.pos.forms.*; +import javax.swing.*; +import com.unicenta.pos.sales.*; +import com.unicenta.pos.ticket.TicketInfo; + +/** + * + * @author JG uniCenta + */ +public class JTicketsBagSimple extends JTicketsBag { + + /** Creates new form JTicketsBagSimple + * @param app + * @param panelticket */ + public JTicketsBagSimple(AppView app, TicketsEditor panelticket) { + + super(app, panelticket); + + initComponents(); + } + + /** + * + */ + @Override + public void activate() { + + m_panelticket.setActiveTicket(new TicketInfo(), null); + + // Authorization + m_jDelTicket.setEnabled(m_App.getAppUserView().getUser().hasPermission("com.unicenta.pos.sales.JPanelTicketEdits")); + + } + + /** + * + * @return + */ + @Override + public boolean deactivate() { + m_panelticket.setActiveTicket(null, null); + return true; + } + + /** + * + */ + @Override + public void deleteTicket() { + m_panelticket.setActiveTicket(new TicketInfo(), null); + } + + /** + * + * @return + */ + @Override + protected JComponent getBagComponent() { + return this; + } + + /** + * + * @return + */ + @Override + protected JComponent getNullComponent() { + return new JPanel(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jDelTicket = new javax.swing.JButton(); + + setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); + + m_jDelTicket.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_delete.png"))); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + m_jDelTicket.setToolTipText(bundle.getString("tooltip.delete")); // NOI18N + m_jDelTicket.setFocusPainted(false); + m_jDelTicket.setFocusable(false); + m_jDelTicket.setMargin(new java.awt.Insets(0, 4, 0, 4)); + m_jDelTicket.setMaximumSize(new java.awt.Dimension(50, 40)); + m_jDelTicket.setMinimumSize(new java.awt.Dimension(50, 40)); + m_jDelTicket.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jDelTicket.setRequestFocusEnabled(false); + m_jDelTicket.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jDelTicketActionPerformed(evt); + } + }); + add(m_jDelTicket); + }// </editor-fold>//GEN-END:initComponents + + private void m_jDelTicketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jDelTicketActionPerformed + + int res = JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.wannadelete"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + + if (res == JOptionPane.YES_OPTION) { + deleteTicket(); + } + + }//GEN-LAST:event_m_jDelTicketActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton m_jDelTicket; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/scale/DeviceScale.java b/src/main/java/com/unicenta/pos/scale/DeviceScale.java new file mode 100644 index 0000000..6ff516f --- /dev/null +++ b/src/main/java/com/unicenta/pos/scale/DeviceScale.java @@ -0,0 +1,106 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scale; + +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppProperties; +import com.unicenta.pos.util.StringParser; +import java.awt.Component; + +/** + * + * @author JG uniCenta + */ +public class DeviceScale { + + private Scale m_scale; + + /** Creates a new instance of DeviceScale + * @param parent + * @param props */ + public DeviceScale(Component parent, AppProperties props) { + StringParser sd = new StringParser(props.getProperty("machine.scale")); + String sScaleType = sd.nextToken(':'); + String sScaleParam1 = sd.nextToken(','); + // String sScaleParam2 = sd.nextToken(','); + switch (sScaleType) { + case "acompc100": + m_scale = new ScaleAcomPC100(sScaleParam1); + break; + case "averyberkel6720": + m_scale = new ScaleAvery(sScaleParam1); + break; + case "casiopd1": + m_scale = new ScaleCasioPD1(sScaleParam1); + break; + case "dialog1": + m_scale = new ScaleComm(sScaleParam1); + break; + case "samsungesp": + m_scale = new ScaleSamsungEsp(sScaleParam1); + break; + case "caspdii": + m_scale = new ScaleCASPDII(sScaleParam1); + break; + case "fake": + // a fake scale for debugging purposes + m_scale = new ScaleFake(); + break; + case "screen": + // on screen scale + m_scale = new ScaleDialog(parent); + break; + default: + m_scale = null; + break; + } + } + + /** + * + * @return + */ + public boolean existsScale() { + return m_scale != null; + } + + /** + * + * @return + * @throws ScaleException + */ + public Double readWeight() throws ScaleException { + + if (m_scale == null) { + throw new ScaleException(AppLocal.getIntString("scale.notdefined")); + } else { + Double result = m_scale.readWeight(); + if (result == null) { + return null; // Canceled by the user / scale + } else if (result < 0.002) { + // invalid result. nothing on the scale + throw new ScaleException(AppLocal.getIntString("scale.invalidvalue")); + } else { + // valid result + return result; + } + } + } +} diff --git a/src/main/java/com/unicenta/pos/scale/Scale.java b/src/main/java/com/unicenta/pos/scale/Scale.java new file mode 100644 index 0000000..1702665 --- /dev/null +++ b/src/main/java/com/unicenta/pos/scale/Scale.java @@ -0,0 +1,34 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scale; + +/** + * + * @author JG uniCenta + */ +public interface Scale { + + /** + * + * @return + * @throws ScaleException + */ + public Double readWeight() throws ScaleException; +} diff --git a/src/main/java/com/unicenta/pos/scale/ScaleAcomPC100.java b/src/main/java/com/unicenta/pos/scale/ScaleAcomPC100.java new file mode 100644 index 0000000..c4d5f8f --- /dev/null +++ b/src/main/java/com/unicenta/pos/scale/ScaleAcomPC100.java @@ -0,0 +1,181 @@ +//    uniCenta oPOS  - Touch Friendly Point Of Sale +//    Copyright (c) 2018 uniCenta & previous Openbravo POS works +// Contribution by Hajinder Singh +//    https://unicenta.com +// +//    This file is part of uniCenta oPOS +// +//    uniCenta oPOS 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. +// +//   uniCenta oPOS 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 uniCenta oPOS.  If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scale; + +import gnu.io.*; +import java.io.*; +import java.util.TooManyListenersException; + +/** +* +* @author uniCenta + H Singh +*/ +public class ScaleAcomPC100 implements Scale, SerialPortEventListener { + +private CommPortIdentifier m_PortIdPrinter; +private SerialPort m_CommPortPrinter; + +private final String m_sPortScale; +private OutputStream m_out; +private InputStream m_in; + +private static final int SCALE_READY = 0; +private static final int SCALE_READING = 1; +private static final int SCALE_READINGDECIMALS = 2; + +private double m_dWeightBuffer; +private double m_dWeightDecimals; +private int m_iStatusScale; +private String m_sScaleReading; + +/** Creates a new instance of ScaleComm +* @param sPortPrinter */ + public ScaleAcomPC100(String sPortPrinter) { + m_sPortScale = sPortPrinter; + m_out = null; + m_in = null; + m_iStatusScale = SCALE_READY; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + } + +/** +* +* @return +*/ +@Override +public Double readWeight() { + + synchronized(this) { + + if (m_iStatusScale != SCALE_READY) { + try { + wait(200); + } catch (InterruptedException e) { + } + if (m_iStatusScale != SCALE_READY) { + m_iStatusScale = SCALE_READY; + } + } + + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + write(new byte[] {0x57,0X0D}); // $ + flush(); + + try { + wait(200); + } catch (InterruptedException e) { + } + + if (m_iStatusScale == SCALE_READY) { + double dWeight = m_dWeightBuffer / m_dWeightDecimals; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + return dWeight; + } else { + m_iStatusScale = SCALE_READY; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + return 0.0; + } + } +} + +private void flush() { + try { + m_out.flush(); + } catch (IOException e) { + } +} + +private void write(byte[] data) { + try { + if (m_out == null) { + m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale); + m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000); + + m_out = m_CommPortPrinter.getOutputStream(); + m_in = m_CommPortPrinter.getInputStream(); + + m_CommPortPrinter.addEventListener(this); + m_CommPortPrinter.notifyOnDataAvailable(true); + + m_CommPortPrinter.setSerialPortParams(9600, + SerialPort.DATABITS_7, + SerialPort.STOPBITS_1, + SerialPort.PARITY_EVEN); + } + m_out.write(data); + } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException + | TooManyListenersException | IOException e) { + } +} + +/** +* +* @param e +*/ +@Override +public void serialEvent(SerialPortEvent e) { + + switch (e.getEventType()) { + case SerialPortEvent.BI: + case SerialPortEvent.OE: + case SerialPortEvent.FE: + case SerialPortEvent.PE: + case SerialPortEvent.CD: + case SerialPortEvent.CTS: + case SerialPortEvent.DSR: + case SerialPortEvent.RI: + case SerialPortEvent.OUTPUT_BUFFER_EMPTY: + break; + case SerialPortEvent.DATA_AVAILABLE: + try { + int i; + i = m_in.available(); + byte[] readBuffer = new byte[i]; + if (i > 0) { + m_in.read(readBuffer); + } + + m_sScaleReading = m_sScaleReading + new String(readBuffer); + + try { + int start = m_sScaleReading.indexOf((char) 10); + int end = m_sScaleReading.indexOf((char) 3); + + if (start >= 0 && end >= 0) { + + start = m_sScaleReading.indexOf((char) 10); + end = m_sScaleReading.indexOf((char) 75); + m_dWeightBuffer = Double.parseDouble(m_sScaleReading.substring(start+1, end)); + m_sScaleReading = ""; + } + } catch (IndexOutOfBoundsException ex) { + System.out.println("IndexOutOfBoundsException, message not complete yet. Waiting for more data."); + } + + } catch (IOException eIO) {} + break; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/scale/ScaleAvery.java b/src/main/java/com/unicenta/pos/scale/ScaleAvery.java new file mode 100644 index 0000000..e533cb9 --- /dev/null +++ b/src/main/java/com/unicenta/pos/scale/ScaleAvery.java @@ -0,0 +1,195 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +/* + * uniCenta Feb 2017 + * Original code supplied Ryan Airey Feb 2017 +*/ + +package com.unicenta.pos.scale; + +import gnu.io.*; +import java.io.*; +import java.util.TooManyListenersException; + +public class ScaleAvery implements Scale, SerialPortEventListener { + + private CommPortIdentifier m_PortIdPrinter; + private SerialPort m_CommPortPrinter; + + private String m_sPortScale; + private OutputStream m_out; + private InputStream m_in; + + private static final int SCALE_READY = 0; + private static final int SCALE_READING = 1; + private static final int SCALE_READINGDECIMALS = 2; + private static int SCALE_NOMORE = 1; + + private double m_dWeightBuffer; + private double m_dWeightDecimals; + private int m_iStatusScale; + + public ScaleAvery(String sPortPrinter) { + m_sPortScale = sPortPrinter; + m_out = null; + m_in = null; + + m_iStatusScale = SCALE_READY; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + + } + + @Override + public Double readWeight() { + synchronized(this) { + if (m_iStatusScale != SCALE_READY) { + try { + wait(1000); + } catch (InterruptedException e) { + } + if (m_iStatusScale != SCALE_READY) { + + m_iStatusScale = SCALE_READY; + } + } + + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + + // Send command to get data from scale + write(new byte[] {0x0057}); + flush(); + write(new byte[] {0x000D}); + try { + wait(1000); + } catch (InterruptedException e) { + } + + if (m_iStatusScale == SCALE_READY) { + double dWeight = m_dWeightBuffer / m_dWeightDecimals; +// System.out.println(" ----- ScaleAvery : readWeight --- if ------ "+dWeight); + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + return dWeight; + } else { + m_iStatusScale = SCALE_READY; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + return 0.0; + } + } + } + + private void flush() { + try { + m_out.flush(); + } catch (IOException e) { + } + } + + private void write(byte[] data) { + try { + + + if (m_out == null) { + + m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale); + m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000); + m_out = m_CommPortPrinter.getOutputStream(); + m_in = m_CommPortPrinter.getInputStream(); + + m_CommPortPrinter.addEventListener(this); + m_CommPortPrinter.notifyOnDataAvailable(true); + + m_CommPortPrinter.setSerialPortParams(9600, + SerialPort.DATABITS_7, + SerialPort.STOPBITS_1, + SerialPort.PARITY_EVEN); + } + m_out.write(data); + + } catch (NoSuchPortException | PortInUseException + | UnsupportedCommOperationException | TooManyListenersException + | IOException e) { +// System.out.println(" Exception While Writing the Data, Might be Serial Dll Missing or COM Port not Supported, Or COM Port already in use"); + } + } + + @Override + public void serialEvent(SerialPortEvent e) { + + switch (e.getEventType()) { + case SerialPortEvent.BI: + case SerialPortEvent.OE: + case SerialPortEvent.FE: + case SerialPortEvent.PE: + case SerialPortEvent.CD: + case SerialPortEvent.CTS: + case SerialPortEvent.DSR: + case SerialPortEvent.RI: + case SerialPortEvent.OUTPUT_BUFFER_EMPTY: + break; + case SerialPortEvent.DATA_AVAILABLE: + try { + while (m_in.available() > 0) { + int b = m_in.read(); + if (b==0x0003 || b==3) { + synchronized (this) { + SCALE_NOMORE = 1; + m_iStatusScale = SCALE_READY; + notifyAll(); } + } else if (b == 0x004C || b==76) { + synchronized (this) { + SCALE_NOMORE = 0; } + } else if (SCALE_NOMORE==0){ + m_iStatusScale = SCALE_READY; + } else if (b > 0x002F + && b < 0x003A + && SCALE_NOMORE==1 + || b == 0x002E) { + synchronized(this) { + if (m_iStatusScale == SCALE_READY) { + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + m_iStatusScale = SCALE_READING; + } + if (b == 0x002E) { + m_iStatusScale = SCALE_READINGDECIMALS; + } else { + m_dWeightBuffer = m_dWeightBuffer * 10.0 + b - 0x0030; + if (m_iStatusScale == SCALE_READINGDECIMALS) { + m_dWeightDecimals *= 10.0; + } + } + } + } else { + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + m_iStatusScale = SCALE_READY; + } + } + } catch (IOException eIO) { +// System.out.println(" Error At serialEvent due to unknowen response data from scale "); + } + break; + } + } + } \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/scale/ScaleCASPDII.java b/src/main/java/com/unicenta/pos/scale/ScaleCASPDII.java new file mode 100644 index 0000000..2b95747 --- /dev/null +++ b/src/main/java/com/unicenta/pos/scale/ScaleCASPDII.java @@ -0,0 +1,178 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com/ +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scale; + +import gnu.io.*; +import java.io.*; +import java.util.TooManyListenersException; + +public class ScaleCASPDII implements Scale, SerialPortEventListener { + + private CommPortIdentifier m_PortIdPrinter; + private SerialPort m_CommPortPrinter; + + private final String m_sPortScale; + private OutputStream m_out; + private InputStream m_in; + + private static final int SCALE_READY = 0; + private static final int SCALE_READING = 1; + private static final int SCALE_READINGDECIMALS = 2; + + private double m_dWeightBuffer; + private double m_dWeightDecimals; + private int m_iStatusScale; + + /** Creates a new instance of ScaleComm + * @param sPortPrinter */ + public ScaleCASPDII(String sPortPrinter) { + m_sPortScale = sPortPrinter; + m_out = null; + m_in = null; + + m_iStatusScale = SCALE_READY; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + } + + @Override + public Double readWeight() { + + synchronized(this) { + + if (m_iStatusScale != SCALE_READY) { + try { + wait(1000); + } catch (InterruptedException e) { + } + if (m_iStatusScale != SCALE_READY) { + m_iStatusScale = SCALE_READY; + } + } + + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + write(new byte[] {0x57}); + flush(); + + try { + wait(1000); + } catch (InterruptedException e) { + } + + if (m_iStatusScale == SCALE_READY) { + double dWeight = m_dWeightBuffer / m_dWeightDecimals; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1000.0; + return dWeight; + } else { + m_iStatusScale = SCALE_READY; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1000.0; + return 0.0; + } + } + } + + private void flush() { + try { + m_out.flush(); + } catch (IOException e) { + } + } + + private void write(byte[] data) { + try { + if (m_out == null) { + m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale); + m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 1000); + + m_out = m_CommPortPrinter.getOutputStream(); + m_in = m_CommPortPrinter.getInputStream(); + + m_CommPortPrinter.addEventListener(this); + m_CommPortPrinter.notifyOnDataAvailable(true); + + m_CommPortPrinter.setSerialPortParams(9600, + SerialPort.DATABITS_7, + SerialPort.STOPBITS_1, + SerialPort.PARITY_EVEN); + } + m_out.write(data); + } catch (NoSuchPortException | + PortInUseException | + UnsupportedCommOperationException | + TooManyListenersException | + IOException e) { + } + } + + @Override + public void serialEvent(SerialPortEvent e) { + + switch (e.getEventType()) { + case SerialPortEvent.BI: + case SerialPortEvent.OE: + case SerialPortEvent.FE: + case SerialPortEvent.PE: + case SerialPortEvent.CD: + case SerialPortEvent.CTS: + case SerialPortEvent.DSR: + case SerialPortEvent.RI: + case SerialPortEvent.OUTPUT_BUFFER_EMPTY: + break; + case SerialPortEvent.DATA_AVAILABLE: + try { + while (m_in.available() > 0) { + int b = m_in.read(); + + if (b == 0x000D) { + synchronized (this) { + m_iStatusScale = SCALE_READY; + notifyAll(); + } + } else if ((b > 0x002F && b < 0x003A) || b == 0x002E){ + synchronized(this) { + if (m_iStatusScale == SCALE_READY) { + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1000.0; + m_iStatusScale = SCALE_READING; + } + if (b == 0x002E) { + m_iStatusScale = SCALE_READINGDECIMALS; + } else { + m_dWeightBuffer = m_dWeightBuffer * 10.0 + b - 0x0030; + if (m_iStatusScale == SCALE_READINGDECIMALS) { + m_dWeightDecimals *= 10.0; + } + } + } + } else { + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1000.0; + m_iStatusScale = SCALE_READY; + } + } + + } catch (IOException eIO) {} + break; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/scale/ScaleCasioPD1.java b/src/main/java/com/unicenta/pos/scale/ScaleCasioPD1.java new file mode 100644 index 0000000..2b8b2d1 --- /dev/null +++ b/src/main/java/com/unicenta/pos/scale/ScaleCasioPD1.java @@ -0,0 +1,202 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scale; + +import gnu.io.*; +import java.io.*; +import java.util.TooManyListenersException; + +/** + * + * @author JG uniCenta + */ +public class ScaleCasioPD1 implements Scale, SerialPortEventListener { + + private CommPortIdentifier m_PortIdPrinter; + private SerialPort m_CommPortPrinter; + + private String m_sPortScale; + private OutputStream m_out; + private InputStream m_in; + + private static final int SCALE_READY = 0; + private static final int SCALE_READING = 1; + private static final int SCALE_READINGDECIMALS = 2; + private static int SCALE_NOMORE = 1; + + private double m_dWeightBuffer; + private double m_dWeightDecimals; + private int m_iStatusScale; + + /** Creates a new instance of ScaleComm + * @param sPortPrinter */ + public ScaleCasioPD1(String sPortPrinter) { + m_sPortScale = sPortPrinter; + m_out = null; + m_in = null; + + m_iStatusScale = SCALE_READY; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + } + + /** + * + * @return + */ + @Override + public Double readWeight() { + + synchronized(this) { + + if (m_iStatusScale != SCALE_READY) { + try { + wait(1000); + } catch (InterruptedException e) { + } + if (m_iStatusScale != SCALE_READY) { + // bascula tonta. + m_iStatusScale = SCALE_READY; + } + } + + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + write(new byte[] {0x0057}); + flush(); + write(new byte[] {0x000D}); + + // Esperamos un ratito + try { + wait(1000); + } catch (InterruptedException e) { + } + + if (m_iStatusScale == SCALE_READY) { + double dWeight = m_dWeightBuffer / m_dWeightDecimals; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + return dWeight; + } else { + m_iStatusScale = SCALE_READY; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + return 0.0; + } + } + } + + private void flush() { + try { + m_out.flush(); + } catch (IOException e) { + } + } + + private void write(byte[] data) { + try { + if (m_out == null) { + m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale); + m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000); + + m_out = m_CommPortPrinter.getOutputStream(); + m_in = m_CommPortPrinter.getInputStream(); + + m_CommPortPrinter.addEventListener(this); + m_CommPortPrinter.notifyOnDataAvailable(true); + + m_CommPortPrinter.setSerialPortParams(9600, + SerialPort.DATABITS_7, + SerialPort.STOPBITS_1, + SerialPort.PARITY_EVEN); + } + m_out.write(data); + } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | TooManyListenersException | IOException e) { + } + } + + /** + * + * @param e + */ + @Override + public void serialEvent(SerialPortEvent e) { + + // Determine type of event. + switch (e.getEventType()) { + case SerialPortEvent.BI: + case SerialPortEvent.OE: + case SerialPortEvent.FE: + case SerialPortEvent.PE: + case SerialPortEvent.CD: + case SerialPortEvent.CTS: + case SerialPortEvent.DSR: + case SerialPortEvent.RI: + case SerialPortEvent.OUTPUT_BUFFER_EMPTY: + break; + case SerialPortEvent.DATA_AVAILABLE: + try { + while (m_in.available() > 0) { + int b = m_in.read(); + + if (b==0x0003 || b==3) { + synchronized (this) { + SCALE_NOMORE = 1; + m_iStatusScale = SCALE_READY; + notifyAll(); + } + + }else if (b == 0x004C || b==76) { + synchronized (this) { + SCALE_NOMORE = 0; + } + + }else if (SCALE_NOMORE==0){ + m_iStatusScale = SCALE_READY; + + }else if (b > 0x002F && b < 0x003A && SCALE_NOMORE==1 || b == 0x002E){ + synchronized(this) { + + if (m_iStatusScale == SCALE_READY) { + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + m_iStatusScale = SCALE_READING; + } + if (b == 0x002E) { + m_iStatusScale = SCALE_READINGDECIMALS; + } else { + m_dWeightBuffer = m_dWeightBuffer * 10.0 + b - 0x0030; + + if (m_iStatusScale == SCALE_READINGDECIMALS) { + m_dWeightDecimals *= 10.0; + } + } + } + } else { + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + m_iStatusScale = SCALE_READY; + } + } + } catch (IOException eIO) {} + break; + } + } + } \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/scale/ScaleComm.java b/src/main/java/com/unicenta/pos/scale/ScaleComm.java new file mode 100644 index 0000000..0336aab --- /dev/null +++ b/src/main/java/com/unicenta/pos/scale/ScaleComm.java @@ -0,0 +1,178 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scale; + +import gnu.io.*; +import java.io.*; +import java.util.TooManyListenersException; + +/** + * + * @author JG uniCenta + */ +public class ScaleComm implements Scale, SerialPortEventListener { + + private String m_sPortScale; + private CommPortIdentifier m_PortIdPrinter; + private SerialPort m_CommPortPrinter; + private OutputStream m_out; + private InputStream m_in; + + private static final int SCALE_READY = 0; + private static final int SCALE_READING = 1; + + private double m_dWeightBuffer; + private int m_iStatusScale; + + /** Creates a new instance of ScaleComm + * @param sPortPrinter */ + public ScaleComm(String sPortPrinter) { + m_sPortScale = sPortPrinter; + m_out = null; + m_in = null; + + m_iStatusScale = SCALE_READY; + m_dWeightBuffer = 0.0; + } + + /** + * + * @return + */ + @Override + public Double readWeight() { + + synchronized(this) { + + if (m_iStatusScale != SCALE_READY) { + try { + wait(1000); + } catch (InterruptedException e) { + } + if (m_iStatusScale != SCALE_READY) { + // bascula tonta. + m_iStatusScale = SCALE_READY; + } + } + + // Ya estamos en SCALE_READY + m_dWeightBuffer = 0.0; + write(new byte[] {0x05}); + flush(); + + // Esperamos un ratito + try { + wait(1000); + } catch (InterruptedException e) { + } + + if (m_iStatusScale == SCALE_READY) { + // a value as been readed. + double dWeight = m_dWeightBuffer / 1000.0; + m_dWeightBuffer = 0.0; + return new Double(dWeight); + } else { + m_iStatusScale = SCALE_READY; + m_dWeightBuffer = 0.0; + return new Double(0.0); + } + } + } + + private void flush() { + try { + m_out.flush(); + } catch (IOException e) { + } + } + + private void write(byte[] data) { + try { + if (m_out == null) { + m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale); // Tomamos el puerto + m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000); // Abrimos el puerto + + m_out = m_CommPortPrinter.getOutputStream(); // Tomamos el chorro de escritura + m_in = m_CommPortPrinter.getInputStream(); + + m_CommPortPrinter.addEventListener(this); + m_CommPortPrinter.notifyOnDataAvailable(true); + + m_CommPortPrinter.setSerialPortParams(4800, + SerialPort.DATABITS_8, + SerialPort.STOPBITS_1, + SerialPort.PARITY_ODD); // Configuramos el puerto + } + m_out.write(data); + } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | TooManyListenersException | IOException e) { + } + } + + /** + * + * @param e + */ + @Override + public void serialEvent(SerialPortEvent e) { + + // Determine type of event. + switch (e.getEventType()) { + case SerialPortEvent.BI: + case SerialPortEvent.OE: + case SerialPortEvent.FE: + case SerialPortEvent.PE: + case SerialPortEvent.CD: + case SerialPortEvent.CTS: + case SerialPortEvent.DSR: + case SerialPortEvent.RI: + case SerialPortEvent.OUTPUT_BUFFER_EMPTY: + break; + case SerialPortEvent.DATA_AVAILABLE: + try { + while (m_in.available() > 0) { + int b = m_in.read(); + + if (b == 0x001E) { // RS ASCII + // Fin de lectura + synchronized (this) { + m_iStatusScale = SCALE_READY; + notifyAll(); + } + } else if (b > 0x002F && b < 0x003A){ + synchronized(this) { + if (m_iStatusScale == SCALE_READY) { + m_dWeightBuffer = 0.0; // se supone que esto debe estar ya garantizado + m_iStatusScale = SCALE_READING; + } + m_dWeightBuffer = m_dWeightBuffer * 10.0 + b - 0x0030; + } + } else { + // caracteres invalidos, reseteamos. + m_dWeightBuffer = 0.0; // se supone que esto debe estar ya garantizado + m_iStatusScale = SCALE_READY; + } + } + + } catch (IOException eIO) {} + break; + } + + } +} diff --git a/src/main/java/com/unicenta/pos/scale/ScaleDialog.java b/src/main/java/com/unicenta/pos/scale/ScaleDialog.java new file mode 100644 index 0000000..1bd4015 --- /dev/null +++ b/src/main/java/com/unicenta/pos/scale/ScaleDialog.java @@ -0,0 +1,57 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scale; + +import com.unicenta.beans.JNumberDialog; +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; +import javax.swing.ImageIcon; + +/** + * + * @author adrian + */ +public class ScaleDialog implements Scale { + + private Component parent; + + /** + * + * @param parent + */ + public ScaleDialog(Component parent) { + this.parent = parent; + } + + /** + * + * @return + * @throws ScaleException + */ + @Override + public Double readWeight() throws ScaleException { + + // Set title for grams Kilos, ounzes, pounds, ... + return JNumberDialog.showEditNumber(parent, + AppLocal.getIntString("label.scale"), + AppLocal.getIntString("label.scaleinput"), + new ImageIcon(ScaleDialog.class.getResource("/com/unicenta/images/ark2.png"))); + } +} diff --git a/src/main/java/com/unicenta/pos/scale/ScaleException.java b/src/main/java/com/unicenta/pos/scale/ScaleException.java new file mode 100644 index 0000000..6b56da4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/scale/ScaleException.java @@ -0,0 +1,41 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scale; + +/** + * + * @author JG uniCenta + */ +public class ScaleException extends java.lang.Exception { + + /** + * Creates a new instance of <code>ScaleException</code> without detail message. + */ + public ScaleException() { + } + + /** + * Constructs an instance of <code>ScaleException</code> with the specified detail message. + * @param msg the detail message. + */ + public ScaleException(String msg) { + super(msg); + } +} diff --git a/src/main/java/com/unicenta/pos/scale/ScaleFake.java b/src/main/java/com/unicenta/pos/scale/ScaleFake.java new file mode 100644 index 0000000..22a50fc --- /dev/null +++ b/src/main/java/com/unicenta/pos/scale/ScaleFake.java @@ -0,0 +1,38 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009 Openbravo, S.L. +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scale; + +public class ScaleFake implements Scale { + + /** Creates a new instance of ScaleFake */ + public ScaleFake() { + } + + /** + * + * @return + * @throws ScaleException + */ + @Override + public Double readWeight() throws ScaleException { + return new Double(Math.random() * 2.0); + } + +} diff --git a/src/main/java/com/unicenta/pos/scale/ScaleMTIND221.java b/src/main/java/com/unicenta/pos/scale/ScaleMTIND221.java new file mode 100644 index 0000000..798dd51 --- /dev/null +++ b/src/main/java/com/unicenta/pos/scale/ScaleMTIND221.java @@ -0,0 +1,198 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scale; + +import gnu.io.*; +import lombok.extern.slf4j.Slf4j; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream;import java.util.TooManyListenersException; + +/** + * + * @author Nicholas Fritz - changes by JG + */ +@Slf4j +public class ScaleMTIND221 implements Scale, SerialPortEventListener { + + private CommPortIdentifier m_PortIdPrinter; + private SerialPort m_CommPortPrinter; + + private final String m_sPortScale; + private OutputStream m_out; + private InputStream m_in; + + private static final int SCALE_READY = 0; + private static final int SCALE_READING = 1; + private static final int SCALE_READINGDECIMALS = 2; + + private double m_dWeightBuffer; + private double m_dWeightDecimals; + private int m_iStatusScale; + + /** Creates a new instance of ScaleComm + * @param sPortPrinter */ + public ScaleMTIND221(String sPortPrinter) { + m_sPortScale = sPortPrinter; + m_out = null; + m_in = null; + + m_iStatusScale = SCALE_READY; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + } + + /** + * + * @return + */ + @Override + public Double readWeight() { + + synchronized(this) { + + if (m_iStatusScale != SCALE_READY) { + try { + wait(1000); + } catch (InterruptedException ex) { + log.error(ex.getMessage()); + } + if (m_iStatusScale != SCALE_READY) { + // bascula tonta. + m_iStatusScale = SCALE_READY; + } + } + + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + try { + write(new byte[] {0x50}); // P + } catch (TooManyListenersException ex) { + log.error(ex.getMessage()); + } + flush(); + + try { + wait(1000); + } catch (InterruptedException ex) { + log.error(ex.getMessage()); + } + + if (m_iStatusScale == SCALE_READY) { + // hemos recibido cositas o si no hemos recibido nada estamos a 0.0 + double dWeight = m_dWeightBuffer / (m_dWeightDecimals*100.0); + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + return dWeight; + } else { + m_iStatusScale = SCALE_READY; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + return 0.0; + } + } + } + + private void flush() { + try { + m_out.flush(); + } catch (IOException e) { + } + } + + private void write(byte[] data) throws TooManyListenersException { + try { + if (m_out == null) { + m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale); // Tomamos el puerto + m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000); // Abrimos el puerto + + m_out = m_CommPortPrinter.getOutputStream(); // Tomamos el chorro de escritura + m_in = m_CommPortPrinter.getInputStream(); + + m_CommPortPrinter.addEventListener(this); + m_CommPortPrinter.notifyOnDataAvailable(true); + + m_CommPortPrinter.setSerialPortParams(9600, 8, 1, 0); // Configuramos el puerto + } + m_out.write(data); + } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | IOException e) { + } + } + + /** + * + * @param e + */ + @Override + public void serialEvent(SerialPortEvent e) { + + // Determine type of event. + switch (e.getEventType()) { + case SerialPortEvent.BI: + case SerialPortEvent.OE: + case SerialPortEvent.FE: + case SerialPortEvent.PE: + case SerialPortEvent.CD: + case SerialPortEvent.CTS: + case SerialPortEvent.DSR: + case SerialPortEvent.RI: + case SerialPortEvent.OUTPUT_BUFFER_EMPTY: + break; + case SerialPortEvent.DATA_AVAILABLE: + try { + while (m_in.available() > 0) { + int b = m_in.read(); + + if (b == 0x000D) { // CR ASCII + // Fin de lectura + synchronized (this) { + m_iStatusScale = SCALE_READY; + notifyAll(); + } + } else if (((b > 0x002F) && (b < 0x003A)) || (b == 0x002E)){ + synchronized(this) { + if (m_iStatusScale == SCALE_READY) { + m_dWeightBuffer = 0.0; // se supone que esto debe estar ya garantizado + m_dWeightDecimals = 1.0; + m_iStatusScale = SCALE_READING; + } + if (b == 0x002E) { + m_iStatusScale = SCALE_READINGDECIMALS; + } else { + m_dWeightBuffer = m_dWeightBuffer * 10.0 + b - 0x0030; + if (m_iStatusScale == SCALE_READINGDECIMALS) { + m_dWeightDecimals *= 10.0; + } + } + } + } else { + // caracteres invalidos, reseteamos. + //m_dWeightBuffer = 0.0; // se supone que esto debe estar ya garantizado + m_dWeightDecimals = 1.0; + m_iStatusScale = SCALE_READY; + } + } + + } catch (IOException eIO) {} + break; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/scale/ScaleSamsungEsp.java b/src/main/java/com/unicenta/pos/scale/ScaleSamsungEsp.java new file mode 100644 index 0000000..5ae8499 --- /dev/null +++ b/src/main/java/com/unicenta/pos/scale/ScaleSamsungEsp.java @@ -0,0 +1,193 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scale; + +import gnu.io.*; +import java.io.*; +import java.util.TooManyListenersException; + +/** + * + * @author JG uniCenta + */ +public class ScaleSamsungEsp implements Scale, SerialPortEventListener { + + private CommPortIdentifier m_PortIdPrinter; + private SerialPort m_CommPortPrinter; + + private String m_sPortScale; + private OutputStream m_out; + private InputStream m_in; + + private static final int SCALE_READY = 0; + private static final int SCALE_READING = 1; + private static final int SCALE_READINGDECIMALS = 2; + + private double m_dWeightBuffer; + private double m_dWeightDecimals; + private int m_iStatusScale; + + /** Creates a new instance of ScaleComm + * @param sPortPrinter */ + public ScaleSamsungEsp(String sPortPrinter) { + m_sPortScale = sPortPrinter; + m_out = null; + m_in = null; + + m_iStatusScale = SCALE_READY; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + } + + /** + * + * @return + */ + @Override + public Double readWeight() { + + synchronized(this) { + + if (m_iStatusScale != SCALE_READY) { + try { + wait(1000); + } catch (InterruptedException e) { + } + if (m_iStatusScale != SCALE_READY) { + // bascula tonta. + m_iStatusScale = SCALE_READY; + } + } + + // Ya estamos en SCALE_READY + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + write(new byte[] {0x24}); // $ + flush(); + + // Esperamos un ratito + try { + wait(1000); + } catch (InterruptedException e) { + } + + if (m_iStatusScale == SCALE_READY) { + // hemos recibido cositas o si no hemos recibido nada estamos a 0.0 + double dWeight = m_dWeightBuffer / m_dWeightDecimals; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + return new Double(dWeight); + } else { + m_iStatusScale = SCALE_READY; + m_dWeightBuffer = 0.0; + m_dWeightDecimals = 1.0; + return new Double(0.0); + } + } + } + + private void flush() { + try { + m_out.flush(); + } catch (IOException e) { + } + } + + private void write(byte[] data) { + try { + if (m_out == null) { + m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale); // Tomamos el puerto + m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000); // Abrimos el puerto + + m_out = m_CommPortPrinter.getOutputStream(); // Tomamos el chorro de escritura + m_in = m_CommPortPrinter.getInputStream(); + + m_CommPortPrinter.addEventListener(this); + m_CommPortPrinter.notifyOnDataAvailable(true); + + m_CommPortPrinter.setSerialPortParams(4800, + SerialPort.DATABITS_8, + SerialPort.STOPBITS_1, + SerialPort.PARITY_ODD); // Configuramos el puerto + } + m_out.write(data); + } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | TooManyListenersException | IOException e) { + } + } + + /** + * + * @param e + */ + @Override + public void serialEvent(SerialPortEvent e) { + + // Determine type of event. + switch (e.getEventType()) { + case SerialPortEvent.BI: + case SerialPortEvent.OE: + case SerialPortEvent.FE: + case SerialPortEvent.PE: + case SerialPortEvent.CD: + case SerialPortEvent.CTS: + case SerialPortEvent.DSR: + case SerialPortEvent.RI: + case SerialPortEvent.OUTPUT_BUFFER_EMPTY: + break; + case SerialPortEvent.DATA_AVAILABLE: + try { + while (m_in.available() > 0) { + int b = m_in.read(); + + if (b == 0x000D) { // CR ASCII + // Fin de lectura + synchronized (this) { + m_iStatusScale = SCALE_READY; + notifyAll(); + } + } else if ((b > 0x002F && b < 0x003A) || b == 0x002E){ + synchronized(this) { + if (m_iStatusScale == SCALE_READY) { + m_dWeightBuffer = 0.0; // se supone que esto debe estar ya garantizado + m_dWeightDecimals = 1.0; + m_iStatusScale = SCALE_READING; + } + if (b == 0x002E) { + m_iStatusScale = SCALE_READINGDECIMALS; + } else { + m_dWeightBuffer = m_dWeightBuffer * 10.0 + b - 0x0030; + if (m_iStatusScale == SCALE_READINGDECIMALS) { + m_dWeightDecimals *= 10.0; + } + } + } + } else { + // caracteres invalidos, reseteamos. + m_dWeightBuffer = 0.0; // se supone que esto debe estar ya garantizado + m_dWeightDecimals = 1.0; + m_iStatusScale = SCALE_READY; + } + } + + } catch (IOException eIO) {} + break; + } + } +} diff --git a/src/main/java/com/unicenta/pos/scanpal2/DeviceScanner.java b/src/main/java/com/unicenta/pos/scanpal2/DeviceScanner.java new file mode 100644 index 0000000..d5cdc26 --- /dev/null +++ b/src/main/java/com/unicenta/pos/scanpal2/DeviceScanner.java @@ -0,0 +1,72 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scanpal2; + +/** + * + * @author JG uniCenta + */ +public interface DeviceScanner { + + /** + * + * @throws DeviceScannerException + */ + public void connectDevice() throws DeviceScannerException; + + /** + * + */ + public void disconnectDevice(); + + /** + * + * @throws DeviceScannerException + */ + public void startDownloadProduct() throws DeviceScannerException; + + /** + * + * @return + * @throws DeviceScannerException + */ + public ProductDownloaded recieveProduct() throws DeviceScannerException; + + /** + * + * @throws DeviceScannerException + */ + public void startUploadProduct() throws DeviceScannerException; + + /** + * + * @param sName + * @param sCode + * @param dPrice + * @throws DeviceScannerException + */ + public void sendProduct(String sName, String sCode, Double dPrice) throws DeviceScannerException; + + /** + * + * @throws DeviceScannerException + */ + public void stopUploadProduct() throws DeviceScannerException; +} diff --git a/src/main/java/com/unicenta/pos/scanpal2/DeviceScannerComm.java b/src/main/java/com/unicenta/pos/scanpal2/DeviceScannerComm.java new file mode 100644 index 0000000..97d3f7e --- /dev/null +++ b/src/main/java/com/unicenta/pos/scanpal2/DeviceScannerComm.java @@ -0,0 +1,368 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scanpal2; + +import gnu.io.*; +import java.io.*; +import java.util.LinkedList; +import java.util.Queue; +import java.util.StringTokenizer; + +/** + * + * @author JG uniCenta + */ +public class DeviceScannerComm implements DeviceScanner, SerialPortEventListener { + + private CommPortIdentifier m_PortIdPrinter; + private SerialPort m_CommPortPrinter; + + private String m_sPort; + private OutputStream m_out; + private InputStream m_in; + + private static final byte[] COMMAND_READ = new byte[] {0x52, 0x45, 0x41, 0x44}; + private static final byte[] COMMAND_CIPHER = new byte[] {0x43, 0x49, 0x50, 0x48, 0x45, 0x52}; + private static final byte[] COMMAND_OVER = new byte[] {0x4F, 0x56, 0x45, 0x52}; + private static final byte[] COMMAND_ACK = new byte[] {0x41, 0x43, 0x4B}; + + private Queue<byte[]> m_aLines; + private ByteArrayOutputStream m_abuffer; + private int m_iStatus; +// private static final int STATUS_WAITING = 0; +// private static final int STATUS_LINEREADY = 1; +// private static final int STATUS_READING = 2; + + private int m_iProductOrder; + + /** Creates a new instance of ScanDeviceComm */ + DeviceScannerComm(String sPort) { + m_sPort = sPort; + + m_PortIdPrinter = null; + m_CommPortPrinter = null; + m_out = null; + m_in = null; + } + + /** + * + * @throws DeviceScannerException + */ + public void connectDevice() throws DeviceScannerException { + + try { + // Conecto con el puerto + m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPort); // Tomamos el puerto + m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000); // Abrimos el puerto + + m_out = m_CommPortPrinter.getOutputStream(); // Tomamos el chorro de escritura + m_in = m_CommPortPrinter.getInputStream(); + + m_CommPortPrinter.addEventListener(this); + m_CommPortPrinter.notifyOnDataAvailable(true); + + m_CommPortPrinter.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); // Configuramos el puerto +// } catch (NoSuchPortException e) { +// e.printStackTrace(); +// } catch (PortInUseException e) { +// e.printStackTrace(); +// } catch (UnsupportedCommOperationException e) { +// e.printStackTrace(); +// } catch (TooManyListenersException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); + } catch (Exception e) { + m_PortIdPrinter = null; + m_CommPortPrinter = null; + m_out = null; + m_in = null; + throw new DeviceScannerException(e); + } + + synchronized(this) { + // m_iStatus = STATUS_WAITING; + m_aLines = new LinkedList<byte[]>(); + m_abuffer = new ByteArrayOutputStream(); + } + } + + /** + * + */ + public void disconnectDevice() { + + try { + m_out.close(); + m_in.close(); + m_CommPortPrinter.close(); + } catch (IOException e) { + } + + synchronized(this) { + // m_iStatus = STATUS_WAITING; + m_aLines = null; + m_abuffer = null; + } + + m_PortIdPrinter = null; + m_CommPortPrinter = null; + m_out = null; + m_in = null; + } + + /** + * + * @throws DeviceScannerException + */ + public void startDownloadProduct() throws DeviceScannerException { + writeLine(COMMAND_READ); // writeLine(COMMAND_READ); + readCommand(COMMAND_ACK); + } + + /** + * + * @return + * @throws DeviceScannerException + */ + public ProductDownloaded recieveProduct() throws DeviceScannerException { + byte[] line = readLine(); + if (checkCommand(COMMAND_OVER, line)) { + // La Scanpal a terminado. + return null; + } else { + // procesamos la linea + ProductDownloaded p = new ProductDownloaded(); + try { + String sLine = new String(line, 1, line.length - 3, "ISO-8859-1"); + StringTokenizer T = new StringTokenizer(sLine, "|"); + while (T.hasMoreTokens()) { + String sToken = T.nextToken(); + if (sToken.startsWith("IEAN")) { + p.setCode(sToken.substring(4).trim()); + } else if (sToken.startsWith("ICANT")) { + try { + p.setQuantity(Double.parseDouble(sToken.substring(5).trim())); + } catch (NumberFormatException e) { + } + } + } + } catch (UnsupportedEncodingException e) { + } + writeLine(COMMAND_ACK); + return p; + } + } + + /** + * + * @throws DeviceScannerException + */ + public void startUploadProduct() throws DeviceScannerException { + // Inicializamos la conversacion + writeLine(COMMAND_CIPHER); + readCommand(COMMAND_ACK); + m_iProductOrder = 0; + } + + /** + * + * @param sName + * @param sCode + * @param dPrice + * @throws DeviceScannerException + */ + public void sendProduct(String sName, String sCode, Double dPrice) throws DeviceScannerException { + + m_iProductOrder++; + + ByteArrayOutputStream lineout = new ByteArrayOutputStream(); + try { + lineout.write(convert(Integer.toString(m_iProductOrder))); + lineout.write(0x7c); // El Pipe "|" + lineout.write(convert(sName)); + lineout.write(0x7c); // El Pipe "|" + lineout.write(convert(sCode)); + lineout.write(0x7c); // El Pipe "|" + lineout.write(0x7c); // El Pipe "|" + lineout.write(0x7c); // El Pipe "|" + lineout.write(0x7c); // El Pipe "|" + lineout.write(convert(dPrice.toString())); + lineout.write(0x7c); // El Pipe "|" + // Mandamos el checksum + lineout.write(calcCheckSum1(lineout.toByteArray())); + } catch (UnsupportedEncodingException e) { + } catch (IOException e) { + } + + writeLine(lineout.toByteArray()); + readCommand(COMMAND_ACK); + } + + /** + * + * @throws DeviceScannerException + */ + public void stopUploadProduct() throws DeviceScannerException { + // Cerramos la conversacion + writeLine(COMMAND_OVER); + readCommand(COMMAND_ACK); + } + + private void readCommand(byte[] cmd) throws DeviceScannerException { + byte[] b = readLine(); + if (!checkCommand(cmd, b)) { + // excepcion que te crio. + throw new DeviceScannerException("Command not expected"); + } + } + + private void writeLine(byte[] aline) throws DeviceScannerException { + + if (m_CommPortPrinter == null) { + throw new DeviceScannerException("No Serial port opened"); + } else { + + synchronized(this) { + try { + m_out.write(aline); + m_out.write(0x0D); + m_out.flush(); + } catch (IOException e) { + throw new DeviceScannerException(e); + } + } + } + } + + private byte[] readLine() throws DeviceScannerException { + + synchronized (this) { + + if (!m_aLines.isEmpty()) { + return m_aLines.poll(); + } + + // esperamos un ratito + try { + wait(1000); + } catch (InterruptedException e) { + } + + if (m_aLines.isEmpty()) { + throw new DeviceScannerException("Timeout"); + } else { + return m_aLines.poll(); + } + } + } + + private byte[] convert(String sdata) { + + // return sdata.getBytes("ISO-8859-1"); + if (sdata == null) { + return new byte[0]; + } else { + byte[] result = new byte[sdata.length()]; + + for (int i = 0; i < sdata.length(); i++) { + char c = sdata.charAt(i); + if (c == 0x7c) { // El pipe | + result[i] = '.'; + } else if ((c >= 0x0020) && (c < 0x0080)) { + result[i] = (byte) c; + } else { + result[i] = ' '; + } + } + return result; + } + } + + private byte[] calcCheckSum1(byte[] adata) { + + int isum = 0; + for (int i = 0; i < adata.length; i++) { + isum += adata[i]; + } + + byte high = (byte) ((isum & 0xFF00) >> 8); + if (high == 0x0D) high = 0x0E; + byte low = (byte) (isum & 0x00FF); + if (low == 0x0D) low = 0x0E; + + byte[] result = new byte[2]; + result[0] = high; + result[1] = low; + return result; + } + + private boolean checkCommand(byte[] bcommand, byte[] brecieved) { + + if (bcommand.length == brecieved.length) { + for (int i = 0; i < bcommand.length; i++) { + if (bcommand[i] != brecieved[i]) { + return false; + } + } + return true; + } else { + return false; + } + } + + /** + * + * @param e + */ + public void serialEvent(SerialPortEvent e) { + + // Determine type of event. + switch (e.getEventType()) { + case SerialPortEvent.BI: + case SerialPortEvent.OE: + case SerialPortEvent.FE: + case SerialPortEvent.PE: + case SerialPortEvent.CD: + case SerialPortEvent.CTS: + case SerialPortEvent.DSR: + case SerialPortEvent.RI: + case SerialPortEvent.OUTPUT_BUFFER_EMPTY: + break; + case SerialPortEvent.DATA_AVAILABLE: + try { + while (m_in.available() > 0) { + int b = m_in.read(); + synchronized(this) { + if (b == 0x0D) { + m_aLines.add(m_abuffer.toByteArray()); + m_abuffer.reset(); + notifyAll(); + } else { + m_abuffer.write(b); + } + } + } + } catch (IOException eIO) {} + break; + } + } +} diff --git a/src/main/java/com/unicenta/pos/scanpal2/DeviceScannerException.java b/src/main/java/com/unicenta/pos/scanpal2/DeviceScannerException.java new file mode 100644 index 0000000..445a783 --- /dev/null +++ b/src/main/java/com/unicenta/pos/scanpal2/DeviceScannerException.java @@ -0,0 +1,60 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + + +package com.unicenta.pos.scanpal2; + +/** + * + * @author adrianromero + */ +public class DeviceScannerException extends java.lang.Exception { + + /** + * Creates a new instance of <code>DeviceScannerException</code> without detail message. + */ + public DeviceScannerException() { + } + + + /** + * Constructs an instance of <code>DeviceScannerException</code> with the specified detail message. + * @param msg the detail message. + */ + public DeviceScannerException(String msg) { + super(msg); + } + + /** + * + * @param msg + * @param cause + */ + public DeviceScannerException(String msg, Throwable cause) { + super(msg, cause); + } + + /** + * + * @param cause + */ + public DeviceScannerException(Throwable cause) { + super(cause); + } +} diff --git a/src/main/java/com/unicenta/pos/scanpal2/DeviceScannerFactory.java b/src/main/java/com/unicenta/pos/scanpal2/DeviceScannerFactory.java new file mode 100644 index 0000000..c546aa0 --- /dev/null +++ b/src/main/java/com/unicenta/pos/scanpal2/DeviceScannerFactory.java @@ -0,0 +1,53 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scanpal2; + +import com.unicenta.pos.forms.AppProperties; +import com.unicenta.pos.util.StringParser; + +/** + * + * @author JG uniCenta + */ +public class DeviceScannerFactory { + + /** Creates a new instance of DeviceScannerFactory */ + private DeviceScannerFactory() { + } + + /** + * + * @param props + * @return + */ + public static DeviceScanner createInstance(AppProperties props) { + + StringParser sd = new StringParser(props.getProperty("machine.scanner")); + String sScannerType = sd.nextToken(':'); + String sScannerParam1 = sd.nextToken(','); + // String sScannerParam2 = sd.nextToken(','); + + if ("scanpal2".equals(sScannerType)) { + return new DeviceScannerComm(sScannerParam1); + } else { + return null; + } + } +} diff --git a/src/main/java/com/unicenta/pos/scanpal2/ProductDownloaded.java b/src/main/java/com/unicenta/pos/scanpal2/ProductDownloaded.java new file mode 100644 index 0000000..8e27ef2 --- /dev/null +++ b/src/main/java/com/unicenta/pos/scanpal2/ProductDownloaded.java @@ -0,0 +1,68 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scanpal2; + +/** + * + * @author JG uniCenta + */ +public class ProductDownloaded { + + private String m_sCode; + private double m_dQuantity; + + /** + * + */ + public ProductDownloaded() { + } + + /** + * + * @param value + */ + public void setCode(String value) { + m_sCode = value; + } + + /** + * + * @return + */ + public String getCode() { + return m_sCode; + } + + /** + * + * @param value + */ + public void setQuantity(double value) { + m_dQuantity = value; + } + + /** + * + * @return + */ + public double getQuantity() { + return m_dQuantity; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/scripting/ScriptEngine.java b/src/main/java/com/unicenta/pos/scripting/ScriptEngine.java new file mode 100644 index 0000000..0d8623b --- /dev/null +++ b/src/main/java/com/unicenta/pos/scripting/ScriptEngine.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scripting; + +/** + * + * @author adrianromero + * Created on 5 de marzo de 2007, 19:56 + * + */ +public interface ScriptEngine { + + /** + * + * @param key + * @param value + */ + public void put(String key, Object value); + + /** + * + * @param key + * @return + */ + public Object get(String key); + + /** + * + * @param src + * @return + * @throws ScriptException + */ + public Object eval(String src) throws ScriptException; + +} diff --git a/src/main/java/com/unicenta/pos/scripting/ScriptEngineBeanshell.java b/src/main/java/com/unicenta/pos/scripting/ScriptEngineBeanshell.java new file mode 100644 index 0000000..4fd3f7e --- /dev/null +++ b/src/main/java/com/unicenta/pos/scripting/ScriptEngineBeanshell.java @@ -0,0 +1,68 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scripting; + +import bsh.EvalError; +import bsh.Interpreter; + +/** + * + * @author adrianromero + * Created on 5 de marzo de 2007, 19:57 + * + */ +class ScriptEngineBeanshell implements ScriptEngine { + + private Interpreter i; + + /** Creates a new instance of ScriptEngineBeanshell */ + public ScriptEngineBeanshell() { + i = new Interpreter(); + } + + @Override + public void put(String key, Object value) { + + try { + i.set(key, value); + } catch (EvalError e) { + } + } + + @Override + public Object get(String key) { + + try { + return i.get(key); + } catch (EvalError e) { + return null; + } + } + + @Override + public Object eval(String src) throws ScriptException { + + try { + return i.eval(src); + } catch (EvalError e) { + throw new ScriptException(e.getMessage(), e); + } + } +} diff --git a/src/main/java/com/unicenta/pos/scripting/ScriptEngineVelocity.java b/src/main/java/com/unicenta/pos/scripting/ScriptEngineVelocity.java new file mode 100644 index 0000000..1e0650f --- /dev/null +++ b/src/main/java/com/unicenta/pos/scripting/ScriptEngineVelocity.java @@ -0,0 +1,107 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scripting; + +import com.unicenta.pos.forms.AppView; +// import com.unicenta.pos.util.ScriptletUtil; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.VelocityEngine; +import org.apache.velocity.exception.MethodInvocationException; +import org.apache.velocity.exception.ParseErrorException; + +/** + * + * @author adrianromero + * Created on 5 de marzo de 2007, 19:57 + * + */ +class ScriptEngineVelocity implements ScriptEngine { + + private static VelocityEngine m_ve = null; + + private VelocityContext c = null; + private AppView m_App; + + + /** Creates a new instance of ScriptEngineVelocity */ + public ScriptEngineVelocity() throws ScriptException { + + if (m_ve == null) { + // Inicializo Velocity + m_ve = new VelocityEngine(); + // ve.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this); + + // m_ve.setProperty(VelocityEngine.RESOURCE_LOADER, "class"); + // // m_ve.setProperty("class.resource.loader.description", "Velocity Classpath Resource Loader"); + // // m_ve.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + // m_ve.setProperty("class.resource.loader.class", "com.unicenta.pos.forms.SystemResourceLoader"); + // m_ve.setProperty("class.resource.loader.description", "Velocity Resource Loader"); + // m_ve.setProperty("class.resource.loader.appresources", this); + + m_ve.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.NullLogSystem"); + m_ve.setProperty(VelocityEngine.ENCODING_DEFAULT, "UTF-8"); + m_ve.setProperty(VelocityEngine.INPUT_ENCODING, "UTF-8"); + try { + m_ve.init(); + } catch (Exception e) { + throw new ScriptException("Cannot initialize Velocity Engine", e); + } + } + c = new VelocityContext(); + +// Add JG uniCenta - see com.unicenta.pos.ScriptletUtil +// this.put("scriptletutil", new ScriptletUtil()); + + } + + @Override + public void put(String key, Object value) { + c.put(key, value); + } + @Override + public Object get(String key) { + return c.get(key); + } + + @Override + public Object eval(String src) throws ScriptException { + if (m_ve == null) { + throw new ScriptException("Velocity engine not initialized."); + } else { + Writer w = new StringWriter(); + try { + if (m_ve.evaluate(c, w, "log", new StringReader(src))) { + return w.toString(); + } else { + throw new ScriptException("Velocity engine unexpected error."); + } + } catch (ParseErrorException e) { + throw new ScriptException(e.getMessage(), e); + } catch (MethodInvocationException e) { + throw new ScriptException(e.getMessage(), e); + } catch (Exception e) { + throw new ScriptException(e.getMessage(), e); + } + } + } +} diff --git a/src/main/java/com/unicenta/pos/scripting/ScriptException.java b/src/main/java/com/unicenta/pos/scripting/ScriptException.java new file mode 100644 index 0000000..2fecb37 --- /dev/null +++ b/src/main/java/com/unicenta/pos/scripting/ScriptException.java @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scripting; + +/** + * + * @author adrianromero + */ +public class ScriptException extends java.lang.Exception { + + /** + * Creates a new instance of <code>ScriptException</code> without detail message. + */ + public ScriptException() { + } + + + /** + * Constructs an instance of <code>ScriptException</code> with the specified detail message. + * @param msg the detail message. + */ + public ScriptException(String msg) { + super(msg); + } + + /** + * + * @param msg + * @param cause + */ + public ScriptException(String msg, Throwable cause) { + super(msg, cause); + } + +} diff --git a/src/main/java/com/unicenta/pos/scripting/ScriptFactory.java b/src/main/java/com/unicenta/pos/scripting/ScriptFactory.java new file mode 100644 index 0000000..84ee619 --- /dev/null +++ b/src/main/java/com/unicenta/pos/scripting/ScriptFactory.java @@ -0,0 +1,70 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.scripting; + +/** + * + * @author adrianromero + * Created on 5 de marzo de 2007, 19:56 + * + */ +public class ScriptFactory { + + /** + * + */ + public static final String VELOCITY = "velocity"; + + /** + * + */ + public static final String BEANSHELL = "beanshell"; + + /** + * + */ + public static final String RHINO = "rhino"; + + /** Creates a new instance of ScriptFactory */ + private ScriptFactory() { + } + + /** + * + * @param name + * @return + * @throws ScriptException + */ + public static ScriptEngine getScriptEngine(String name) throws ScriptException { +// JG 16 May use switch + switch (name) { + case VELOCITY: + return new ScriptEngineVelocity(); + case BEANSHELL: + return new ScriptEngineBeanshell(); + // } else if (RHINO.equals(name)) { + // return new ScriptEngineRhino(); + // } else if (name.startsWith("generic:")) { + // return new ScriptEngineGeneric(name.substring(8)); + default: + throw new ScriptException("Script engine not found: " + name); + } + } +} diff --git a/src/main/java/com/unicenta/pos/suppliers/DataLogicSuppliers.java b/src/main/java/com/unicenta/pos/suppliers/DataLogicSuppliers.java new file mode 100644 index 0000000..89ec360 --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/DataLogicSuppliers.java @@ -0,0 +1,242 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.suppliers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.*; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.BeanFactoryDataSingle; +import java.util.List; + +/** + * @author JG uniCenta + */ +public class DataLogicSuppliers extends BeanFactoryDataSingle { + + /** + * Main Method for supplier object + */ + protected Session s; + private TableDefinition tsuppliers; + private static final Datas[] supplierdatas = new Datas[] { + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.STRING, + Datas.STRING}; + + /** + * + * @param s + */ + @Override + public void init(Session s){ + this.s = s; + tsuppliers = new TableDefinition(s + , "suppliers" + , new String[] { + "ID", + "SEARCHKEY", + "TAXID", + "NAME", + "MAXDEBT", + "ADDRESS", + "ADDRESS2", + "POSTAL", + "CITY", + "REGION", + "COUNTRY", + "FIRSTNAME", + "LASTNAME", + "EMAIL", + "PHONE", + "PHONE2", + "FAX", + "NOTES", + "VISIBLE", + "CURDATE", + "CURDEBT", + "VATID" } + , new String[] { + "ID", + AppLocal.getIntString("label.searchkey"), + AppLocal.getIntString("label.suppliertaxid"), + AppLocal.getIntString("label.name"), + + AppLocal.getIntString("label.maxdebt"), + AppLocal.getIntString("label.address"), + AppLocal.getIntString("label.address2"), + AppLocal.getIntString("label.postal"), + + AppLocal.getIntString("label.city"), + AppLocal.getIntString("label.region"), + AppLocal.getIntString("label.country"), + AppLocal.getIntString("label.firstname"), + + AppLocal.getIntString("label.lastname"), + AppLocal.getIntString("label.email"), + AppLocal.getIntString("label.phone"), + AppLocal.getIntString("label.phone2"), + + AppLocal.getIntString("label.fax"), + AppLocal.getIntString("label.notes"), + "VISIBLE", + AppLocal.getIntString("label.curdate"), + + AppLocal.getIntString("label.curdebt"), + AppLocal.getIntString("label.suppliervatid") } + , new Datas[] { + Datas.STRING, Datas.STRING, Datas.STRING, Datas.STRING, + Datas.DOUBLE, Datas.STRING, Datas.STRING, Datas.STRING, + Datas.STRING, Datas.STRING, Datas.STRING, Datas.STRING, + Datas.STRING, Datas.STRING, Datas.STRING, Datas.STRING, + Datas.STRING, Datas.STRING, Datas.BOOLEAN, Datas.TIMESTAMP, + Datas.DOUBLE, Datas.STRING } + , new Formats[] { + Formats.STRING, Formats.STRING, Formats.STRING, Formats.STRING, + Formats.CURRENCY, Formats.STRING, Formats.STRING, Formats.STRING, + Formats.STRING, Formats.STRING, Formats.STRING, Formats.STRING, + Formats.STRING, Formats.STRING, Formats.STRING, Formats.STRING, + Formats.STRING, Formats.STRING, Formats.BOOLEAN, Formats.TIMESTAMP, + Formats.CURRENCY, Formats.STRING } + , new int[] {0} + ); + } + + /** + * + * @return supplier data + */ + public SentenceList getSupplierList() { + return new StaticSentence(s + , new QBFBuilder("SELECT " + + "ID, SEARCHKEY, TAXID, NAME, " + + "POSTAL, PHONE, EMAIL " + + "FROM suppliers " + + "WHERE VISIBLE = " + s.DB.TRUE() + " AND ?(QBF_FILTER) ORDER BY NAME" + , new String[] {"SEARCHKEY", "TAXID", "NAME", "POSTAL", "PHONE", "EMAIL"}) + , new SerializerWriteBasic(new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING}) + , (DataRead dr) -> { + SupplierInfo s1 = new SupplierInfo(dr.getString(1)); + s1.setSearchkey(dr.getString(2)); + s1.setTaxid(dr.getString(3)); + s1.setName(dr.getString(4)); + s1.setPostal(dr.getString(5)); + s1.setPhone(dr.getString(6)); + s1.setEmail(dr.getString(7)); + return s1; + }); + } + + /** + * + * @return supplier data + */ + public SentenceList getSuppList() { + return new StaticSentence(s + , new QBFBuilder("SELECT " + + "ID, SEARCHKEY, TAXID, NAME, " + + "POSTAL, PHONE, EMAIL " + + "FROM suppliers " + + "WHERE VISIBLE = " + s.DB.TRUE() + " ORDER BY NAME" + , new String[] {"SEARCHKEY", "TAXID", "NAME", "POSTAL", "PHONE", "EMAIL"}) + , new SerializerWriteBasic(new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING}) + , (DataRead dr) -> { + SupplierInfo s1 = new SupplierInfo(dr.getString(1)); + s1.setSearchkey(dr.getString(2)); + s1.setTaxid(dr.getString(3)); + s1.setName(dr.getString(4)); + s1.setPostal(dr.getString(5)); + s1.setPhone(dr.getString(6)); + s1.setEmail(dr.getString(7)); + return s1; + }); + } + + /** + * + * @param supplier + * @return + * @throws BasicException + */ + public int updateSupplierExt(final SupplierInfoExt supplier) throws BasicException { + + return new PreparedSentence(s + , "UPDATE suppliers SET NOTES = ? WHERE ID = ?" + , SerializerWriteParams.INSTANCE ) + .exec(new DataParams() { + @Override + public void writeValues() throws BasicException { + setString(1, supplier.getNotes()); + setString(2, supplier.getID()); + } + }); + } + public final TableDefinition getTableSuppliers() { + return tsuppliers; + } + + /** + * JG Aug 2017 - Return Supplier Id - sId param + * @param sId + * @return + * @throws BasicException + */ + @SuppressWarnings("unchecked") + public final List<SupplierTransaction> getSuppliersTransactionList(String sId) throws BasicException { + + return new PreparedSentence(s, + "SELECT " + + "stockdiary.datenew, " + + "products.NAME, " + + "stockdiary.units, " + + "stockdiary.price, " + + "stockdiary.reason, " + + "suppliers.id " + + "FROM (stockdiary stockdiary " + + "INNER JOIN suppliers suppliers " + + "ON (stockdiary.supplier = suppliers.id)) " + + "INNER JOIN products products " + + "ON (stockdiary.product = products.ID) " + + "WHERE suppliers.id = ? " + + "GROUP BY " + + "stockdiary.datenew, " + + "products.NAME, " + + "stockdiary.reason " + + "ORDER BY stockdiary.datenew DESC", + SerializerWriteString.INSTANCE, + SupplierTransaction.getSerializerRead()).list(sId); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/suppliers/JDialogNewSupplier.form b/src/main/java/com/unicenta/pos/suppliers/JDialogNewSupplier.form new file mode 100644 index 0000000..27543e4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/JDialogNewSupplier.form @@ -0,0 +1,424 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.supplier" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-57,0,0,2,116"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleName" type="java.lang.String" value=""/> + </AccessibilityProperties> + <AuxValues> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,26,0,0,4,11"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblEmail" alignment="0" max="-2" attributes="1"/> + <Component id="jLblTelephone1" alignment="0" max="-2" attributes="1"/> + <Component id="jLblTelephone2" alignment="1" max="-2" attributes="1"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="txtPhone" max="-2" attributes="2"/> + <Component id="txtEmail" max="-2" attributes="2"/> + <Component id="txtPhone2" max="-2" attributes="1"/> + </Group> + </Group> + <Group type="103" alignment="0" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblFirstName" max="-2" attributes="1"/> + <Component id="jLblLastName" alignment="1" max="-2" attributes="1"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="txtLastName" max="-2" attributes="2"/> + <Component id="txtFirstName" max="-2" attributes="1"/> + </Group> + </Group> + <Group type="103" alignment="0" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLblTaxID" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jTaxID" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="24" max="-2" attributes="0"/> + <Component id="jLblSearchkey" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jSearchkey" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLblName" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jName" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + <EmptySpace pref="34" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="32767" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="jLblSearchkey" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jSearchkey" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="m_jTaxID" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblTaxID" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLblName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="txtFirstName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblFirstName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLblLastName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtLastName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLblEmail" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtEmail" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLblTelephone1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtPhone" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLblTelephone2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtPhone2" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLblTaxID"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.taxid" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jTaxID"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="CustomersView_m_jTaxID"/> + </AuxValues> + </Component> + <Component class="javax.swing.JLabel" name="jLblSearchkey"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.searchkeym" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[82, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jSearchkey"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Text Cursor"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.supplier" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblFirstName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.firstname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="alignmentX" type="float" value="0.5"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtFirstName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblLastName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.lastname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtLastName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblEmail"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.email" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtEmail"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblTelephone1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.phone" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtPhone"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblTelephone2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.phone2" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtPhone2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="alignment" type="int" value="2"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="m_jBtnOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="Button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBtnOKActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="m_jBtnCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="Button.Cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jBtnCancelActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/suppliers/JDialogNewSupplier.java b/src/main/java/com/unicenta/pos/suppliers/JDialogNewSupplier.java new file mode 100644 index 0000000..fb7eef8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/JDialogNewSupplier.java @@ -0,0 +1,399 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +package com.unicenta.pos.suppliers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.LocalRes; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Window; +import java.util.UUID; +import javax.swing.JFrame; + +public class JDialogNewSupplier extends javax.swing.JDialog { + + private DataLogicSuppliers dlSupplier; + private DataLogicSales dlSales; + private TableDefinition tsuppliers; + private SupplierInfoExt selectedSupplier; + private Object m_oId; + + /** Creates new form quick New Supplier + * @param parent */ + protected JDialogNewSupplier(java.awt.Frame parent) { + super(parent, true); + } + + /** Creates new form quick New Supplier + * @param parent */ + protected JDialogNewSupplier(java.awt.Dialog parent) { + super(parent, true); + } + + private void init(AppView app) { + + dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + dlSupplier = (DataLogicSuppliers) app.getBean("com.unicenta.pos.suppliers.DataLogicSuppliers"); + tsuppliers = dlSupplier.getTableSuppliers(); + + initComponents(); + + getRootPane().setDefaultButton(m_jBtnOK); + + } + + public Object createValue() throws BasicException { + Object[] supplier = new Object[22]; + supplier[0] = m_oId; + supplier[1] = m_jSearchkey.getText(); + supplier[2] = m_jTaxID.getText(); + supplier[3] = m_jName.getText(); + supplier[4] = 0.0; + supplier[5] = null; + supplier[6] = null; + supplier[7] = null; + supplier[8] = null; + supplier[9] = null; + supplier[10] = null; + supplier[11] = Formats.STRING.parseValue(txtFirstName.getText()); + supplier[12] = Formats.STRING.parseValue(txtLastName.getText()); + supplier[13] = Formats.STRING.parseValue(txtEmail.getText()); + supplier[14] = Formats.STRING.parseValue(txtPhone.getText()); + supplier[15] = Formats.STRING.parseValue(txtPhone2.getText()); + supplier[16] = null; + supplier[17] = null; + supplier[18] = true; + supplier[19] = null; + supplier[20] = 0.0; + supplier[21] = null; + + return supplier; + } + + + public static JDialogNewSupplier getDialog(Component parent,AppView app) { + + Window window = getWindow(parent); + + JDialogNewSupplier quicknewsupplier; + + if (window instanceof Frame) { + quicknewsupplier = new JDialogNewSupplier((Frame) window); + } else { + quicknewsupplier = new JDialogNewSupplier((Dialog) window); + } + + quicknewsupplier.init(app); + + return quicknewsupplier; + } + + protected static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window)parent; + } else { + return getWindow(parent.getParent()); + } + } + + public SupplierInfoExt getSelectedSupplier() { + return selectedSupplier; + } + + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel3 = new javax.swing.JPanel(); + jLblTaxID = new javax.swing.JLabel(); + m_jTaxID = new javax.swing.JTextField(); + jLblSearchkey = new javax.swing.JLabel(); + m_jSearchkey = new javax.swing.JTextField(); + jLblName = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + jLblFirstName = new javax.swing.JLabel(); + txtFirstName = new javax.swing.JTextField(); + jLblLastName = new javax.swing.JLabel(); + txtLastName = new javax.swing.JTextField(); + jLblEmail = new javax.swing.JLabel(); + txtEmail = new javax.swing.JTextField(); + jLblTelephone1 = new javax.swing.JLabel(); + txtPhone = new javax.swing.JTextField(); + jLblTelephone2 = new javax.swing.JLabel(); + txtPhone2 = new javax.swing.JTextField(); + jPanel2 = new javax.swing.JPanel(); + m_jBtnOK = new javax.swing.JButton(); + m_jBtnCancel = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("label.supplier")); // NOI18N + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setResizable(false); + + jPanel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + + jLblTaxID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblTaxID.setText(AppLocal.getIntString("label.taxid")); // NOI18N + jLblTaxID.setMaximumSize(new java.awt.Dimension(150, 30)); + jLblTaxID.setMinimumSize(new java.awt.Dimension(140, 25)); + jLblTaxID.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jTaxID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTaxID.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLblSearchkey.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblSearchkey.setText(AppLocal.getIntString("label.searchkeym")); // NOI18N + jLblSearchkey.setPreferredSize(new java.awt.Dimension(82, 30)); + + m_jSearchkey.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSearchkey.setHorizontalAlignment(javax.swing.JTextField.LEFT); + m_jSearchkey.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR)); + m_jSearchkey.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLblName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblName.setText(AppLocal.getIntString("label.supplier")); // NOI18N + jLblName.setMaximumSize(new java.awt.Dimension(140, 25)); + jLblName.setMinimumSize(new java.awt.Dimension(140, 25)); + jLblName.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(400, 30)); + + jLblFirstName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblFirstName.setText(AppLocal.getIntString("label.firstname")); // NOI18N + jLblFirstName.setAlignmentX(0.5F); + jLblFirstName.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtFirstName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtFirstName.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLblLastName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblLastName.setText(AppLocal.getIntString("label.lastname")); // NOI18N + jLblLastName.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtLastName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtLastName.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLblEmail.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblEmail.setText(AppLocal.getIntString("label.email")); // NOI18N + jLblEmail.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtEmail.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtEmail.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLblTelephone1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblTelephone1.setText(AppLocal.getIntString("label.phone")); // NOI18N + jLblTelephone1.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtPhone.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtPhone.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLblTelephone2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblTelephone2.setText(AppLocal.getIntString("label.phone2")); // NOI18N + jLblTelephone2.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtPhone2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtPhone2.setPreferredSize(new java.awt.Dimension(200, 30)); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblEmail, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblTelephone1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblTelephone2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtPhone, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtEmail, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPhone2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblFirstName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblLastName, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtLastName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtFirstName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addComponent(jLblTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(24, 24, 24) + .addComponent(jLblSearchkey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jSearchkey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel3Layout.createSequentialGroup() + .addComponent(jLblName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))) + .addContainerGap(34, Short.MAX_VALUE)) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblSearchkey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSearchkey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblTelephone1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLblTelephone2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPhone2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + ); + + getContentPane().add(jPanel3, java.awt.BorderLayout.NORTH); + jPanel3.getAccessibleContext().setAccessibleName(""); + + jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); + + m_jBtnOK.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jBtnOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + m_jBtnOK.setText(AppLocal.getIntString("Button.OK")); // NOI18N + m_jBtnOK.setFocusPainted(false); + m_jBtnOK.setFocusable(false); + m_jBtnOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jBtnOK.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jBtnOK.setRequestFocusEnabled(false); + m_jBtnOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBtnOKActionPerformed(evt); + } + }); + jPanel2.add(m_jBtnOK); + + m_jBtnCancel.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jBtnCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + m_jBtnCancel.setText(AppLocal.getIntString("Button.Cancel")); // NOI18N + m_jBtnCancel.setFocusPainted(false); + m_jBtnCancel.setFocusable(false); + m_jBtnCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + m_jBtnCancel.setPreferredSize(new java.awt.Dimension(80, 45)); + m_jBtnCancel.setRequestFocusEnabled(false); + m_jBtnCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jBtnCancelActionPerformed(evt); + } + }); + jPanel2.add(m_jBtnCancel); + + getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH); + + setSize(new java.awt.Dimension(628, 455)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void m_jBtnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBtnOKActionPerformed + try { + m_oId = UUID.randomUUID().toString(); + Object supplier = createValue() ; + int status = tsuppliers.getInsertSentence().exec(supplier); + if (status>0){ + selectedSupplier = dlSales.loadSupplierExt(m_oId.toString()); + dispose(); + }else{ + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, + LocalRes.getIntString("message.nosave"), "Error save"); + msg.show(this); + } + } catch (BasicException ex) { + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE, + LocalRes.getIntString("message.nosave"), ex); + msg.show(this); + } + + }//GEN-LAST:event_m_jBtnOKActionPerformed + + private void m_jBtnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jBtnCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_m_jBtnCancelActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLblEmail; + private javax.swing.JLabel jLblFirstName; + private javax.swing.JLabel jLblLastName; + private javax.swing.JLabel jLblName; + private javax.swing.JLabel jLblSearchkey; + private javax.swing.JLabel jLblTaxID; + private javax.swing.JLabel jLblTelephone1; + private javax.swing.JLabel jLblTelephone2; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JButton m_jBtnCancel; + private javax.swing.JButton m_jBtnOK; + private javax.swing.JTextField m_jName; + private javax.swing.JTextField m_jSearchkey; + private javax.swing.JTextField m_jTaxID; + private javax.swing.JTextField txtEmail; + private javax.swing.JTextField txtFirstName; + private javax.swing.JTextField txtLastName; + private javax.swing.JTextField txtPhone; + private javax.swing.JTextField txtPhone2; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/suppliers/JSupplierFinder.form b/src/main/java/com/unicenta/pos/suppliers/JSupplierFinder.form new file mode 100644 index 0000000..bbbf0ce --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/JSupplierFinder.form @@ -0,0 +1,545 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="form.customertitle" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Default Cursor"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,122,0,0,2,-10"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Default Cursor"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Component class="com.unicenta.editor.JEditorKeys" name="m_jKeys"> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JCustomerFinder_m_jKeys"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jPanel8"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Last"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jcmdCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.Cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jcmdOK"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[103, 44]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[103, 44]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Component class="com.unicenta.data.gui.JImageViewerCustomer" name="jImageViewerSupplier"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="First"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel7"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblName" min="-2" max="-2" attributes="0"/> + <Component id="jLblSearchKey" min="-2" max="-2" attributes="0"/> + <Component id="jLblPostal" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jtxtSearchKey" min="-2" max="-2" attributes="0"/> + <Component id="m_jtxtPostal" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="m_jtxtName" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLblTaxID" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jtxtTaxID" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="1" max="-2" attributes="0"> + <Component id="jLblEmail" max="-2" attributes="0"/> + <Component id="jLblPhone" alignment="0" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jtxtPhone" min="-2" max="-2" attributes="0"/> + <Component id="m_jtxtName2" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jtxtTaxID" min="-2" max="-2" attributes="0"/> + <Component id="jLblTaxID" alignment="1" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jtxtSearchKey" min="-2" max="-2" attributes="0"/> + <Component id="jLblSearchKey" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblPostal" min="-2" max="-2" attributes="0"/> + <Component id="m_jtxtPostal" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jtxtName" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jLblName" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jtxtPhone" min="-2" max="-2" attributes="0"/> + <Component id="jLblPhone" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLblEmail" min="-2" max="-2" attributes="0"/> + <Component id="m_jtxtName2" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLblTaxID"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.taxid" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtTaxID"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblSearchKey"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.searchkey" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtSearchKey"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblPostal"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Postal"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JCustomerFinder_jLblPostal"/> + </AuxValues> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtPostal"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JCustomerFinder_m_jtxtPostal"/> + </AuxValues> + </Component> + <Component class="javax.swing.JLabel" name="jLblName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 15]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleName" type="java.lang.String" value=""/> + </AccessibilityProperties> + </Component> + <Component class="javax.swing.JLabel" name="jLblPhone"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.companytelephone" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLblEmail"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.companyemail" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtPhone"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtName2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 140]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 147]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JList" name="jListSuppliers"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jListSuppliersMouseClicked"/> + <EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="jListSuppliersValueChanged"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel6"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="First"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jbtnReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.reset" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Clear Filter"/> + <Property name="actionCommand" type="java.lang.String" value="Reset "/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" value=""/> + </AccessibilityProperties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnResetActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jbtnExecute"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.executefilter" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value="Execute Filter"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 45]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" value=""/> + </AccessibilityProperties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnExecuteActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/suppliers/JSupplierFinder.java b/src/main/java/com/unicenta/pos/suppliers/JSupplierFinder.java new file mode 100644 index 0000000..2a2cffc --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/JSupplierFinder.java @@ -0,0 +1,692 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.suppliers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.user.EditorCreator; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import java.awt.*; +import java.util.ArrayList; +import javax.swing.JFrame; +import javax.swing.*; + +import java.awt.event.KeyEvent; + +/** + * + * @author adrianromero + */ +public class JSupplierFinder extends javax.swing.JDialog implements EditorCreator { + + private SupplierInfo m_ReturnSupplier; + private ListProvider lpr; + private AppView appView; + + public class Global { + + } + + public void searchKey() { + jbtnExecute.setMnemonic(KeyEvent.VK_E); + executeSearch(); + + + } + + public void resetKey() { + jbtnReset.setMnemonic(KeyEvent.VK_R); + m_jtxtTaxID.reset(); + m_jtxtSearchKey.reset(); + m_jtxtName.reset(); + m_jtxtPostal.reset(); + m_jtxtPhone.reset(); + m_jtxtName2.reset(); + + m_jtxtTaxID.activate(); + + cleanSearch(); + + } + + public void setAppView(AppView appView) { + this.appView = appView; + } + + /** Creates new form JSupplierFinder */ + private JSupplierFinder(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + + /** + * Creates new form JSupplierFinder + */ + private JSupplierFinder(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + /** + * + * @param parent + * @param dlSuppliers + * @return + */ + public static JSupplierFinder getSupplierFinder(Component parent, DataLogicSuppliers dlSuppliers) { + Window window = getWindow(parent); + + JSupplierFinder myMsg; + if (window instanceof Frame) { + myMsg = new JSupplierFinder((Frame) window, true); + } else { + myMsg = new JSupplierFinder((Dialog) window, true); + } + myMsg.init(dlSuppliers); + myMsg.applyComponentOrientation(parent.getComponentOrientation()); + + return myMsg; + } + + /** + * + * @return + */ + public SupplierInfo getSelectedSupplier() { + return m_ReturnSupplier; + } + + private void init(DataLogicSuppliers dlSuppliers) { + + initComponents(); + + jImageViewerSupplier.setVisible(false); + + jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35)); + + m_jtxtTaxID.addEditorKeys(m_jKeys); + m_jtxtSearchKey.addEditorKeys(m_jKeys); + m_jtxtName.addEditorKeys(m_jKeys); + m_jtxtPostal.addEditorKeys(m_jKeys); + m_jtxtPhone.addEditorKeys(m_jKeys); + m_jtxtName2.addEditorKeys(m_jKeys); + + m_jtxtTaxID.reset(); + m_jtxtSearchKey.reset(); + m_jtxtName.reset(); + m_jtxtPostal.reset(); + m_jtxtPhone.reset(); + m_jtxtName2.reset(); + + m_jtxtTaxID.activate(); + + lpr = new ListProviderCreator(dlSuppliers.getSupplierList(), this); + + jListSuppliers.setCellRenderer(new SupplierRenderer()); + + getRootPane().setDefaultButton(jcmdOK); + + m_ReturnSupplier = null; +// m_jKeys.setSupplierFinder(this); + + } + + /** + * + * @param supplier + */ + public void search(SupplierInfo supplier) { + + if (supplier == null || supplier.getName() == null || supplier.getName().equals("")) { + + m_jtxtTaxID.reset(); + m_jtxtSearchKey.reset(); + m_jtxtName.reset(); + m_jtxtPostal.reset(); + m_jtxtPhone.reset(); + m_jtxtName2.reset(); + + m_jtxtTaxID.activate(); + + cleanSearch(); + } else { + + m_jtxtTaxID.setText(supplier.getTaxid()); + m_jtxtSearchKey.setText(supplier.getSearchkey()); + m_jtxtName.setText(supplier.getName()); + m_jtxtPostal.setText(supplier.getPostal()); + m_jtxtPhone.setText(supplier.getPhone()); + m_jtxtName2.setText(supplier.getEmail()); + + m_jtxtTaxID.activate(); + + executeSearch(); + } + } + + private void cleanSearch() { + m_jtxtTaxID.setText(""); + m_jtxtSearchKey.setText(""); + m_jtxtName.setText(""); + m_jtxtPostal.setText(""); + m_jtxtPhone.setText(""); + m_jtxtName2.setText(""); + + jListSuppliers.setModel(new MyListData(new ArrayList())); + } + + /** + * This method actions the Supplier data search + */ + public void executeSearch() { + + try { + jListSuppliers.setModel(new MyListData(lpr.loadData())); + if (jListSuppliers.getModel().getSize() > 0) { + jListSuppliers.setSelectedIndex(0); + } else { + if(!m_jtxtName.getText().equals("")) { + + int n = JOptionPane.showConfirmDialog( + null, + AppLocal.getIntString("message.suppliernotfound"), + AppLocal.getIntString("title.editor"), + JOptionPane.YES_NO_OPTION); + + if (n != 1) { + SupplierInfoGlobal supplierInfoGlobal = SupplierInfoGlobal.getInstance(); + SupplierInfoExt supplierInfoExt = supplierInfoGlobal.getSupplierInfoExt(); + this.setVisible(false); + appView.getAppUserView().showTask("com.unicenta.pos.suppliers.SuppliersPanel"); + JOptionPane.showMessageDialog(null, + "You must complete Account and Search Key Then Save to add to Ticket", + "Create Supplier",JOptionPane.OK_OPTION); + } + } + } + } catch (BasicException e) { + } + } + + /** + * + * @return creates object for search method + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + Object[] afilter = new Object[12]; + + // TaxID + if (m_jtxtTaxID.getText() == null || m_jtxtTaxID.getText().equals("")) { + afilter[0] = QBFCompareEnum.COMP_NONE; + afilter[1] = null; + } else { + afilter[0] = QBFCompareEnum.COMP_RE; + afilter[1] = "%" + m_jtxtTaxID.getText() + "%"; + } + + // SearchKey + if (m_jtxtSearchKey.getText() == null || m_jtxtSearchKey.getText().equals("")) { + afilter[2] = QBFCompareEnum.COMP_NONE; + afilter[3] = null; + } else { + afilter[2] = QBFCompareEnum.COMP_RE; + afilter[3] = "%" + m_jtxtSearchKey.getText() + "%"; + } + + // Name + if (m_jtxtName.getText() == null || m_jtxtName.getText().equals("")) { + afilter[4] = QBFCompareEnum.COMP_NONE; + afilter[5] = null; + } else { + afilter[4] = QBFCompareEnum.COMP_RE; + afilter[5] = "%" + m_jtxtName.getText() + "%"; + } + + // Postal + if (m_jtxtPostal.getText() == null || m_jtxtPostal.getText().equals("")) { + afilter[6] = QBFCompareEnum.COMP_NONE; + afilter[7] = null; + } else { + afilter[6] = QBFCompareEnum.COMP_RE; + afilter[7] = "%" + m_jtxtPostal.getText() + "%"; + } + + // Phone + if (m_jtxtPhone.getText() == null || m_jtxtPhone.getText().equals("")) { + afilter[8] = QBFCompareEnum.COMP_NONE; + afilter[9] = null; + } else { + afilter[8] = QBFCompareEnum.COMP_RE; + afilter[9] = "%" + m_jtxtPhone.getText() + "%"; + } + + // Email + if (m_jtxtName2.getText() == null || m_jtxtName2.getText().equals("")) { + afilter[10] = QBFCompareEnum.COMP_NONE; + afilter[11] = null; + } else { + afilter[10] = QBFCompareEnum.COMP_RE; + afilter[11] = "%" + m_jtxtName2.getText() + "%"; + } + + return afilter; + } + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window) parent; + } else { + return getWindow(parent.getParent()); + } + } + + private static class MyListData extends javax.swing.AbstractListModel { + + private final java.util.List m_data; + + public MyListData(java.util.List data) { + m_data = data; + } + + @Override + public Object getElementAt(int index) { + return m_data.get(index); + } + + @Override + public int getSize() { + return m_data.size(); + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel2 = new javax.swing.JPanel(); + m_jKeys = new com.unicenta.editor.JEditorKeys(); + jPanel8 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jcmdCancel = new javax.swing.JButton(); + jcmdOK = new javax.swing.JButton(); + jImageViewerSupplier = new com.unicenta.data.gui.JImageViewerCustomer(); + jPanel3 = new javax.swing.JPanel(); + jPanel5 = new javax.swing.JPanel(); + jPanel7 = new javax.swing.JPanel(); + jLblTaxID = new javax.swing.JLabel(); + m_jtxtTaxID = new com.unicenta.editor.JEditorString(); + jLblSearchKey = new javax.swing.JLabel(); + m_jtxtSearchKey = new com.unicenta.editor.JEditorString(); + jLblPostal = new javax.swing.JLabel(); + m_jtxtPostal = new com.unicenta.editor.JEditorString(); + jLblName = new javax.swing.JLabel(); + m_jtxtName = new com.unicenta.editor.JEditorString(); + jLblPhone = new javax.swing.JLabel(); + jLblEmail = new javax.swing.JLabel(); + m_jtxtPhone = new com.unicenta.editor.JEditorString(); + m_jtxtName2 = new com.unicenta.editor.JEditorString(); + jPanel4 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jListSuppliers = new javax.swing.JList(); + jPanel6 = new javax.swing.JPanel(); + jbtnReset = new javax.swing.JButton(); + jbtnExecute = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("form.customertitle")); // NOI18N + setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + + jPanel2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + jPanel2.setLayout(new java.awt.BorderLayout()); + jPanel2.add(m_jKeys, java.awt.BorderLayout.NORTH); + + jPanel8.setLayout(new java.awt.BorderLayout()); + + jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setText(AppLocal.getIntString("button.Cancel")); // NOI18N + jcmdCancel.setFocusPainted(false); + jcmdCancel.setFocusable(false); + jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdCancel.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdCancel.setRequestFocusEnabled(false); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel1.add(jcmdCancel); + + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + jcmdOK.setEnabled(false); + jcmdOK.setFocusPainted(false); + jcmdOK.setFocusable(false); + jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdOK.setMaximumSize(new java.awt.Dimension(103, 44)); + jcmdOK.setMinimumSize(new java.awt.Dimension(103, 44)); + jcmdOK.setPreferredSize(new java.awt.Dimension(110, 45)); + jcmdOK.setRequestFocusEnabled(false); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel1.add(jcmdOK); + + jPanel8.add(jPanel1, java.awt.BorderLayout.LINE_END); + + jPanel2.add(jPanel8, java.awt.BorderLayout.PAGE_END); + jPanel2.add(jImageViewerSupplier, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel2, java.awt.BorderLayout.LINE_END); + + jPanel3.setPreferredSize(new java.awt.Dimension(450, 0)); + jPanel3.setLayout(new java.awt.BorderLayout()); + + jPanel5.setLayout(new java.awt.BorderLayout()); + + jLblTaxID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblTaxID.setText(AppLocal.getIntString("label.taxid")); // NOI18N + jLblTaxID.setMaximumSize(new java.awt.Dimension(60, 15)); + jLblTaxID.setMinimumSize(new java.awt.Dimension(60, 15)); + jLblTaxID.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jtxtTaxID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtTaxID.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLblSearchKey.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblSearchKey.setText(AppLocal.getIntString("label.searchkey")); // NOI18N + jLblSearchKey.setMaximumSize(new java.awt.Dimension(60, 15)); + jLblSearchKey.setMinimumSize(new java.awt.Dimension(60, 15)); + jLblSearchKey.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jtxtSearchKey.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtSearchKey.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLblPostal.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblPostal.setText("Postal"); + jLblPostal.setMaximumSize(new java.awt.Dimension(60, 15)); + jLblPostal.setMinimumSize(new java.awt.Dimension(60, 15)); + jLblPostal.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jtxtPostal.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtPostal.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLblName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblName.setText(AppLocal.getIntString("label.prodname")); // NOI18N + jLblName.setMaximumSize(new java.awt.Dimension(60, 15)); + jLblName.setMinimumSize(new java.awt.Dimension(60, 15)); + jLblName.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jtxtName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtName.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLblPhone.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLblPhone.setText(bundle.getString("label.companytelephone")); // NOI18N + jLblPhone.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLblEmail.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblEmail.setText(bundle.getString("label.companyemail")); // NOI18N + jLblEmail.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jtxtPhone.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtPhone.setMinimumSize(new java.awt.Dimension(150, 30)); + m_jtxtPhone.setPreferredSize(new java.awt.Dimension(250, 30)); + + m_jtxtName2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtName2.setMinimumSize(new java.awt.Dimension(150, 30)); + m_jtxtName2.setPreferredSize(new java.awt.Dimension(250, 30)); + + javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); + jPanel7.setLayout(jPanel7Layout); + jPanel7Layout.setHorizontalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblSearchKey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jtxtSearchKey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel7Layout.createSequentialGroup() + .addComponent(jLblTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jtxtTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel7Layout.createSequentialGroup() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jLblEmail, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblPhone, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jtxtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtName2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap()) + ); + jPanel7Layout.setVerticalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jtxtTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblTaxID, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jtxtSearchKey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblSearchKey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(jPanel7Layout.createSequentialGroup() + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLblName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jtxtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLblEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtName2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + m_jtxtName.getAccessibleContext().setAccessibleName(""); + + jPanel5.add(jPanel7, java.awt.BorderLayout.CENTER); + + jPanel3.add(jPanel5, java.awt.BorderLayout.PAGE_START); + + jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel4.setPreferredSize(new java.awt.Dimension(450, 140)); + jPanel4.setLayout(new java.awt.BorderLayout()); + + jScrollPane1.setPreferredSize(new java.awt.Dimension(400, 147)); + + jListSuppliers.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jListSuppliers.setFocusable(false); + jListSuppliers.setRequestFocusEnabled(false); + jListSuppliers.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jListSuppliersMouseClicked(evt); + } + }); + jListSuppliers.addListSelectionListener(new javax.swing.event.ListSelectionListener() { + public void valueChanged(javax.swing.event.ListSelectionEvent evt) { + jListSuppliersValueChanged(evt); + } + }); + jScrollPane1.setViewportView(jListSuppliers); + + jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER); + + jbtnReset.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jbtnReset.setText(bundle.getString("button.reset")); // NOI18N + jbtnReset.setToolTipText("Clear Filter"); + jbtnReset.setActionCommand("Reset "); + jbtnReset.setFocusable(false); + jbtnReset.setPreferredSize(new java.awt.Dimension(110, 45)); + jbtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnResetActionPerformed(evt); + } + }); + jPanel6.add(jbtnReset); + jbtnReset.getAccessibleContext().setAccessibleDescription(""); + + jbtnExecute.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnExecute.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jbtnExecute.setText(AppLocal.getIntString("button.executefilter")); // NOI18N + jbtnExecute.setToolTipText("Execute Filter"); + jbtnExecute.setFocusPainted(false); + jbtnExecute.setPreferredSize(new java.awt.Dimension(110, 45)); + jbtnExecute.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnExecuteActionPerformed(evt); + } + }); + jPanel6.add(jbtnExecute); + jbtnExecute.getAccessibleContext().setAccessibleDescription(""); + + jPanel4.add(jPanel6, java.awt.BorderLayout.PAGE_START); + + jPanel3.add(jPanel4, java.awt.BorderLayout.CENTER); + + getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER); + + setSize(new java.awt.Dimension(758, 634)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + m_ReturnSupplier = (SupplierInfo) jListSuppliers.getSelectedValue(); + dispose(); + + }//GEN-LAST:event_jcmdOKActionPerformed + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_jcmdCancelActionPerformed + + private void jbtnExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnExecuteActionPerformed + + m_ReturnSupplier=null; + executeSearch(); + + }//GEN-LAST:event_jbtnExecuteActionPerformed + + private void jListSuppliersValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListSuppliersValueChanged + + m_ReturnSupplier = (SupplierInfo) jListSuppliers.getSelectedValue(); + + if (m_ReturnSupplier != null) { + m_ReturnSupplier = (SupplierInfo) jListSuppliers.getSelectedValue(); + +// if (m_ReturnSupplier != null) { +// jImageViewerSupplier.setImage(m_ReturnSupplier.getImage()); +// } + } + + jcmdOK.setEnabled(jListSuppliers.getSelectedValue() != null); + + }//GEN-LAST:event_jListSuppliersValueChanged + + private void jListSuppliersMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListSuppliersMouseClicked + + m_ReturnSupplier = (SupplierInfo) jListSuppliers.getSelectedValue(); + + if (m_ReturnSupplier != null) { + m_ReturnSupplier = (SupplierInfo) jListSuppliers.getSelectedValue(); + +// if (m_ReturnSupplier != null) { +// jImageViewerSupplier.setImage(m_ReturnSupplier.getImage()); +// } + } + + }//GEN-LAST:event_jListSuppliersMouseClicked + +private void jbtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnResetActionPerformed + + m_jtxtTaxID.reset(); + m_jtxtSearchKey.reset(); + m_jtxtName.reset(); + m_jtxtPostal.reset(); + m_jtxtPhone.reset(); + m_jtxtName2.reset(); + + m_jtxtTaxID.activate(); + + cleanSearch(); +}//GEN-LAST:event_jbtnResetActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private com.unicenta.data.gui.JImageViewerCustomer jImageViewerSupplier; + private javax.swing.JLabel jLblEmail; + private javax.swing.JLabel jLblName; + private javax.swing.JLabel jLblPhone; + private javax.swing.JLabel jLblPostal; + private javax.swing.JLabel jLblSearchKey; + private javax.swing.JLabel jLblTaxID; + private javax.swing.JList jListSuppliers; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JPanel jPanel7; + private javax.swing.JPanel jPanel8; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JButton jbtnExecute; + private javax.swing.JButton jbtnReset; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + private com.unicenta.editor.JEditorKeys m_jKeys; + private com.unicenta.editor.JEditorString m_jtxtName; + private com.unicenta.editor.JEditorString m_jtxtName2; + private com.unicenta.editor.JEditorString m_jtxtPhone; + private com.unicenta.editor.JEditorString m_jtxtPostal; + private com.unicenta.editor.JEditorString m_jtxtSearchKey; + private com.unicenta.editor.JEditorString m_jtxtTaxID; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/suppliers/OrderSupplierList.form b/src/main/java/com/unicenta/pos/suppliers/OrderSupplierList.form new file mode 100644 index 0000000..391ee3b --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/OrderSupplierList.form @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[256, 560]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[256, 560]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,88,0,0,1,44"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanelSuppliers"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/suppliers/OrderSupplierList.java b/src/main/java/com/unicenta/pos/suppliers/OrderSupplierList.java new file mode 100644 index 0000000..e57d235 --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/OrderSupplierList.java @@ -0,0 +1,334 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.suppliers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.pos.catalog.JCatalogTab; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.sales.DataLogicReceipts; +import com.unicenta.pos.sales.SharedTicketInfo; +import com.unicenta.pos.sales.TicketsEditor; +import com.unicenta.pos.ticket.TicketInfo; +import com.unicenta.pos.util.ThumbNailBuilder; +import lombok.extern.slf4j.Slf4j; + +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.event.EventListenerList; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.*; + +/** + * + * @author JG uniCenta - outline/prep for uniCenta mobile + eCommerce connector + */ +@Slf4j +public class OrderSupplierList extends JPanel implements SupplierTicketSelector { + + /** + * Source origin and Ticket + */ + protected AppView application; + private String currentTicket; + + /** + * This instance interface + */ + protected TicketsEditor panelticket; + + /** + * Set listeners for new/change Supplier/Receipt events + */ + protected EventListenerList listeners = new EventListenerList(); + private final DataLogicSuppliers dataLogicSuppliers; + private final DataLogicReceipts dataLogicReceipts; + private final ThumbNailBuilder tnbbutton; + + /** + * Creates new form SuppliersList + * @param dlSuppliers + * @param app + * @param panelticket + */ + public OrderSupplierList(DataLogicSuppliers dlSuppliers, AppView app, TicketsEditor panelticket) { + this.application = app; + this.panelticket = panelticket; + this.dataLogicSuppliers = dlSuppliers; + this.dataLogicReceipts = (DataLogicReceipts) application.getBean("com.unicenta.pos.sales.DataLogicReceipts"); + tnbbutton = new ThumbNailBuilder(90, 98); + + initComponents(); + } + + /** + * + * @return + */ + public Component getComponent() { + return this; + } + + /** + * + * @throws BasicException + */ + public void reloadSuppliers() throws BasicException { +// synchroniseData(); + loadSuppliers(); + } + + /** + * + * @throws BasicException + */ + + public void loadSuppliers() throws BasicException { + + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + + long time = System.currentTimeMillis(); + jPanelSuppliers.removeAll(); + + JCatalogTab flowTab = new JCatalogTab(); + jPanelSuppliers.add(flowTab); + + List<SupplierInfoExt> suppliers = null; + List<SharedTicketInfo> ticketList = null; + try { + log.info("Time of getSuppliersWithOutImage {}", (System.currentTimeMillis() - time)); + + time = System.currentTimeMillis(); + + ticketList = dataLogicReceipts.getSharedTicketList(); + log.info("Time of getSharedTicketList {}", (System.currentTimeMillis() - time)); + time = System.currentTimeMillis(); + + + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + HashMap<SharedTicketInfo, SupplierInfoExt> orderMap = new HashMap<>(); + + for (SharedTicketInfo sharedTicketInfo : ticketList) { + + String ticketName = sharedTicketInfo.getName().trim(); + + if (ticketName.contains("[") && ticketName.contains("]")) { + + // found order + if (ticketName.startsWith("[")) { + orderMap.put(sharedTicketInfo, null); + } else if (!suppliers.isEmpty()) { + for (SupplierInfoExt supplier : suppliers) { + if (supplier != null) { + String name = supplier.getName().trim(); + if (ticketName.startsWith(name)) { + orderMap.put(sharedTicketInfo, supplier); + break; + } + } + } + } + } + } + // sort + SupplierComparator bvc = new SupplierComparator(orderMap); + TreeMap<SharedTicketInfo, SupplierInfoExt> sortedMap = new TreeMap<>(bvc); + sortedMap.putAll(orderMap); + log.info("Time of orderMap {}", (System.currentTimeMillis() - time)); + time = System.currentTimeMillis(); + + // set button list + for (Map.Entry<SharedTicketInfo, SupplierInfoExt> entry : sortedMap.entrySet()) { + SharedTicketInfo ticket = entry.getKey(); + SupplierInfoExt supplier = entry.getValue(); + + String name = ticket.getName(); + BufferedImage image = null; + + if (image == null) { + try { + InputStream is = getClass().getResourceAsStream("/com/unicenta/images/no_image.png"); + if (is != null) { + image = ImageIO.read(is); + } + } catch (IOException ex) { + log.error(ex.getMessage()); + } + } + String username; + if (name.indexOf("[") != 0) { + username = name.substring(0, name.indexOf("[") - 1); + username = username.replace("-", ""); + } else { + username = "unknown"; + } + String orderId = name.substring(name.indexOf("["), name.indexOf("]") + 1); + String text = "<html><center>" + username.trim() + "<br/>" + orderId.trim() + "</center></html>"; + + ImageIcon icon = new ImageIcon(tnbbutton.getThumbNailText(image, text)); +// flowTab.addButton(icon, new SelectedSupplierAction(ticket.getId())); + } + log.info("Time of finished loadSupplierOrders {}", (System.currentTimeMillis() - time)); + } + }); + } + + /** + * + * @param value + */ + + public void setComponentEnabled(boolean value) { + jPanelSuppliers.setEnabled(value); + + synchronized (jPanelSuppliers.getTreeLock()) { + int compCount = jPanelSuppliers.getComponentCount(); + for (int i = 0; i < compCount; i++) { + jPanelSuppliers.getComponent(i).setEnabled(value); + } + } + this.setEnabled(value); + } + + /** + * + * @param l + */ + + public void addActionListener(ActionListener l) { + listeners.add(ActionListener.class, l); + } + + /** + * + * @param l + */ + + public void removeActionListener(ActionListener l) { + listeners.remove(ActionListener.class, l); + } + + private void setActiveTicket(String id) throws BasicException { + + currentTicket = panelticket.getActiveTicket().getId(); + + TicketInfo ticket = dataLogicReceipts.getSharedTicket(id); + if (ticket == null) { + throw new BasicException(AppLocal.getIntString("message.noticket")); + } else { + dataLogicReceipts.deleteSharedTicket(id); + currentTicket = id; + panelticket.setActiveTicket(ticket, null); + fireTicketSelectionChanged(ticket.getId()); + } + } + + private void fireTicketSelectionChanged(String ticketId) { + EventListener[] l = listeners.getListeners(ActionListener.class); + ActionEvent e = null; + for (EventListener l1 : l) { + if (e == null) { + e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, ticketId); + } + ((ActionListener) l1).actionPerformed(e); + } + } + + @Override + public void loadSupplierss() throws BasicException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + private class SelectedSupplierAction implements ActionListener { + + private final String ticketId; + + public SelectedSupplierAction(String ticketId) { + this.ticketId = ticketId; + } + + @Override + public void actionPerformed(ActionEvent e) { + try { + if (ticketId != null) { + setActiveTicket(ticketId); + } + } catch (BasicException ex) { + new MessageInf(ex).show(OrderSupplierList.this); + } + } + } + + class SupplierComparator implements Comparator<SharedTicketInfo> { + + Map<SharedTicketInfo, SupplierInfoExt> base; + + public SupplierComparator(Map<SharedTicketInfo, SupplierInfoExt> base) { + this.base = base; + } + + @Override + public int compare(SharedTicketInfo a, SharedTicketInfo b) { + String nameA = base.get(a).getName(); + String nameB = base.get(b).getName(); + + if (nameA.compareToIgnoreCase(nameB) < 0) { + return -1; + } else { + return 1; + } + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanelSuppliers = new javax.swing.JPanel(); + + setMinimumSize(new java.awt.Dimension(256, 560)); + setPreferredSize(new java.awt.Dimension(256, 560)); + setLayout(new java.awt.BorderLayout()); + + jPanelSuppliers.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPanelSuppliers.setLayout(new java.awt.CardLayout()); + add(jPanelSuppliers, java.awt.BorderLayout.CENTER); + }// </editor-fold>//GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel jPanelSuppliers; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/suppliers/SupplierInfo.java b/src/main/java/com/unicenta/pos/suppliers/SupplierInfo.java new file mode 100644 index 0000000..e44caaa --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/SupplierInfo.java @@ -0,0 +1,178 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.suppliers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.pos.util.StringUtils; +import java.io.Serializable; + +/** @author Jack Gerrard */ + + +public class SupplierInfo implements Serializable, IKeyed { + + private static final long serialVersionUID = 9093257536541L; + + protected String m_sID; + protected String m_sSearchkey; + protected String m_sTaxid; + protected String m_sName; + protected String m_sPostal; + protected String m_sPhone; + protected String m_sEmail; + + /** Creates a new instance of SupplierInfo + * @param id */ + public SupplierInfo(String id) { + + m_sID = id; + m_sSearchkey = null; + m_sTaxid = null; + m_sName = null; + m_sPostal = null; + m_sPhone = null; + m_sEmail = null; + } + + public SupplierInfo(String id, String searchkey, String name) { + m_sID = id; + m_sSearchkey = searchkey; + m_sName = name; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return m_sID; + } + + /** + * + * @param dr + * @throws BasicException + */ + public void readValues(DataRead dr) throws BasicException { + m_sID = dr.getString(1); + m_sName = dr.getString(2); + } + + /** + * + * @return id string + */ + public String getID() { + return m_sID; + } + public void setID(String sID) { + m_sID = sID; + } + + + /** + * + * @return taxid string + */ + + public String getTaxid() { + return m_sTaxid; + } + public void setTaxid(String sTaxid) { + m_sTaxid = sTaxid; + } + public String printTaxid() { + return StringUtils.encodeXML(m_sTaxid); + } + + + /** + * + * @return searchkey string + */ + public String getSearchkey() { + return m_sSearchkey; + } + public void setSearchkey(String sSearchkey) { + m_sSearchkey = sSearchkey; + } + + /** + * + * @return name string + */ + public String getName() { + return m_sName; + } + public void setName(String sName) { + m_sName = sName; + } + + /** + * + * @return postal/zip code string + */ + public String getPostal() { + return m_sPostal; + } + public void setPostal(String sPostal) { + m_sPostal = sPostal; + } + + /** + * + * @return Primary Telephone string + */ + public String getPhone() { + return m_sPhone; + } + public void setPhone(String sPhone) { + m_sPhone = sPhone; + } + + /** + * + * @return email string + */ + public String getEmail() { + return m_sEmail; + } + + public void setEmail(String sEmail) { + m_sEmail = sEmail; + } + + /** + * + * @return + */ + public String printName() { + return StringUtils.encodeXML(m_sName); + } + + @Override + public String toString() { + return getName(); + } + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/suppliers/SupplierInfoExt.java b/src/main/java/com/unicenta/pos/suppliers/SupplierInfoExt.java new file mode 100644 index 0000000..65b5b7c --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/SupplierInfoExt.java @@ -0,0 +1,272 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.suppliers; + +import com.unicenta.format.Formats; +import com.unicenta.pos.util.RoundUtils; +import java.util.Date; + +/** + * + * @author JG uniCenta + */ +public class SupplierInfoExt extends SupplierInfo { + + protected String suppliertaxid; + protected String suppliervatid; + protected String notes; + protected boolean visible; + protected String card; + protected Double maxdebt; + protected Date curdate; + protected Double curdebt; + protected String firstname; + protected String lastname; + protected String email; + protected String phone; + protected String phone2; + protected String fax; + protected String address; + protected String address2; + protected String postal; + protected String city; + protected String region; + protected String country; + + /** Creates a new instance of SupplierInfoExt + * @param id */ + public SupplierInfoExt(String id) { + super(id); + } + + public String getSupplierTaxID() { + return suppliertaxid; + } + public void setSupplierTAXID(String suppliertaxid) { + this.suppliertaxid = suppliertaxid; + } + public String printSupplierTaxID() { + return Formats.STRING.formatValue(suppliertaxid); + } + + public String getSupplierVATID() { + return suppliervatid; + } + public void setSupplierVATID(String suppliervatid) { + this.suppliervatid = suppliervatid; + } + public String printSupplierVATID() { + return Formats.STRING.formatValue(suppliervatid); + } + + public String getNotes() { + return notes; + } + public void setNotes(String notes) { + this.notes = notes; + } + + public boolean isVisible() { + return visible; + } + public void setVisible(boolean visible) { + this.visible = visible; + } + + public Double getMaxdebt() { + return maxdebt; + } + public void setMaxdebt(Double maxdebt) { + this.maxdebt = maxdebt; + } + public String printMaxDebt() { + return Formats.CURRENCY.formatValue(RoundUtils.getValue(getMaxdebt())); + } + + public Date getCurdate() { + return curdate; + } + public void setCurdate(Date curdate) { + this.curdate = curdate; + } + public String printCurDate() { + return Formats.DATE.formatValue(getCurdate()); + } + + public Double getCurdebt() { + return curdebt; + } + public void setCurdebt(Double curdebt) { + this.curdebt = curdebt; + } + public String printCurDebt() { + return Formats.CURRENCY.formatValue(RoundUtils.getValue(getCurdebt())); + } + + + /** + * + * @param amount + * @param d + */ + public void updateCurDebt(Double amount, Date d) { + + curdebt = curdebt == null ? amount : curdebt + amount; + curdate = (new Date()); + + if (RoundUtils.compare(curdebt, 0.0) > 0) { + if (curdate == null) { + curdate = d; + } + } else if (RoundUtils.compare(curdebt, 0.0) == 0) { + curdebt = null; + curdate = null; + } else { // < 0 + curdate = null; + } + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + @Override + public String getEmail() { + return email; + } + + @Override + public void setEmail(String email) { + this.email = email; + } + + @Override + public String getPhone() { + return phone; + } + @Override + public void setPhone(String phone) { + this.phone = phone; + } + public String printPhone() { + return Formats.STRING.formatValue(phone); + } + + public String getPhone2() { + return phone2; + } + public void setPhone2(String phone2) { + this.phone2 = phone2; + } + + public String getFax() { + return fax; + } + public void setFax(String fax) { + this.fax = fax; + } + + /** + * + * @return supplier's address line 1 string + */ + public String getAddress() { + return address; + } + public void setAddress(String address) { + this.address = address; + } + public String printAddress() { + return Formats.STRING.formatValue(address); + } + + /** + * + * @return supplier's address line 2 string + */ + public String getAddress2() { + return address2; + } + public void setAddress2(String address2) { + this.address2 = address2; + } + + /** + * + * @return supplier's postal/zip code string + */ + @Override + public String getPostal() { + return postal; + } + @Override + public void setPostal(String postal) { + this.postal = postal; + } + public String printPostal() { + return Formats.STRING.formatValue(postal); + } + + /** + * + * @return supplier's address city string + */ + public String getCity() { + return city; + } + public void setCity(String city) { + this.city = city; + } + + /** + * + * @return supplier's address region/state/county string + */ + public String getRegion() { + return region; + } + public void setRegion(String region) { + this.region = region; + } + + /** + * + * @return supplier's address country string + */ + public String getCountry() { + return country; + } + public void setCountry(String country) { + this.country = country; + } + +} diff --git a/src/main/java/com/unicenta/pos/suppliers/SupplierInfoGlobal.java b/src/main/java/com/unicenta/pos/suppliers/SupplierInfoGlobal.java new file mode 100644 index 0000000..7883319 --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/SupplierInfoGlobal.java @@ -0,0 +1,83 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// + +// For BrowseEditableData + +package com.unicenta.pos.suppliers; + +import com.unicenta.data.user.BrowsableEditableData; + +/** + * + * @author Jack Gerrard + */ +public class SupplierInfoGlobal { + + private static SupplierInfoGlobal INSTANCE; + private SupplierInfoExt supplierInfoExt; + private BrowsableEditableData editableData; + + private SupplierInfoGlobal() { + } + + /** + * + * @return + */ + public static SupplierInfoGlobal getInstance() { + if (INSTANCE == null) { + INSTANCE = new SupplierInfoGlobal(); + } + + return INSTANCE; + } + + /** + * + * @return + */ + public SupplierInfoExt getSupplierInfoExt() { + return supplierInfoExt; + } + + /** + * + * @param supplierInfoExt + */ + public void setSupplierInfoExt(SupplierInfoExt supplierInfoExt) { + this.supplierInfoExt = supplierInfoExt; + } + + /** + * + * @return + */ + public BrowsableEditableData getEditableData() { + return editableData; +} + + /** + * + * @param editableData + */ + public void setEditableData(BrowsableEditableData editableData) { + this.editableData = editableData; + } +} diff --git a/src/main/java/com/unicenta/pos/suppliers/SupplierRenderer.java b/src/main/java/com/unicenta/pos/suppliers/SupplierRenderer.java new file mode 100644 index 0000000..65cd41b --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/SupplierRenderer.java @@ -0,0 +1,49 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.suppliers; + +import java.awt.Component; +import javax.swing.DefaultListCellRenderer; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JList; + +/** + * + * @author Jack Gerrard + */ +public class SupplierRenderer extends DefaultListCellRenderer { + + private Icon icosupplier; + + /** Creates a new instance of SupplierRenderer */ + public SupplierRenderer() { + + icosupplier = new ImageIcon(getClass().getClassLoader().getResource("com/unicenta/images/supplier_sml.png")); + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, null, index, isSelected, cellHasFocus); + setText(value.toString()); + setIcon(icosupplier); + return this; + } +} diff --git a/src/main/java/com/unicenta/pos/suppliers/SupplierTicketSelector.java b/src/main/java/com/unicenta/pos/suppliers/SupplierTicketSelector.java new file mode 100644 index 0000000..3a19161 --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/SupplierTicketSelector.java @@ -0,0 +1,46 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.suppliers; + +import com.unicenta.basic.BasicException; +import java.awt.Component; +import java.awt.event.ActionListener; + +/** + * + * @author JG uniCenta - outline/prep for uniCenta mobile + eCommerce connector + */ +public interface SupplierTicketSelector { + + /** + * + * @throws BasicException + */ + public void loadSupplierss() throws BasicException; + + /** + * + * @param value + */ + public void setComponentEnabled(boolean value); + + /** + * + * @return + */ + public Component getComponent(); + + /** + * + * @param l + */ + public void addActionListener(ActionListener l); + + /** + * + * @param l + */ + public void removeActionListener(ActionListener l); +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/suppliers/SupplierTransaction.java b/src/main/java/com/unicenta/pos/suppliers/SupplierTransaction.java new file mode 100644 index 0000000..2020440 --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/SupplierTransaction.java @@ -0,0 +1,171 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.suppliers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.SerializerRead; +import lombok.extern.slf4j.Slf4j; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * + * @author Jack Gerrard + * Used in Supplier's transactions tab to display all this Supplier's + * ticketline values + */ +@Slf4j +public class SupplierTransaction { + + Date transactionDate; + String productName; + String unit; + Double price; + Integer reason; + + String supplierId; + + /** + * Main method to return all supplier's transactions from StockDiary + */ + public SupplierTransaction() { + } + + /** + * + * @param transactionDate + * @param productName + * @param unit + * @param price + * @param reason + * @param sId + */ + public SupplierTransaction(Date transactionDate, String productName, String unit, Double price, Integer reason, String sId) { + this.transactionDate = transactionDate; + this.productName = productName; + this.unit = unit; + this.price = price; + this.reason = reason; + + this.supplierId = sId; + } + + + /** + * + * @return ticket's transaction date + */ + public Date getTransactionDate() { + return transactionDate; + } + public void setTransactionDate(Date transactionDate) { + this.transactionDate = transactionDate; + } + + /** + * + * @return product name string + */ + public String getProductName() { + return productName; + } + public void setProductName(String productName) { + this.productName = productName; + } + + /** + * + * @return quantity string value + */ + public String getUnit() { + return unit; + } + public void setUnit(String unit) { + this.unit = unit; + } + /** + * + * @return price value + */ + public Double getPrice() { + return price; + } + public void setPrice(Double price) { + this.price = price; + } + + /** + * + * @return + */ + public Integer getReason() { + return reason; + } + public void setReason(Integer reason) { + this.reason = reason; + } + + + /** + * + * @return supplier's account name string + */ + public String getSupplierId() { + return supplierId; + } + public void setSupplierId(String supplierId) { + this.supplierId = supplierId; + } + + + /** + * + * @return stockdiary for this supplier + */ + public static SerializerRead getSerializerRead() { + return new SerializerRead() { + + @Override + public Object readValues(DataRead dr) throws BasicException { + + String dateValue = dr.getString(1); + String productName = dr.getString(2); + String unit = dr.getString(3); + Double price = dr.getDouble(4); + Integer reason = dr.getInt(5); + + String supplierId = dr.getString(6); + + + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + Date date = null; + try { + date = formatter.parse(dateValue); + } catch (ParseException ex) { + log.error(ex.getMessage()); + } + return new SupplierTransaction(date, productName, unit, price, reason, supplierId); + } + }; + } +} diff --git a/src/main/java/com/unicenta/pos/suppliers/SuppliersPanel.java b/src/main/java/com/unicenta/pos/suppliers/SuppliersPanel.java new file mode 100644 index 0000000..4b5d389 --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/SuppliersPanel.java @@ -0,0 +1,134 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.suppliers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ListCellRendererBasic; +import com.unicenta.data.loader.ComparatorCreator; +import com.unicenta.data.loader.TableDefinition; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.data.user.ListProvider; +import com.unicenta.data.user.ListProviderCreator; +import com.unicenta.data.user.SaveProvider; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.JPanelTable; +import javax.swing.ListCellRenderer; + +/** + * + * @author Jack Gerrard + */ +public class SuppliersPanel extends JPanelTable { + + private TableDefinition tsuppliers; + private SuppliersView jeditor; + + /** Creates a new instance of SuppliersPanel */ + public SuppliersPanel() { + SupplierInfoGlobal.getInstance().setEditableData(bd); + } + + /** + * + */ + @Override + protected void init() { + DataLogicSuppliers dlSuppliers = (DataLogicSuppliers) app.getBean("com.unicenta.pos.suppliers.DataLogicSuppliers"); + tsuppliers = dlSuppliers.getTableSuppliers(); + jeditor = new SuppliersView(app, dirty); + + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + jeditor.activate(); + super.activate(); + } + + /** + * + * @return + */ + @Override + public ListProvider getListProvider() { + return new ListProviderCreator(tsuppliers); + } + + /** + * + * @return + */ + @Override + public SaveProvider getSaveProvider() { + return new SaveProvider(tsuppliers, new int[] { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}); + } + + /** + * + * @return + */ + @Override + public Vectorer getVectorer() { + return tsuppliers.getVectorerBasic(new int[]{1, 2, 3, 4}); + } + + /** + * + * @return + */ + @Override + public ComparatorCreator getComparatorCreator() { + return tsuppliers.getComparatorCreator(new int[] {1, 2, 3, 4}); + } + + /** + * + * @return + */ + @Override + public ListCellRenderer getListCellRenderer() { + return new ListCellRendererBasic(tsuppliers.getRenderStringBasic(new int[]{3})); + } + + /** + * + * @return + */ + @Override + public EditorRecord getEditor() { + return jeditor; + } + + /** + * + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.SuppliersManagement"); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/suppliers/SuppliersView.form b/src/main/java/com/unicenta/pos/suppliers/SuppliersView.form new file mode 100644 index 0000000..64b71ba --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/SuppliersView.form @@ -0,0 +1,1050 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[1000, 600]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jTabbedPane1" min="-2" max="-2" attributes="0"/> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="1"/> + <Component id="jLabel7" alignment="0" max="32767" attributes="1"/> + <Component id="jLabel9" alignment="0" max="32767" attributes="1"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" attributes="1"> + <Component id="m_jTaxID" min="-2" max="-2" attributes="2"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jLabel8" min="-2" pref="87" max="-2" attributes="0"/> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Component id="m_jSearchkey" min="-2" pref="136" max="-2" attributes="2"/> + </Group> + <Component id="m_jName" alignment="0" min="-2" pref="395" max="-2" attributes="2"/> + <Component id="m_jVATID" min="-2" max="-2" attributes="2"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="0" max="-2" attributes="0"> + <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="1"/> + <Component id="jLabel1" alignment="0" max="32767" attributes="1"/> + </Group> + <Component id="jLabel4" min="-2" max="-2" attributes="1"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jVisible" alignment="0" min="-2" pref="21" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="txtMaxdebt" min="-2" max="-2" attributes="0"/> + <Component id="txtCurdebt" alignment="0" min="-2" max="-2" attributes="1"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="txtCurdate" min="-2" max="-2" attributes="1"/> + <Component id="jLabel6" alignment="0" min="-2" max="-2" attributes="1"/> + </Group> + </Group> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jSearchkey" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jTaxID" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jVATID" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + <Component id="m_jVisible" alignment="0" min="-2" pref="25" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtMaxdebt" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="txtCurdate" min="-2" max="-2" attributes="0"/> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtCurdebt" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jTabbedPane1" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="48" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/info.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.suppliertaxid" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jLabel7MouseClicked"/> + </Events> + </Component> + <Component class="javax.swing.JTextField" name="m_jTaxID"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="CustomersView_m_jTaxID"/> + </AuxValues> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.searchkeym" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jSearchkey"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.supplier" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.visible" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JCheckBox" name="m_jVisible"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.maxdebt" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtMaxdebt"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.curdebt" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtCurdebt"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.curdate" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtCurdate"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Container class="javax.swing.JTabbedPane" name="jTabbedPane1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[650, 300]"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> + <JTabbedPaneConstraints tabName="Contact"> + <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.contact" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </JTabbedPaneConstraints> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel15" min="-2" pref="110" max="-2" attributes="1"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="txtLastName" min="-2" max="-2" attributes="2"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel14" min="-2" pref="110" max="-2" attributes="2"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="txtFax" min="-2" max="-2" attributes="2"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel16" alignment="0" min="-2" pref="110" max="-2" attributes="1"/> + <Component id="jLabel17" alignment="0" min="-2" pref="110" max="-2" attributes="1"/> + <Component id="jLabel18" alignment="0" min="-2" pref="110" max="-2" attributes="1"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="txtPhone" min="-2" max="-2" attributes="2"/> + <Component id="txtEmail" min="-2" max="-2" attributes="2"/> + <Component id="txtPhone2" min="-2" max="-2" attributes="1"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel19" min="-2" pref="110" max="-2" attributes="1"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="txtFirstName" min="-2" max="-2" attributes="1"/> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="webBtnMail" min="-2" pref="89" max="-2" attributes="0"/> + <EmptySpace pref="216" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel19" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtFirstName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel15" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtLastName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel16" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtEmail" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="webBtnMail" alignment="3" min="-2" pref="31" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel17" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtPhone" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel18" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtPhone2" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="txtFax" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel14" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" pref="57" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel19"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.firstname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="alignmentX" type="float" value="0.5"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtFirstName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel15"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.lastname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtLastName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel16"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.email" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtEmail"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel17"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.phone" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtPhone"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel18"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.phone2" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtPhone2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel14"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.fax" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtFax"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.button.WebButton" name="webBtnMail"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/mail24.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.email" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[90, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="webBtnMailActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> + <JTabbedPaneConstraints tabName="Address"> + <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.locationaddress" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </JTabbedPaneConstraints> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="jLabel20" min="-2" max="-2" attributes="1"/> + <Component id="jLabel24" alignment="0" min="-2" max="-2" attributes="1"/> + <Component id="jLabel23" alignment="0" min="-2" max="-2" attributes="1"/> + <Component id="jLabel21" alignment="0" min="-2" max="-2" attributes="1"/> + <Component id="jLabel13" alignment="0" min="-2" max="-2" attributes="1"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="txtCity" alignment="0" max="32767" attributes="1"/> + <Component id="txtAddress" alignment="0" max="32767" attributes="1"/> + <Component id="txtAddress2" alignment="0" max="32767" attributes="1"/> + <Component id="txtRegion" alignment="0" max="32767" attributes="1"/> + <Component id="txtCountry" alignment="0" max="32767" attributes="1"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="txtPostal" min="-2" pref="89" max="-2" attributes="0"/> + <Component id="jLabel22" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtAddress" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel21" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtAddress2" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel23" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtCity" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel22" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel24" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtRegion" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtPostal" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel20" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtCountry" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel13"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.address" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtAddress"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel20"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.country" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtCountry"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel21"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.address2" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtAddress2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel22"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.postal" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtPostal"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel23"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.city" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtCity"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel24"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.region" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="txtRegion"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[535, 0]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> + <JTabbedPaneConstraints tabName="Transactions"> + <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.SupplierTransactions" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + </JTabbedPaneConstraints> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> + <Component id="jScrollPane3" min="-2" pref="622" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jBtnShowTrans" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jLblTranCount" max="32767" attributes="0"/> + </Group> + </Group> + <EmptySpace pref="13" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jBtnShowTrans" min="-2" max="-2" attributes="0"/> + <Component id="jLblTranCount" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="jScrollPane3" min="-2" pref="233" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="jBtnShowTrans"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.SupplierTrans" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnShowTransActionPerformed"/> + </Events> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="jTableSupplierTransactions"> + <Properties> + <Property name="autoCreateRowSorter" type="boolean" value="true"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="5" rowCount="100"> + <Column editable="true" title="Date" type="java.lang.Object"/> + <Column editable="true" title="Product" type="java.lang.Object"/> + <Column editable="true" title="Qty" type="java.lang.Object"/> + <Column editable="true" title="Price" type="java.lang.Object"/> + <Column editable="true" title="Reason" type="java.lang.Object"/> + </Table> + </Property> + <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> + <TableColumnModel selectionModel="0"> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="gridColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="cc" red="66" type="rgb"/> + </Property> + <Property name="opaque" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[375, 200]"/> + </Property> + <Property name="rowHeight" type="int" value="25"/> + <Property name="showVerticalLines" type="boolean" value="false"/> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="true" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLblTranCount"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription"> + <JTabbedPaneConstraints tabName="Notes"> + <Property name="tabTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.notes" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </JTabbedPaneConstraints> + </Constraint> + </Constraints> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jScrollPane1" min="-2" pref="458" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jScrollPane1" pref="247" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="m_jNotes"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 0]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel9"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.suppliervatid" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[140, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jVATID"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="CustomersView_m_jTaxID"/> + </AuxValues> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/suppliers/SuppliersView.java b/src/main/java/com/unicenta/pos/suppliers/SuppliersView.java new file mode 100644 index 0000000..f341009 --- /dev/null +++ b/src/main/java/com/unicenta/pos/suppliers/SuppliersView.java @@ -0,0 +1,1336 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.suppliers; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.BeanFactoryException; +import com.unicenta.pos.inventory.MovementReason; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.JTableHeader; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +/** + * + * @author Jack Gerrard + */ +@Slf4j +public final class SuppliersView extends javax.swing.JPanel implements EditorRecord { + + private static final long serialVersionUID = 1L; + private Object m_oId; + +// private SentenceList m_sentcat; + private List<SupplierTransaction> supplierTransactionList; + private TransactionTableModel transactionModel; + + private DirtyManager m_Dirty; + private DataLogicSuppliers dlSuppliers; + + private AppView appView; + private SupplierInfo supplierInfo; + + /** Creates new form SuppliersView + * @param app + * @param dirty */ + public SuppliersView(AppView app, DirtyManager dirty) { + try { + setAppView(app); + dlSuppliers = (DataLogicSuppliers) app.getBean("com.unicenta.pos.suppliers.DataLogicSuppliers"); + + initComponents(); + + m_Dirty = dirty; + m_jTaxID.getDocument().addDocumentListener(dirty); + m_jVATID.getDocument().addDocumentListener(dirty); + m_jSearchkey.getDocument().addDocumentListener(dirty); + m_jName.getDocument().addDocumentListener(dirty); + + m_jNotes.getDocument().addDocumentListener(dirty); + txtMaxdebt.getDocument().addDocumentListener(dirty); + m_jVisible.addActionListener(dirty); + + txtFirstName.getDocument().addDocumentListener(dirty); + txtLastName.getDocument().addDocumentListener(dirty); + txtEmail.getDocument().addDocumentListener(dirty); + txtPhone.getDocument().addDocumentListener(dirty); + txtPhone2.getDocument().addDocumentListener(dirty); + txtFax.getDocument().addDocumentListener(dirty); + + txtAddress.getDocument().addDocumentListener(dirty); + txtAddress2.getDocument().addDocumentListener(dirty); + txtPostal.getDocument().addDocumentListener(dirty); + txtCity.getDocument().addDocumentListener(dirty); + txtRegion.getDocument().addDocumentListener(dirty); + txtCountry.getDocument().addDocumentListener(dirty); + + init(); + } catch (BeanFactoryException ex) { + log.error(ex.getMessage()); + } + } + + private void init() { + writeValueEOF(); + } + + /** + * Instantiate object + * @throws BasicException + */ + @SuppressWarnings("unchecked") + public void activate() throws BasicException { + + String sId = null; + } + + /** + * Refresh object + */ + @Override + public void refresh() { + jLblTranCount.setText(null); + } + + /** + * Write EOF + */ + @Override + public void writeValueEOF() { + m_oId = null; + m_jTaxID.setText(null); + m_jVATID.setText(null); + m_jSearchkey.setText(null); + m_jName.setText(null); + m_jNotes.setText(null); + txtMaxdebt.setText(null); + txtCurdebt.setText(null); + txtCurdate.setText(null); + m_jVisible.setSelected(false); + + txtFirstName.setText(null); + txtLastName.setText(null); + txtEmail.setText(null); + txtPhone.setText(null); + txtPhone2.setText(null); + txtFax.setText(null); + txtAddress.setText(null); + txtAddress2.setText(null); + txtPostal.setText(null); + txtCity.setText(null); + txtRegion.setText(null); + txtCountry.setText(null); + + m_jTaxID.setEnabled(false); + m_jVATID.setEnabled(false); + m_jSearchkey.setEnabled(false); + m_jName.setEnabled(false); + m_jNotes.setEnabled(false); + txtMaxdebt.setEnabled(false); + txtCurdebt.setEnabled(false); + txtCurdate.setEnabled(false); + m_jVisible.setEnabled(false); + + txtFirstName.setEnabled(false); + txtLastName.setEnabled(false); + txtEmail.setEnabled(false); + txtPhone.setEnabled(false); + txtPhone2.setEnabled(false); + txtFax.setEnabled(false); + + txtAddress.setEnabled(false); + txtAddress2.setEnabled(false); + txtPostal.setEnabled(false); + txtCity.setEnabled(false); + txtRegion.setEnabled(false); + txtCountry.setEnabled(false); + + jTableSupplierTransactions.setEnabled(false); + + repaint(); + refresh(); + } + + @Override + public void writeValueInsert() { + m_oId = null; + m_jTaxID.setText(null); + m_jVATID.setText(null); + m_jSearchkey.setText(null); + m_jName.setText(null); + txtMaxdebt.setText(null); + txtCurdebt.setText(null); + txtCurdate.setText(null); + + txtFirstName.setText(null); + txtLastName.setText(null); + txtPhone.setText(null); + txtPhone2.setText(null); + txtEmail.setText(null); + + txtFax.setText(null); + txtAddress.setText(null); + txtAddress2.setText(null); + txtPostal.setText(null); + txtCity.setText(null); + txtRegion.setText(null); + txtCountry.setText(null); + + m_jNotes.setText(null); + m_jVisible.setSelected(true); + + m_jTaxID.setEnabled(true); + m_jVATID.setEnabled(true); + m_jSearchkey.setEnabled(true); + m_jName.setEnabled(true); + + txtFirstName.setEnabled(true); + txtLastName.setEnabled(true); + txtEmail.setEnabled(true); + webBtnMail.setEnabled(true); + txtPhone.setEnabled(true); + txtPhone2.setEnabled(true); + txtFax.setEnabled(true); + + txtAddress.setEnabled(true); + txtAddress2.setEnabled(true); + txtPostal.setEnabled(true); + txtCity.setEnabled(true); + txtRegion.setEnabled(true); + txtCountry.setEnabled(true); + + m_jNotes.setEnabled(true); + txtMaxdebt.setEnabled(true); + txtCurdebt.setEnabled(true); + txtCurdate.setEnabled(true); + m_jVisible.setEnabled(true); + jTableSupplierTransactions.setEnabled(false); + + repaint(); + refresh(); + } + + /** + * Delete from object + * @param value + */ + @Override + public void writeValueDelete(Object value) { + + Object[] supplier = (Object[]) value; + m_oId = supplier[0]; + m_jSearchkey.setText((String) supplier[1]); + m_jTaxID.setText((String) supplier[2]); + m_jName.setText((String) supplier[3]); + txtMaxdebt.setText(Formats.CURRENCY.formatValue(supplier[4])); + + txtAddress.setText(Formats.STRING.formatValue(supplier[5])); + txtAddress2.setText(Formats.STRING.formatValue(supplier[6])); + txtPostal.setText(Formats.STRING.formatValue(supplier[7])); + txtCity.setText(Formats.STRING.formatValue(supplier[8])); + txtRegion.setText(Formats.STRING.formatValue(supplier[9])); + txtCountry.setText(Formats.STRING.formatValue(supplier[10])); + + txtFirstName.setText(Formats.STRING.formatValue(supplier[11])); + txtLastName.setText(Formats.STRING.formatValue(supplier[12])); + txtEmail.setText(Formats.STRING.formatValue(supplier[13])); + txtPhone.setText(Formats.STRING.formatValue(supplier[14])); + txtPhone2.setText(Formats.STRING.formatValue(supplier[15])); + txtFax.setText(Formats.STRING.formatValue(supplier[16])); + + m_jNotes.setText((String) supplier[17]); + m_jVisible.setSelected(((Boolean) supplier[18])); + + txtCurdate.setText(Formats.DATE.formatValue(supplier[19])); + txtCurdebt.setText(Formats.CURRENCY.formatValue(supplier[20])); + + m_jVATID.setText((String) supplier[21]); + + m_jTaxID.setEnabled(false); + m_jVATID.setEnabled(false); + m_jSearchkey.setEnabled(false); + m_jName.setEnabled(false); + m_jNotes.setEnabled(false); + txtMaxdebt.setEnabled(false); + txtCurdebt.setEnabled(false); + txtCurdate.setEnabled(false); + m_jVisible.setEnabled(false); + + txtFirstName.setEnabled(false); + txtLastName.setEnabled(false); + txtEmail.setEnabled(false); + webBtnMail.setEnabled(false); + txtPhone.setEnabled(false); + txtPhone2.setEnabled(false); + txtFax.setEnabled(false); + + txtAddress.setEnabled(false); + txtAddress2.setEnabled(false); + txtPostal.setEnabled(false); + txtCity.setEnabled(false); + txtRegion.setEnabled(false); + txtCountry.setEnabled(false); + + transactionModel = new TransactionTableModel(getTransactionOfName((String) m_oId)); + jTableSupplierTransactions.setModel(transactionModel); + jTableSupplierTransactions.setEnabled(false); + + repaint(); + refresh(); + + } + + /** + * Edit object + * @param value + */ + @Override + public void writeValueEdit(Object value) { + Object[] supplier = (Object[]) value; + m_oId = supplier[0]; + m_jSearchkey.setText((String) supplier[1]); + m_jTaxID.setText((String) supplier[2]); + m_jName.setText((String) supplier[3]); + txtMaxdebt.setText(Formats.CURRENCY.formatValue(supplier[4])); + + txtAddress.setText(Formats.STRING.formatValue(supplier[5])); + txtAddress2.setText(Formats.STRING.formatValue(supplier[6])); + txtPostal.setText(Formats.STRING.formatValue(supplier[7])); + txtCity.setText(Formats.STRING.formatValue(supplier[8])); + txtRegion.setText(Formats.STRING.formatValue(supplier[9])); + txtCountry.setText(Formats.STRING.formatValue(supplier[10])); + txtFirstName.setText(Formats.STRING.formatValue(supplier[11])); + txtLastName.setText(Formats.STRING.formatValue(supplier[12])); + txtEmail.setText(Formats.STRING.formatValue(supplier[13])); + txtPhone.setText(Formats.STRING.formatValue(supplier[14])); + txtPhone2.setText(Formats.STRING.formatValue(supplier[15])); + txtFax.setText(Formats.STRING.formatValue(supplier[16])); + + m_jNotes.setText((String) supplier[17]); + m_jVisible.setSelected(((Boolean) supplier[18])); + txtCurdate.setText(Formats.DATE.formatValue(supplier[19])); + txtCurdebt.setText(Formats.CURRENCY.formatValue(supplier[20])); + + m_jVATID.setText((String) supplier[21]); + + m_jSearchkey.setEnabled(true); + m_jTaxID.setEnabled(true); + m_jName.setEnabled(true); + txtMaxdebt.setEnabled(true); + + txtAddress.setEnabled(true); + txtAddress2.setEnabled(true); + txtPostal.setEnabled(true); + txtCity.setEnabled(true); + txtRegion.setEnabled(true); + txtCountry.setEnabled(true); + + txtFirstName.setEnabled(true); + txtLastName.setEnabled(true); + txtEmail.setEnabled(true); + webBtnMail.setEnabled(true); + txtPhone.setEnabled(true); + txtPhone2.setEnabled(true); + txtFax.setEnabled(true); + + m_jNotes.setEnabled(true); + m_jVisible.setEnabled(true); + txtCurdebt.setEnabled(true); + txtCurdate.setEnabled(true); + m_jVATID.setEnabled(true); + + jTableSupplierTransactions.setVisible(false); + jTableSupplierTransactions.setEnabled(true); + resetTranxTable(); + + txtCurdate.repaint(); + txtCurdebt.repaint(); + jTableSupplierTransactions.repaint(); + repaint(); + refresh(); + } + +public void resetTranxTable() { + + jTableSupplierTransactions.getColumnModel().getColumn(0).setPreferredWidth(100); + jTableSupplierTransactions.getColumnModel().getColumn(1).setPreferredWidth(225); + jTableSupplierTransactions.getColumnModel().getColumn(2).setPreferredWidth(30); + jTableSupplierTransactions.getColumnModel().getColumn(3).setPreferredWidth(50); + jTableSupplierTransactions.getColumnModel().getColumn(4).setPreferredWidth(55); + + // set font for headers + Font f = new Font("Arial", Font.BOLD, 14); + JTableHeader header = jTableSupplierTransactions.getTableHeader(); + header.setFont(f); + + jTableSupplierTransactions.getTableHeader().setReorderingAllowed(true); + jTableSupplierTransactions.setAutoCreateRowSorter(true); + + jTableSupplierTransactions.repaint(); + + +} + + + /** + * Create object + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + Object[] supplier = new Object[23]; + supplier[0] = m_oId == null ? UUID.randomUUID().toString() : m_oId; + supplier[1] = m_jSearchkey.getText(); + supplier[2] = m_jTaxID.getText(); + supplier[3] = m_jName.getText(); + supplier[4] = Formats.CURRENCY.parseValue(txtMaxdebt.getText(), 0.0); + supplier[5] = Formats.STRING.parseValue(txtAddress.getText()); + supplier[6] = Formats.STRING.parseValue(txtAddress2.getText()); + supplier[7] = Formats.STRING.parseValue(txtPostal.getText()); + supplier[8] = Formats.STRING.parseValue(txtCity.getText()); + supplier[9] = Formats.STRING.parseValue(txtRegion.getText()); + supplier[10] = Formats.STRING.parseValue(txtCountry.getText()); + supplier[11] = Formats.STRING.parseValue(txtFirstName.getText()); + supplier[12] = Formats.STRING.parseValue(txtLastName.getText()); + supplier[13] = Formats.STRING.parseValue(txtEmail.getText()); + supplier[14] = Formats.STRING.parseValue(txtPhone.getText()); + supplier[15] = Formats.STRING.parseValue(txtPhone2.getText()); + supplier[16] = Formats.STRING.parseValue(txtFax.getText()); + supplier[17] = m_jNotes.getText(); + supplier[18] = m_jVisible.isSelected(); + supplier[19] = Formats.TIMESTAMP.parseValue(txtCurdate.getText()); + supplier[20] = Formats.CURRENCY.parseValue(txtCurdebt.getText()); + supplier[21] = m_jVATID.getText(); + + supplier[22] = (Object)getAppView(); + + repaint(); + refresh(); + + return supplier; + } + + public AppView getAppView() { + return appView; + } + + public void setAppView(AppView appView) { + this.appView = appView; + } + + @Override + public Component getComponent() { + return this; + } + + private List<SupplierTransaction> getTransactionOfName(String sId) { + + try { + supplierTransactionList = dlSuppliers.getSuppliersTransactionList(sId); + + + } catch (BasicException ex) { + log.error(ex.getMessage()); + } + + List<SupplierTransaction> supplierList = new ArrayList<>(); + + for (SupplierTransaction supplierTransaction : supplierTransactionList) { + String supplierId = supplierTransaction.getSupplierId(); + if (supplierId.equals(sId)) { + supplierList.add(supplierTransaction); + } + } + + txtCurdate.repaint(); + txtCurdebt.repaint(); + + repaint(); + refresh(); + + return supplierList; + } + + class TransactionTableModel extends AbstractTableModel { +String dte = AppLocal.getIntString("label.suptblHeaderCol1"); +String prd = AppLocal.getIntString("label.suptblHeaderCol2"); +String qty = AppLocal.getIntString("label.suptblHeaderCol3"); +String pri = AppLocal.getIntString("label.suptblHeaderCol4"); +String rsn = AppLocal.getIntString("label.suptblHeaderCol5"); + + + List<SupplierTransaction> transactionList; + String[] columnNames = {dte, prd, qty, pri, rsn}; + public Double Tamount; + + public TransactionTableModel(List<SupplierTransaction> list) { + transactionList = list; + } + + @Override + public int getColumnCount() { + return 5; + } + + @Override + public int getRowCount() { + return transactionList.size(); + } + + // this method is called to set the value of each cell + @Override + public Object getValueAt(int row, int column) { + SupplierTransaction supplierTransaction = transactionList.get(row); + + jTableSupplierTransactions.setRowHeight(25); + + switch (column) { + + case 0: + Date transactionDate = supplierTransaction.getTransactionDate(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + String formattedDate = sdf.format(transactionDate); + return formattedDate; + case 1: + return supplierTransaction.getProductName(); + case 2: + return supplierTransaction.getUnit(); + case 3: + Double price = supplierTransaction.getPrice(); + DecimalFormat df = new DecimalFormat("#.##"); + String formattedAmount = df.format(price); + return formattedAmount; + case 4: + Integer reason = supplierTransaction.getReason(); + String s = String.valueOf(reason); + + if (s.equals("1")) { + s = MovementReason.IN_PURCHASE.toString(); + } + if (s.equals("2")) { + s = MovementReason.IN_REFUND.toString(); + } + if (s.equals("4")) { + s = MovementReason.IN_MOVEMENT.toString(); + } + if (s.equals("-1")) { + s = MovementReason.OUT_SALE.toString(); + } + if (s.equals("-2")) { + s = MovementReason.OUT_REFUND.toString(); + } + if (s.equals("-3")) { + s = MovementReason.OUT_BREAK.toString(); + } + if (s.equals("-4")) { + s = MovementReason.OUT_MOVEMENT.toString(); + } + if (s.equals("-5")) { + s = MovementReason.OUT_SAMPLE.toString(); + } + if (s.equals("-6")) { + s = MovementReason.OUT_FREE.toString(); + } + if (s.equals("-7")) { + s = MovementReason.OUT_USED.toString(); + } + if (s.equals("-8")) { + s = MovementReason.OUT_SUBTRACT.toString(); + } + return s; + + default: + return ""; + + } + } + + @Override + public String getColumnName(int col) { + return columnNames[col]; + } + } + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel7 = new javax.swing.JLabel(); + m_jTaxID = new javax.swing.JTextField(); + jLabel8 = new javax.swing.JLabel(); + m_jSearchkey = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + m_jName = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + m_jVisible = new javax.swing.JCheckBox(); + jLabel1 = new javax.swing.JLabel(); + txtMaxdebt = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + txtCurdebt = new javax.swing.JTextField(); + jLabel6 = new javax.swing.JLabel(); + txtCurdate = new javax.swing.JTextField(); + jTabbedPane1 = new javax.swing.JTabbedPane(); + jPanel1 = new javax.swing.JPanel(); + jLabel19 = new javax.swing.JLabel(); + txtFirstName = new javax.swing.JTextField(); + jLabel15 = new javax.swing.JLabel(); + txtLastName = new javax.swing.JTextField(); + jLabel16 = new javax.swing.JLabel(); + txtEmail = new javax.swing.JTextField(); + jLabel17 = new javax.swing.JLabel(); + txtPhone = new javax.swing.JTextField(); + jLabel18 = new javax.swing.JLabel(); + txtPhone2 = new javax.swing.JTextField(); + jLabel14 = new javax.swing.JLabel(); + txtFax = new javax.swing.JTextField(); + webBtnMail = new com.alee.laf.button.WebButton(); + jPanel2 = new javax.swing.JPanel(); + jLabel13 = new javax.swing.JLabel(); + txtAddress = new javax.swing.JTextField(); + jLabel20 = new javax.swing.JLabel(); + txtCountry = new javax.swing.JTextField(); + jLabel21 = new javax.swing.JLabel(); + txtAddress2 = new javax.swing.JTextField(); + jLabel22 = new javax.swing.JLabel(); + txtPostal = new javax.swing.JTextField(); + jLabel23 = new javax.swing.JLabel(); + txtCity = new javax.swing.JTextField(); + jLabel24 = new javax.swing.JLabel(); + txtRegion = new javax.swing.JTextField(); + jPanel4 = new javax.swing.JPanel(); + jBtnShowTrans = new javax.swing.JButton(); + jScrollPane3 = new javax.swing.JScrollPane(); + jTableSupplierTransactions = new javax.swing.JTable(); + jLblTranCount = new javax.swing.JLabel(); + jPanel3 = new javax.swing.JPanel(); + jScrollPane1 = new javax.swing.JScrollPane(); + m_jNotes = new javax.swing.JTextArea(); + jLabel9 = new javax.swing.JLabel(); + m_jVATID = new javax.swing.JTextField(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setPreferredSize(new java.awt.Dimension(1000, 600)); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/info.png"))); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.suppliertaxid")); // NOI18N + jLabel7.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel7.setMinimumSize(new java.awt.Dimension(140, 25)); + jLabel7.setPreferredSize(new java.awt.Dimension(150, 30)); + jLabel7.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel7MouseClicked(evt); + } + }); + + m_jTaxID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jTaxID.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel8.setText(AppLocal.getIntString("label.searchkeym")); // NOI18N + + m_jSearchkey.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSearchkey.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.supplier")); // NOI18N + jLabel3.setMaximumSize(new java.awt.Dimension(140, 25)); + jLabel3.setMinimumSize(new java.awt.Dimension(140, 25)); + jLabel3.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.visible")); // NOI18N + jLabel4.setMaximumSize(new java.awt.Dimension(140, 25)); + jLabel4.setMinimumSize(new java.awt.Dimension(140, 25)); + jLabel4.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jVisible.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.maxdebt")); // NOI18N + jLabel1.setMaximumSize(new java.awt.Dimension(140, 25)); + jLabel1.setMinimumSize(new java.awt.Dimension(140, 25)); + jLabel1.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtMaxdebt.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtMaxdebt.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + txtMaxdebt.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.curdebt")); // NOI18N + jLabel2.setMaximumSize(new java.awt.Dimension(140, 25)); + jLabel2.setMinimumSize(new java.awt.Dimension(140, 25)); + jLabel2.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtCurdebt.setEditable(false); + txtCurdebt.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCurdebt.setHorizontalAlignment(javax.swing.JTextField.RIGHT); + txtCurdebt.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel6.setText(AppLocal.getIntString("label.curdate")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtCurdate.setEditable(false); + txtCurdate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCurdate.setHorizontalAlignment(javax.swing.JTextField.CENTER); + txtCurdate.setPreferredSize(new java.awt.Dimension(150, 30)); + + jTabbedPane1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTabbedPane1.setPreferredSize(new java.awt.Dimension(650, 300)); + + jPanel1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + jLabel19.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel19.setText(AppLocal.getIntString("label.firstname")); // NOI18N + jLabel19.setAlignmentX(0.5F); + jLabel19.setPreferredSize(new java.awt.Dimension(0, 30)); + + txtFirstName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtFirstName.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel15.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel15.setText(AppLocal.getIntString("label.lastname")); // NOI18N + jLabel15.setPreferredSize(new java.awt.Dimension(0, 30)); + + txtLastName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtLastName.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel16.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel16.setText(AppLocal.getIntString("label.email")); // NOI18N + jLabel16.setPreferredSize(new java.awt.Dimension(0, 30)); + + txtEmail.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtEmail.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel17.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel17.setText(AppLocal.getIntString("label.phone")); // NOI18N + jLabel17.setPreferredSize(new java.awt.Dimension(0, 30)); + + txtPhone.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtPhone.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel18.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel18.setText(AppLocal.getIntString("label.phone2")); // NOI18N + jLabel18.setPreferredSize(new java.awt.Dimension(0, 30)); + + txtPhone2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtPhone2.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel14.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel14.setText(AppLocal.getIntString("label.fax")); // NOI18N + jLabel14.setPreferredSize(new java.awt.Dimension(0, 30)); + + txtFax.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtFax.setPreferredSize(new java.awt.Dimension(200, 30)); + + webBtnMail.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/mail24.png"))); // NOI18N + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + webBtnMail.setText(bundle.getString("button.email")); // NOI18N + webBtnMail.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + webBtnMail.setPreferredSize(new java.awt.Dimension(90, 30)); + webBtnMail.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + webBtnMailActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(txtLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(txtFax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPhone2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(jPanel1Layout.createSequentialGroup() + .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(txtFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(webBtnMail, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(216, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webBtnMail, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPhone2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtFax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(57, 57, 57)) + ); + + jTabbedPane1.addTab(AppLocal.getIntString("label.contact"), jPanel1); // NOI18N + + jLabel13.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel13.setText(AppLocal.getIntString("label.address")); // NOI18N + jLabel13.setPreferredSize(new java.awt.Dimension(110, 30)); + + txtAddress.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtAddress.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel20.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel20.setText(AppLocal.getIntString("label.country")); // NOI18N + jLabel20.setPreferredSize(new java.awt.Dimension(110, 30)); + + txtCountry.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCountry.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel21.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel21.setText(AppLocal.getIntString("label.address2")); // NOI18N + jLabel21.setPreferredSize(new java.awt.Dimension(110, 30)); + + txtAddress2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtAddress2.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel22.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel22.setText(AppLocal.getIntString("label.postal")); // NOI18N + jLabel22.setPreferredSize(new java.awt.Dimension(110, 30)); + + txtPostal.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtPostal.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel23.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel23.setText(AppLocal.getIntString("label.city")); // NOI18N + jLabel23.setPreferredSize(new java.awt.Dimension(110, 30)); + + txtCity.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtCity.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel24.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel24.setText(AppLocal.getIntString("label.region")); // NOI18N + jLabel24.setPreferredSize(new java.awt.Dimension(110, 30)); + + txtRegion.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtRegion.setPreferredSize(new java.awt.Dimension(200, 30)); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(txtCity, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(txtAddress, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(txtAddress2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(txtRegion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(txtCountry, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(18, 18, 18) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtPostal, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtAddress2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtCity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtRegion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPostal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtCountry, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + jTabbedPane1.addTab(AppLocal.getIntString("label.locationaddress"), jPanel2); // NOI18N + + jPanel4.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jPanel4.setPreferredSize(new java.awt.Dimension(535, 0)); + + jBtnShowTrans.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jBtnShowTrans.setText(bundle.getString("button.SupplierTrans")); // NOI18N + jBtnShowTrans.setToolTipText(""); + jBtnShowTrans.setPreferredSize(new java.awt.Dimension(140, 30)); + jBtnShowTrans.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnShowTransActionPerformed(evt); + } + }); + + jScrollPane3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + jTableSupplierTransactions.setAutoCreateRowSorter(true); + jTableSupplierTransactions.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jTableSupplierTransactions.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null} + }, + new String [] { + "Date", "Product", "Qty", "Price", "Reason" + } + )); + jTableSupplierTransactions.setGridColor(new java.awt.Color(102, 204, 255)); + jTableSupplierTransactions.setOpaque(false); + jTableSupplierTransactions.setPreferredSize(new java.awt.Dimension(375, 200)); + jTableSupplierTransactions.setRowHeight(25); + jTableSupplierTransactions.setShowVerticalLines(false); + jScrollPane3.setViewportView(jTableSupplierTransactions); + + jLblTranCount.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblTranCount.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLblTranCount.setOpaque(true); + jLblTranCount.setPreferredSize(new java.awt.Dimension(50, 30)); + + javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addGap(10, 10, 10) + .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 622, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jBtnShowTrans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jLblTranCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addContainerGap(13, Short.MAX_VALUE)) + ); + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jBtnShowTrans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblTranCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 233, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + jTabbedPane1.addTab(bundle.getString("label.SupplierTransactions"), jPanel4); // NOI18N + + m_jNotes.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jNotes.setPreferredSize(new java.awt.Dimension(0, 0)); + jScrollPane1.setViewportView(m_jNotes); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 458, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel3Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 247, Short.MAX_VALUE) + .addContainerGap()) + ); + + jTabbedPane1.addTab(AppLocal.getIntString("label.notes"), jPanel3); // NOI18N + + jLabel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel9.setText(AppLocal.getIntString("label.suppliervatid")); // NOI18N + jLabel9.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel9.setMinimumSize(new java.awt.Dimension(140, 25)); + jLabel9.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jVATID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jVATID.setPreferredSize(new java.awt.Dimension(150, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(m_jTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jSearchkey, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, 395, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jVATID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jVisible, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtMaxdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtCurdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtCurdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSearchkey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jTaxID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jVATID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jVisible, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtMaxdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtCurdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtCurdebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(48, Short.MAX_VALUE)) + ); + }// </editor-fold>//GEN-END:initComponents + + private void webBtnMailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_webBtnMailActionPerformed + + if(!"".equals(txtEmail.getText())) { + Desktop desktop; + + if (Desktop.isDesktopSupported() + && (desktop = Desktop.getDesktop()).isSupported(Desktop.Action.MAIL)) { + URI mailto = null; + try { + mailto = new URI("mailto:" + + txtEmail.getText()); + } catch (URISyntaxException ex) { + log.error(ex.getMessage()); + } + try { + desktop.mail(mailto); + } catch (IOException ex) { + log.error(ex.getMessage()); + } + } else { + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.email"), + "Email", JOptionPane.INFORMATION_MESSAGE); + } + } + + }//GEN-LAST:event_webBtnMailActionPerformed + + private void jBtnShowTransActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnShowTransActionPerformed + String cId = m_oId.toString(); + if (cId != null) { + transactionModel = new TransactionTableModel(getTransactionOfName(cId)); + jTableSupplierTransactions.setModel(transactionModel); + if (transactionModel.getRowCount()> 0){ + jTableSupplierTransactions.setVisible(true); + String TranCount = String.valueOf(transactionModel.getRowCount()); + jLblTranCount.setText(TranCount + " for " + m_jName.getText()); + }else{ + jTableSupplierTransactions.setVisible(false); + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.nosupptranx"), + "Transactions", JOptionPane.INFORMATION_MESSAGE); + } + resetTranxTable(); + } + }//GEN-LAST:event_jBtnShowTransActionPerformed + + private void jLabel7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel7MouseClicked + + if (evt.getClickCount() == 2) { + String uuidString = m_oId.toString(); + StringSelection stringSelection = new StringSelection(uuidString); + Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); + clpbrd.setContents(stringSelection, null); + + JOptionPane.showMessageDialog(null, + AppLocal.getIntString("message.uuidcopy")); + } + }//GEN-LAST:event_jLabel7MouseClicked + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jBtnShowTrans; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel15; + private javax.swing.JLabel jLabel16; + private javax.swing.JLabel jLabel17; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel19; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel20; + private javax.swing.JLabel jLabel21; + private javax.swing.JLabel jLabel22; + private javax.swing.JLabel jLabel23; + private javax.swing.JLabel jLabel24; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JLabel jLblTranCount; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane3; + private javax.swing.JTabbedPane jTabbedPane1; + private javax.swing.JTable jTableSupplierTransactions; + private javax.swing.JTextField m_jName; + private javax.swing.JTextArea m_jNotes; + private javax.swing.JTextField m_jSearchkey; + private javax.swing.JTextField m_jTaxID; + private javax.swing.JTextField m_jVATID; + private javax.swing.JCheckBox m_jVisible; + private javax.swing.JTextField txtAddress; + private javax.swing.JTextField txtAddress2; + private javax.swing.JTextField txtCity; + private javax.swing.JTextField txtCountry; + private javax.swing.JTextField txtCurdate; + private javax.swing.JTextField txtCurdebt; + private javax.swing.JTextField txtEmail; + private javax.swing.JTextField txtFax; + private javax.swing.JTextField txtFirstName; + private javax.swing.JTextField txtLastName; + private javax.swing.JTextField txtMaxdebt; + private javax.swing.JTextField txtPhone; + private javax.swing.JTextField txtPhone2; + private javax.swing.JTextField txtPostal; + private javax.swing.JTextField txtRegion; + private com.alee.laf.button.WebButton webBtnMail; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/ticket/CardInfo.java b/src/main/java/com/unicenta/pos/ticket/CardInfo.java new file mode 100644 index 0000000..e05fa41 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/CardInfo.java @@ -0,0 +1,72 @@ + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.loader.ImageUtils; +import com.unicenta.data.loader.SerializerRead; +import java.awt.image.*; + +public class CardInfo implements IKeyed { + + private static final long serialVersionUID = 1612339444103L; + private String m_sID; + private String m_sCardName; + private double m_Charges; + + /** Creates new CategoryInfo */ + public CardInfo(String id, String name, double charges) { + m_sID = id; + m_sCardName = name; + m_Charges = charges; + } + + @Override + public Object getKey() { + return m_sID; + } + + public void setID(String sID) { + m_sID = sID; + } + + public String getID() { + return m_sID; + } + + public String getName() { + return m_sCardName; + } + + public void setName(String sName) { + m_sCardName = sName; + } + + @Override + public String toString() { + return m_sCardName; + } + + public static SerializerRead getSerializerRead() { + return new SerializerRead() {@Override + public Object readValues(DataRead dr) throws BasicException { + return new CardInfo(dr.getString(1), dr.getString(2), dr.getDouble(3)); + }}; + } + + + /** + * @return the m_Charges + */ + public double getM_Charges() { + return m_Charges; + } + + /** + * @param m_Charges the m_Charges to set + */ + public void setM_Charges(double m_Charges) { + this.m_Charges = m_Charges; + } +} diff --git a/src/main/java/com/unicenta/pos/ticket/CategoryFilter.form b/src/main/java/com/unicenta/pos/ticket/CategoryFilter.form new file mode 100644 index 0000000..b45df9d --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/CategoryFilter.form @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 50]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="1"/> + <EmptySpace min="-2" pref="5" max="-2" attributes="0"/> + <Component id="m_jCategory" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jCategory" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JComboBox" name="m_jCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodcategory" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/ticket/CategoryFilter.java b/src/main/java/com/unicenta/pos/ticket/CategoryFilter.java new file mode 100644 index 0000000..18af4bb --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/CategoryFilter.java @@ -0,0 +1,167 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.reports.ReportEditorCreator; +import java.awt.Component; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public class CategoryFilter extends javax.swing.JPanel implements ReportEditorCreator { + + private SentenceList m_sentcat; + private ComboBoxValModel m_CategoryModel; + + /** Creates new form JQBFProduct */ + public CategoryFilter() { + + initComponents(); + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + m_sentcat = dlSales.getCategoriesList(); + m_CategoryModel = new ComboBoxValModel(); + + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + List catlist = m_sentcat.list(); + catlist.add(0, null); + m_CategoryModel = new ComboBoxValModel(catlist); + m_jCategory.setModel(m_CategoryModel); + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + return new SerializerWriteBasic( + new Datas[] { + Datas.OBJECT, Datas.STRING + } + ); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + return new Object[] { + m_CategoryModel.getSelectedKey() == null + ? QBFCompareEnum.COMP_NONE + : QBFCompareEnum.COMP_EQUALS, + m_CategoryModel.getSelectedKey(), + + QBFCompareEnum.COMP_NONE, null }; + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jCategory = new javax.swing.JComboBox(); + jLabel1 = new javax.swing.JLabel(); + + setPreferredSize(new java.awt.Dimension(400, 50)); + + m_jCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCategory.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.prodcategory")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(150, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(5, 5, 5) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JComboBox m_jCategory; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/ticket/CategoryFilter_1.form b/src/main/java/com/unicenta/pos/ticket/CategoryFilter_1.form new file mode 100644 index 0000000..2245838 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/CategoryFilter_1.form @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 50]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCategory" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCategory" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JComboBox" name="m_jCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodcategory" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/ticket/CategoryFilter_1.java b/src/main/java/com/unicenta/pos/ticket/CategoryFilter_1.java new file mode 100644 index 0000000..42a70b4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/CategoryFilter_1.java @@ -0,0 +1,167 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.reports.ReportEditorCreator; +import java.awt.Component; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public class CategoryFilter_1 extends javax.swing.JPanel implements ReportEditorCreator { + + private SentenceList m_sentcat; + private ComboBoxValModel m_CategoryModel; + + /** Creates new form JQBFProduct */ + public CategoryFilter_1() { + + initComponents(); + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + m_sentcat = dlSales.getCategoriesList_1(); + m_CategoryModel = new ComboBoxValModel(); + + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + List catlist = m_sentcat.list(); + catlist.add(0, null); + m_CategoryModel = new ComboBoxValModel(catlist); + m_jCategory.setModel(m_CategoryModel); + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + return new SerializerWriteBasic( + new Datas[] { + Datas.OBJECT, Datas.STRING + } + ); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + return new Object[] { + m_CategoryModel.getSelectedKey() == null + ? QBFCompareEnum.COMP_NONE + : QBFCompareEnum.COMP_EQUALS, + m_CategoryModel.getSelectedKey(), + + QBFCompareEnum.COMP_NONE, null }; + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jCategory = new javax.swing.JComboBox(); + jLabel1 = new javax.swing.JLabel(); + + setPreferredSize(new java.awt.Dimension(400, 50)); + + m_jCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCategory.setPreferredSize(new java.awt.Dimension(200, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.prodcategory")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(150, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JComboBox m_jCategory; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/ticket/CategoryInfo.java b/src/main/java/com/unicenta/pos/ticket/CategoryInfo.java new file mode 100644 index 0000000..5f990e4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/CategoryInfo.java @@ -0,0 +1,172 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.loader.ImageUtils; +import com.unicenta.data.loader.SerializerRead; +import java.awt.image.*; + +/** + * + * @author Adrian + * @version + */ +public class CategoryInfo implements IKeyed { + + private static final long serialVersionUID = 8612449444103L; + private String m_sID; + private String m_sName; + private String m_sTextTip; + private BufferedImage m_Image; + private Boolean m_bCatShowName; + + /** Creates new CategoryInfo + * @param id + * @param name + * @param image + * @param texttip + * @param catshowname */ + public CategoryInfo(String id, String name, BufferedImage image, String texttip, Boolean catshowname) { + m_sID = id; + m_sName = name; + m_Image = image; + m_sTextTip = texttip; + m_bCatShowName = catshowname; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return m_sID; + } + + /** + * + * @param sID + */ + public void setID(String sID) { + m_sID = sID; + } + + /** + * + * @return + */ + public String getID() { + return m_sID; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + + /** + * + * @param sName + */ + public void setName(String sName) { + m_sName = sName; + } + + + /** + * + * @return + */ + public String getTextTip() { + return m_sTextTip; + } + + /** + * + * @param sName + */ + public void setTextTip(String sName) { + m_sTextTip = sName; + } + + /** + * + * @return + */ + public Boolean getCatShowName() { + return m_bCatShowName; + } + + /** + * + * @param bcatshowname + */ + public void setCatShowName(Boolean bcatshowname) { + m_bCatShowName = bcatshowname; + } + + + + + + // ******************************* + + /** + * + * @return + */ + + public BufferedImage getImage() { + return m_Image; + } + + /** + * + * @param img + */ + public void setImage(BufferedImage img) { + m_Image = img; + } + + @Override + public String toString() { + return m_sName; + } + + /** + * + * @return + */ + public static SerializerRead getSerializerRead() { + return new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + return new CategoryInfo(dr.getString(1), + dr.getString(2), ImageUtils.readImage(dr.getBytes(3)), + dr.getString(4),dr.getBoolean(5)); + }}; + } +} diff --git a/src/main/java/com/unicenta/pos/ticket/FindTicketsInfo.java b/src/main/java/com/unicenta/pos/ticket/FindTicketsInfo.java new file mode 100644 index 0000000..8780f5c --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/FindTicketsInfo.java @@ -0,0 +1,97 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.SerializableRead; +import com.unicenta.format.Formats; +import java.util.Date; + +/** + * + * @author Mikel irurita + */ +public class FindTicketsInfo implements SerializableRead { + + private int ticketid; + private int tickettype; + private Date date; + private String name; + private String customer; + private double total; + private int ticketstatus; + + public FindTicketsInfo() { + + } + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + + ticketid = dr.getInt(1); + tickettype = dr.getInt(2); + date = dr.getTimestamp(3); + name = dr.getString(4); + customer = dr.getString(5); + total = (dr.getObject(6) == null) ? 0.0 : dr.getDouble(6); + ticketstatus = dr.getInt(7); + } + + @Override + public String toString(){ + + String sCustomer = (customer==null) ? "" : customer; + + String sHtml = "<tr><td width=\"75\">"+ "["+ ticketid +"]" +"</td>" + + "<td width=\"75\">"+ Formats.TIMESTAMP.formatValue(date) +"</td>" + + "<td align=\"right\" width=\"100\">"+ Formats.CURRENCY.formatValue(total) +"</td>"+ + "<td align=\"left\" width=\"100\">"+ sCustomer +"</td>" + + "<td align=\"left\" width=\"100\">"+ Formats.STRING.formatValue(name) +"</td></tr>"; + + return sHtml; + } + + /** + * + * @return + */ + public int getTicketId(){ + return this.ticketid; + } + + /** + * + * @return + */ + public int getTicketType(){ + return this.tickettype; + } + + public int getTicketStatus() { + return this.ticketstatus; + } + +} diff --git a/src/main/java/com/unicenta/pos/ticket/FindTicketsRenderer.java b/src/main/java/com/unicenta/pos/ticket/FindTicketsRenderer.java new file mode 100644 index 0000000..03790e8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/FindTicketsRenderer.java @@ -0,0 +1,69 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import java.awt.Component; +import javax.swing.DefaultListCellRenderer; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JList; + +/** + * + * @author Mikel Irurita + */ +public class FindTicketsRenderer extends DefaultListCellRenderer { + + private final Icon icoTicketNormal; + private final Icon icoTicketRefund; + private final Icon icoTicketRefunded; + /** + * + */ + public static final int RECEIPT_NORMAL = 0; + public static final int RECEIPT_REFUND = 1; + + /** Creates a new instance of TicketRenderer */ + public FindTicketsRenderer() { + this.icoTicketNormal = new ImageIcon(getClass().getClassLoader().getResource("com/unicenta/images/pay.png")); + this.icoTicketRefund = new ImageIcon(getClass().getClassLoader().getResource("com/unicenta/images/refundit.png")); + this.icoTicketRefunded = new ImageIcon(getClass().getClassLoader().getResource("com/unicenta/images/cancel.png")); + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, null, index, isSelected, cellHasFocus); + + int ticketType = ((FindTicketsInfo)value).getTicketType(); + int ticketStatus = ((FindTicketsInfo)value).getTicketStatus(); + + setText("<html><table>" + value.toString() +"</table></html>"); + + if (ticketType == RECEIPT_NORMAL) { + setIcon(icoTicketNormal); + } else if (ticketType == RECEIPT_REFUND) { + setIcon(icoTicketRefund); + } else if (ticketType == RECEIPT_NORMAL && ticketStatus > 0) { + setIcon(icoTicketRefunded); + } + + return this; + } +} diff --git a/src/main/java/com/unicenta/pos/ticket/HostInfo.java b/src/main/java/com/unicenta/pos/ticket/HostInfo.java new file mode 100644 index 0000000..bc47a59 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/HostInfo.java @@ -0,0 +1,76 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.loader.SerializerRead; + +public class HostInfo implements IKeyed { + + //MONEY HOST HOSTSEQUENCE DATESTART DATEEND + //private static final long serialVersionUID = 8612449444103L; + private String m_sMoney; + private String m_sHost; + private String m_Hostsequence; + + /** Creates new CategoryInfo + * @param money + * @param host + * @param hostsequence */ + public HostInfo(String money, String host, String hostsequence) { + + m_sMoney = host; // hack to search by hostname + m_sHost = host; + m_Hostsequence = hostsequence; + } + + @Override + public Object getKey() { + return m_sMoney; + } + + public String getHostsequence() { + return m_Hostsequence; + } + + public void setHostsequence(String m_Hostsequence) { + this.m_Hostsequence = m_Hostsequence; + } + + public String getHost() { + return m_sHost; + } + + public void setHost(String m_sHost) { + this.m_sHost = m_sHost; + } + + public String getMoney() { + return m_sMoney; + } + + public void setMoney(String m_sMoney) { + this.m_sMoney = m_sMoney; + } + + @Override + public String toString() { + return m_sHost; + } + + public static SerializerRead getSerializerRead() { + return new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + return new HostInfo(dr.getString(1), dr.getString(2), dr.getString(3)); + } + }; + } +} + diff --git a/src/main/java/com/unicenta/pos/ticket/LocationFilterSales.form b/src/main/java/com/unicenta/pos/ticket/LocationFilterSales.form new file mode 100644 index 0000000..b4baa58 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/LocationFilterSales.form @@ -0,0 +1,242 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[370, 170]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel3" min="-2" pref="110" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> + <Component id="m_jCboPriceSell" min="-2" pref="150" max="-2" attributes="0"/> + <EmptySpace min="10" pref="10" max="-2" attributes="0"/> + <Component id="m_jPriceSell" min="-2" pref="130" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel1" min="-2" pref="110" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> + <Component id="m_jtxtBarCode" min="-2" pref="290" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel5" min="-2" pref="110" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> + <Component id="m_jtxtName" min="-2" pref="290" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel2" min="-2" pref="110" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> + <Component id="m_jCategory" min="-2" pref="260" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel4" min="-2" pref="110" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> + <Component id="m_jCboPriceBuy" min="-2" pref="150" max="-2" attributes="0"/> + <EmptySpace min="10" pref="10" max="-2" attributes="0"/> + <Component id="m_jPriceBuy" min="-2" pref="130" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="32767" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <Component id="m_jtxtBarCode" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <Component id="m_jtxtName" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jCategory" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jCboPriceBuy" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="m_jPriceBuy" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jCboPriceSell" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="m_jPriceSell" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodcategory" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricebuy" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboPriceBuy"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jCboPriceBuyActionPerformed"/> + </Events> + </Component> + <Component class="com.unicenta.editor.JEditorCurrency" name="m_jPriceBuy"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricesell" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboPriceSell"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorCurrency" name="m_jPriceSell"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtBarCode"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbarcode" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/ticket/LocationFilterSales.java b/src/main/java/com/unicenta/pos/ticket/LocationFilterSales.java new file mode 100644 index 0000000..edb1484 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/LocationFilterSales.java @@ -0,0 +1,288 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import java.util.List; +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.ListQBFModelNumber; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.user.EditorCreator; +import com.unicenta.editor.JEditorKeys; +import com.unicenta.editor.JEditorString; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; + +/** + * + * @author JG uniCenta + */ +public class LocationFilterSales extends javax.swing.JPanel implements EditorCreator { + + private SentenceList m_sentcat; + private ComboBoxValModel m_CategoryModel; + + /** Creates new form ProductFilterSales + * @param dlSales + * @param jKeys */ + public LocationFilterSales(DataLogicSales dlSales, JEditorKeys jKeys) { + initComponents(); + + // El modelo de categorias + m_sentcat = dlSales.getCategoriesList(); + m_CategoryModel = new ComboBoxValModel(); + +// m_jCboPriceBuy.setModel(new ListQBFModelNumber()); + m_jCboPriceBuy.setModel(ListQBFModelNumber.getMandatoryNumber()); + m_jPriceBuy.addEditorKeys(jKeys); + +// m_jCboPriceSell.setModel(new ListQBFModelNumber()); + m_jCboPriceSell.setModel(ListQBFModelNumber.getMandatoryNumber()); + m_jPriceSell.addEditorKeys(jKeys); + + m_jtxtName.addEditorKeys(jKeys); + + m_jtxtBarCode.addEditorKeys(jKeys); + } + + /** + * + */ + public void activate() { + + m_jtxtBarCode.reset(); + m_jtxtBarCode.setEditModeEnum(JEditorString.MODE_123); + m_jtxtName.reset(); + m_jPriceBuy.reset(); + m_jPriceSell.reset(); + m_jtxtName.activate(); + + try { + List catlist = m_sentcat.list(); + catlist.add(0, null); + m_CategoryModel = new ComboBoxValModel(catlist); + m_jCategory.setModel(m_CategoryModel); + } catch (BasicException eD) { + // no hay validacion + } + } + + /** + * + * @return + * @throws BasicException + */ + public Object createValue() throws BasicException { + + Object[] afilter = new Object[10]; + + // Nombre + if (m_jtxtName.getText() == null || m_jtxtName.getText().equals("")) { + afilter[0] = QBFCompareEnum.COMP_NONE; + afilter[1] = null; + } else { + afilter[0] = QBFCompareEnum.COMP_RE; + afilter[1] = "%" + m_jtxtName.getText() + "%"; + } + + // Precio de compra + afilter[3] = m_jPriceBuy.getDoubleValue(); + afilter[2] = afilter[3] == null ? QBFCompareEnum.COMP_NONE : m_jCboPriceBuy.getSelectedItem(); + + // Precio de venta + afilter[5] = m_jPriceSell.getDoubleValue(); + afilter[4] = afilter[5] == null ? QBFCompareEnum.COMP_NONE : m_jCboPriceSell.getSelectedItem(); + + // Categoria + if (m_CategoryModel.getSelectedKey() == null) { + afilter[6] = QBFCompareEnum.COMP_NONE; + afilter[7] = null; + } else { + afilter[6] = QBFCompareEnum.COMP_EQUALS; + afilter[7] = m_CategoryModel.getSelectedKey(); + } + + // el codigo de barras + if (m_jtxtBarCode.getText() == null || m_jtxtBarCode.getText().equals("")) { + afilter[8] = QBFCompareEnum.COMP_NONE; + afilter[9] = null; + } else{ + afilter[8] = QBFCompareEnum.COMP_RE; + afilter[9] = "%" + m_jtxtBarCode.getText() + "%"; + } + + return afilter; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel5 = new javax.swing.JLabel(); + m_jtxtName = new com.unicenta.editor.JEditorString(); + jLabel2 = new javax.swing.JLabel(); + m_jCategory = new javax.swing.JComboBox(); + jLabel4 = new javax.swing.JLabel(); + m_jCboPriceBuy = new javax.swing.JComboBox(); + m_jPriceBuy = new com.unicenta.editor.JEditorCurrency(); + jLabel3 = new javax.swing.JLabel(); + m_jCboPriceSell = new javax.swing.JComboBox(); + m_jPriceSell = new com.unicenta.editor.JEditorCurrency(); + m_jtxtBarCode = new com.unicenta.editor.JEditorString(); + jLabel1 = new javax.swing.JLabel(); + + setPreferredSize(new java.awt.Dimension(370, 170)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.prodname")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jtxtName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtName.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.prodcategory")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCategory.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.prodpricebuy")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jCboPriceBuy.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboPriceBuy.setPreferredSize(new java.awt.Dimension(0, 30)); + m_jCboPriceBuy.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jCboPriceBuyActionPerformed(evt); + } + }); + + m_jPriceBuy.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceBuy.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.prodpricesell")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jCboPriceSell.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboPriceSell.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jPriceSell.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceSell.setPreferredSize(new java.awt.Dimension(0, 30)); + + m_jtxtBarCode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtBarCode.setMaximumSize(new java.awt.Dimension(100, 25)); + m_jtxtBarCode.setPreferredSize(new java.awt.Dimension(0, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.prodbarcode")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(0, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(10, 10, 10) + .addComponent(m_jCboPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(10, 10, 10) + .addComponent(m_jPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(10, 10, 10) + .addComponent(m_jtxtBarCode, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(10, 10, 10) + .addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(10, 10, 10) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(10, 10, 10) + .addComponent(m_jCboPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(10, 10, 10) + .addComponent(m_jPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtBarCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(5, 5, 5) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(5, 5, 5) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(5, 5, 5) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jCboPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(5, 5, 5) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jCboPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + ); + }// </editor-fold>//GEN-END:initComponents + + private void m_jCboPriceBuyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jCboPriceBuyActionPerformed + + }//GEN-LAST:event_m_jCboPriceBuyActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JComboBox m_jCategory; + private javax.swing.JComboBox m_jCboPriceBuy; + private javax.swing.JComboBox m_jCboPriceSell; + private com.unicenta.editor.JEditorCurrency m_jPriceBuy; + private com.unicenta.editor.JEditorCurrency m_jPriceSell; + private com.unicenta.editor.JEditorString m_jtxtBarCode; + private com.unicenta.editor.JEditorString m_jtxtName; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/ticket/ProductFilter.form b/src/main/java/com/unicenta/pos/ticket/ProductFilter.form new file mode 100644 index 0000000..09bc099 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductFilter.form @@ -0,0 +1,265 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[976, 125]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCategory" min="-2" max="-2" attributes="1"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jBarcode" max="32767" attributes="0"/> + <EmptySpace min="-2" pref="2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel2" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCboName" max="32767" attributes="1"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel4" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCboPriceBuy" min="-2" max="-2" attributes="2"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jPriceBuy" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCboPriceSell" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jPriceSell" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="m_jName" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jBtnReset" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace pref="189" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="2" attributes="0"> + <Component id="jLabel1" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jCategory" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jLabel4" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jCboPriceBuy" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jPriceBuy" alignment="2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="2" attributes="0"> + <Component id="jLabel5" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jBarcode" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jCboPriceSell" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jPriceSell" alignment="2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="2" attributes="0"> + <Component id="jLabel2" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jCboName" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace pref="12" max="32767" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="32767" attributes="0"/> + <Component id="jBtnReset" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodcategory" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbarcode" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jBarcode"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[330, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricebuy" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboPriceBuy"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jPriceBuy"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricesell" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboPriceSell"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jPriceSell"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jBtnReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnResetActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/ticket/ProductFilter.java b/src/main/java/com/unicenta/pos/ticket/ProductFilter.java new file mode 100644 index 0000000..3f9119b --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductFilter.java @@ -0,0 +1,318 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.ListQBFModelNumber; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.reports.ReportEditorCreator; +import java.awt.Component; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public class ProductFilter extends javax.swing.JPanel implements ReportEditorCreator { + + private SentenceList m_sentcat; + private ComboBoxValModel m_CategoryModel; + +// private SentenceList m_sentsup; +// private ComboBoxValModel m_SupplierModel; + + /** Creates new form JQBFProduct */ + public ProductFilter() { + + initComponents(); + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + m_sentcat = dlSales.getCategoriesList(); + m_CategoryModel = new ComboBoxValModel(); + + m_jCboName.setModel(ListQBFModelNumber.getMandatoryString()); + m_jCboPriceBuy.setModel(ListQBFModelNumber.getMandatoryNumber()); + m_jCboPriceSell.setModel(ListQBFModelNumber.getMandatoryNumber()); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + List catlist = m_sentcat.list(); + catlist.add(0, null); + m_CategoryModel = new ComboBoxValModel(catlist); + m_jCategory.setModel(m_CategoryModel); + + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + return new SerializerWriteBasic( + new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING}); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + if (m_jBarcode.getText() == null || m_jBarcode.getText().equals("")) { + + return new Object[] { + m_jCboName.getSelectedItem(), m_jName.getText(), + m_jCboPriceBuy.getSelectedItem(), Formats.CURRENCY.parseValue(m_jPriceBuy.getText()), + m_jCboPriceSell.getSelectedItem(), Formats.CURRENCY.parseValue(m_jPriceSell.getText()), + m_CategoryModel.getSelectedKey() == null ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_EQUALS, m_CategoryModel.getSelectedKey(), +// m_SupplierModel.getSelectedKey() == null ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_EQUALS, m_SupplierModel.getSelectedKey(), + QBFCompareEnum.COMP_NONE, null + }; + } else { + return new Object[] { + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_EQUALS, m_jBarcode.getText() + }; + } + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + m_jCategory = new javax.swing.JComboBox(); + jLabel5 = new javax.swing.JLabel(); + m_jBarcode = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + m_jCboName = new javax.swing.JComboBox(); + m_jName = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + m_jCboPriceBuy = new javax.swing.JComboBox(); + m_jPriceBuy = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + m_jCboPriceSell = new javax.swing.JComboBox(); + m_jPriceSell = new javax.swing.JTextField(); + jBtnReset = new javax.swing.JButton(); + + setPreferredSize(new java.awt.Dimension(976, 125)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.prodcategory")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCategory.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.prodbarcode")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jBarcode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jBarcode.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.prodname")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jCboName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboName.setPreferredSize(new java.awt.Dimension(250, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(330, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.prodpricebuy")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jCboPriceBuy.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboPriceBuy.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jPriceBuy.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceBuy.setPreferredSize(new java.awt.Dimension(60, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.prodpricesell")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jCboPriceSell.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboPriceSell.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jPriceSell.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceSell.setPreferredSize(new java.awt.Dimension(60, 30)); + + jBtnReset.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jBtnReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jBtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnResetActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jBarcode, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(2, 2, 2)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCboName, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCboPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCboPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jBtnReset))) + .addContainerGap(189, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCboPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCboPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCboName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(12, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jBtnReset) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jBtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnResetActionPerformed + m_jBarcode.setText(null); + m_jCategory.setSelectedIndex(0); + m_jCboName.setSelectedIndex(0); + m_jCboPriceBuy.setSelectedIndex(0); + m_jCboPriceSell.setSelectedIndex(0); + m_jName.setText(null); + m_jPriceBuy.setText(null); + m_jPriceSell.setText(null); + }//GEN-LAST:event_jBtnResetActionPerformed + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jBtnReset; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JTextField m_jBarcode; + private javax.swing.JComboBox m_jCategory; + private javax.swing.JComboBox m_jCboName; + private javax.swing.JComboBox m_jCboPriceBuy; + private javax.swing.JComboBox m_jCboPriceSell; + private javax.swing.JTextField m_jName; + private javax.swing.JTextField m_jPriceBuy; + private javax.swing.JTextField m_jPriceSell; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/ticket/ProductFilter1.form b/src/main/java/com/unicenta/pos/ticket/ProductFilter1.form new file mode 100644 index 0000000..e02df0d --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductFilter1.form @@ -0,0 +1,204 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[946, 50]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCboName" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jName" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCategory" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel5" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jBarcode" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel3" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCboUnits" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jUnits" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jBtnReset" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jBtnReset" min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCboName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCategory" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jBarcode" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCboUnits" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jUnits" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JTextField" name="m_jBarcode"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbarcode" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodcategory" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.produnits" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboUnits"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jUnits"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[50, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jBtnReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnResetActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/ticket/ProductFilter1.java b/src/main/java/com/unicenta/pos/ticket/ProductFilter1.java new file mode 100644 index 0000000..5a55ee9 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductFilter1.java @@ -0,0 +1,269 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.ListQBFModelNumber; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.reports.ReportEditorCreator; +import java.awt.Component; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public class ProductFilter1 extends javax.swing.JPanel implements ReportEditorCreator { + + private SentenceList m_sentcat; + private ComboBoxValModel m_CategoryModel; + + /** Creates new form JQBFProduct */ + public ProductFilter1() { + + initComponents(); + } + + /** + * + * @param app + */ + public void init(AppView app) { + + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + m_sentcat = dlSales.getCategoriesList(); + m_CategoryModel = new ComboBoxValModel(); + m_jCboName.setModel(ListQBFModelNumber.getMandatoryString()); + m_jCboUnits.setModel(ListQBFModelNumber.getMandatoryString()); + + } + + /** + * + * @throws BasicException + */ + public void activate() throws BasicException { + + List catlist = m_sentcat.list(); + catlist.add(0, null); + m_CategoryModel = new ComboBoxValModel(catlist); + m_jCategory.setModel(m_CategoryModel); + } + + /** + * + * @return + */ + public SerializerWrite getSerializerWrite() { + return new SerializerWriteBasic( + new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING}); + } + + /** + * + * @return + */ + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + public Object createValue() throws BasicException { + + if (m_jBarcode.getText() == null || m_jBarcode.getText().equals("")) { + + return new Object[] { + m_jCboName.getSelectedItem(), m_jName.getText(), + m_CategoryModel.getSelectedKey() == null + ? QBFCompareEnum.COMP_NONE + : QBFCompareEnum.COMP_EQUALS, m_CategoryModel.getSelectedKey(), + QBFCompareEnum.COMP_NONE, null, + m_jCboUnits.getSelectedItem(), m_jUnits.getText() + }; + } else { + // Filtro por codigo de barras. + return new Object[] { + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_RE, "%" + m_jBarcode.getText() + "%", + QBFCompareEnum.COMP_NONE, null + }; + } + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jBarcode = new javax.swing.JTextField(); + jLabel5 = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + m_jCategory = new javax.swing.JComboBox(); + m_jCboName = new javax.swing.JComboBox(); + m_jName = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + m_jCboUnits = new javax.swing.JComboBox(); + m_jUnits = new javax.swing.JTextField(); + jBtnReset = new javax.swing.JButton(); + + setPreferredSize(new java.awt.Dimension(946, 50)); + + m_jBarcode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jBarcode.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.prodbarcode")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(70, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.prodcategory")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(70, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.prodname")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(70, 30)); + + m_jCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCategory.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jCboName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboName.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.produnits")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(50, 30)); + + m_jCboUnits.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboUnits.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jUnits.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jUnits.setPreferredSize(new java.awt.Dimension(50, 30)); + + jBtnReset.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jBtnReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jBtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnResetActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCboName, 0, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jBarcode, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCboUnits, 0, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jUnits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jBtnReset) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jBtnReset) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCboName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCboUnits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jUnits, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jBtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnResetActionPerformed + m_jBarcode.setText(null); + m_jCategory.setSelectedIndex(0); + m_jCboName.setSelectedIndex(0); + m_jCboUnits.setSelectedIndex(0); + m_jName.setText(null); + m_jUnits.setText(null); + }//GEN-LAST:event_jBtnResetActionPerformed + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jBtnReset; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel5; + private javax.swing.JTextField m_jBarcode; + private javax.swing.JComboBox m_jCategory; + private javax.swing.JComboBox m_jCboName; + private javax.swing.JComboBox m_jCboUnits; + private javax.swing.JTextField m_jName; + private javax.swing.JTextField m_jUnits; + // End of variables declaration//GEN-END:variables + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/ticket/ProductFilter2.form b/src/main/java/com/unicenta/pos/ticket/ProductFilter2.form new file mode 100644 index 0000000..93a40cd --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductFilter2.form @@ -0,0 +1,278 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[976, 100]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel1" min="-2" pref="66" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCategory" min="-2" pref="46" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel4" min="-2" pref="74" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCboPriceBuy" min="-2" pref="36" max="-2" attributes="2"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jPriceBuy" min="-2" pref="50" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel3" min="-2" pref="50" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCboPriceSell" min="-2" pref="42" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jPriceSell" min="-2" pref="36" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Component id="jLabel2" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCboName" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jName" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jBarcode" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jBtnReset" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="2" attributes="0"> + <Component id="jBtnReset" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="m_jBarcode" alignment="2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCboPriceBuy" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jPriceBuy" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCboPriceSell" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jPriceSell" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCategory" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <Group type="102" attributes="0"> + <EmptySpace min="12" pref="12" max="-2" attributes="0"/> + <Component id="m_jName" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace min="11" pref="11" max="-2" attributes="0"/> + <Component id="m_jCboName" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace min="11" pref="11" max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace min="11" pref="11" max="-2" attributes="0"/> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JTextField" name="m_jBarcode"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbarcode" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodcategory" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricebuy" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricesell" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboPriceBuy"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboPriceSell"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jPriceBuy"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jPriceSell"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jBtnReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnResetActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/ticket/ProductFilter2.java b/src/main/java/com/unicenta/pos/ticket/ProductFilter2.java new file mode 100644 index 0000000..a703195 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductFilter2.java @@ -0,0 +1,321 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.ListQBFModelNumber; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.reports.ReportEditorCreator; +import java.awt.Component; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public class ProductFilter2 extends javax.swing.JPanel implements ReportEditorCreator { + + private SentenceList m_sentcat; + private ComboBoxValModel m_CategoryModel; + + /** Creates new form JQBFProduct */ + public ProductFilter2() { + + initComponents(); + } + + /** + * + * @param app + */ + public void init(AppView app) { + + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + m_sentcat = dlSales.getCategoriesList(); + m_CategoryModel = new ComboBoxValModel(); + + m_jCboName.setModel(ListQBFModelNumber.getMandatoryString()); + m_jCboPriceBuy.setModel(ListQBFModelNumber.getMandatoryNumber()); + m_jCboPriceSell.setModel(ListQBFModelNumber.getMandatoryNumber()); + } + + /** + * + * @throws BasicException + */ + public void activate() throws BasicException { + + List catlist = m_sentcat.list(); + catlist.add(0, null); + m_CategoryModel = new ComboBoxValModel(catlist); + m_jCategory.setModel(m_CategoryModel); + } + + /** + * + * @return + */ + public SerializerWrite getSerializerWrite() { + return new SerializerWriteBasic( + new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING}); + } + + /** + * + * @return + */ + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + public Object createValue() throws BasicException { + + if (m_jBarcode.getText() == null || m_jBarcode.getText().equals("")) { + + return new Object[] { + m_jCboName.getSelectedItem(), m_jName.getText(), + m_jCboPriceBuy.getSelectedItem(), Formats.CURRENCY.parseValue(m_jPriceBuy.getText()), + m_jCboPriceSell.getSelectedItem(), Formats.CURRENCY.parseValue(m_jPriceSell.getText()), + m_CategoryModel.getSelectedKey() == null ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_EQUALS, m_CategoryModel.getSelectedKey(), + QBFCompareEnum.COMP_NONE, null + }; + } else { + // Filtro por codigo de barras. + return new Object[] { + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_EQUALS, m_jBarcode.getText() + }; + } + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jBarcode = new javax.swing.JTextField(); + jLabel5 = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + m_jCategory = new javax.swing.JComboBox(); + m_jCboName = new javax.swing.JComboBox(); + m_jName = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + m_jCboPriceBuy = new javax.swing.JComboBox(); + m_jCboPriceSell = new javax.swing.JComboBox(); + m_jPriceBuy = new javax.swing.JTextField(); + m_jPriceSell = new javax.swing.JTextField(); + jBtnReset = new javax.swing.JButton(); + + setPreferredSize(new java.awt.Dimension(976, 100)); + + m_jBarcode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jBarcode.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.prodbarcode")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.prodcategory")); // NOI18N + jLabel1.setEnabled(false); + jLabel1.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.prodname")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCategory.setEnabled(false); + m_jCategory.setPreferredSize(new java.awt.Dimension(250, 30)); + + m_jCboName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboName.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.prodpricebuy")); // NOI18N + jLabel4.setEnabled(false); + jLabel4.setPreferredSize(new java.awt.Dimension(110, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.prodpricesell")); // NOI18N + jLabel3.setEnabled(false); + jLabel3.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jCboPriceBuy.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboPriceBuy.setEnabled(false); + m_jCboPriceBuy.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jCboPriceSell.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboPriceSell.setEnabled(false); + m_jCboPriceSell.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jPriceBuy.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceBuy.setEnabled(false); + m_jPriceBuy.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jPriceSell.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceSell.setEnabled(false); + m_jPriceSell.setPreferredSize(new java.awt.Dimension(150, 30)); + + jBtnReset.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jBtnReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jBtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnResetActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCboPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCboPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCboName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jBtnReset) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jBtnReset) + .addComponent(m_jBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCboPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCboPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGroup(layout.createSequentialGroup() + .addGap(12, 12, 12) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGap(11, 11, 11) + .addComponent(m_jCboName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGap(11, 11, 11) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGap(11, 11, 11) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jBtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnResetActionPerformed + m_jBarcode.setText(null); + m_jCategory.setSelectedIndex(0); + m_jCboName.setSelectedIndex(0); + m_jCboPriceBuy.setSelectedIndex(0); + m_jCboPriceSell.setSelectedIndex(0); + m_jName.setText(null); + m_jPriceBuy.setText(null); + m_jPriceSell.setText(null); + }//GEN-LAST:event_jBtnResetActionPerformed + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jBtnReset; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JTextField m_jBarcode; + private javax.swing.JComboBox m_jCategory; + private javax.swing.JComboBox m_jCboName; + private javax.swing.JComboBox m_jCboPriceBuy; + private javax.swing.JComboBox m_jCboPriceSell; + private javax.swing.JTextField m_jName; + private javax.swing.JTextField m_jPriceBuy; + private javax.swing.JTextField m_jPriceSell; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/ticket/ProductFilter3.form b/src/main/java/com/unicenta/pos/ticket/ProductFilter3.form new file mode 100644 index 0000000..0c28f17 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductFilter3.form @@ -0,0 +1,291 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[976, 100]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" max="-2" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <Component id="jLabel2" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCboName" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jName" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCategory" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel6" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jSupplier" min="-2" max="-2" attributes="1"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jBarcode" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="jLabel4" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCboPriceBuy" min="-2" max="-2" attributes="2"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jPriceBuy" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel3" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCboPriceSell" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jPriceSell" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="jBtnReset" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="59" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jBtnReset" min="-2" max="-2" attributes="0"/> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jSupplier" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCboName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCategory" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="3" attributes="0"> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jBarcode" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCboPriceBuy" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jPriceBuy" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCboPriceSell" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jPriceSell" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JTextField" name="m_jBarcode"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbarcode" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodcategory" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricebuy" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricesell" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboPriceBuy"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboPriceSell"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jPriceBuy"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jPriceSell"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodsupplier" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jSupplier"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jBtnReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnResetActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/ticket/ProductFilter3.java b/src/main/java/com/unicenta/pos/ticket/ProductFilter3.java new file mode 100644 index 0000000..64cc9c8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductFilter3.java @@ -0,0 +1,344 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.ListQBFModelNumber; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.reports.ReportEditorCreator; +import com.unicenta.pos.suppliers.DataLogicSuppliers; +import java.awt.Component; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public class ProductFilter3 extends javax.swing.JPanel implements ReportEditorCreator { + + private SentenceList m_sentcat; + private ComboBoxValModel m_CategoryModel; + + private SentenceList m_sentsup; + private ComboBoxValModel m_SupplierModel; + + /** Creates new form JQBFProduct */ + public ProductFilter3() { + + initComponents(); + } + + /** + * + * @param app + */ + @Override + public void init(AppView app) { + + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + DataLogicSuppliers dlSuppliers = (DataLogicSuppliers) app.getBean("com.unicenta.pos.suppliers.DataLogicSuppliers"); + + m_sentcat = dlSales.getCategoriesList(); + m_CategoryModel = new ComboBoxValModel(); + + m_sentsup = dlSuppliers.getSupplierList(); + m_SupplierModel = new ComboBoxValModel(); + + m_jCboName.setModel(ListQBFModelNumber.getMandatoryString()); + m_jCboPriceBuy.setModel(ListQBFModelNumber.getMandatoryNumber()); + m_jCboPriceSell.setModel(ListQBFModelNumber.getMandatoryNumber()); + } + + /** + * + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + + List catlist = m_sentcat.list(); + catlist.add(0, null); + m_CategoryModel = new ComboBoxValModel(catlist); + m_jCategory.setModel(m_CategoryModel); + + List suplist = m_sentsup.list(); + suplist.add(0, null); + m_SupplierModel = new ComboBoxValModel(suplist); + m_jSupplier.setModel(m_SupplierModel); + } + + /** + * + * @return + */ + @Override + public SerializerWrite getSerializerWrite() { + return new SerializerWriteBasic( + new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.DOUBLE, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING}); + } + + /** + * + * @return + */ + @Override + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + @Override + public Object createValue() throws BasicException { + + if (m_jBarcode.getText() == null || m_jBarcode.getText().equals("")) { + + return new Object[] { + m_jCboName.getSelectedItem(), m_jName.getText(), + m_jCboPriceBuy.getSelectedItem(), Formats.CURRENCY.parseValue(m_jPriceBuy.getText()), + m_jCboPriceSell.getSelectedItem(), Formats.CURRENCY.parseValue(m_jPriceSell.getText()), + m_CategoryModel.getSelectedKey() == null ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_EQUALS, m_CategoryModel.getSelectedKey(), + m_SupplierModel.getSelectedKey() == null ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_EQUALS, m_SupplierModel.getSelectedKey(), + QBFCompareEnum.COMP_NONE, null + }; + } else { + return new Object[] { + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_EQUALS, m_jBarcode.getText() + }; + } + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jBarcode = new javax.swing.JTextField(); + jLabel5 = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + m_jCategory = new javax.swing.JComboBox(); + m_jCboName = new javax.swing.JComboBox(); + m_jName = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + m_jCboPriceBuy = new javax.swing.JComboBox(); + m_jCboPriceSell = new javax.swing.JComboBox(); + m_jPriceBuy = new javax.swing.JTextField(); + m_jPriceSell = new javax.swing.JTextField(); + jLabel6 = new javax.swing.JLabel(); + m_jSupplier = new javax.swing.JComboBox(); + jBtnReset = new javax.swing.JButton(); + + setPreferredSize(new java.awt.Dimension(976, 100)); + + m_jBarcode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jBarcode.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.prodbarcode")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.prodcategory")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.prodname")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCategory.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jCboName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboName.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.prodpricebuy")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.prodpricesell")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jCboPriceBuy.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboPriceBuy.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jCboPriceSell.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboPriceSell.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jPriceBuy.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceBuy.setPreferredSize(new java.awt.Dimension(60, 30)); + + m_jPriceSell.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceSell.setPreferredSize(new java.awt.Dimension(60, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel6.setText(AppLocal.getIntString("label.prodsupplier")); // NOI18N + jLabel6.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jSupplier.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jSupplier.setPreferredSize(new java.awt.Dimension(150, 30)); + + jBtnReset.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jBtnReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jBtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnResetActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCboName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jSupplier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCboPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCboPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jBtnReset) + .addContainerGap(59, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jBtnReset) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jSupplier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCboName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCboPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCboPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jBtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnResetActionPerformed + m_jBarcode.setText(null); + m_jCategory.setSelectedIndex(0); + m_jCboName.setSelectedIndex(0); + m_jCboPriceBuy.setSelectedIndex(0); + m_jCboPriceSell.setSelectedIndex(0); + m_jName.setText(null); + m_jPriceBuy.setText(null); + m_jPriceSell.setText(null); + }//GEN-LAST:event_jBtnResetActionPerformed + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jBtnReset; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JTextField m_jBarcode; + private javax.swing.JComboBox m_jCategory; + private javax.swing.JComboBox m_jCboName; + private javax.swing.JComboBox m_jCboPriceBuy; + private javax.swing.JComboBox m_jCboPriceSell; + private javax.swing.JTextField m_jName; + private javax.swing.JTextField m_jPriceBuy; + private javax.swing.JTextField m_jPriceSell; + private javax.swing.JComboBox m_jSupplier; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/ticket/ProductFilter4.form b/src/main/java/com/unicenta/pos/ticket/ProductFilter4.form new file mode 100644 index 0000000..d686077 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductFilter4.form @@ -0,0 +1,160 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[946, 50]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCboName" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jName" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCategory" min="-2" max="-2" attributes="1"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel5" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jBarcode" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jBtnReset" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jBtnReset" min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCboName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jName" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCategory" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jBarcode" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JTextField" name="m_jBarcode"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbarcode" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodcategory" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jBtnReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnResetActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/ticket/ProductFilter4.java b/src/main/java/com/unicenta/pos/ticket/ProductFilter4.java new file mode 100644 index 0000000..288a8e8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductFilter4.java @@ -0,0 +1,236 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.ListQBFModelNumber; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.loader.SerializerWrite; +import com.unicenta.data.loader.SerializerWriteBasic; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSales; +import com.unicenta.pos.reports.ReportEditorCreator; +import java.awt.Component; +import java.util.List; + +/** + * + * @author JG uniCenta + */ +public class ProductFilter4 extends javax.swing.JPanel implements ReportEditorCreator { + + private SentenceList m_sentcat; + private ComboBoxValModel m_CategoryModel; + + /** Creates new form JQBFProduct */ + public ProductFilter4() { + + initComponents(); + } + + /** + * + * @param app + */ + public void init(AppView app) { + + DataLogicSales dlSales = (DataLogicSales) app.getBean("com.unicenta.pos.forms.DataLogicSales"); + + m_sentcat = dlSales.getCategoriesList(); + m_CategoryModel = new ComboBoxValModel(); + m_jCboName.setModel(ListQBFModelNumber.getMandatoryString()); + } + + /** + * + * @throws BasicException + */ + public void activate() throws BasicException { + + List catlist = m_sentcat.list(); + catlist.add(0, null); + m_CategoryModel = new ComboBoxValModel(catlist); + m_jCategory.setModel(m_CategoryModel); + } + + /** + * + * @return + */ + public SerializerWrite getSerializerWrite() { + return new SerializerWriteBasic( + new Datas[] { + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING, + Datas.OBJECT, Datas.STRING}); + } + + /** + * + * @return + */ + public Component getComponent() { + return this; + } + + /** + * + * @return + * @throws BasicException + */ + public Object createValue() throws BasicException { + + if (m_jBarcode.getText() == null || m_jBarcode.getText().equals("")) { + + return new Object[] { + m_jCboName.getSelectedItem(), m_jName.getText(), + m_CategoryModel.getSelectedKey() == null + ? QBFCompareEnum.COMP_NONE + : QBFCompareEnum.COMP_EQUALS, m_CategoryModel.getSelectedKey(), + QBFCompareEnum.COMP_NONE, null + }; + } else { + // Filtro por codigo de barras. + return new Object[] { + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_NONE, null, + QBFCompareEnum.COMP_RE, "%" + m_jBarcode.getText() + "%" + }; + } + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + m_jBarcode = new javax.swing.JTextField(); + jLabel5 = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + m_jCategory = new javax.swing.JComboBox(); + m_jCboName = new javax.swing.JComboBox(); + m_jName = new javax.swing.JTextField(); + jBtnReset = new javax.swing.JButton(); + + setPreferredSize(new java.awt.Dimension(946, 50)); + + m_jBarcode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jBarcode.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.prodbarcode")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.prodcategory")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.prodname")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCategory.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jCboName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboName.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jName.setPreferredSize(new java.awt.Dimension(150, 30)); + + jBtnReset.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jBtnReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jBtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnResetActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCboName, 0, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jBarcode, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jBtnReset) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jBtnReset) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCboName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void jBtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnResetActionPerformed + m_jBarcode.setText(null); + m_jCategory.setSelectedIndex(0); + m_jCboName.setSelectedIndex(0); + m_jName.setText(null); + }//GEN-LAST:event_jBtnResetActionPerformed + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jBtnReset; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel5; + private javax.swing.JTextField m_jBarcode; + private javax.swing.JComboBox m_jCategory; + private javax.swing.JComboBox m_jCboName; + private javax.swing.JTextField m_jName; + // End of variables declaration//GEN-END:variables + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/ticket/ProductFilterSales.form b/src/main/java/com/unicenta/pos/ticket/ProductFilterSales.form new file mode 100644 index 0000000..bd1c51b --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductFilterSales.form @@ -0,0 +1,276 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[410, 200]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jtxtBarCode" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jBtnReset" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="41" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCategory" min="-2" pref="240" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jtxtName" min="-2" pref="270" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="64" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCboPriceBuy" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jPriceBuy" pref="0" max="32767" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jCboPriceSell" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="m_jPriceSell" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="10" pref="10" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <Component id="m_jtxtBarCode" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jBtnReset" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="3" max="-2" attributes="0"/> + <Component id="m_jtxtName" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="m_jCategory" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCboPriceBuy" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="m_jPriceBuy" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="5" pref="5" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCboPriceSell" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="m_jPriceSell" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodname" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtName"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodcategory" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCategory"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricebuy" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboPriceBuy"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="m_jCboPriceBuyActionPerformed"/> + </Events> + </Component> + <Component class="com.unicenta.editor.JEditorCurrency" name="m_jPriceBuy"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodpricesell" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="m_jCboPriceSell"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorCurrency" name="m_jPriceSell"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.unicenta.editor.JEditorString" name="m_jtxtBarCode"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 25]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[230, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.prodbarcode" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jBtnReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnResetActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/ticket/ProductFilterSales.java b/src/main/java/com/unicenta/pos/ticket/ProductFilterSales.java new file mode 100644 index 0000000..d7da5ad --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductFilterSales.java @@ -0,0 +1,322 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import java.util.List; +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.gui.ListQBFModelNumber; +import com.unicenta.data.loader.QBFCompareEnum; +import com.unicenta.data.loader.SentenceList; +import com.unicenta.data.user.EditorCreator; +import com.unicenta.editor.JEditorKeys; +import com.unicenta.editor.JEditorString; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.DataLogicSales; + +/** + * + * @author JG uniCenta + */ +public class ProductFilterSales extends javax.swing.JPanel implements EditorCreator { + + private SentenceList m_sentcat; + private ComboBoxValModel m_CategoryModel; + + /** Creates new form ProductFilterSales + * @param dlSales + * @param jKeys */ + public ProductFilterSales(DataLogicSales dlSales, JEditorKeys jKeys) { + initComponents(); + + // El modelo de categorias + m_sentcat = dlSales.getCategoriesList(); + m_CategoryModel = new ComboBoxValModel(); + +// m_jCboPriceBuy.setModel(new ListQBFModelNumber()); + m_jCboPriceBuy.setModel(ListQBFModelNumber.getMandatoryNumber()); + m_jPriceBuy.addEditorKeys(jKeys); + +// m_jCboPriceSell.setModel(new ListQBFModelNumber()); + m_jCboPriceSell.setModel(ListQBFModelNumber.getMandatoryNumber()); + m_jPriceSell.addEditorKeys(jKeys); + + m_jtxtName.addEditorKeys(jKeys); + + m_jtxtBarCode.addEditorKeys(jKeys); + } + + /** + * + */ + public void activate() { + + m_jtxtBarCode.reset(); + m_jtxtBarCode.setEditModeEnum(JEditorString.MODE_123); + m_jtxtName.reset(); + m_jPriceBuy.reset(); + m_jPriceSell.reset(); + m_jtxtName.activate(); + + try { + List catlist = m_sentcat.list(); + catlist.add(0, null); + m_CategoryModel = new ComboBoxValModel(catlist); + m_jCategory.setModel(m_CategoryModel); + } catch (BasicException eD) { + // no hay validacion + } + } + + /** + * + * @return + * @throws BasicException + */ + public Object createValue() throws BasicException { + + Object[] afilter = new Object[10]; + + // Nombre + if (m_jtxtName.getText() == null || m_jtxtName.getText().equals("")) { + afilter[0] = QBFCompareEnum.COMP_NONE; + afilter[1] = null; + } else { + afilter[0] = QBFCompareEnum.COMP_RE; + afilter[1] = "%" + m_jtxtName.getText() + "%"; + } + + // Precio de compra + afilter[3] = m_jPriceBuy.getDoubleValue(); + afilter[2] = afilter[3] == null ? QBFCompareEnum.COMP_NONE : m_jCboPriceBuy.getSelectedItem(); + + // Precio de venta + afilter[5] = m_jPriceSell.getDoubleValue(); + afilter[4] = afilter[5] == null ? QBFCompareEnum.COMP_NONE : m_jCboPriceSell.getSelectedItem(); + + // Categoria + if (m_CategoryModel.getSelectedKey() == null) { + afilter[6] = QBFCompareEnum.COMP_NONE; + afilter[7] = null; + } else { + afilter[6] = QBFCompareEnum.COMP_EQUALS; + afilter[7] = m_CategoryModel.getSelectedKey(); + } + + // el codigo de barras + if (m_jtxtBarCode.getText() == null || m_jtxtBarCode.getText().equals("")) { + afilter[8] = QBFCompareEnum.COMP_NONE; + afilter[9] = null; + } else{ + afilter[8] = QBFCompareEnum.COMP_RE; + afilter[9] = "%" + m_jtxtBarCode.getText() + "%"; + } + + return afilter; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel5 = new javax.swing.JLabel(); + m_jtxtName = new com.unicenta.editor.JEditorString(); + jLabel2 = new javax.swing.JLabel(); + m_jCategory = new javax.swing.JComboBox(); + jLabel4 = new javax.swing.JLabel(); + m_jCboPriceBuy = new javax.swing.JComboBox(); + m_jPriceBuy = new com.unicenta.editor.JEditorCurrency(); + jLabel3 = new javax.swing.JLabel(); + m_jCboPriceSell = new javax.swing.JComboBox(); + m_jPriceSell = new com.unicenta.editor.JEditorCurrency(); + m_jtxtBarCode = new com.unicenta.editor.JEditorString(); + jLabel1 = new javax.swing.JLabel(); + jBtnReset = new javax.swing.JButton(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setPreferredSize(new java.awt.Dimension(410, 200)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.prodname")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jtxtName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtName.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.prodcategory")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jCategory.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCategory.setPreferredSize(new java.awt.Dimension(250, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setText(AppLocal.getIntString("label.prodpricebuy")); // NOI18N + jLabel4.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jCboPriceBuy.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboPriceBuy.setPreferredSize(new java.awt.Dimension(150, 30)); + m_jCboPriceBuy.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + m_jCboPriceBuyActionPerformed(evt); + } + }); + + m_jPriceBuy.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceBuy.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.prodpricesell")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(110, 30)); + + m_jCboPriceSell.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCboPriceSell.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jPriceSell.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jPriceSell.setPreferredSize(new java.awt.Dimension(150, 30)); + + m_jtxtBarCode.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jtxtBarCode.setMaximumSize(new java.awt.Dimension(100, 25)); + m_jtxtBarCode.setPreferredSize(new java.awt.Dimension(230, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setText(AppLocal.getIntString("label.prodbarcode")); // NOI18N + jLabel1.setPreferredSize(new java.awt.Dimension(110, 30)); + + jBtnReset.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jBtnReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jBtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBtnResetActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(10, 10, 10) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jtxtBarCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jBtnReset) + .addGap(41, 41, 41)) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(64, 64, 64))) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCboPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jCboPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(m_jPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))) + .addContainerGap()))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(10, 10, 10) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jtxtBarCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jBtnReset) + .addGap(3, 3, 3) + .addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCategory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(5, 5, 5) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCboPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jPriceBuy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(5, 5, 5) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCboPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(m_jPriceSell, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + }// </editor-fold>//GEN-END:initComponents + + private void m_jCboPriceBuyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_m_jCboPriceBuyActionPerformed + + }//GEN-LAST:event_m_jCboPriceBuyActionPerformed + + private void jBtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnResetActionPerformed + m_jtxtBarCode.setText(null); + m_jCategory.setSelectedIndex(0); + m_jCboPriceBuy.setSelectedIndex(0); + m_jCboPriceSell.setSelectedIndex(0); + m_jtxtName.setText(null); + m_jPriceBuy.setDoubleValue(null); + m_jPriceSell.setDoubleValue(null); + }//GEN-LAST:event_jBtnResetActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jBtnReset; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JComboBox m_jCategory; + private javax.swing.JComboBox m_jCboPriceBuy; + private javax.swing.JComboBox m_jCboPriceSell; + private com.unicenta.editor.JEditorCurrency m_jPriceBuy; + private com.unicenta.editor.JEditorCurrency m_jPriceSell; + private com.unicenta.editor.JEditorString m_jtxtBarCode; + private com.unicenta.editor.JEditorString m_jtxtName; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/ticket/ProductInfo.java b/src/main/java/com/unicenta/pos/ticket/ProductInfo.java new file mode 100644 index 0000000..6011ce9 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductInfo.java @@ -0,0 +1,124 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.loader.SerializerRead; + +/** + * + * @author Jack + * @version + */ +public class ProductInfo implements IKeyed { + + private static final long serialVersionUID = 8712449444103L; + private String m_sID; + private String m_sRef; + private String m_sCode; + private String m_sName; + + /** Creates new ProductInfo + * @param id + * @param ref + * @param code + * @param name */ + public ProductInfo(String id, String ref, String code, String name) { + m_sID = id; + m_sRef = ref; + m_sCode = code; + m_sName = name; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return m_sID; + } + + /** + * + * @param sID + */ + public void setID(String sID) { + m_sID = sID; + } + public String getID() { + return m_sID; + } + + /** + * + * @return + */ + public String getRef() { + return m_sRef; + } + public void setRef(String sRef) { + m_sRef = sRef; + } + + + /** + * + * @return + */ + public String getCode() { + return m_sCode; + } + public void setCode(String sCode) { + m_sCode = sCode; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + public void setName(String sName) { + m_sName = sName; + } + + + @Override + public String toString() { + return m_sName; + } + + /** + * + * @return + */ + public static SerializerRead getSerializerRead() { + return new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + return new ProductInfo(dr.getString(1), dr.getString(2), + dr.getString(3), dr.getString(4)); + }}; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/ticket/ProductInfoEdit.java b/src/main/java/com/unicenta/pos/ticket/ProductInfoEdit.java new file mode 100644 index 0000000..c44edf3 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductInfoEdit.java @@ -0,0 +1,207 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import java.awt.image.BufferedImage; +import java.util.Properties; + +/** + * + * @author adrianromero + * Created on 21 de marzo de 2007, 21:28 + * + */ +public class ProductInfoEdit { + + /** + * + */ + protected String m_ID; + protected String m_sRef; + protected String m_sCode; + protected String m_sCodeType; + protected String m_sName; + protected double m_dPriceBuy; + protected double m_dPriceSell; + protected String m_sCategoryID; + protected String m_sTaxID; + protected String attributeuseid; + protected Double m_dStockCost; + protected Double m_dStockVolume; + protected BufferedImage m_Image; + protected boolean m_bCom; + protected boolean m_bScale; + protected boolean m_bKitchen; + protected boolean m_bPrintKB; + protected boolean m_bSendStatus; + protected boolean m_bService; + protected Properties attributes; + protected String m_sDisplay; + protected boolean m_bVprice; + protected boolean m_bVerpatrib; + protected String m_sTextTip; + protected boolean m_bWarranty; + protected double m_dStockUnits; + + protected Integer m_iCatalogOrder; + + protected String m_sSupplierID; + protected String m_sUomID; + + protected String m_sDatePick; + + + /** Creates a new instance of ProductInfoEdit */ + public ProductInfoEdit() { + m_ID = null; + m_sRef = "0000"; + m_sCode = "0000"; + m_sCodeType = null; + m_sName = null; + m_dPriceBuy = 0.0; + m_dPriceSell = 0.0; + m_sCategoryID = null; + m_sTaxID = null; + attributeuseid = null; + m_dStockCost = null; + m_dStockVolume = null; + m_Image = null; + m_bCom = false; + m_bScale = false; + m_bKitchen = false; + m_bPrintKB = false; + m_bSendStatus = false; + m_bService = false; + attributes = new Properties(); + m_sDisplay = null; + m_bVprice = false; + m_bVerpatrib = false; + m_sTextTip = null; + m_bWarranty = false; + m_dStockUnits = 0.0; + + m_iCatalogOrder = null; + + m_sSupplierID = null; + m_sUomID= null; + + m_sDatePick=null; + } + + /** + * + * @return + */ + public final String getID() { + return m_ID; + } + public final void setID(String id) { + m_ID = id; + } + + public final String getReference(){ + return m_sRef; + } + public final void setReference(String sRef){ + m_sRef = sRef; + } + + public final String getCode(){ + return m_sCode; + } + public final void setCode(String sCode){ + m_sCode = sCode; + } + + public final String getName() { + return m_sName; + } + public final void setName(String sName){ + m_sName = sName; + } + + public final boolean isCom() { + return m_bCom; + } + public final void setCom(boolean bValue){ + m_bCom = bValue; + } + + public final boolean isScale() { + return m_bScale; + } + public final void setScale(boolean bValue){ + m_bScale = bValue; + } + + public final String getCategoryID() { + return m_sCategoryID; + } + public final void setCategoryID(String sCategoryID) { + m_sCategoryID = sCategoryID; + } + + public final String getTaxID() { + return m_sTaxID; + } + public final void setTaxID(String sTaxID) { + m_sTaxID = sTaxID; + } + + public final String getAttributeUseID() { + return attributeuseid; + } + public final void setAttributeUseID(String value) { + attributeuseid = value; + } + + public final double getPriceBuy(){ + return m_dPriceBuy; + } + public final void setPriceBuy(double dPrice) { + m_dPriceBuy = dPrice; + } + + public final double getPriceSell(){ + return m_dPriceSell; + } + public final void setPriceSell(double dPrice) { + m_dPriceSell = dPrice; + } + + public BufferedImage getImage() { + return m_Image; + } + public void setImage(BufferedImage img) { + m_Image = img; + } + + @Override + public final String toString() { + return m_sRef + " - " + m_sName; + } + + public final String getDatePick(){ + return m_sDatePick; + } + public final void setDatePick(String sDatePick){ + m_sDatePick = sDatePick; + } +} diff --git a/src/main/java/com/unicenta/pos/ticket/ProductInfoExt.java b/src/main/java/com/unicenta/pos/ticket/ProductInfoExt.java new file mode 100644 index 0000000..dedcbe3 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductInfoExt.java @@ -0,0 +1,384 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.ImageUtils; +import com.unicenta.data.loader.SerializerRead; +import java.util.Properties; +import com.unicenta.format.Formats; +import java.awt.image.BufferedImage; +import java.util.Date; + +/** + * + * @author adrianromero + * + */ +public class ProductInfoExt { + + private static final long serialVersionUID = 7587696873036L; + + protected String m_ID; + protected String m_sRef; + protected String m_sCode; + protected String m_sCodetype; + protected String m_sName; + protected double m_dPriceBuy; + protected double m_dPriceSell; + protected String categoryid; + protected String taxcategoryid; + protected String attributesetid; + protected double m_stockCost; + protected double m_stockVolume; + protected BufferedImage m_Image; + protected boolean m_bCom; + protected boolean m_bScale; + protected boolean m_bConstant; + protected boolean m_bPrintKB; + protected boolean m_bSendStatus; + private boolean m_bService; + protected Properties attributes; + protected String m_sDisplay; + protected boolean m_bVprice; + protected boolean m_bVerpatrib; + protected String m_sTextTip; + protected boolean m_bWarranty; + public double m_dStockUnits; + public String m_sPrinter; + public String supplierid; + private String uomid; + protected String memodate; + + public ProductInfoExt() { + m_ID = null; + m_sRef = "0000"; + m_sCode = "0000"; + m_sCodetype = null; + m_sName = null; + m_dPriceBuy = 0.0; + m_dPriceSell = 0.0; + categoryid = null; + taxcategoryid = null; + attributesetid = null; + m_stockCost = 0.0; + m_stockVolume = 0.0; + m_Image = null; + m_bCom = false; + m_bScale = false; + m_bConstant = false; + m_bPrintKB = false; + m_bSendStatus = false; + m_bService = false; + attributes = new Properties(); + m_sDisplay = null; + m_bVprice = false; + m_bVerpatrib = false; + m_sTextTip = null; + m_bWarranty = false; + m_dStockUnits = 0.0; + m_sPrinter = null; + supplierid = "0"; + uomid = "0"; + memodate = null; + } + + /** + * + * @return + */ + public final String getID() { + return m_ID; + } + public final void setID(String id) { + m_ID = id; + } + + public final String getReference() { + return m_sRef; + } + public final void setReference(String sRef) { + m_sRef = sRef; + } + + public final String getCode() { + return m_sCode; + } + public final void setCode(String sCode) { + m_sCode = sCode; + } + + public final String getCodetype() { + return m_sCodetype; + } + public final void setCodetype(String sCodetype) { + m_sCodetype = sCodetype; + } + + public final String getName() { + return m_sName; + } + public final void setName(String sName) { + m_sName = sName; + } + + public final double getPriceBuy() { + return m_dPriceBuy; + } + public final void setPriceBuy(double dPrice) { + m_dPriceBuy = dPrice; + } + + public final double getPriceSell() { + return m_dPriceSell; + } + public final void setPriceSell(double dPrice) { + m_dPriceSell = dPrice; + } + + public final String getCategoryID() { + return categoryid; + } + public final void setCategoryID(String sCategoryID) { + categoryid = sCategoryID; + } + + public final String getTaxCategoryID() { + return taxcategoryid; + } + public final void setTaxCategoryID(String value) { + taxcategoryid = value; + } + + public final String getAttributeSetID() { + return attributesetid; + } + public final void setAttributeSetID(String value) { + attributesetid = value; + } + + public final double getStockCost() { + return m_stockCost; + } + public final void setStockCost(double dPrice) { + m_stockCost = dPrice; + } + + public final double getStockVolume() { + return m_stockVolume; + } + public final void setStockVolume(double dStockVolume) { + m_stockVolume = dStockVolume; + } + + public BufferedImage getImage() { + return m_Image; + } + public void setImage(BufferedImage img) { + m_Image = img; + } + + public final boolean isCom() { + return m_bCom; + } + public final void setCom(boolean bValue) { + m_bCom = bValue; + } + + public final boolean isScale() { + return m_bScale; + } + public final void setScale(boolean bValue) { + m_bScale = bValue; + } + + public final boolean isConstant() { + return m_bConstant; + } + public final void setConstant(boolean bValue) { + m_bConstant = bValue; + } + + public final boolean isPrintKB() { + return m_bPrintKB; + } + public final void setPrintKB(boolean bValue) { + m_bPrintKB = bValue; + } + + public final boolean isSendStatus() { + return m_bSendStatus; + } + public final void setSendStatus(boolean bValue) { + m_bSendStatus = bValue; + } + + public final boolean isService() { + return m_bService; + } + public final void setService(boolean bValue) { + m_bService = bValue; + } + + public String getProperty(String key) { + return attributes.getProperty(key); + } + public String getProperty(String key, String defaultvalue) { + return attributes.getProperty(key, defaultvalue); + } + public void setProperty(String key, String value) { + attributes.setProperty(key, value); + } + public Properties getProperties() { + return attributes; + } + + public final String getDisplay() { + return m_sDisplay; + } + public final void setDisplay(String sDisplay) { + m_sDisplay = sDisplay; + } + + public final boolean isVprice() { + return m_bVprice; + } + + public final boolean isVerpatrib() { + return m_bVerpatrib; + } + + public final String getTextTip() { + return m_sTextTip; + } + public final void setTextTip(String value) { + m_sTextTip = value; + } + + public final boolean getWarranty() { + return m_bWarranty; + } + public final void setWarranty(boolean bValue) { + m_bWarranty = bValue; + } + + public final Double getStockUnits() { + return m_dStockUnits; + } + public final void setStockUnits(double dStockUnits) { + m_dStockUnits = dStockUnits; + } + + public String printPriceSell() { + return Formats.CURRENCY.formatValue(getPriceSell()); + } + + public final double getPriceSellTax(TaxInfo tax) { + return m_dPriceSell * (1.0 + tax.getRate()); + } + public String printPriceSellTax(TaxInfo tax) { + return Formats.CURRENCY.formatValue(getPriceSellTax(tax)); + } + + public final String getPrinter() { + return m_sPrinter; + } + public final void setPrinter(String value) { + m_sPrinter = value; + } + + public final String getSupplierID() { + return supplierid; + } + public final void setSupplierID(String sSupplierID) { + supplierid = sSupplierID; + } + + public final String getUomID() { + return uomid; + } + public final void setUomID(String sUomID) { + uomid = sUomID; + } + + /** + * + * @return memo date string + */ + public String getMemoDate() { + return memodate; + } + public void setMemoDate(String memodate) { + this.memodate = memodate; + } + public String printMemoDate() { + return Formats.STRING.formatValue(memodate); + } + + /** + * + * @return + */ + public static SerializerRead getSerializerRead() { + return new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + ProductInfoExt product = new ProductInfoExt(); + product.m_ID = dr.getString(1); + product.m_sRef = dr.getString(2); + product.m_sCode = dr.getString(3); + product.m_sCodetype = dr.getString(4); + product.m_sName = dr.getString(5); + product.m_dPriceBuy = dr.getDouble(6); + product.m_dPriceSell = dr.getDouble(7); + product.categoryid = dr.getString(8); + product.taxcategoryid = dr.getString(9); + product.attributesetid = dr.getString(10); + product.m_stockCost = dr.getDouble(11); + product.m_stockVolume = dr.getDouble(12); + product.m_Image = ImageUtils.readImage(dr.getBytes(13)); + product.m_bCom = dr.getBoolean(14); + product.m_bScale = dr.getBoolean(15); + product.m_bConstant = dr.getBoolean(16); + product.m_bPrintKB = dr.getBoolean(17); + product.m_bSendStatus = dr.getBoolean(18); + product.m_bService = dr.getBoolean(19); + product.attributes = ImageUtils.readProperties(dr.getBytes(20)); + product.m_sDisplay = dr.getString(21); + product.m_bVprice = dr.getBoolean(22); + product.m_bVerpatrib = dr.getBoolean(23); + product.m_sTextTip = dr.getString(24); + product.m_bWarranty = dr.getBoolean(25); + product.m_dStockUnits = dr.getDouble(26); + product.m_sPrinter = dr.getString(27); + product.supplierid = dr.getString(28); + product.uomid = dr.getString(29); + product.memodate = dr.getString(30); + + return product; + } + }; + } + + @Override + public final String toString() { + return m_sRef + " - " + m_sName; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/ticket/ProductRenderer.java b/src/main/java/com/unicenta/pos/ticket/ProductRenderer.java new file mode 100644 index 0000000..f231534 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductRenderer.java @@ -0,0 +1,64 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.format.Formats; +import com.unicenta.pos.util.ThumbNailBuilder; +import java.awt.*; +import javax.swing.*; + +/** + * + * @author uniCenta 2017 + * + */ +public class ProductRenderer extends DefaultListCellRenderer { + + ThumbNailBuilder tnbprod; + + /** Creates a new instance of ProductRenderer */ + public ProductRenderer() { +// tnbprod = new ThumbNailBuilder(48,48, "com/unicenta/images/package.png"); + tnbprod = new ThumbNailBuilder(48,48, "com/unicenta/images/null.png"); + + + } + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, null, index, isSelected, cellHasFocus); + + ProductInfoExt prod = (ProductInfoExt) value; + + if (prod != null) { + + setText("<html><center>" + + prod.getReference() + + " - " + + prod.getName() + " - " + Formats.CURRENCY.formatValue(prod.getPriceSell()) +// + "<br>" + prod.getStockUnits() + " | " + Formats.DATE.formatValue(prod.getMemoDate()) + " | " + prod.getPriceSellTax(tax) + ); + + Image img = tnbprod.getThumbNail(prod.getImage()); + setIcon(img == null ? null :new ImageIcon(img)); + } + return this; + } +} diff --git a/src/main/java/com/unicenta/pos/ticket/ProductVectorer.java b/src/main/java/com/unicenta/pos/ticket/ProductVectorer.java new file mode 100644 index 0000000..b3c722c --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProductVectorer.java @@ -0,0 +1,69 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.format.Formats; +import com.unicenta.data.loader.Vectorer; +import com.unicenta.basic.BasicException; +import com.unicenta.pos.forms.AppLocal; +/** + * + * @author adrian + */ +public class ProductVectorer implements Vectorer { + + private static String[] m_sHeaders = { + AppLocal.getIntString("label.prodref"), + AppLocal.getIntString("label.prodbarcode"), + AppLocal.getIntString("label.prodname"), + AppLocal.getIntString("label.prodpricebuy"), + AppLocal.getIntString("label.prodpricesell") + }; + + /** Creates a new instance of ProductVectorer */ + public ProductVectorer() { + } + + /** + * + * @return + * @throws BasicException + */ + public String[] getHeaders() throws BasicException { + return m_sHeaders; + } + + /** + * + * @param obj + * @return + * @throws BasicException + */ + public String[] getValues(Object obj) throws BasicException { + ProductInfoExt myprod = (ProductInfoExt) obj; + String[] m_sValues = new String[5]; + m_sValues[0] = Formats.STRING.formatValue(myprod.getReference()); + m_sValues[1] = Formats.STRING.formatValue(myprod.getCode()); + m_sValues[2] = Formats.STRING.formatValue(myprod.getName()); + m_sValues[3] = Formats.CURRENCY.formatValue(new Double(myprod.getPriceBuy())); + m_sValues[4] = Formats.CURRENCY.formatValue(new Double(myprod.getPriceSell())); + return m_sValues; + } +} diff --git a/src/main/java/com/unicenta/pos/ticket/ProviderInfo.java b/src/main/java/com/unicenta/pos/ticket/ProviderInfo.java new file mode 100644 index 0000000..0495641 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/ProviderInfo.java @@ -0,0 +1,72 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +/** + * + * @author JG uniCenta + */ +public class ProviderInfo { + + private int m_iProviderID; + private String m_sName; + + /** Creates new Provider */ + public ProviderInfo() { + m_iProviderID = 0; + m_sName = ""; + } + + /** + * + * @return + */ + public int getProviderID() { + return m_iProviderID; + } + + /** + * + * @param iProviderID + */ + public void setProviderID(int iProviderID) { + m_iProviderID = iProviderID; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } + + /** + * + * @param sName + */ + public void setName(String sName) { + m_sName = sName; + } + + public String toString(){ + return m_sName; + } +} diff --git a/src/main/java/com/unicenta/pos/ticket/SalesDetailInfo.java b/src/main/java/com/unicenta/pos/ticket/SalesDetailInfo.java new file mode 100644 index 0000000..ce63426 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/SalesDetailInfo.java @@ -0,0 +1,130 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +//***************************************************************************** + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.loader.SerializerRead; +import com.unicenta.format.Formats; + +/** + * + * @author Adrian + * @version + */ +public class SalesDetailInfo implements IKeyed { + + private static final long serialVersionUID = 8612449444103L; + private String productName; + private int lineNO; + + /** + * + * @return + */ + public int getLineNO() { + return lineNO; + } + + /** + * + * @param lineNO + */ + public void setLineNO(int lineNO) { + this.lineNO = lineNO; + } + + /** + * + * @return + */ + public double getPrice() { + return price; + } + + /** + * + * @return + */ + public String printPrice() { + return Formats.CURRENCY.formatValue(price); + } + + /** + * + * @param price + */ + public void setPrice(double price) { + this.price = price; + } + + /** + * + * @return + */ + public String getProductName() { + return productName; + } + + /** + * + * @param productName + */ + public void setProductName(String productName) { + this.productName = productName; + } + private double price; + + /** Creates new CategoryInfo + * @param lineNo + * @param productName + * @param price */ + public SalesDetailInfo(int lineNo, String productName, double price) { + this.lineNO = lineNo; + this.productName = productName; + this.price = price; + } + + /** + * + * @return + */ + public static SerializerRead getSerializerRead() { + return new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + return new SalesDetailInfo( + dr.getInt(1), + dr.getString(2), + dr.getDouble(3)); + }}; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return getLineNO(); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/ticket/SalesDetailInfo_1.java b/src/main/java/com/unicenta/pos/ticket/SalesDetailInfo_1.java new file mode 100644 index 0000000..145fdd2 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/SalesDetailInfo_1.java @@ -0,0 +1,129 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +//***************************************************************************** + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.loader.SerializerRead; +import com.unicenta.format.Formats; + +/** + * + * @author Adrian + * @version + */ +public class SalesDetailInfo_1 implements IKeyed { + + private static final long serialVersionUID = 8612449444103L; + private String productName; + private int lineNO; + + /** + * + * @return + */ + public int getLineNO() { + return lineNO; + } + + /** + * + * @param lineNO + */ + public void setLineNO(int lineNO) { + this.lineNO = lineNO; + } + + /** + * + * @return + */ + public double getPrice() { + return price; + } + + /** + * + * @return + */ + public String printPrice() { + return Formats.CURRENCY.formatValue(price); + } + + /** + * + * @param price + */ + public void setPrice(double price) { + this.price = price; + } + + /** + * + * @return + */ + public String getProductName() { + return productName; + } + + /** + * + * @param productName + */ + public void setProductName(String productName) { + this.productName = productName; + } + private double price; + + /** Creates new CategoryInfo + * @param lineNo + * @param productName + * @param price */ + public SalesDetailInfo_1(int lineNo, String productName, double price) { + this.lineNO = lineNo; + this.productName = productName; + this.price = price; + } + + /** + * + * @return + */ + public static SerializerRead getSerializerRead() { + return new SerializerRead() {@Override + public Object readValues(DataRead dr) throws BasicException { + return new SalesDetailInfo( + dr.getInt(1), + dr.getString(2), + dr.getDouble(3)); + }}; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return getLineNO(); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/ticket/Signumprovider.java b/src/main/java/com/unicenta/pos/ticket/Signumprovider.java new file mode 100644 index 0000000..0d164fd --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/Signumprovider.java @@ -0,0 +1,68 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import java.util.*; + +/** + * + * @author JG uniCenta + */ +public class Signumprovider { + + private Set m_positives = new HashSet(); + private Set m_negatives = new HashSet(); + + /** Creates a new instance of Signumprovider */ + public Signumprovider() { + } + + /** + * + * @param key + */ + public void addPositive(Object key) { + m_positives.add(key); + } + + /** + * + * @param key + */ + public void addNegative(Object key) { + m_negatives.add(key); + } + + /** + * + * @param key + * @param value + * @return + */ + public Double correctSignum(Object key, Double value) { + if (m_positives.contains(key)) { + return value.doubleValue() < 0.0 ? new Double(-value.doubleValue()) : value; + } else if (m_negatives.contains(key)) { + return value.doubleValue() > 0.0 ? new Double(-value.doubleValue()) : value; + } else { + return value; + } + } +} diff --git a/src/main/java/com/unicenta/pos/ticket/TaxInfo.java b/src/main/java/com/unicenta/pos/ticket/TaxInfo.java new file mode 100644 index 0000000..c34b198 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/TaxInfo.java @@ -0,0 +1,213 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.data.loader.IKeyed; +import java.io.Serializable; + +/** + * + * @author adrianromero + */ +public class TaxInfo implements Serializable, IKeyed { + + private static final long serialVersionUID = -2705212098856473043L; + private String id; + private String name; + private String taxcategoryid; // Product + private String taxcustcategoryid; // Customer + private String parentid; + + private double rate; + private boolean cascade; + private Integer order; + + /** Creates new TaxInfo + * @param id + * @param name + * @param taxcategoryid + * @param taxcustcategoryid + * @param rate + * @param cascade + * @param parentid + * @param order */ + public TaxInfo(String id, String name, String taxcategoryid, String taxcustcategoryid, + String parentid, double rate, boolean cascade, Integer order) { + this.id = id; + this.name = name; + this.taxcategoryid = taxcategoryid; + this.taxcustcategoryid = taxcustcategoryid; + this.parentid = parentid; + + this.rate = rate; + this.cascade = cascade; + this.order = order; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return id; + } + + /** + * + * @param value + */ + public void setID(String value) { + id = value; + } + + /** + * + * @return + */ + public String getId() { + return id; + } + + /** + * + * @return + */ + public String getName() { + return name; + } + + /** + * + * @param value + */ + public void setName(String value) { + name = value; + } + + /** + * The Product's + * @return + */ + public String getTaxCategoryID() { + return taxcategoryid; + } + + /** + * + * @param value + */ + public void setTaxCategoryID(String value) { + taxcategoryid = value; + } + + /** + * The Customer + * @return + */ + public String getTaxCustCategoryID() { + return taxcustcategoryid; + } + + /** + * + * @param value + */ + public void setTaxCustCategoryID(String value) { + taxcustcategoryid = value; + } + + /** + * + * @return + */ + public String getParentID() { + return parentid; + } + + /** + * + * @param value + */ + public void setParentID(String value) { + parentid = value; + } + + /** + * + * @return + */ + public double getRate() { + return rate; + } + + /** + * + * @param value + */ + public void setRate(double value) { + rate = value; + } + + /** + * + * @return + */ + public boolean isCascade() { + return cascade; + } + + /** + * + * @param value + */ + public void setCascade(boolean value) { + cascade = value; + } + + /** + * + * @return + */ + public Integer getOrder() { + return order; + } + + /** + * + * @return + */ + public Integer getApplicationOrder() { + return order == null ? Integer.MAX_VALUE : order.intValue(); + } + + /** + * + * @param value + */ + public void setOrder(Integer value) { + order = value; + } + + @Override + public String toString(){ + return name; + } +} diff --git a/src/main/java/com/unicenta/pos/ticket/TicketInfo.java b/src/main/java/com/unicenta/pos/ticket/TicketInfo.java new file mode 100644 index 0000000..9d1b984 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/TicketInfo.java @@ -0,0 +1,773 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.LocalRes; +import com.unicenta.data.loader.SerializableRead; +import com.unicenta.format.Formats; +import com.unicenta.pos.customers.CustomerInfoExt; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.payment.PaymentInfo; +import com.unicenta.pos.payment.PaymentInfoMagcard; +import com.unicenta.pos.payment.PaymentInfoTicket; +import com.unicenta.pos.util.StringUtils; +import java.io.*; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * + * @author adrianromero + */ +public final class TicketInfo implements SerializableRead, Externalizable { + + private static final long serialVersionUID = 2765650092387265178L; + + public static final int RECEIPT_NORMAL = 0; + public static final int RECEIPT_REFUND = 1; + public static final int RECEIPT_PAYMENT = 2; + public static final int RECEIPT_NOSALE = 3; + +// JG Jun 2017 - contain partial/full refunds + public static final int REFUND_NOT = 0; // is a non-refunded ticket + public static final int REFUND_PARTIAL = 1; + public static final int REFUND_ALL = 2; + + private static final DateFormat m_dateformat = new SimpleDateFormat("hh:mm"); + + private String m_sHost; + private String m_sId; + private int tickettype; + private int m_iTicketId; + private int m_iPickupId; + private java.util.Date m_dDate; + private Properties attributes; + private UserInfo m_User; + private Double multiply; + private CustomerInfoExt m_Customer; + private String m_sActiveCash; + private List<TicketLineInfo> m_aLines; + private List<PaymentInfo> payments; + private List<TicketTaxInfo> taxes; + private final String m_sResponse; + private String loyaltyCardNumber; + private Boolean oldTicket; + private boolean tip; + private PaymentInfoTicket m_paymentInfo; + private boolean m_isProcessed; + private final String m_locked; + private Double nsum; + private int ticketstatus; + + private static String Hostname; + + public static void setHostname(String name) { + Hostname=name; + } + + public static String getHostname() { + return Hostname; + } + + /** Creates new TicketModel */ + public TicketInfo() { + m_sId = UUID.randomUUID().toString(); + tickettype = RECEIPT_NORMAL; + m_iTicketId = 0; // incrementamos + m_dDate = new Date(); + attributes = new Properties(); + m_User = null; + m_Customer = null; + m_sActiveCash = null; + m_aLines = new ArrayList<>(); + payments = new ArrayList<>(); + taxes = null; + m_sResponse = null; + oldTicket=false; + + AppConfig config = new AppConfig(new File(new File( + System.getProperty("user.home")), AppLocal.APP_ID + ".properties")); + config.load(); + tip = Boolean.valueOf(config.getProperty("machine.showTip")); + m_isProcessed = false; + m_locked = null; + ticketstatus = 0; + } + + @Override + public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(m_sId); + out.writeInt(tickettype); + out.writeInt(m_iTicketId); + out.writeObject(m_Customer); + out.writeObject(m_dDate); + out.writeObject(attributes); + out.writeObject(m_aLines); + + out.writeInt(ticketstatus); + } + + @Override + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + m_sId = (String) in.readObject(); + tickettype = in.readInt(); + m_iTicketId = in.readInt(); + m_Customer = (CustomerInfoExt) in.readObject(); + m_dDate = (Date) in.readObject(); + attributes = (Properties) in.readObject(); + m_aLines = (List<TicketLineInfo>) in.readObject(); + m_User = null; + m_sActiveCash = null; + payments = new ArrayList<>(); // JG June 2102 diamond inference + taxes = null; + + ticketstatus = in.readInt(); + } + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_sId = dr.getString(1); + tickettype = dr.getInt(2); + m_iTicketId = dr.getInt(3); + m_dDate = dr.getTimestamp(4); + m_sActiveCash = dr.getString(5); + try { + byte[] img = dr.getBytes(6); + if (img != null) { + attributes.loadFromXML(new ByteArrayInputStream(img)); + } + } catch (IOException e) { + } + m_User = new UserInfo(dr.getString(7), dr.getString(8)); + m_Customer = new CustomerInfoExt(dr.getString(9)); + m_aLines = new ArrayList<>(); + payments = new ArrayList<>(); + taxes = null; + + ticketstatus = dr.getInt(10); + } + + /** + * + * @return + */ + public TicketInfo copyTicket() { + TicketInfo t = new TicketInfo(); + + t.tickettype = tickettype; + t.m_iTicketId = m_iTicketId; + t.m_dDate = m_dDate; + t.m_sActiveCash = m_sActiveCash; + t.attributes = (Properties) attributes.clone(); + t.m_User = m_User; + t.m_Customer = m_Customer; + + t.m_aLines = new ArrayList<>(); // JG June 2102 diamond inference + m_aLines.forEach((l) -> { + t.m_aLines.add(l.copyTicketLine()); + }); + t.refreshLines(); + + t.payments = new LinkedList<>(); // JG June 2102 diamond inference + payments.forEach((p) -> { + t.payments.add(p.copyPayment()); + }); + t.oldTicket=oldTicket; + // taxes are not copied, must be calculated again. + + t.ticketstatus = ticketstatus; + + return t; + } + + public String getId() { + return m_sId; + } + + public int getTicketType() { + return tickettype; + } + public void setTicketType(int tickettype) { + this.tickettype = tickettype; + } + + public int getTicketId() { + return m_iTicketId; + } + public void setTicketId(int iTicketId) { + m_iTicketId = iTicketId; + } + + public int getTicketStatus() { + return ticketstatus; + } + public void setTicketStatus(int ticketstatus) { + if (m_iTicketId >0) { + this.ticketstatus = m_iTicketId; + }else{ + this.ticketstatus = ticketstatus; + } + } + + public void setPickupId(int iTicketId) { + m_iPickupId = iTicketId; + } + + public int getPickupId() { + return m_iPickupId; + } + + public String getName(Object info) { +// JG Aug 2014 - Add User info + List<String> name = new ArrayList<>(); + + String nameprop = getProperty("name"); + if (nameprop != null) { + name.add(nameprop); + } + + if (m_User != null) { + name.add(m_User.getName()); + } + + if (info == null) { + if (m_iTicketId == 0) { + name.add("(" + m_dateformat.format(m_dDate) + " " + + Long.toString(m_dDate.getTime() % 1000) + ")"); + } else { + name.add(Integer.toString(m_iTicketId)); + } + } else { + name.add(info.toString()); + } + + if (m_Customer != null) { + name.add(m_Customer.getName()); + } + + return org.apache.commons.lang.StringUtils.join(name, " - "); + } + + public String getName() { + return getName(null); + } + + public java.util.Date getDate() { + return m_dDate; + } + + public void setDate(java.util.Date dDate) { + m_dDate = dDate; + } + + public String getHost() { + AppConfig m_config_host = new AppConfig(new File((System.getProperty("user.home")), + AppLocal.APP_ID + ".properties")); + m_config_host.load(); + String machineHostname =(m_config_host.getProperty("machine.hostname")); + m_config_host = null; + return machineHostname; + } + + public UserInfo getUser() { + return m_User; + } + + public void setUser(UserInfo value) { + m_User = value; + } + + public CustomerInfoExt getCustomer() { + return m_Customer; + } + + public void setCustomer(CustomerInfoExt value) { + m_Customer = value; + } + + public String getCustomerId() { + if (m_Customer == null) { + return null; + } else { + return m_Customer.getId(); + } + } + + public String getTransactionID(){ + return (getPayments().size()>0) + ? ( getPayments().get(getPayments().size()-1) ).getTransactionID() + : StringUtils.getCardNumber(); //random transaction ID + } + + public String getReturnMessage(){ + return ( (getPayments().get(getPayments().size()-1)) instanceof PaymentInfoMagcard ) + ? ((PaymentInfoMagcard)(getPayments().get(getPayments().size()-1))).getReturnMessage() + : LocalRes.getIntString("button.OK"); + } + + public void setActiveCash(String value) { + m_sActiveCash = value; + } + + public String getActiveCash() { + return m_sActiveCash; + } + + public String getProperty(String key) { + return attributes.getProperty(key); + } + + public String getProperty(String key, String defaultvalue) { + return attributes.getProperty(key, defaultvalue); + } + + public void setProperty(String key, String value) { + attributes.setProperty(key, value); + } + + public Properties getProperties() { + return attributes; + } + + public TicketLineInfo getLine(int index) { + return m_aLines.get(index); + } + + public void addLine(TicketLineInfo oLine) { + oLine.setTicket(m_sId, m_aLines.size()); + m_aLines.add(oLine); + } + + public void insertLine(int index, TicketLineInfo oLine) { + m_aLines.add(index, oLine); + refreshLines(); + } + + public void setLine(int index, TicketLineInfo oLine) { + oLine.setTicket(m_sId, index); + m_aLines.set(index, oLine); + } + + public void removeLine(int index) { + m_aLines.remove(index); + refreshLines(); + + } + + public void refreshLines() { + for (int i = 0; i < m_aLines.size(); i++) { + getLine(i).setTicket(m_sId, i); + } + } + + public int getLinesCount() { + return m_aLines.size(); + } + + public double getArticlesCount() { + double dArticles = 0.0; + TicketLineInfo oLine; + + for (Iterator<TicketLineInfo> i = m_aLines.iterator(); i.hasNext();) { + oLine = i.next(); + dArticles += oLine.getMultiply(); + } + + return dArticles; + } + + public double getSubTotal() { + double sum = 0.0; + sum = m_aLines.stream().map((line) -> + line.getSubValue()).reduce(sum, (accumulator, _item) -> + accumulator + _item); + return sum; + } + + public double getTax() { + + double sum = 0.0; + if (hasTaxesCalculated()) { + for (TicketTaxInfo tax : taxes) { + sum += tax.getTax(); // Taxes are already rounded... + nsum = sum; + } + } else { + sum = m_aLines.stream().map((line) -> + line.getTax()).reduce(sum, (accumulator, _item) -> + accumulator + _item); + } + return sum; + } + + public double getTotal() { + return getSubTotal() + getTax(); + + } + + public double getServiceCharge() { + return (getTotal() + getTax()); + + } + + public double getTotalPaid() { + double sum = 0.0; + sum = payments.stream().filter((p) -> + (!"debtpaid".equals(p.getName()))).map((p) -> + p.getTotal()).reduce(sum, (accumulator, _item) -> + accumulator + _item); + return sum; + } + + public double getTendered() { + return getTotalPaid(); + } + + public List<TicketLineInfo> getLines() { + return m_aLines; + } + + public void setLines(List<TicketLineInfo> l) { + m_aLines = l; + } + + public List<PaymentInfo> getPayments() { + return payments; + } + + public void setPayments(List<PaymentInfo> l) { + payments = l; + } + + public void resetPayments() { + payments = new ArrayList<>(); // JG June 2102 diamond inference + } + + public List<TicketTaxInfo> getTaxes() { + return taxes; + } + + public boolean hasTaxesCalculated() { + return taxes != null; + } + + public void setTaxes(List<TicketTaxInfo> l) { + taxes = l; + } + + public void resetTaxes() { + taxes = null; + } + + public void setTip(boolean tips) { + tip = tips; + } + + public boolean hasTip() { + return tip; + } + + public void setIsProcessed(boolean isP) { + m_isProcessed = isP; + } + + public TicketTaxInfo getTaxLine(TaxInfo tax) { + + for (TicketTaxInfo taxline : taxes) { + if (tax.getId().equals(taxline.getTaxInfo().getId())) { + return taxline; + } + } + + return new TicketTaxInfo(tax); + } + + public TicketTaxInfo[] getTaxLines() { + + Map<String, TicketTaxInfo> m = new HashMap<>(); + + TicketLineInfo oLine; + for (Iterator<TicketLineInfo> i = m_aLines.iterator(); i.hasNext();) { + oLine = i.next(); + + TicketTaxInfo t = m.get(oLine.getTaxInfo().getId()); + if (t == null) { + t = new TicketTaxInfo(oLine.getTaxInfo()); + m.put(t.getTaxInfo().getId(), t); + } + t.add(oLine.getSubValue()); + } + + // return dSuma; + Collection<TicketTaxInfo> avalues = m.values(); + return avalues.toArray(new TicketTaxInfo[avalues.size()]); + } + + public String printId() { + + AppConfig m_config = new AppConfig(new File( + (System.getProperty("user.home")), AppLocal.APP_ID + ".properties")); + m_config.load(); + String receiptSize =(m_config.getProperty("till.receiptsize")); + String receiptPrefix =(m_config.getProperty("till.receiptprefix")); + + m_config =null; + + if (m_iTicketId > 0) { + String tmpTicketId=Integer.toString(m_iTicketId); + if (receiptSize == null || (Integer.parseInt(receiptSize) <= tmpTicketId.length())){ + if (receiptPrefix != null){ + tmpTicketId=receiptPrefix+tmpTicketId; + } + return tmpTicketId; + } + while (tmpTicketId.length()<Integer.parseInt(receiptSize)){ + tmpTicketId="0"+tmpTicketId; + } + if (receiptPrefix != null){ + tmpTicketId=receiptPrefix+tmpTicketId; + } + return tmpTicketId; + } else { + return ""; + } + } + + public String printDate() { + return Formats.TIMESTAMP.formatValue(m_dDate); + } + + public String printUser() { + return m_User == null ? "" : m_User.getName(); + + } + + public String printHost() { + return m_sHost; + } + + +// Added JDL 28.05.13 for loyalty card functions + + /** + * + */ + public void clearCardNumber(){ + loyaltyCardNumber=null; + } + + /** + * + * @param cardNumber + */ + public void setLoyaltyCardNumber(String cardNumber){ + loyaltyCardNumber=cardNumber; + } + + /** + * + * @return + */ + public String getLoyaltyCardNumber(){ + return (loyaltyCardNumber); + } + + public String printCustomer() { + return m_Customer == null ? "" : m_Customer.getName(); + } + + public String printPhone1() { + return m_Customer == null ? "" : m_Customer.getPhone1(); + } + + public String printArticlesCount() { + return Formats.DOUBLE.formatValue(getArticlesCount()); + } + + public String printSubTotal() { + return Formats.CURRENCY.formatValue(getSubTotal()); + } + + public String printTax() { + return Formats.CURRENCY.formatValue(getTax()); + } + + public String printTotal() { + return Formats.CURRENCY.formatValue(getTotal()); + } + + public String printTotalPaid() { + return Formats.CURRENCY.formatValue(getTotalPaid()); + } + + public String printTendered() { + return Formats.CURRENCY.formatValue(getTendered()); + } + + public String VoucherReturned(){ + return Formats.CURRENCY.formatValue(getTotalPaid()- getTotal()); + } + + public boolean getOldTicket() { + return (oldTicket); + } + + public void setOldTicket(Boolean otState) { + oldTicket = otState; + } + + public String getTicketHeaderFooterData(String data) { + AppConfig m_config = new AppConfig(new File((System.getProperty("user.home")) + , AppLocal.APP_ID + ".properties")); + m_config.load(); + String row =(m_config.getProperty("tkt."+data)); + + return row; + } + + public String printTicketHeaderLine1() { + String lineData = getTicketHeaderFooterData("header1"); + + if(lineData != null) { + return lineData; + } else { + return ""; + } + } + + public String printTicketHeaderLine2() { + String lineData = getTicketHeaderFooterData("header2"); + + if(lineData != null) { + return lineData; + } else { + return ""; + } + } + + public String printTicketHeaderLine3() { + String lineData = getTicketHeaderFooterData("header3"); + + if(lineData != null) { + return lineData; + } else { + return ""; + } + } + + public String printTicketHeaderLine4() { + String lineData = getTicketHeaderFooterData("header4"); + + if(lineData != null) { + return lineData; + } else { + return ""; + } + } + + public String printTicketHeaderLine5() { + String lineData = getTicketHeaderFooterData("header5"); + + if(lineData != null) { + return lineData; + } else { + return ""; + } + } + + public String printTicketHeaderLine6() { + String lineData = getTicketHeaderFooterData("header6"); + + if(lineData != null) { + return lineData; + } else { + return ""; + } + } + + public String printTicketFooterLine1() { + String lineData = getTicketHeaderFooterData("footer1"); + + if(lineData != null) { + return lineData; + } else { + return ""; + } + } + + public String printTicketFooterLine2() { + String lineData = getTicketHeaderFooterData("footer2"); + + if(lineData != null) { + return lineData; + } else { + return ""; + } + } + + public String printTicketFooterLine3() { + String lineData = getTicketHeaderFooterData("footer3"); + + if(lineData != null) { + return lineData; + } else { + return ""; + } + } + + public String printTicketFooterLine4() { + String lineData = getTicketHeaderFooterData("footer4"); + + if(lineData != null) { + return lineData; + } else { + return ""; + } + } + + public String printTicketFooterLine5() { + String lineData = getTicketHeaderFooterData("footer5"); + + if(lineData != null) { + return lineData; + } else { + return ""; + } + } + + public String printTicketFooterLine6() { + String lineData = getTicketHeaderFooterData("footer6"); + + if(lineData != null) { + return lineData; + } else { + return ""; + } + } + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/ticket/TicketLineInfo.java b/src/main/java/com/unicenta/pos/ticket/TicketLineInfo.java new file mode 100644 index 0000000..c241957 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/TicketLineInfo.java @@ -0,0 +1,484 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.DataWrite; +import com.unicenta.data.loader.SerializableRead; +import com.unicenta.data.loader.SerializableWrite; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.StringUtils; +import java.io.*; +import java.util.Properties; + +/** + * + * @author adrianromero + */ +public class TicketLineInfo implements SerializableWrite, SerializableRead, Serializable { + + private static final long serialVersionUID = 6608012948284450199L; + private String m_sTicket; + private int m_iLine; + private double multiply; + private double price; + private TaxInfo tax; + private Properties attributes; + private String productid; + private String attsetinstid; + private Boolean updated = false; + + private double newprice = 0.0; + + /** Creates new TicketLineInfo + * @param productid + * @param dMultiply + * @param dPrice + * @param tax + * @param props */ + public TicketLineInfo(String productid, double dMultiply, double dPrice, TaxInfo tax, Properties props) { + init(productid, null, dMultiply, dPrice, tax, props); + } + + /** + * + * @param productid + * @param dMultiply + * @param dPrice + * @param tax + */ + public TicketLineInfo(String productid, double dMultiply, double dPrice, TaxInfo tax) { + init(productid, null, dMultiply, dPrice, tax, new Properties()); + } + + /** + * Example: Call from script.TotalDiscount event + * @param productid + * @param productname + * @param producttaxcategory + * @param productprinter + * @param dMultiply + * @param dPrice + * @param tax + */ + public TicketLineInfo(String productid, String productname, String producttaxcategory, String productprinter, double dMultiply, double dPrice, TaxInfo tax) { + Properties props = new Properties(); + props.setProperty("product.name", productname); + props.setProperty("product.taxcategoryid", producttaxcategory); + props.setProperty("product.printer", productprinter); //added to props as may introduce printer redirect + + init(productid, null, dMultiply, dPrice, tax, props); + } + + /** + * Example: Call from script.LineDiscount event + * @param productname + * @param producttaxcategory + * @param productprinter //added to props as may introduce printer redirect + * @param dMultiply + * @param dPrice + * @param tax + */ + public TicketLineInfo(String productname, String producttaxcategory, String productprinter, double dMultiply, double dPrice, TaxInfo tax) { + + Properties props = new Properties(); + props.setProperty("product.name", productname); + props.setProperty("product.taxcategoryid", producttaxcategory); + props.setProperty("product.printer", productprinter); + + init(null, null, dMultiply, dPrice, tax, props); + } + + /** + * + */ + public TicketLineInfo() { + init(null, null, 0.0, 0.0, null, new Properties()); + } + + /** + * + * @param product + * @param dMultiply + * @param dPrice + * @param tax + * @param attributes + */ + public TicketLineInfo(ProductInfoExt product, double dMultiply, double dPrice, TaxInfo tax, Properties attributes) { + + String pid; + + if (product == null) { + pid = null; + tax = null; + } else { + pid = product.getID(); + attributes.setProperty("product.name", product.getName()); + attributes.setProperty("product.reference", product.getReference()); + attributes.setProperty("product.code", product.getCode()); + + if (product.getMemoDate() == null) { + attributes.setProperty("product.memodate", "1900-01-01 00:00:01"); + } else { + attributes.setProperty("product.memodate", product.getMemoDate()); + } + + attributes.setProperty("product.com", product.isCom() ? "true" : "false"); + attributes.setProperty("product.constant", product.isConstant() ? "true" : "false"); + + if (product.getPrinter() != null) { + attributes.setProperty("product.printer", product.getPrinter()); + } else { + attributes.setProperty("product.printer", "1"); + } + + attributes.setProperty("product.service", product.isService() ? "true" : "false"); + attributes.setProperty("product.vprice", product.isVprice() ? "true" : "false"); + attributes.setProperty("product.verpatrib", product.isVerpatrib() ? "true" : "false"); + + if (product.getTextTip() != null) { + attributes.setProperty("product.texttip", product.getTextTip()); + } + + attributes.setProperty("product.warranty", product.getWarranty()? "true" : "false"); + + if (product.getAttributeSetID() != null) { + attributes.setProperty("product.attsetid", product.getAttributeSetID()); + } + + attributes.setProperty("product.taxcategoryid", product.getTaxCategoryID()); + + if (product.getCategoryID() != null) { + attributes.setProperty("product.categoryid", product.getCategoryID()); + } + + if ("true".equals(attributes.getProperty("ticket.updated"))) { + attributes.setProperty("ticket.updated", "false"); + } else { + attributes.setProperty("ticket.updated", "true"); + } + } + + init(pid, null, dMultiply, dPrice, tax, attributes); + } + + /** + * + * @param oProduct + * @param dPrice + * @param tax + * @param attributes + */ + public TicketLineInfo(ProductInfoExt oProduct, double dPrice, TaxInfo tax, Properties attributes) { + this(oProduct, 1.0, dPrice, tax, attributes); + } + + /** + * + * @param line + */ + public TicketLineInfo(TicketLineInfo line) { + init(line.productid, line.attsetinstid, line.multiply, line.price, + line.tax, (Properties) line.attributes.clone()); + } + + private void init(String productid, String attsetinstid, double dMultiply, double dPrice, TaxInfo tax, Properties attributes) { + + this.productid = productid; + this.attsetinstid = attsetinstid; + multiply = dMultiply; + price = dPrice; + this.tax = tax; + this.attributes = attributes; + + m_sTicket = null; + m_iLine = -1; + } + + void setTicket(String ticket, int line) { + m_sTicket = ticket; + m_iLine = line; + } + + /** + * + * @param dp + * @throws BasicException + */ + @Override + public void writeValues(DataWrite dp) throws BasicException { + dp.setString(1, m_sTicket); + dp.setInt(2, m_iLine); + dp.setString(3, productid); + dp.setString(4, attsetinstid); + dp.setDouble(5, multiply); + dp.setDouble(6, price); + dp.setString(7, tax.getId()); + + try { + ByteArrayOutputStream o = new ByteArrayOutputStream(); + attributes.storeToXML(o, AppLocal.APP_NAME, "UTF-8"); + dp.setBytes(8, o.toByteArray()); + } catch (IOException e) { + dp.setBytes(8, null); + } + } + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_sTicket = dr.getString(1); + m_iLine = dr.getInt(2); + productid = dr.getString(3); + attsetinstid = dr.getString(4); + multiply = dr.getDouble(5); + price = dr.getDouble(6); + tax = new TaxInfo( + dr.getString(7), + dr.getString(8), + dr.getString(9), + dr.getString(10), + dr.getString(11), + dr.getDouble(12), + dr.getBoolean(13), + dr.getInt(14)); + attributes = new Properties(); + + try { + byte[] img = dr.getBytes(15); + if (img != null) { + attributes.loadFromXML(new ByteArrayInputStream(img)); + } + } catch (IOException e) { + } + } + + /** + * + * @return + */ + public TicketLineInfo copyTicketLine() { + TicketLineInfo l = new TicketLineInfo(); + l.productid = productid; + l.attsetinstid = attsetinstid; + l.multiply = multiply; + l.price = price; + l.tax = tax; + l.attributes = (Properties) attributes.clone(); + + return l; + } + + /** + * + * @return + */ + public int getTicketLine() { + return m_iLine; + } +// These are the Lookups + public String getProductID() { + return productid; + } + public String getProductCategoryID() { + return (attributes.getProperty("product.categoryid")); + } + public String getProductAttSetId() { + return attributes.getProperty("product.attsetid"); + } + public String getProductAttSetInstId() { + return attsetinstid; + } + public String getProductAttSetInstDesc() { + return attributes.getProperty("product.attsetdesc", ""); + } + public String getProductTaxCategoryID() { + return (attributes.getProperty("product.taxcategoryid")); + } + public String getTicketUpdated() { + return (attributes.getProperty("ticket.updated")); + } + public TaxInfo getTaxInfo() { + return tax; + } + public void setTaxInfo(TaxInfo oTaxInfo) { + tax = oTaxInfo; + } + +// These appear on Printed TicketLine + public String getProductName() { + return attributes.getProperty("product.name"); + } + public String getProductMemoDate() { + return attributes.getProperty("product.memodate"); + } + public double getPrice() { + return price; + } + public double getMultiply() { + return multiply; + } + public double getTaxRate() { + return tax == null ? 0.0 : tax.getRate(); + } + public double getNewPrice() { + newprice = price * (1.0 + getTaxRate()); + return price; + } + public String getProductPrinter() { + return attributes.getProperty("product.printer"); + } + +// These are the Summaries + public double getPriceTax() { + return price * (1.0 + getTaxRate()); + } + + public Properties getProperties() { + return attributes; + } + public String getProperty(String key) { + return attributes.getProperty(key); + } + public String getProperty(String key, String defaultvalue) { + return attributes.getProperty(key, defaultvalue); + } + +// These are Ticket Totals + public double getTax() { + return price * multiply * getTaxRate(); + } + public double getValue() { + return price * multiply * (1.0 + getTaxRate()); + } + public double getSubValue() { + return price * multiply; + } + +// SETTERS + public void setPrice(double dValue) { + price = dValue; + } + public void setPriceTax(double dValue) { + price = dValue / (1.0 + getTaxRate()); + } + public void setMultiply(double dValue) { + multiply = dValue; + } + public void setProperty(String key, String value) { + attributes.setProperty(key, value); + } + public void setProductTaxCategoryID(String taxID){ + attributes.setProperty("product.taxcategoryid",taxID); + } + public void setProductAttSetInstId(String value) { + attsetinstid = value; + } + public void setProductAttSetInstDesc(String value) { + if (value == null) { + attributes.remove(value); + } else { + attributes.setProperty("product.attsetdesc", value); + } + } + public void setTicketUpdated(String key, String value){ + attributes.setProperty("ticket.updated",value); + } + public void setProductPrinter(String value) { + if (value == null) { + attributes.remove(value); + } else { + attributes.setProperty("product.printer", value); + } + } + + /** + * + * @return + */ + // Print to actual ${ticketline + public String printReference() { + return StringUtils.encodeXML(attributes.getProperty("product.reference")); + } + public String printCode() { + return StringUtils.encodeXML(attributes.getProperty("product.code")); + } + public String printName() { + return StringUtils.encodeXML(attributes.getProperty("product.name")); + } + public String printProductMemoDate() { + return StringUtils.encodeXML(attributes.getProperty("product.memodate")); + } + public String printPrice() { + return Formats.CURRENCY.formatValue(getPrice()); + } + public String printPriceTax() { + return Formats.CURRENCY.formatValue(getPriceTax()); + } + public String printMultiply() { + return Formats.DOUBLE.formatValue(multiply); + } + public String printValue() { + return Formats.CURRENCY.formatValue(getValue()); + } + public String printTaxRate() { + return Formats.PERCENT.formatValue(getTaxRate()); + } + public String printSubValue() { + return Formats.CURRENCY.formatValue(getSubValue()); + } + public String printTax() { + return Formats.CURRENCY.formatValue(getTax()); + } + public String printTextTip() { + return attributes.getProperty("product.texttip"); + } + public String printPrinter() { + return StringUtils.encodeXML(attributes.getProperty("product.printer")); + } + public boolean isProductCom() { + return "true".equals(attributes.getProperty("product.com")); + } + public boolean isProductService() { + return "true".equals(attributes.getProperty("product.service")); + } + public boolean isProductVprice() { + return "true".equals(attributes.getProperty("product.vprice")); + } + public boolean isProductVerpatrib() { + return "true".equals(attributes.getProperty("product.verpatrib")); + } + public boolean isProductWarranty() { + return "true".equals(attributes.getProperty("product.warranty")); + } + public boolean getUpdated() { + return "true".equals(attributes.getProperty("ticket.updated")); + } + public void setUpdated(Boolean value) { + updated = value; + } + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/ticket/TicketLineInfo1.java b/src/main/java/com/unicenta/pos/ticket/TicketLineInfo1.java new file mode 100644 index 0000000..ae65855 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/TicketLineInfo1.java @@ -0,0 +1,637 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.DataWrite; +import com.unicenta.data.loader.SerializableRead; +import com.unicenta.data.loader.SerializableWrite; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.util.StringUtils; +import java.io.*; +import java.util.Properties; + +/** + * + * @author adrianromero + */ +public class TicketLineInfo1 implements SerializableWrite, SerializableRead, Serializable { + + private static final long serialVersionUID = 6608012948284450199L; + private String m_sTicket; + private int m_iLine; + private double multiply; + private double price; + private TaxInfo tax; + private Properties attributes; + private String productid; + private String attsetinstid; + + /** Creates new TicketLineInfo + * @param productid + * @param dMultiply + * @param dPrice + * @param tax + * @param props */ + public TicketLineInfo1(String productid, double dMultiply, double dPrice, TaxInfo tax, Properties props) { + init(productid, null, dMultiply, dPrice, tax, props); + } + + /** + * + * @param productid + * @param dMultiply + * @param dPrice + * @param tax + */ + public TicketLineInfo1(String productid, double dMultiply, double dPrice, TaxInfo tax) { + init(productid, null, dMultiply, dPrice, tax, new Properties()); + } + + /** + * + * @param productid + * @param productname + * @param producttaxcategory + * @param dMultiply + * @param dPrice + * @param tax + */ + public TicketLineInfo1(String productid, String productname, String producttaxcategory, double dMultiply, double dPrice, TaxInfo tax) { + Properties props = new Properties(); + props.setProperty("product.name", productname); + props.setProperty("product.taxcategoryid", producttaxcategory); + init(productid, null, dMultiply, dPrice, tax, props); + } + + /** + * + * @param productname + * @param producttaxcategory + * @param dMultiply + * @param dPrice + * @param tax + */ + public TicketLineInfo1(String productname, String producttaxcategory, double dMultiply, double dPrice, TaxInfo tax) { + + Properties props = new Properties(); + props.setProperty("product.name", productname); + props.setProperty("product.taxcategoryid", producttaxcategory); + init(null, null, dMultiply, dPrice, tax, props); + } + + /** + * + */ + public TicketLineInfo1() { + init(null, null, 0.0, 0.0, null, new Properties()); + } + + /** + * + * @param product + * @param dMultiply + * @param dPrice + * @param tax + * @param attributes + */ + public TicketLineInfo1(ProductInfoExt product, double dMultiply, double dPrice, TaxInfo tax, Properties attributes) { + + String pid; + + if (product == null) { + pid = null; + } else { + pid = product.getID(); + attributes.setProperty("product.name", product.getName()); + attributes.setProperty("product.com", product.isCom() ? "true" : "false"); + attributes.setProperty("product.constant", product.isConstant() ? "true" : "false"); + attributes.setProperty("product.printer", product.getPrinter()); + attributes.setProperty("product.service", product.isService() ? "true" : "false"); + attributes.setProperty("product.vprice", product.isVprice() ? "true" : "false"); + attributes.setProperty("product.verpatrib", product.isVerpatrib() ? "true" : "false"); + + if (product.getTextTip() != null) { + attributes.setProperty("product.texttip", product.getTextTip()); + } + + attributes.setProperty("product.warranty", product.getWarranty()? "true" : "false"); + + if (product.getAttributeSetID() != null) { + attributes.setProperty("product.attsetid", product.getAttributeSetID()); + } + attributes.setProperty("product.taxcategoryid", product.getTaxCategoryID()); + + if (product.getCategoryID() != null) { + attributes.setProperty("product.categoryid", product.getCategoryID()); + } + } + init(pid, null, dMultiply, dPrice, tax, attributes); + } + + /** + * + * @param oProduct + * @param dPrice + * @param tax + * @param attributes + */ + public TicketLineInfo1(ProductInfoExt oProduct, double dPrice, TaxInfo tax, Properties attributes) { + this(oProduct, 1.0, dPrice, tax, attributes); + } + + /** + * + * @param line + */ + public TicketLineInfo1(TicketLineInfo1 line) { + init(line.productid, line.attsetinstid, line.multiply, line.price, line.tax, (Properties) line.attributes.clone()); + } + + private void init(String productid, String attsetinstid, double dMultiply, double dPrice, TaxInfo tax, Properties attributes) { + + this.productid = productid; + this.attsetinstid = attsetinstid; + multiply = dMultiply; + price = dPrice; + this.tax = tax; + this.attributes = attributes; + + m_sTicket = null; + m_iLine = -1; + } + + void setTicket(String ticket, int line) { + m_sTicket = ticket; + m_iLine = line; + } + + /** + * + * @param dp + * @throws BasicException + */ + @Override + public void writeValues(DataWrite dp) throws BasicException { + dp.setString(1, m_sTicket); + dp.setInt(2, new Integer(m_iLine)); + dp.setString(3, productid); + dp.setString(4, attsetinstid); + + dp.setDouble(5, new Double(multiply)); + dp.setDouble(6, new Double(price)); + + dp.setString(7, tax.getId()); + try { + ByteArrayOutputStream o = new ByteArrayOutputStream(); + attributes.storeToXML(o, AppLocal.APP_NAME, "UTF-8"); + dp.setBytes(8, o.toByteArray()); + } catch (IOException e) { + dp.setBytes(8, null); + } + } + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + m_sTicket = dr.getString(1); + m_iLine = dr.getInt(2).intValue(); + productid = dr.getString(3); + attsetinstid = dr.getString(4); + multiply = dr.getDouble(5); + price = dr.getDouble(6); + tax = new TaxInfo( + dr.getString(7), + dr.getString(8), + dr.getString(9), + dr.getString(10), + dr.getString(11), + dr.getDouble(12), + dr.getBoolean(13), + dr.getInt(14)); + attributes = new Properties(); + try { + byte[] img = dr.getBytes(15); + if (img != null) { + attributes.loadFromXML(new ByteArrayInputStream(img)); + } + } catch (IOException e) { + } + } + + /** + * + * @return + */ + public TicketLineInfo1 copyTicketLine() { + TicketLineInfo1 l = new TicketLineInfo1(); + l.productid = productid; + l.attsetinstid = attsetinstid; + l.multiply = multiply; + l.price = price; + l.tax = tax; + l.attributes = (Properties) attributes.clone(); + return l; + } + + /** + * + * @return + */ + public int getTicketLine() { + return m_iLine; + } + + /** + * + * @return + */ + public String getProductID() { + return productid; + } + + /** + * + * @return + */ + public String getProductName() { + return attributes.getProperty("product.name"); + } + + /** + * + * @return + */ + public String getProductPrinter() { + return attributes.getProperty("product.printer"); + } + + /** + * + * @return + */ + public String getProductAttSetId() { + return attributes.getProperty("product.attsetid"); + } + + /** + * + * @return + */ + public String getProductAttSetInstDesc() { + return attributes.getProperty("product.attsetdesc", ""); + } + + /** + * + * @param value + */ + public void setProductAttSetInstDesc(String value) { + if (value == null) { + attributes.remove(value); + } else { + attributes.setProperty("product.attsetdesc", value); + } + } + + /** + * + * @return + */ + public String getProductAttSetInstId() { + return attsetinstid; + } + + /** + * + * @param value + */ + public void setProductAttSetInstId(String value) { + attsetinstid = value; + } + + /** + * + * @return + */ + public boolean isProductCom() { + return "true".equals(attributes.getProperty("product.com")); + } + + /** + * + * @return + */ + public String getProductTaxCategoryID() { + return (attributes.getProperty("product.taxcategoryid")); + } + + /** + * + * @param taxID + */ + public void setProductTaxCategoryID(String taxID){ + attributes.setProperty("product.taxcategoryid",taxID); + } + + /** + * + * @return + */ + public String getProductCategoryID() { + return (attributes.getProperty("product.categoryid")); + } + + /** + * + * @return + */ + public double getMultiply() { + return multiply; + } + + /** + * + * @param dValue + */ + public void setMultiply(double dValue) { + multiply = dValue; + } + + /** + * + * @return + */ + public double getPrice() { + return price; + } + + /** + * + * @param dValue + */ + public void setPrice(double dValue) { + price = dValue; + } + + /** + * + * @return + */ + public double getPriceTax() { + return price * (1.0 + getTaxRate()); + } + + /** + * + * @param dValue + */ + public void setPriceTax(double dValue) { + price = dValue / (1.0 + getTaxRate()); + } + + /** + * + * @return + */ + public TaxInfo getTaxInfo() { + return tax; + } + + /** + * + * @param value + */ + public void setTaxInfo(TaxInfo value) { + tax = value; + } + + /** + * + * @param key + * @return + */ + public String getProperty(String key) { + return attributes.getProperty(key); + } + + /** + * + * @param key + * @param defaultvalue + * @return + */ + public String getProperty(String key, String defaultvalue) { + return attributes.getProperty(key, defaultvalue); + } + + /** + * + * @param key + * @param value + */ + public void setProperty(String key, String value) { + attributes.setProperty(key, value); + } + + /** + * + * @return + */ + public Properties getProperties() { + return attributes; + } + + /** + * + * @return + */ + public double getTaxRate() { + return tax == null ? 0.0 : tax.getRate(); + } + + /** + * + * @return + */ + public double getSubValue() { + return price * multiply; + } + + /** + * + * @return + */ + public double getTax() { + return price * multiply * getTaxRate(); + } + + /** + * + * @return + */ + public double getValue() { + return price * multiply * (1.0 + getTaxRate()); + } + + /** + * + * @return + */ + public String printName() { + return StringUtils.encodeXML(attributes.getProperty("product.name")); + } + + /** + * + * @return + */ + public String printPrinter() { + return StringUtils.encodeXML(attributes.getProperty("product.printer")); + } + + /** + * + * @return + */ + public String printMultiply() { + return Formats.DOUBLE.formatValue(multiply); + } + + /** + * + * @return + */ + public String printPrice() { + return Formats.CURRENCY.formatValue(getPrice()); + } + + /** + * + * @return + */ + public String printPriceTax() { + return Formats.CURRENCY.formatValue(getPriceTax()); + } + + /** + * + * @return + */ + public String printTax() { + return Formats.CURRENCY.formatValue(getTax()); + } + + /** + * + * @return + */ + public String printTaxRate() { + return Formats.PERCENT.formatValue(getTaxRate()); + } + + /** + * + * @return + */ + public String printSubValue() { + return Formats.CURRENCY.formatValue(getSubValue()); + } + + /** + * + * @return + */ + public String printValue() { + return Formats.CURRENCY.formatValue(getValue()); + } +// ADDED JG 20.12.10 - Kitchen Print + + /** + * + * @return + */ + public boolean isProductConstant() { + return "true".equals(attributes.getProperty("product.constant")); +} +// *** +// ADDED JG 25.06.11 - Is Service + + /** + * + * @return + */ + public boolean isProductService() { + return "true".equals(attributes.getProperty("product.service")); +} +// Added JDL 19.12.12 - Variable price product + + /** + * + * @return + */ + public boolean isProductVprice() { + return "true".equals(attributes.getProperty("product.vprice")); +// + +} + +// Added JDL 09.02.13 for Chris + + /** + * + * @return + */ + public boolean isProductVerpatrib() { + return "true".equals(attributes.getProperty("product.verpatrib")); +// + +} + +// Added JDL 09.04.12 - Variable price product + + /** + * + * @return + */ + public String printTextTip() { + return attributes.getProperty("product.texttip"); +// + +} + +// Added JDL 09.02.13 + + /** + * + * @return + */ + public boolean isProductWarranty() { + return "true".equals(attributes.getProperty("product.warranty")); +// + + } +} diff --git a/src/main/java/com/unicenta/pos/ticket/TicketTaxInfo.java b/src/main/java/com/unicenta/pos/ticket/TicketTaxInfo.java new file mode 100644 index 0000000..d8f1ea4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/TicketTaxInfo.java @@ -0,0 +1,108 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.ticket; + +import com.unicenta.format.Formats; + +/** + * + * @author JG uniCenta + */ +public class TicketTaxInfo { + + private TaxInfo tax; + + private double subtotal; + private double taxtotal; + + /** Creates a new instance of TicketTaxInfo + * @param tax */ + public TicketTaxInfo(TaxInfo tax) { + this.tax = tax; + + subtotal = 0.0; + taxtotal = 0.0; + } + + /** + * + * @return + */ + public TaxInfo getTaxInfo() { + return tax; + } + + /** + * + * @param dValue + */ + public void add(double dValue) { + subtotal += dValue; + taxtotal = subtotal * tax.getRate(); + } + + /** + * + * @return + */ + public double getSubTotal() { + return subtotal; + } + + /** + * + * @return + */ + public double getTax() { + return taxtotal; + } + + /** + * + * @return + */ + public double getTotal() { + return subtotal + taxtotal; + } + + /** + * + * @return + */ + public String printSubTotal() { + return Formats.CURRENCY.formatValue(getSubTotal()); + } + + /** + * + * @return + */ + public String printTax() { + return Formats.CURRENCY.formatValue(getTax()); + } + + /** + * + * @return + */ + public String printTotal() { + return Formats.CURRENCY.formatValue(getTotal()); + } +} diff --git a/src/main/java/com/unicenta/pos/ticket/UserInfo.java b/src/main/java/com/unicenta/pos/ticket/UserInfo.java new file mode 100644 index 0000000..d4404b6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/ticket/UserInfo.java @@ -0,0 +1,56 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +package com.unicenta.pos.ticket; + +import java.io.Serializable; + +/** + * + * @author adrianromero + */ +public class UserInfo implements Serializable { + + private static final long serialVersionUID = 7537578737839L; + private String m_sId; + private String m_sName; + + /** Creates a new instance of UserInfoBasic + * @param id + * @param name */ + public UserInfo(String id, String name) { + m_sId = id; + m_sName = name; + } + + /** + * + * @return + */ + public String getId() { + return m_sId; + } + + /** + * + * @return + */ + public String getName() { + return m_sName; + } +} diff --git a/src/main/java/com/unicenta/pos/transfer/Transfer.form b/src/main/java/com/unicenta/pos/transfer/Transfer.form new file mode 100644 index 0000000..5e5503c --- /dev/null +++ b/src/main/java/com/unicenta/pos/transfer/Transfer.form @@ -0,0 +1,1109 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.8" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[900, 425]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel9" min="0" pref="0" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="cbSource" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel2" max="-2" attributes="0"/> + <Component id="jLabel12" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jtxtDbType" min="-2" max="-2" attributes="0"/> + <Component id="jtxtDbServerPort" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel18" alignment="0" max="-2" attributes="0"/> + <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jtxtDbDriver" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="jtxtDbDriverLib" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jbtnDbDriverLib" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="366" max="-2" attributes="0"/> + <Component id="jbtnReset" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="jbtnConnect" min="-2" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <Component id="txtDbUser" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="txtDbPass" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jTransferPanel" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel6" min="-2" pref="202" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jlblSource" min="-2" pref="316" max="-2" attributes="0"/> + </Group> + <Component id="jLabel16" alignment="0" min="-2" pref="278" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel8" min="-2" pref="125" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="webPBar" min="-2" pref="109" max="-2" attributes="0"/> + <EmptySpace min="20" max="32767" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace min="18" pref="18" max="-2" attributes="0"/> + <Component id="jScrollPane1" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="webPBar" min="-2" pref="32" max="-2" attributes="0"/> + <Component id="jLabel8" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel6" alignment="1" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jlblSource" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel16" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="cbSource" min="-2" max="-2" attributes="0"/> + <Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" alignment="0" groupAlignment="2" attributes="0"> + <Component id="jLabel18" alignment="2" min="-2" max="-2" attributes="0"/> + <Component id="jtxtDbDriverLib" alignment="2" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jbtnDbDriverLib" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jtxtDbDriver" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jtxtDbType" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jtxtDbServerPort" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtDbUser" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="txtDbPass" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jbtnConnect" min="-2" max="-2" attributes="0"/> + <Component id="jbtnReset" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Component id="jLabel9" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="jTransferPanel" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + <Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.DbType" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel18"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.dbdriverlib" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.DbDriver" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleName" type="java.lang.String" value="DBDriver"/> + </AccessibilityProperties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" value="Type"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.DbUser" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.DbPassword" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="33" red="33" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" value="Currently connected to :"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.combobox.WebComboBox" name="cbSource"> + <Properties> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="33" red="33" type="rgb"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.transferfromdb" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbSourceActionPerformed"/> + </Events> + </Component> + <Component class="com.alee.laf.text.WebTextField" name="jtxtDbDriverLib"> + <Properties> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="33" red="33" type="rgb"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tootltip.transferlib" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[360, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jbtnDbDriverLib"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/fileopen.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.openfile" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 32]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[64, 32]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[60, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.text.WebTextField" name="jtxtDbDriver"> + <Properties> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="33" red="33" type="rgb"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tootltip.transferclass" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[360, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.text.WebTextField" name="jtxtDbType"> + <Properties> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="33" red="33" type="rgb"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tootltip.transferdbtype" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.text.WebTextField" name="txtDbUser"> + <Properties> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="33" red="33" type="rgb"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.dbuser" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.text.WebPasswordField" name="txtDbPass"> + <Properties> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="33" red="33" type="rgb"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.dbpassword" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + <Property name="verticalScrollBarPolicy" type="int" value="22"/> + <Property name="viewportBorder" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="cc" green="cc" red="cc" type="rgb"/> + </LineBorder> + </Border> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="13" style="0"/> + </Property> + <Property name="horizontalScrollBar" type="javax.swing.JScrollBar" editor="org.netbeans.modules.form.ComponentChooserEditor"> + <ComponentRef name="null"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[200, 350]"/> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="txtOut"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="99" red="0" type="rgb"/> + </Property> + <Property name="rows" type="int" value="5"/> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.transfertxtout" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="null"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel8"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="99" red="0" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" value="PROGRESS"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jlblSource"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="99" red="0" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel9"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.DbUser" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jbtnConnect"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/btn1.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="Button.Test" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.dbtest" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="Button.Test" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="horizontalTextPosition" type="int" value="4"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnConnectjButtonTestConnectionActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JPanelConfigDatabase_jButtonTest"/> + </AuxValues> + </Component> + <Component class="com.alee.laf.progressbar.WebProgressBar" name="webPBar"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="13" style="0"/> + </Property> + <Property name="highlightDarkWhite" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="0" green="0" red="cc" type="rgb"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[240, 30]"/> + </Property> + <Property name="progressBottomColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="99" red="0" type="rgb"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.text.WebTextField" name="jtxtDbServerPort"> + <Properties> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="33" red="33" type="rgb"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tootltip.servernameport" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[360, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel12"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="labelServerPort" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + </Component> + <Container class="javax.swing.JPanel" name="jTransferPanel"> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel7" max="-2" attributes="0"/> + <Component id="jtxtDbName" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" pref="7" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" max="-2" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jlblVersion" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel11" min="-2" pref="100" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jlblDBSize" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jbtnSet" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="jbtnTransfer" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Component id="jbtnReset1" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel13" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jCBSchema" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jLabel15" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" max="-2" attributes="0"> + <Component id="webMemoryBar" min="-2" pref="125" max="-2" attributes="0"/> + <Component id="jLabel10" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel14" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jtxtDbParams" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel15" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jCBSchema" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="webMemoryBar" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jtxtDbParams" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel14" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jlblVersion" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="jLabel11" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="jLabel7" alignment="1" min="-2" max="-2" attributes="0"/> + <Component id="jlblDBSize" alignment="1" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jbtnTransfer" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jbtnSet" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jtxtDbName" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Component id="jbtnReset1" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel13"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.DbSource" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jCBSchema"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tootltip.transferdbname" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[360, 30]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + <Component class="javax.swing.JLabel" name="jLabel14"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.DBParameters" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.text.WebTextField" name="jtxtDbParams"> + <Properties> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="33" red="33" type="rgb"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tootltip.transferdbparams" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[360, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" value="DB Version"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jlblVersion"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="16" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="cc" red="0" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.transferdbversion" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="ff" green="cc" red="0" type="rgb"/> + </LineBorder> + </Border> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[125, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel11"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" value="DB Size"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jlblDBSize"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="16" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="cc" red="0" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.transferdbsize" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder> + <Color PropertyName="color" blue="ff" green="cc" red="0" type="rgb"/> + </LineBorder> + </Border> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[120, 30]"/> + </Property> + </Properties> + </Component> + <Component class="com.alee.laf.text.WebTextField" name="jtxtDbName"> + <Properties> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="33" green="33" red="33" type="rgb"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tootltip.transferdbname" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="opaque" type="boolean" value="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 0]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jbtnTransfer"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/btn3.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.transfer" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.transferdb" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="horizontalTextPosition" type="int" value="4"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnTransferActionPerformed"/> + </Events> + </Component> + <Component class="com.alee.extended.statusbar.WebMemoryBar" name="webMemoryBar"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="99" green="99" red="99" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" value="Text"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="usedBorderColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="cc" green="cc" red="0" type="rgb"/> + </Property> + <Property name="usedFillColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="cc" red="0" type="rgb"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel10"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="66" green="66" red="66" type="rgb"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="text" type="java.lang.String" value="Memory State"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel15"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="99" red="0" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" value="CHOOSE DATABASE TO TRANSFER FROM"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jbtnSet"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/btn2.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.setTransfer" replaceFormat="AppLocal.getIntString("button.setTransfer")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.checkTransfer" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="horizontalAlignment" type="int" value="2"/> + <Property name="horizontalTextPosition" type="int" value="4"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[160, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnSetActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jbtnReset1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.transferReset" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnReset1ActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="jbtnReset"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.transferReset" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 33]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[70, 33]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnResetActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel16"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="18" style="0"/> + </Property> + <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="99" green="99" red="99" type="rgb"/> + </Property> + <Property name="text" type="java.lang.String" value="SET SERVER TO CONNECT TO"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/transfer/Transfer.java b/src/main/java/com/unicenta/pos/transfer/Transfer.java new file mode 100644 index 0000000..3901ec9 --- /dev/null +++ b/src/main/java/com/unicenta/pos/transfer/Transfer.java @@ -0,0 +1,3018 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2016 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.transfer; + + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.JMessageDialog; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.BatchSentence; +import com.unicenta.data.loader.BatchSentenceResource; +import com.unicenta.data.loader.Session; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.pos.config.PanelConfig; +import com.unicenta.pos.forms.*; +import com.unicenta.pos.util.AltEncrypter; +import com.unicenta.pos.util.DirectoryEvent; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.*; +import java.awt.*; +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.sql.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.regex.Matcher; + +/** + * @author JG uniCenta + */ +@Slf4j +public final class Transfer extends JPanel implements JPanelView { + + private DirtyManager dirty = new DirtyManager(); + private AppConfig config; + private AppProperties m_props; + private Properties m_propsdb = null; + + private List<PanelConfig> m_panelconfig; + + private Connection con_source; + private Connection con_target; + + private String sDB_source; + private String sDB_target; + + private Session session_source; + private Session session_target; + + private ResultSet rs; + + private Statement stmt_source; + private Statement stmt_target; + private PreparedStatement pstmt; + private String SQL; + + private String source_version; + + private String ticketsnum; + private String ticketsnumRefund; + private String ticketsnumPayment; + + private String targetCreate = ""; + private String targetFKadd = ""; + private String targetFKdrop = ""; + + ArrayList<String> stringList = new ArrayList<>(); + + public String strOut = ""; + + // the db connection session + private Session s; + private Connection con; + private Session session; + private boolean m_bInTransaction; + + String db_url = null; + String db_schema = null; + String db_options = null; + String db_user = null; + String db_password = null; + + /** + * Creates new form JPaneldbTransfer + * + * @param oApp + */ + public Transfer(AppView oApp) { + this(oApp.getProperties()); + } + + /** + * @param props + */ + public Transfer(AppProperties props) { + + initComponents(); + + config = new AppConfig(props.getConfigFile()); + m_props = props; + m_panelconfig = new ArrayList<>(); + config.load(); + + m_panelconfig.stream().forEach((c) -> { + c.loadProperties(config); + }); + + jtxtDbDriverLib.getDocument().addDocumentListener(dirty); + jtxtDbDriver.getDocument().addDocumentListener(dirty); + jtxtDbType.getDocument().addDocumentListener(dirty); + txtDbPass.getDocument().addDocumentListener(dirty); + txtDbUser.getDocument().addDocumentListener(dirty); + txtOut.getDocument().addDocumentListener(dirty); + + jbtnDbDriverLib.addActionListener(new DirectoryEvent(jtxtDbDriverLib)); + + cbSource.addActionListener(dirty); + + cbSource.addItem("MySQL"); + cbSource.addItem("PostgreSQL"); + cbSource.addItem("Derby"); + + stringList.add("Transfer Ready..." + "\n"); + txtOut.setText(stringList.get(0)); + + webPBar.setIndeterminate(true); + webPBar.setStringPainted(true); + webPBar.setString("Waiting..."); + webPBar.setVisible(false); + + jTransferPanel.setVisible(false); + jbtnTransfer.setEnabled(false); + jbtnReset.setEnabled(true); + + } + + /** + * @return + */ + @Override + public JComponent getComponent() { + return this; + } + + /** + * @return + */ + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Transfer"); + } + + /** + * @return + */ + public Boolean getSource() { + + String db_url2 = jtxtDbType.getText() + + jtxtDbServerPort.getText() + + jtxtDbName.getText() + + jtxtDbParams.getText(); + String db_user2 = txtDbUser.getText(); + char[] pass = txtDbPass.getPassword(); + String db_password2 = new String(pass); + + Properties connectionProps = new Properties(); + connectionProps.put("user", db_user2); + connectionProps.put("password", db_password2); + + try { + Class.forName(jtxtDbDriver.getText()); + + ClassLoader cloader = new URLClassLoader( + new URL[]{ + new File(jtxtDbDriverLib.getText()).toURI().toURL() + }); + DriverManager.registerDriver( + new DriverWrapper((Driver) Class.forName(jtxtDbDriver.getText(), + true, cloader).newInstance())); + con_source = (Connection) DriverManager.getConnection( + db_url2, db_user2, db_password2); + + session_source = new Session(db_url2, db_user2, db_password2); + sDB_source = con_source.getMetaData().getDatabaseProductName(); + + txtOut.append("Connected to Source OK" + "\n"); + jbtnTransfer.setEnabled(true); + + return (true); + + } catch (ClassNotFoundException + | MalformedURLException + | InstantiationException + | IllegalAccessException + | SQLException e) { + + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_DANGER, + AppLocal.getIntString("database.UnableToConnect"), + e)); + return (false); + } + + } + + + /** + * @return + */ + @SuppressWarnings("empty-statement") + public Boolean createTargetDB() { +// Transfer is into current MySQL database in unicentaopos.properties + + targetCreate = "/com/unicenta/pos/scripts/" + sDB_target + "-create-transfer.sql"; + targetFKadd = "/com/unicenta/pos/scripts/MySQL-FKeys.sql"; + targetFKdrop = "/com/unicenta/pos/scripts/MySQL-dropFKeys.sql"; + + if ("".equals(targetCreate)) { + return (false); + } + + try { + BatchSentence bsentence = new BatchSentenceResource(session_target, targetCreate); + bsentence = new BatchSentenceResource(session_target, targetFKdrop); + + bsentence.putParameter("APP_ID", Matcher.quoteReplacement(AppLocal.APP_ID)); + bsentence.putParameter("APP_NAME", Matcher.quoteReplacement(AppLocal.APP_NAME)); + bsentence.putParameter("APP_VERSION", Matcher.quoteReplacement(AppLocal.APP_VERSION)); + + java.util.List l = bsentence.list(); + + if (l.size() > 0) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("transfer.warning"), + l.toArray(new Throwable[l.size()]))); + } else { + + txtOut.append("Connected to Target OK" + "\n"); + txtOut.revalidate(); + txtOut.repaint(); + } + + } catch (BasicException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_DANGER, + AppLocal.getIntString("transfer.warningnodefault"), + e)); + session_source.close(); + } finally { + } + + return (true); + } + + /** + * @return + */ + public Boolean FKeys() { + if ("".equals(targetFKadd)) { + return (false); + } + try { + txtOut.append("Adding Foreign Keys" + "\n"); + webPBar.setString("Adding Keys..."); + webPBar.setBgBottom(Color.MAGENTA); + BatchSentence bsentence = new BatchSentenceResource(session_target, targetFKadd); + + java.util.List l = bsentence.list(); + if (l.size() > 0) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("transfer.warning"), + l.toArray(new Throwable[l.size()]))); + txtOut.append("Foreign Key error" + "\n"); + } else { + txtOut.append("Foreign Keys completed" + "\n"); + } + + } catch (BasicException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_DANGER, + AppLocal.getIntString("database.ScriptNotFound"), + e)); + session_source.close(); + } finally { + } + txtOut.revalidate(); + txtOut.repaint(); + return (true); + + } + + /** + * @throws BasicException + */ + @Override + public void activate() throws BasicException { + /* + * Repeating this block as Transfer can be run externally + */ + + if ("true".equals(m_props.getProperty("db.multi"))) { + ImageIcon icon = new ImageIcon("/com/unicenta/images/unicentaopos.png"); + Object[] dbs = { + "0 - " + m_props.getProperty("db.name"), + "1 - " + m_props.getProperty("db1.name")}; + + Object s = (Object) JOptionPane.showInputDialog( + null, AppLocal.getIntString("message.databasechoose"), + "Selection", JOptionPane.OK_OPTION, + icon, dbs, m_props.getProperty("db.name")); + + if (s.toString().startsWith("1")) { + db_url = (m_props.getProperty("db1.URL")); + db_schema = (m_props.getProperty("db1.schema")); + db_options = (m_props.getProperty("db1.options")); + db_user = (m_props.getProperty("db1.user")); + db_password = (m_props.getProperty("db1.password")); + if (db_user != null && db_password != null && db_password.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + db_user); + db_password = cypher.decrypt(db_password.substring(6)); + } + String url = db_url + db_schema + db_options; + try { + session_target = new Session(url, db_user, db_password); + con_target = DriverManager.getConnection(url, db_user, db_password); + sDB_target = con_target.getMetaData().getDatabaseProductName(); + jlblSource.setText(con_target.getCatalog()); + } catch (SQLException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_DANGER, + AppLocal.getIntString("database.UnableToConnect"), + e)); + } + + } else { + db_url = (m_props.getProperty("db.URL")); + db_schema = (m_props.getProperty("db.schema")); + db_options = (m_props.getProperty("db.options")); + db_user = (m_props.getProperty("db.user")); + db_password = (m_props.getProperty("db.password")); + if (db_user != null && db_password != null && db_password.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + db_user); + db_password = cypher.decrypt(db_password.substring(6)); + } + String url = db_url + db_schema + db_options; + try { + session_target = new Session(url, db_user, db_password); + con_target = DriverManager.getConnection(url, db_user, db_password); + sDB_target = con_target.getMetaData().getDatabaseProductName(); + jlblSource.setText(con_target.getCatalog()); + } catch (SQLException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_DANGER, + AppLocal.getIntString("database.UnableToConnect"), + e)); + } + } + } else { + db_url = (m_props.getProperty("db.URL")); + db_schema = (m_props.getProperty("db.schema")); + db_options = (m_props.getProperty("db.options")); + db_user = (m_props.getProperty("db.user")); + db_password = (m_props.getProperty("db.password")); + if (db_user != null && db_password != null && db_password.startsWith("crypt:")) { + AltEncrypter cypher = new AltEncrypter("cypherkey" + db_user); + db_password = cypher.decrypt(db_password.substring(6)); + } + String url = db_url + db_schema + db_options; + try { + session_target = new Session(url, db_user, db_password); + con_target = DriverManager.getConnection(url, db_user, db_password); + sDB_target = con_target.getMetaData().getDatabaseProductName(); + jlblSource.setText(con_target.getCatalog()); + } catch (SQLException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_DANGER, + AppLocal.getIntString("database.UnableToConnect"), + e)); + } + } + } + + /** + * @return + */ + @Override + public boolean deactivate() { + return (true); + } + + /** + * @throws java.sql.SQLException + */ + public void clearData() throws SQLException { + Statement stmt = null; + try { + this.con_target.setAutoCommit(false); + stmt = this.con_target.createStatement(); + + stmt.addBatch("DELETE FROM attributesetinstance;"); + stmt.addBatch("DELETE FROM attributeinstance;"); + stmt.addBatch("DELETE FROM attributevalue"); + stmt.addBatch("DELETE FROM attributeuse"); + stmt.addBatch("DELETE FROM attributeset"); + stmt.addBatch("DELETE FROM attribute"); + stmt.addBatch("DELETE FROM people;"); + stmt.addBatch("DELETE FROM categories;"); + stmt.addBatch("DELETE FROM taxcategories;"); + stmt.addBatch("DELETE FROM taxcustcategories;"); + stmt.addBatch("DELETE FROM taxes;"); + stmt.addBatch("DELETE FROM locations;"); + stmt.addBatch("DELETE FROM floors;"); + stmt.addBatch("DELETE FROM places;"); + stmt.addBatch("DELETE FROM shifts;"); + stmt.addBatch("DELETE FROM breaks;"); + stmt.addBatch("DELETE FROM shift_breaks;"); + stmt.addBatch("DELETE FROM closedcash;"); + stmt.addBatch("DELETE FROM csvimport;"); + stmt.addBatch("DELETE FROM customers;"); + stmt.addBatch("DELETE FROM draweropened;"); + stmt.addBatch("DELETE FROM leaves;"); + stmt.addBatch("DELETE FROM lineremoved;"); + stmt.addBatch("DELETE FROM payments;"); + stmt.addBatch("DELETE FROM products_cat;"); + stmt.addBatch("DELETE FROM products_com;"); + stmt.addBatch("DELETE FROM products;"); + stmt.addBatch("DELETE FROM receipts;"); + stmt.addBatch("DELETE FROM roles WHERE NOT ID = '0';"); + stmt.addBatch("DELETE FROM stockcurrent;"); + stmt.addBatch("DELETE FROM stockdiary;"); + stmt.addBatch("DELETE FROM stocklevel;"); + stmt.addBatch("DELETE FROM suppliers;"); + stmt.addBatch("DELETE FROM uom;"); + stmt.addBatch("DELETE FROM vouchers;"); + + stmt.addBatch("SET autocommit=0;"); + stmt.addBatch("SET unique_checks=0;"); + stmt.addBatch("SET foreign_key_checks=0;"); + + int[] updateCounts = stmt.executeBatch(); + this.con_target.commit(); + + } catch (BatchUpdateException b) { + + } catch (SQLException ex) { + + } finally { + if (stmt != null) { + stmt.close(); + } + this.con_target.setAutoCommit(true); + } + } + + public void doTransfer() throws SQLException { + + webPBar.setString("Starting..."); + webPBar.setVisible(true); + + String Dbtname = ""; + + Double Dbtversion = Double.parseDouble(jlblVersion.getText().substring(0, 3)); + + if (getSource()) { + txtOut.setVisible(true); + txtOut.append("Transfer Started..." + "\n"); + + if (createTargetDB()) { + jbtnTransfer.setEnabled(false); + + try { + stmt_source = (Statement) con_source.createStatement(); + stmt_target = (Statement) con_target.createStatement(); + + clearData(); + + this.con_target.setAutoCommit(false); + + webPBar.setString("Running..."); + + Dbtname = "attribute"; + ResultSet rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Attribute" + "\n"); + SQL = "SELECT ID, NAME FROM attribute"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO attribute (" + + "ID, NAME) " + + "VALUES (?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("NAME")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "attributevalue"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Attributevalue" + "\n"); + SQL = "SELECT ID, ATTRIBUTE_ID, VALUE FROM attributevalue"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO attributevalue (" + + "ID, ATTRIBUTE_ID, VALUE) " + + "VALUES (?, ?, ?)"; + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("ATTRIBUTE_ID")); + pstmt.setString(3, rs.getString("VALUE")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "attributeinstance"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Attributeinstance" + "\n"); + SQL = "SELECT ID, ATTRIBUTESETINSTANCE_ID, ATTRIBUTE_ID, VALUE FROM attributeinstance"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO attributeinstance (" + + "ID, ATTRIBUTESETINSTANCE_ID, ATTRIBUTE_ID, VALUE) " + + "VALUES (?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("ATTRIBUTESETINSTANCE_ID")); + pstmt.setString(3, rs.getString("ATTRIBUTE_ID")); + pstmt.setString(4, rs.getString("VALUE")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "attributesetinstance"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Attributesetinstance" + "\n"); + SQL = "SELECT ID, ATTRIBUTESET_ID, DESCRIPTION FROM attributesetinstance"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO attributesetinstance (" + + "ID, ATTRIBUTESET_ID, DESCRIPTION) " + + "VALUES (?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("ATTRIBUTESET_ID")); + pstmt.setString(3, rs.getString("DESCRIPTION")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "attributeuse"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Attributeuse" + "\n"); + SQL = "SELECT ID, ATTRIBUTESET_ID, ATTRIBUTE_ID FROM attributeuse"; + rs = stmt_source.executeQuery(SQL); + +// removed LINENO as weird bug in MySQL causes Lock Timeout +// only happens to this table, no other affected + + while (rs.next()) { + SQL = "INSERT INTO attributeuse(" + + "ID, ATTRIBUTESET_ID, ATTRIBUTE_ID) " + + "VALUES (?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("ATTRIBUTESET_ID")); + pstmt.setString(3, rs.getString("ATTRIBUTE_ID")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "attributeset"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Attributeset" + "\n"); + SQL = "SELECT ID, NAME FROM attributeset"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO attributeset (" + + "ID, NAME) " + + "VALUES (?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("NAME")); + + pstmt.executeUpdate(); + } + rs.close(); +// introduced in 3.00 + if (Dbtversion >= 3.00) { + Dbtname = "breaks"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Breaks" + "\n"); + SQL = "SELECT * FROM breaks"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO breaks(" + + "ID, NAME, NOTES, VISIBLE) " + + "VALUES (?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("NAME")); + pstmt.setString(3, rs.getString("NOTES")); + pstmt.setBoolean(4, rs.getBoolean("VISIBLE")); + + pstmt.executeUpdate(); + } + } else { + txtOut.append("Breaks... skipped" + "\n"); + } + rs.close(); + + Dbtname = "categories"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Categories" + "\n"); + SQL = "SELECT * FROM categories"; + rs = stmt_source.executeQuery(SQL); + + if (rs.getMetaData().getColumnCount() == 6) { + while (rs.next()) { + SQL = "INSERT INTO categories(" + + "ID, NAME, PARENTID, IMAGE, " + + "TEXTTIP, CATSHOWNAME) " + + "VALUES (?, ?, ?, ?, " + + "?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("NAME")); + pstmt.setString(3, rs.getString("PARENTID")); + pstmt.setBytes(4, rs.getBytes("IMAGE")); + pstmt.setString(5, rs.getString("TEXTTIP")); + pstmt.setBoolean(6, rs.getBoolean("CATSHOWNAME")); + + pstmt.executeUpdate(); + } + } else { + while (rs.next()) { + SQL = "INSERT INTO categories(" + + "ID, NAME, PARENTID, IMAGE) " + + "VALUES (?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("NAME")); + pstmt.setString(3, rs.getString("PARENTID")); + pstmt.setBytes(4, rs.getBytes("IMAGE")); + + pstmt.executeUpdate(); + } + } + rs.close(); + + Dbtname = "closedcash"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("ClosedCash" + "\n"); + SQL = "DELETE FROM closedcash"; + pstmt = con_target.prepareStatement(SQL); + pstmt.executeUpdate(); + + SQL = "SELECT * FROM closedcash"; + rs = stmt_source.executeQuery(SQL); + + if (rs.getMetaData().getColumnCount() == 6) { + while (rs.next()) { + SQL = "INSERT INTO closedcash(" + + "MONEY, HOST, HOSTSEQUENCE, " + + "DATESTART, DATEEND, NOSALES) " + + "VALUES (?, ?, ?, " + + "?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("MONEY")); + pstmt.setString(2, rs.getString("HOST")); + pstmt.setInt(3, rs.getInt("HOSTSEQUENCE")); + pstmt.setTimestamp(4, rs.getTimestamp("DATESTART")); + pstmt.setTimestamp(5, rs.getTimestamp("DATEEND")); + pstmt.setInt(6, rs.getInt("NOSALES")); + + pstmt.executeUpdate(); + } + } else { + while (rs.next()) { + SQL = "INSERT INTO closedcash(" + + "MONEY, HOST, HOSTSEQUENCE, " + + "DATESTART, DATEEND) " + + "VALUES (?, ?, ?, " + + "?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("MONEY")); + pstmt.setString(2, rs.getString("HOST")); + pstmt.setInt(3, rs.getInt("HOSTSEQUENCE")); + pstmt.setTimestamp(4, rs.getTimestamp("DATESTART")); + pstmt.setTimestamp(5, rs.getTimestamp("DATEEND")); + + pstmt.executeUpdate(); + } + } + rs.close(); + + Dbtname = "customers"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Customers" + "\n"); + SQL = "SELECT * FROM customers"; + rs = stmt_source.executeQuery(SQL); + + if (rs.getMetaData().getColumnCount() == 27) { + while (rs.next()) { + SQL = "INSERT INTO customers(" + + "ID, SEARCHKEY, TAXID, NAME, TAXCATEGORY, " + + "CARD, MAXDEBT,ADDRESS, ADDRESS2, POSTAL, " + + "CITY, REGION, COUNTRY, FIRSTNAME, LASTNAME," + + "EMAIL, PHONE, PHONE2, FAX, NOTES, " + + "VISIBLE, CURDATE, CURDEBT, IMAGE, ISVIP, " + + "DISCOUNT, MEMODATE)" + + " VALUES (" + + "?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, " + + "?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("SEARCHKEY")); + pstmt.setString(3, rs.getString("TAXID")); + pstmt.setString(4, rs.getString("NAME")); + pstmt.setString(5, rs.getString("TAXCATEGORY")); + pstmt.setString(6, rs.getString("CARD")); + pstmt.setDouble(7, rs.getDouble("MAXDEBT")); + pstmt.setString(8, rs.getString("ADDRESS")); + pstmt.setString(9, rs.getString("ADDRESS2")); + pstmt.setString(10, rs.getString("POSTAL")); + pstmt.setString(11, rs.getString("CITY")); + pstmt.setString(12, rs.getString("REGION")); + pstmt.setString(13, rs.getString("COUNTRY")); + pstmt.setString(14, rs.getString("FIRSTNAME")); + pstmt.setString(15, rs.getString("LASTNAME")); + pstmt.setString(16, rs.getString("EMAIL")); + pstmt.setString(17, rs.getString("PHONE")); + pstmt.setString(18, rs.getString("PHONE2")); + pstmt.setString(19, rs.getString("FAX")); + pstmt.setString(20, rs.getString("NOTES")); + pstmt.setBoolean(21, rs.getBoolean("VISIBLE")); + pstmt.setTimestamp(22, rs.getTimestamp("CURDATE")); + pstmt.setDouble(23, rs.getDouble("CURDEBT")); + pstmt.setBytes(24, rs.getBytes("IMAGE")); + pstmt.setBoolean(25, rs.getBoolean("ISVIP")); + pstmt.setDouble(26, rs.getDouble("DISCOUNT")); + pstmt.setTimestamp(27, rs.getTimestamp("MEMODATE")); + + pstmt.executeUpdate(); + } + } else { + while (rs.next()) { + SQL = "INSERT INTO customers(" + + "ID, SEARCHKEY, TAXID, NAME, " + + "TAXCATEGORY, CARD, MAXDEBT," + + "ADDRESS, ADDRESS2, POSTAL, CITY, " + + "REGION, COUNTRY, FIRSTNAME, LASTNAME, " + + "EMAIL, PHONE, PHONE2, FAX, " + + "NOTES, VISIBLE, CURDATE, CURDEBT)" + + " VALUES (" + + "?, ?, ?, ?, " + + "?, ?, ?, " + + "?, ?, ?, ?, " + + "?, ?, ?, ?, " + + "?, ?, ?, ?, " + + "?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("SEARCHKEY")); + pstmt.setString(3, rs.getString("TAXID")); + pstmt.setString(4, rs.getString("NAME")); + pstmt.setString(5, rs.getString("TAXCATEGORY")); + pstmt.setString(6, rs.getString("CARD")); + pstmt.setDouble(7, rs.getDouble("MAXDEBT")); + pstmt.setString(8, rs.getString("ADDRESS")); + pstmt.setString(9, rs.getString("ADDRESS2")); + pstmt.setString(10, rs.getString("POSTAL")); + pstmt.setString(11, rs.getString("CITY")); + pstmt.setString(12, rs.getString("REGION")); + pstmt.setString(13, rs.getString("COUNTRY")); + pstmt.setString(14, rs.getString("FIRSTNAME")); + pstmt.setString(15, rs.getString("LASTNAME")); + pstmt.setString(16, rs.getString("EMAIL")); + pstmt.setString(17, rs.getString("PHONE")); + pstmt.setString(18, rs.getString("PHONE2")); + pstmt.setString(19, rs.getString("FAX")); + pstmt.setString(20, rs.getString("NOTES")); + pstmt.setBoolean(21, rs.getBoolean("VISIBLE")); + pstmt.setTimestamp(22, rs.getTimestamp("CURDATE")); + pstmt.setDouble(23, rs.getDouble("CURDEBT")); + + pstmt.executeUpdate(); + } + } + rs.close(); + +// introduced 3.50 + if (Dbtversion >= 3.50) { + Dbtname = "draweropened"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("DrawerOpened" + "\n"); + SQL = "SELECT * FROM draweropened"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO draweropened(" + + "OPENDATE, NAME, TICKETID) " + + "VALUES (?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("OPENDATE")); + pstmt.setString(2, rs.getString("NAME")); + pstmt.setString(3, rs.getString("TICKETID")); + + pstmt.executeUpdate(); + } + } + + Dbtname = "floors"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Floors" + "\n"); + SQL = "SELECT * FROM floors"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO floors (" + + "ID, NAME, IMAGE) " + + "VALUES (?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("NAME")); + pstmt.setBytes(3, rs.getBytes("IMAGE")); + + pstmt.executeUpdate(); + } + rs.close(); + +// introduced in 3.00 + if (Dbtversion >= 3.00) { + Dbtname = "leaves"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Leaves" + "\n"); + SQL = "SELECT * FROM leaves"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO leaves (" + + "ID, PPLID, NAME, STARTDATE, " + + "ENDDATE, NOTES) " + + "VALUES (?, ?, ?, ?, " + + "?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("PPLID")); + pstmt.setString(3, rs.getString("NAME")); + pstmt.setTimestamp(4, rs.getTimestamp("STARTDATE")); + pstmt.setTimestamp(5, rs.getTimestamp("ENDDATE")); + pstmt.setString(6, rs.getString("NOTES")); + + pstmt.executeUpdate(); + } + } else { + txtOut.append("Leaves... skipped" + "\n"); + } + rs.close(); + +// introduced in 3.70 + if (Dbtversion >= 3.70) { + Dbtname = "lineremoved"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("LineRemoved" + "\n"); + SQL = "SELECT * FROM lineremoved"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO lineremoved (" + + "REMOVEDDATE, NAME, TICKETID, " + + "PRODUCTID, PRODUCTNAME, UNITS) " + + "VALUES (?, ?, ?, " + + "?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setTimestamp(1, rs.getTimestamp("REMOVEDDATE")); + pstmt.setString(2, rs.getString("NAME")); + pstmt.setString(3, rs.getString("TICKETID")); + pstmt.setString(4, rs.getString("PRODUCTID")); + pstmt.setString(5, rs.getString("PRODUCTNAME")); + pstmt.setDouble(6, rs.getDouble("UNITS")); + + pstmt.executeUpdate(); + } + } else { + txtOut.append("Line Removed... skipped" + "\n"); + } + rs.close(); + + Dbtname = "locations"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Locations" + "\n"); + SQL = "SELECT * FROM locations"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO locations(" + + "ID, NAME, ADDRESS) " + + "VALUES (?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("NAME")); + pstmt.setString(3, rs.getString("ADDRESS")); + + pstmt.executeUpdate(); + } + rs.close(); + +// moorers introduced in 3.50 + if (Dbtversion >= 3.50) { + Dbtname = "moorers"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Moorers" + "\n"); + SQL = "SELECT * FROM moorers"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO moorers(" + + "VESSELNAME, SIZE, DAYS, POWER) " + + "VALUES (?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("VESSELNAME")); + pstmt.setInt(2, rs.getInt("SIZE")); + pstmt.setInt(3, rs.getInt("DAYS")); + pstmt.setBoolean(4, rs.getBoolean("POWER")); + + pstmt.executeUpdate(); + } + } else { + txtOut.append("Moorers... skipped" + "\n"); + } + rs.close(); + + Dbtname = "payments"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Payments" + "\n"); + SQL = "SELECT * FROM payments"; + rs = stmt_source.executeQuery(SQL); + + if (Dbtversion >= 3.02) { + while (rs.next()) { + SQL = "INSERT INTO payments(" + + "ID, RECEIPT, PAYMENT, TOTAL, " + + "TRANSID, RETURNMSG, NOTES, TENDERED) " + + "VALUES (?, ?, ?, ?, " + + "?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("RECEIPT")); + pstmt.setString(3, rs.getString("PAYMENT")); + pstmt.setDouble(4, rs.getDouble("TOTAL")); + pstmt.setString(5, rs.getString("TRANSID")); + pstmt.setBytes(6, rs.getBytes("RETURNMSG")); + pstmt.setString(7, rs.getString("NOTES")); + pstmt.setDouble(8, rs.getDouble("TENDERED")); + + pstmt.executeUpdate(); + } + } else { + while (rs.next()) { + SQL = "INSERT INTO payments(" + + "ID, RECEIPT, PAYMENT, TOTAL, " + + "TRANSID, RETURNMSG) " + + "VALUES (?, ?, ?, ?, " + + "?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("RECEIPT")); + pstmt.setString(3, rs.getString("PAYMENT")); + pstmt.setDouble(4, rs.getDouble("TOTAL")); + pstmt.setString(5, rs.getString("TRANSID")); + pstmt.setBytes(6, rs.getBytes("RETURNMSG")); + + pstmt.executeUpdate(); + } + } + SQL = "UPDATE payments SET payment='ccard' WHERE payment='magcard'"; + pstmt.execute(SQL); + SQL = "UPDATE payments SET payment='ccardrefund' WHERE payment='magcardrefund'"; + pstmt.execute(SQL); + SQL = "UPDATE payments SET tendered = ROUND(total,2) WHERE tendered is null"; + pstmt.execute(SQL); + + rs.close(); + + Dbtname = "people"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("People" + "\n"); + SQL = "SELECT * FROM people"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO people(" + + "ID, NAME, APPPASSWORD, CARD, " + + "ROLE, VISIBLE, IMAGE) " + + "VALUES (?, ?, ?, ?, " + + "?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("NAME")); + pstmt.setString(3, rs.getString("APPPASSWORD")); + pstmt.setString(4, rs.getString("CARD")); + pstmt.setString(5, rs.getString("ROLE")); + pstmt.setBoolean(6, rs.getBoolean("VISIBLE")); + pstmt.setBytes(7, rs.getBytes("IMAGE")); + + pstmt.executeUpdate(); + } + rs.close(); + +// pickup_number introduced in 3.50 + if (Dbtversion >= 3.50 && !jtxtDbType.getText().equals("jdbc:postgresql://")) { + Dbtname = "pickup_number"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Pickup Number" + "\n"); + SQL = "SELECT * FROM pickup_number"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO pickup_number(ID) " + + "VALUES (?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + + pstmt.executeUpdate(); + } + } else { + txtOut.append("Pickup Number... skipped" + "\n"); + } +// deliberately verbose chunk so can see diff's between PostgreSQL v9 & v10 sequence + if (Dbtversion >= 3.50 && jtxtDbType.getText().equals("jdbc:postgresql://")) { + Dbtname = "pickup_number"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Pickup Number" + "\n"); + SQL = "SELECT * FROM pickup_number"; + rs = stmt_source.executeQuery(SQL); + + String pickupNumber = null; + + while (rs.next()) { + pickupNumber = rs.getString("last_value"); + } + + if (pickupNumber != null) { + SQL = "UPDATE pickup_number SET ID=" + pickupNumber; + } else { + SQL = "UPDATE pickup_number SET ID='1'"; + } + stmt_target.executeUpdate(SQL); + } else { + txtOut.append("Pickup Number... skipped" + "\n"); + } + rs.close(); + + Dbtname = "places"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Places" + "\n"); + SQL = "SELECT * FROM places"; + rs = stmt_source.executeQuery(SQL); + + if (rs.getMetaData().getColumnCount() == 9) { + while (rs.next()) { + SQL = "INSERT INTO places (" + + "ID, NAME, X, Y, FLOOR, " + + "CUSTOMER, WAITER, TICKETID, TABLEMOVED," + + "WIDTH, HEIGHT, GUESTS, OCCUPIED) " + + "VALUES (?, ?, ?, ?, ?, " + + "?, ?, ?, ?, " + + "?, ?, ?, ? )"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("NAME")); + pstmt.setInt(3, rs.getInt("X")); + pstmt.setInt(4, rs.getInt("Y")); + pstmt.setString(5, rs.getString("FLOOR")); + pstmt.setString(6, rs.getString("CUSTOMER")); + pstmt.setString(7, rs.getString("WAITER")); + pstmt.setString(8, rs.getString("TICKETID")); + pstmt.setBoolean(9, rs.getBoolean("TABLEMOVED")); + + pstmt.setInt(10, 90); // Width + pstmt.setInt(11, 45); // Height + pstmt.setInt(12, 1); // Guests + pstmt.setTimestamp(13, null); // Occupied + + pstmt.executeUpdate(); + } + } else { + while (rs.next()) { + SQL = "INSERT INTO places (" + + "ID, NAME, X, Y, FLOOR) " + + "VALUES (?, ?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("NAME")); + pstmt.setInt(3, rs.getInt("X")); + pstmt.setInt(4, rs.getInt("Y")); + pstmt.setString(5, rs.getString("FLOOR")); + + pstmt.executeUpdate(); + } + } + rs.close(); + + Dbtname = "products"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Products" + "\n"); + SQL = "SELECT * FROM products"; + rs = stmt_source.executeQuery(SQL); + + switch (rs.getMetaData().getColumnCount()) { + case 30: + while (rs.next()) { + SQL = "INSERT INTO products(" + + "ID, REFERENCE, CODE, CODETYPE, NAME, " + + "PRICEBUY, PRICESELL, CATEGORY, TAXCAT, ATTRIBUTESET_ID, " + + "STOCKCOST, STOCKVOLUME, IMAGE, ISCOM, ISSCALE, " + + "ISCONSTANT, PRINTKB, SENDSTATUS, ISSERVICE, ATTRIBUTES, " + + "DISPLAY, ISVPRICE, ISVERPATRIB, TEXTTIP, WARRANTY, " + + "STOCKUNITS, PRINTTO, SUPPLIER, UOM, MEMODATE) " + + "VALUES (?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?," + + "?, ?, ?, ?, ?," + + "?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, " + + "?, ?, ?, ? ,?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("REFERENCE")); + pstmt.setString(3, rs.getString("CODE")); + pstmt.setString(4, rs.getString("CODETYPE")); + pstmt.setString(5, rs.getString("NAME")); + pstmt.setDouble(6, rs.getDouble("PRICEBUY")); + pstmt.setDouble(7, rs.getDouble("PRICESELL")); + pstmt.setString(8, rs.getString("CATEGORY")); + pstmt.setString(9, rs.getString("TAXCAT")); + pstmt.setString(10, rs.getString("ATTRIBUTESET_ID")); + pstmt.setDouble(11, rs.getDouble("STOCKCOST")); + pstmt.setDouble(12, rs.getDouble("STOCKVOLUME")); + pstmt.setBytes(13, rs.getBytes("IMAGE")); + pstmt.setBoolean(14, rs.getBoolean("ISCOM")); + pstmt.setBoolean(15, rs.getBoolean("ISSCALE")); + pstmt.setBoolean(16, rs.getBoolean("ISCONSTANT")); + pstmt.setBoolean(17, rs.getBoolean("PRINTKB")); + pstmt.setBoolean(18, rs.getBoolean("SENDSTATUS")); + pstmt.setBoolean(19, rs.getBoolean("ISSERVICE")); + pstmt.setBytes(20, rs.getBytes("ATTRIBUTES")); + pstmt.setString(21, rs.getString("DISPLAY")); + pstmt.setBoolean(22, rs.getBoolean("ISVPRICE")); + pstmt.setBoolean(23, rs.getBoolean("ISVERPATRIB")); + pstmt.setString(24, rs.getString("TEXTTIP")); + pstmt.setBoolean(25, rs.getBoolean("WARRANTY")); + pstmt.setDouble(26, rs.getDouble("STOCKUNITS")); + pstmt.setString(27, rs.getString("PRINTTO")); + pstmt.setString(28, rs.getString("SUPPLIER")); + pstmt.setString(29, rs.getString("UOM")); + pstmt.setTimestamp(30, rs.getTimestamp("MEMODATE")); + + pstmt.executeUpdate(); + } + break; + case 29: + while (rs.next()) { + SQL = "INSERT INTO products(" + + "ID, REFERENCE, CODE, CODETYPE, NAME, " + + "PRICEBUY, PRICESELL, CATEGORY, TAXCAT, ATTRIBUTESET_ID, " + + "STOCKCOST, STOCKVOLUME, IMAGE, ISCOM, ISSCALE, " + + "ISCONSTANT, PRINTKB, SENDSTATUS, ISSERVICE, ATTRIBUTES, " + + "DISPLAY, ISVPRICE, ISVERPATRIB, TEXTTIP, WARRANTY, " + + "STOCKUNITS, PRINTTO, SUPPLIER, UOM) " + + "VALUES (?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?," + + "?, ?, ?, ?, ?," + + "?, ?, ?, ?, ?, " + + "?, ?, ?, ?, ?, " + + "?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("REFERENCE")); + pstmt.setString(3, rs.getString("CODE")); + pstmt.setString(4, rs.getString("CODETYPE")); + pstmt.setString(5, rs.getString("NAME")); + pstmt.setDouble(6, rs.getDouble("PRICEBUY")); + pstmt.setDouble(7, rs.getDouble("PRICESELL")); + pstmt.setString(8, rs.getString("CATEGORY")); + pstmt.setString(9, rs.getString("TAXCAT")); + pstmt.setString(10, rs.getString("ATTRIBUTESET_ID")); + pstmt.setDouble(11, rs.getDouble("STOCKCOST")); + pstmt.setDouble(12, rs.getDouble("STOCKVOLUME")); + pstmt.setBytes(13, rs.getBytes("IMAGE")); + pstmt.setBoolean(14, rs.getBoolean("ISCOM")); + pstmt.setBoolean(15, rs.getBoolean("ISSCALE")); + pstmt.setBoolean(16, rs.getBoolean("ISCONSTANT")); + pstmt.setBoolean(17, rs.getBoolean("PRINTKB")); + pstmt.setBoolean(18, rs.getBoolean("SENDSTATUS")); + pstmt.setBoolean(19, rs.getBoolean("ISSERVICE")); + pstmt.setBytes(20, rs.getBytes("ATTRIBUTES")); + pstmt.setString(21, rs.getString("DISPLAY")); + pstmt.setBoolean(22, rs.getBoolean("ISVPRICE")); + pstmt.setBoolean(23, rs.getBoolean("ISVERPATRIB")); + pstmt.setString(24, rs.getString("TEXTTIP")); + pstmt.setBoolean(25, rs.getBoolean("WARRANTY")); + pstmt.setDouble(26, rs.getDouble("STOCKUNITS")); + pstmt.setString(27, rs.getString("PRINTTO")); + pstmt.setString(28, rs.getString("SUPPLIER")); + pstmt.setString(29, rs.getString("UOM")); + + pstmt.executeUpdate(); + } + break; + default: + while (rs.next()) { + SQL = "INSERT INTO products(" + + "ID, REFERENCE, CODE, CODETYPE, NAME, " + + "PRICEBUY, PRICESELL, CATEGORY, TAXCAT, " + + "ATTRIBUTESET_ID, STOCKCOST, STOCKVOLUME, IMAGE, " + + "ISCOM, ISSCALE, ATTRIBUTES, DISPLAY) " + + "VALUES (?, ?, ?, ?, ?, " + + "?, ?, ?, ?, " + + "?, ?, ?, ?, " + + "?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("REFERENCE")); + pstmt.setString(3, rs.getString("CODE")); + pstmt.setString(4, rs.getString("CODETYPE")); + pstmt.setString(5, rs.getString("NAME")); + pstmt.setDouble(6, rs.getDouble("PRICEBUY")); + pstmt.setDouble(7, rs.getDouble("PRICESELL")); + pstmt.setString(8, rs.getString("CATEGORY")); + pstmt.setString(9, rs.getString("TAXCAT")); + pstmt.setString(10, rs.getString("ATTRIBUTESET_ID")); + pstmt.setDouble(11, rs.getDouble("STOCKCOST")); + pstmt.setDouble(12, rs.getDouble("STOCKVOLUME")); + pstmt.setBytes(13, rs.getBytes("IMAGE")); + pstmt.setBoolean(14, rs.getBoolean("ISCOM")); + pstmt.setBoolean(15, rs.getBoolean("ISSCALE")); + pstmt.setBytes(16, rs.getBytes("ATTRIBUTES")); + pstmt.setString(17, "<html><center>" + rs.getString("NAME")); + + pstmt.executeUpdate(); + } + break; + } + SQL = "UPDATE products set supplier = '0' WHERE supplier is null"; + pstmt.execute(SQL); + rs.close(); + + Dbtname = "products_cat"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Products_Cat" + "\n"); + SQL = "SELECT * FROM products_cat"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO products_cat(" + + "PRODUCT, CATORDER) " + + "VALUES (?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("PRODUCT")); + pstmt.setInt(2, rs.getInt("CATORDER")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "products_com"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Products_Com" + "\n"); + SQL = "SELECT * FROM products_com"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO products_com(" + + "ID, PRODUCT, PRODUCT2) " + + "VALUES (?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("PRODUCT")); + pstmt.setString(3, rs.getString("PRODUCT2")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "receipts"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Receipts" + "\n"); + SQL = "SELECT * FROM receipts"; + rs = stmt_source.executeQuery(SQL); + + if (rs.getMetaData().getColumnCount() == 5) { + while (rs.next()) { + SQL = "INSERT INTO receipts(" + + "ID, MONEY, DATENEW, " + + "ATTRIBUTES, PERSON) " + + "VALUES (?, ?, ?, " + + "?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("MONEY")); + pstmt.setTimestamp(3, rs.getTimestamp("DATENEW")); + pstmt.setBytes(4, rs.getBytes("ATTRIBUTES")); + pstmt.setString(5, rs.getString("PERSON")); + + pstmt.executeUpdate(); + } + } else { + while (rs.next()) { + SQL = "INSERT INTO receipts(" + + "ID, MONEY, DATENEW, ATTRIBUTES) " + + "VALUES (?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("MONEY")); + pstmt.setTimestamp(3, rs.getTimestamp("DATENEW")); + pstmt.setBytes(4, rs.getBytes("ATTRIBUTES")); + + pstmt.executeUpdate(); + } + } + rs.close(); + + Dbtname = "reservation_customers"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Reservation_Customers" + "\n"); + SQL = "SELECT * FROM reservation_customers"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO reservation_customers(" + + "ID, CUSTOMER) " + + "VALUES (?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("CUSTOMER")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "reservations"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Reservations" + "\n"); + SQL = "SELECT * FROM reservations"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO reservations(" + + "ID, CREATED, DATENEW, TITLE, " + + "CHAIRS, ISDONE, DESCRIPTION) " + + "VALUES (?, ?, ?, ?, " + + "?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setTimestamp(2, rs.getTimestamp("CREATED")); + pstmt.setTimestamp(3, rs.getTimestamp("DATENEW")); + pstmt.setString(4, rs.getString("TITLE")); + pstmt.setInt(5, rs.getInt("CHAIRS")); + pstmt.setBoolean(6, rs.getBoolean("ISDONE")); + pstmt.setString(7, rs.getString("DESCRIPTION")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "roles"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Roles" + "\n"); + SQL = "SELECT * FROM roles WHERE NOT ID='0' "; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO roles(" + + "ID, NAME, PERMISSIONS) " + + "VALUES (?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("NAME")); + pstmt.setBytes(3, rs.getBytes("PERMISSIONS")); + + pstmt.executeUpdate(); + } + rs.close(); + +// introduced in 3.00 + if (Dbtversion >= 3.00) { + Dbtname = "shift_breaks"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Shift_breaks" + "\n"); + SQL = "SELECT * FROM shift_breaks"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO shift_breaks(" + + "ID, SHIFTID, BREAKID, " + + "STARTTIME, ENDTIME) " + + "VALUES (?, ?, ?, " + + "?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("SHIFTID")); + pstmt.setString(3, rs.getString("BREAKID")); + pstmt.setTimestamp(4, rs.getTimestamp("STARTTIME")); + pstmt.setTimestamp(5, rs.getTimestamp("ENDTIME")); + + pstmt.executeUpdate(); + } + } else { + txtOut.append("Shift Breaks... skipped" + "\n"); + } + rs.close(); + +// introduced in 3.00 + if (Dbtversion >= 3.00) { + Dbtname = "shifts"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Shifts" + "\n"); + SQL = "SELECT * FROM shifts"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO shifts(" + + "ID, STARTSHIFT, ENDSHIFT, PPLID) " + + "VALUES (?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setTimestamp(2, rs.getTimestamp("STARTSHIFT")); + pstmt.setTimestamp(3, rs.getTimestamp("ENDSHIFT")); + pstmt.setString(4, rs.getString("PPLID")); + + pstmt.executeUpdate(); + } + } else { + txtOut.append("Shifts... skipped" + "\n"); + } + rs.close(); + + Dbtname = "stockcurrent"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Stockcurrent" + "\n"); + SQL = "SELECT * FROM stockcurrent"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO stockcurrent(" + + "LOCATION, PRODUCT, " + + "ATTRIBUTESETINSTANCE_ID, UNITS) " + + "VALUES (?, ?, " + + "?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("LOCATION")); + pstmt.setString(2, rs.getString("PRODUCT")); + pstmt.setString(3, rs.getString("ATTRIBUTESETINSTANCE_ID")); + pstmt.setDouble(4, rs.getDouble("UNITS")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "stockdiary"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Stockdiary" + "\n"); + SQL = "SELECT * FROM stockdiary"; + rs = stmt_source.executeQuery(SQL); + if (rs.getMetaData().getColumnCount() == 9) { + while (rs.next()) { + SQL = "INSERT INTO stockdiary(" + + "ID, DATENEW, REASON, LOCATION, " + + "PRODUCT, ATTRIBUTESETINSTANCE_ID, UNITS, " + + "PRICE, APPUSER) " + + "VALUES (?, ?, ?, ?, " + + "?, ?, ?, " + + "?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setTimestamp(2, rs.getTimestamp("DATENEW")); + pstmt.setInt(3, rs.getInt("REASON")); + pstmt.setString(4, rs.getString("LOCATION")); + pstmt.setString(5, rs.getString("PRODUCT")); + pstmt.setString(6, rs.getString("ATTRIBUTESETINSTANCE_ID")); + pstmt.setDouble(7, rs.getDouble("UNITS")); + pstmt.setDouble(8, rs.getDouble("PRICE")); + pstmt.setString(9, rs.getString("APPUSER")); + + pstmt.executeUpdate(); + } + } else { + while (rs.next()) { + SQL = "INSERT INTO stockdiary(" + + "ID, DATENEW, REASON, LOCATION, " + + "PRODUCT, ATTRIBUTESETINSTANCE_ID, UNITS, " + + "PRICE) " + + "VALUES (?, ?, ?, ?, " + + "?, ?, ?, " + + "?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setTimestamp(2, rs.getTimestamp("DATENEW")); + pstmt.setInt(3, rs.getInt("REASON")); + pstmt.setString(4, rs.getString("LOCATION")); + pstmt.setString(5, rs.getString("PRODUCT")); + pstmt.setString(6, rs.getString("ATTRIBUTESETINSTANCE_ID")); + pstmt.setDouble(7, rs.getDouble("UNITS")); + pstmt.setDouble(8, rs.getDouble("PRICE")); + + pstmt.executeUpdate(); + } + } + rs.close(); + + Dbtname = "stocklevel"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Stocklevel" + "\n"); + SQL = "SELECT * FROM stocklevel"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO stocklevel(" + + "ID, LOCATION, PRODUCT, " + + "STOCKSECURITY, STOCKMAXIMUM) " + + "VALUES (?, ?, ?, " + + "?, ?)"; + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("LOCATION")); + pstmt.setString(3, rs.getString("PRODUCT")); + pstmt.setDouble(4, rs.getDouble("STOCKSECURITY")); + pstmt.setDouble(5, rs.getDouble("STOCKMAXIMUM")); + pstmt.executeUpdate(); + } + rs.close(); + +// introduced in 4 + if (Dbtversion >= 4.00) { + Dbtname = "suppliers"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Suppliers" + "\n"); + SQL = "SELECT * FROM suppliers"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO suppliers(" + + "ID, SEARCHKEY, TAXID, NAME, MAXDEBT," + + "ADDRESS, ADDRESS2, POSTAL, CITY, " + + "REGION, COUNTRY, FIRSTNAME, LASTNAME, " + + "EMAIL, PHONE, PHONE2, FAX, " + + "NOTES, VISIBLE, CURDATE, CURDEBT, VATID)" + + " VALUES (" + + "?, ?, ?, ?, ?," + + "?, ?, ?, ?," + + "?, ?, ?, ?, " + + "?, ?, ?, ?, " + + "?, ?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("SEARCHKEY")); + pstmt.setString(3, rs.getString("TAXID")); + pstmt.setString(4, rs.getString("NAME")); + pstmt.setDouble(5, rs.getDouble("MAXDEBT")); + pstmt.setString(6, rs.getString("ADDRESS")); + pstmt.setString(7, rs.getString("ADDRESS2")); + pstmt.setString(8, rs.getString("POSTAL")); + pstmt.setString(9, rs.getString("CITY")); + pstmt.setString(10, rs.getString("REGION")); + pstmt.setString(11, rs.getString("COUNTRY")); + pstmt.setString(12, rs.getString("FIRSTNAME")); + pstmt.setString(13, rs.getString("LASTNAME")); + pstmt.setString(14, rs.getString("EMAIL")); + pstmt.setString(15, rs.getString("PHONE")); + pstmt.setString(16, rs.getString("PHONE2")); + pstmt.setString(17, rs.getString("FAX")); + pstmt.setString(18, rs.getString("NOTES")); + pstmt.setBoolean(19, rs.getBoolean("VISIBLE")); + pstmt.setTimestamp(20, rs.getTimestamp("CURDATE")); + pstmt.setDouble(21, rs.getDouble("CURDEBT")); + pstmt.setString(22, rs.getString("VATID")); + + pstmt.executeUpdate(); + } + } else { + SQL = "INSERT INTO suppliers(" + + "ID, NAME, SEARCHKEY)" + + " VALUES ('0', 'uniCenta', 'unicenta')"; + pstmt.executeUpdate(SQL); + txtOut.append("Added Supplier... uniCenta" + "\n"); + } + rs.close(); + + Dbtname = "taxcategories"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("TaxCategories" + "\n"); + SQL = "SELECT * FROM taxcategories"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO taxcategories(" + + "ID, NAME) " + + "VALUES (?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("NAME")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "taxcustcategories"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Tax Customer Categories" + "\n"); + SQL = "SELECT * FROM taxcustcategories"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO taxcustcategories(" + + "ID, NAME) " + + "VALUES (?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("NAME")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "taxes"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Taxes" + "\n"); + SQL = "SELECT * FROM taxes"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO taxes(" + + "ID, NAME, CATEGORY, CUSTCATEGORY, " + + "PARENTID, RATE, RATECASCADE, RATEORDER) " + + "VALUES (?, ?, ?, ?, " + + "?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("NAME")); + pstmt.setString(3, rs.getString("CATEGORY")); + pstmt.setString(4, rs.getString("CUSTCATEGORY")); + pstmt.setString(5, rs.getString("PARENTID")); + pstmt.setDouble(6, rs.getDouble("RATE")); + pstmt.setBoolean(7, rs.getBoolean("RATECASCADE")); + pstmt.setInt(8, rs.getInt("RATEORDER")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "taxlines"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("TaxLines" + "\n"); + SQL = "SELECT * FROM taxlines"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO taxlines(" + + "ID, RECEIPT, TAXID, BASE, AMOUNT) " + + "VALUES (?, ?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("RECEIPT")); + pstmt.setString(3, rs.getString("TAXID")); + pstmt.setDouble(4, rs.getDouble("BASE")); + pstmt.setDouble(5, rs.getDouble("AMOUNT")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "thirdparties"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("ThirdParties" + "\n"); + SQL = "SELECT * FROM thirdparties"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO thirdparties(" + + "ID, CIF, NAME, ADDRESS, " + + "CONTACTCOMM, CONTACTFACT, PAYRULE, FAXNUMBER, " + + "PHONENUMBER, MOBILENUMBER, EMAIL, " + + "WEBPAGE, NOTES) " + + "VALUES (?, ?, ?, ?, " + + "?, ?, ?, ?, " + + "?, ?, ?, " + + "?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setString(2, rs.getString("CIF")); + pstmt.setString(3, rs.getString("NAME")); + pstmt.setString(4, rs.getString("ADDRESS")); + pstmt.setString(5, rs.getString("CONTACTCOMM")); + pstmt.setString(6, rs.getString("CONTACTFACT")); + pstmt.setString(7, rs.getString("PAYRULE")); + pstmt.setString(8, rs.getString("FAXNUMBER")); + pstmt.setString(9, rs.getString("PHONENUMBER")); + pstmt.setString(10, rs.getString("MOBILENUMBER")); + pstmt.setString(11, rs.getString("EMAIL")); + pstmt.setString(12, rs.getString("WEBPAGE")); + pstmt.setString(13, rs.getString("NOTES")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "ticketlines"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("TicketLines" + "\n"); + SQL = "SELECT * FROM ticketlines"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO ticketlines(" + + "TICKET, LINE, PRODUCT, ATTRIBUTESETINSTANCE_ID, " + + "UNITS, PRICE, TAXID, ATTRIBUTES) " + + "VALUES (?, ?, ?, ?, " + + "?, ?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("TICKET")); + pstmt.setInt(2, rs.getInt("LINE")); + pstmt.setString(3, rs.getString("PRODUCT")); + pstmt.setString(4, rs.getString("ATTRIBUTESETINSTANCE_ID")); + pstmt.setDouble(5, rs.getDouble("UNITS")); + pstmt.setDouble(6, rs.getDouble("PRICE")); + pstmt.setString(7, rs.getString("TAXID")); + pstmt.setBytes(8, rs.getBytes("ATTRIBUTES")); + + pstmt.executeUpdate(); + } + rs.close(); + + Dbtname = "tickets"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Tickets" + "\n"); + SQL = "SELECT * FROM tickets"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO tickets(" + + "ID, TICKETTYPE, TICKETID, " + + "PERSON, CUSTOMER, STATUS) " + + "VALUES (?, ?, ?, " + + "?, ?, ?)"; + + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("ID")); + pstmt.setInt(2, rs.getInt("TICKETTYPE")); + pstmt.setInt(3, rs.getInt("TICKETID")); + pstmt.setString(4, rs.getString("PERSON")); + pstmt.setString(5, rs.getString("CUSTOMER")); + pstmt.setInt(6, rs.getInt("STATUS")); + + pstmt.executeUpdate(); + } + rs.close(); + + if (Dbtversion >= 3.50 && !jtxtDbType.getText().equals("jdbc:postgresql://")) { + Dbtname = "ticketsnum"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Tickets Number" + "\n"); + SQL = "SELECT * FROM ticketsnum"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + ticketsnum = rs.getString("ID"); + } + if (ticketsnum != null) { + SQL = "UPDATE ticketsnum SET ID= " + ticketsnum; + } else { + SQL = "UPDATE ticketsnum SET ID='1'"; + } + stmt_target.executeUpdate(SQL); + } else { + txtOut.append("Ticket Number... skipped" + "\n"); + } +// deliberately verbose chunk so can see diff's between PostgreSQL v9 & v10 + if (Dbtversion >= 3.50 && jtxtDbType.getText().equals("jdbc:postgresql://")) { + Dbtname = "ticketsnum"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Tickets Number" + "\n"); + SQL = "SELECT * FROM ticketsnum"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + ticketsnum = rs.getString("last_value"); + } + if (ticketsnum != null) { + SQL = "UPDATE ticketsnum SET ID= " + ticketsnum; + } else { + SQL = "UPDATE ticketsnum SET ID='1'"; + } + stmt_target.executeUpdate(SQL); + } else { + txtOut.append("Ticket Number... skipped" + "\n"); + } + rs.close(); + + if (Dbtversion >= 3.50 && !jtxtDbType.getText().equals("jdbc:postgresql://")) { + Dbtname = "ticketsnum_payment"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Tickets Number Payments" + "\n"); + SQL = "SELECT * FROM ticketsnum_payment"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + ticketsnumPayment = rs.getString("ID"); + } + if (ticketsnumPayment != null) { + SQL = "UPDATE ticketsnum_payment SET ID= " + ticketsnumPayment; + } else { + SQL = "UPDATE ticketsnum_payment SET ID='1'"; + } + stmt_target.executeUpdate(SQL); + } else { + txtOut.append("Ticket Payment... skipped" + "\n"); + } +// deliberately verbose chunk so can see diff's between PostgreSQL v9 & v10 sequence + if (Dbtversion >= 3.50 && jtxtDbType.getText().equals("jdbc:postgresql://")) { + Dbtname = "ticketsnum_payment"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Tickets Number Payments" + "\n"); + SQL = "SELECT * FROM ticketsnum_payment"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + ticketsnumPayment = rs.getString("last_value"); + } + if (ticketsnumPayment != null) { + SQL = "UPDATE ticketsnum_payment SET ID= " + ticketsnumPayment; + } else { + SQL = "UPDATE ticketsnum_payment SET ID='1'"; + } + stmt_target.executeUpdate(SQL); + } else { + txtOut.append("Ticket Number Payments... skipped" + "\n"); + } + rs.close(); + + if (Dbtversion >= 3.50 && !jtxtDbType.getText().equals("jdbc:postgresql://")) { + Dbtname = "ticketsnum_refund"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Tickets Number Refunds" + "\n"); + SQL = "SELECT * FROM ticketsnum_refund"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + ticketsnumRefund = rs.getString("ID"); + } + if (ticketsnumRefund != null) { + SQL = "UPDATE ticketsnum_refund SET ID= " + ticketsnumRefund; + } else { + SQL = "UPDATE ticketsnum_refund SET ID='1'"; + } + stmt_target.executeUpdate(SQL); + } else { + txtOut.append("Ticket Refund... skipped" + "\n"); + } +// deliberately verbose chunk so can see diff's between PostgreSQL v9 & v10 sequence + if (Dbtversion >= 3.50 && jtxtDbType.getText().equals("jdbc:postgresql://")) { + Dbtname = "ticketsnum_payment"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("Tickets Number Refunds" + "\n"); + SQL = "SELECT * FROM ticketsnum_refund"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + ticketsnumRefund = rs.getString("last_value"); + } + if (ticketsnumRefund != null) { + SQL = "UPDATE ticketsnum_refund SET ID= " + ticketsnumRefund; + } else { + SQL = "UPDATE ticketsnum_refund SET ID='1'"; + } + stmt_target.executeUpdate(SQL); + } else { + txtOut.append("Ticket Refund... skipped" + "\n"); + } + rs.close(); + +// introduced in 4 + if (Dbtversion >= 4.00) { + Dbtname = "uom"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + txtOut.append("UOM" + "\n"); + SQL = "SELECT * FROM uom"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO uom(" + + "id, name) " + + "VALUES (?, ?)"; + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("id")); + pstmt.setString(2, rs.getString("name")); + + pstmt.executeUpdate(); + } + } else { + SQL = "INSERT INTO uom(" + + "ID, NAME)" + + " VALUES ('0', 'Each')"; + + pstmt.executeUpdate(SQL); + txtOut.append("Added UOM... Each" + "\n"); + } + + if (Dbtversion >= 4.00) { + Dbtname = "vouchers"; + rs = con_source.getMetaData().getTables(null, null, Dbtname, null); + + txtOut.append("Vouchers" + "\n"); + SQL = "SELECT * FROM vouchers"; + rs = stmt_source.executeQuery(SQL); + + while (rs.next()) { + SQL = "INSERT INTO vouchers(" + + "id, voucher_number, customer, " + + "amount, status) " + + "VALUES (?, ?, ?, " + + "?, ?)"; + pstmt = con_target.prepareStatement(SQL); + pstmt.setString(1, rs.getString("id")); + pstmt.setString(2, rs.getString("voucher_number")); + pstmt.setString(3, rs.getString("customer")); + pstmt.setDouble(4, rs.getDouble("amount")); + pstmt.setString(5, rs.getString("status")); + + pstmt.executeUpdate(); + } + } else { + txtOut.append("Vouchers... skipped" + "\n"); + } + rs.close(); + + try { + this.con_target.setAutoCommit(true); + } catch (SQLException ex) { + log.error(ex.getMessage()); + } + +// Add ForeignKeys + JOptionPane.showMessageDialog(this + , AppLocal.getIntString("message.transfercomplete") + , AppLocal.getIntString("message.transfermessage") + , JOptionPane.WARNING_MESSAGE); + + FKeys(); + txtOut.append("Data Transfer Complete" + "\n"); + + webPBar.setString("Finished!"); + webPBar.setBgBottom(Color.GREEN); + jbtnTransfer.setEnabled(true); + + JOptionPane.showMessageDialog(this + , AppLocal.getIntString("message.indexcomplete") + , AppLocal.getIntString("message.transfermessage") + , JOptionPane.WARNING_MESSAGE); + + } catch (SQLException | HeadlessException e) { + session_source.close(); + + JMessageDialog.showMessage(this, new MessageInf(MessageInf.SGN_WARNING, SQL, e)); + } + } else { + JFrame frame = new JFrame(); + JOptionPane.showMessageDialog(frame + , AppLocal.getIntString("message.transfernotsupported") + , AppLocal.getIntString("message.transfermessage") + , JOptionPane.WARNING_MESSAGE); + } + + SQL = "COMMIT;\n" + + "SET autocommit=1;\n" + + "SET unique_checks=1;\n" + + "SET foreign_key_checks=1;"; + pstmt.executeUpdate(SQL); + + session_source.close(); + } + } + + public void fillSchema() { + /* Use existing session credentials but declare new session and connection + * to keep separated from current session instance as database could + * be a different server + */ + + if (jCBSchema.getItemCount() >= 1) { + jCBSchema.removeAllItems(); + } + + try { + String driverlib = jtxtDbDriverLib.getText(); + String driver = jtxtDbDriver.getText(); + String url = jtxtDbType.getText() + + jtxtDbServerPort.getText() + + jtxtDbName.getText() + + jtxtDbParams.getText(); + String user = txtDbUser.getText(); + String password = new String(txtDbPass.getPassword()); + + ClassLoader cloader = new URLClassLoader(new URL[]{ + new File(driverlib).toURI().toURL() + }); + + DriverManager.registerDriver( + new DriverWrapper((Driver) + Class.forName(driver, true, cloader).newInstance())); + + Session session1 = new Session(url, user, password); + + if (jtxtDbType.getText().equals("jdbc:postgresql://")) { + Connection connection1 = DriverManager.getConnection(url, user, password); + Statement st = connection1.createStatement(); + ResultSet rs = st.executeQuery("SELECT datname FROM pg_database WHERE datistemplate = false;"); + while (rs.next()) { + jCBSchema.addItem(rs.getString("datname")); + } + } else { + Connection connection1 = session1.getConnection(); + ResultSet rs = connection1.getMetaData().getCatalogs(); + while (rs.next()) { + jCBSchema.addItem(rs.getString("TABLE_CAT")); + } + } + + jCBSchema.setEnabled(true); + jCBSchema.setSelectedIndex(0); + } catch (MalformedURLException | ClassNotFoundException | SQLException + | InstantiationException | IllegalAccessException ex) { + log.error(ex.getMessage()); + } + } + + public void reset() { +// Main Panel + jtxtDbDriver.setText("com.mysql.jdbc.Driver"); + jtxtDbType.setText("jdbc:mysql://"); + jtxtDbServerPort.setText("localhost:3306/"); + txtDbUser.setText(null); + txtDbPass.setText(null); + jbtnConnect.setEnabled(true); + +// TransferPanel + jCBSchema.removeAllItems(); + jtxtDbName.setText(null); + jtxtDbParams.setText("?zeroDateTimeBehavior=convertToNull"); + jlblVersion.setText(null); + jlblDBSize.setText(null); + + jTransferPanel.setVisible(false); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel5 = new javax.swing.JLabel(); + jLabel18 = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + cbSource = new com.alee.laf.combobox.WebComboBox(); + jtxtDbDriverLib = new com.alee.laf.text.WebTextField(); + jbtnDbDriverLib = new javax.swing.JButton(); + jtxtDbDriver = new com.alee.laf.text.WebTextField(); + jtxtDbType = new com.alee.laf.text.WebTextField(); + txtDbUser = new com.alee.laf.text.WebTextField(); + txtDbPass = new com.alee.laf.text.WebPasswordField(); + jScrollPane1 = new javax.swing.JScrollPane(); + txtOut = new javax.swing.JTextArea(); + jLabel8 = new javax.swing.JLabel(); + jlblSource = new javax.swing.JLabel(); + jLabel9 = new javax.swing.JLabel(); + jbtnConnect = new javax.swing.JButton(); + webPBar = new com.alee.laf.progressbar.WebProgressBar(); + jtxtDbServerPort = new com.alee.laf.text.WebTextField(); + jLabel12 = new javax.swing.JLabel(); + jTransferPanel = new javax.swing.JPanel(); + jLabel13 = new javax.swing.JLabel(); + jCBSchema = new javax.swing.JComboBox<>(); + jLabel14 = new javax.swing.JLabel(); + jtxtDbParams = new com.alee.laf.text.WebTextField(); + jLabel7 = new javax.swing.JLabel(); + jlblVersion = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + jlblDBSize = new javax.swing.JLabel(); + jtxtDbName = new com.alee.laf.text.WebTextField(); + jbtnTransfer = new javax.swing.JButton(); + webMemoryBar = new com.alee.extended.statusbar.WebMemoryBar(); + jLabel10 = new javax.swing.JLabel(); + jLabel15 = new javax.swing.JLabel(); + jbtnSet = new javax.swing.JButton(); + jbtnReset1 = new javax.swing.JButton(); + jbtnReset = new javax.swing.JButton(); + jLabel16 = new javax.swing.JLabel(); + + setBackground(new java.awt.Color(255, 255, 255)); + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + setPreferredSize(new java.awt.Dimension(900, 425)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setForeground(new java.awt.Color(102, 102, 102)); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N + jLabel5.setText(bundle.getString("label.DbType")); // NOI18N + jLabel5.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel5.setMinimumSize(new java.awt.Dimension(150, 30)); + jLabel5.setPreferredSize(new java.awt.Dimension(160, 30)); + + jLabel18.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel18.setForeground(new java.awt.Color(102, 102, 102)); + jLabel18.setText(AppLocal.getIntString("label.dbdriverlib")); // NOI18N + jLabel18.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel18.setMinimumSize(new java.awt.Dimension(150, 30)); + jLabel18.setPreferredSize(new java.awt.Dimension(160, 30)); + + jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel1.setForeground(new java.awt.Color(102, 102, 102)); + jLabel1.setText(AppLocal.getIntString("label.DbDriver")); // NOI18N + jLabel1.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel1.setMinimumSize(new java.awt.Dimension(150, 30)); + jLabel1.setPreferredSize(new java.awt.Dimension(160, 30)); + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setForeground(new java.awt.Color(102, 102, 102)); + jLabel2.setText("Type"); + jLabel2.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel2.setMinimumSize(new java.awt.Dimension(150, 30)); + jLabel2.setPreferredSize(new java.awt.Dimension(160, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setForeground(new java.awt.Color(102, 102, 102)); + jLabel3.setText(AppLocal.getIntString("label.DbUser")); // NOI18N + jLabel3.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel3.setMinimumSize(new java.awt.Dimension(150, 30)); + jLabel3.setPreferredSize(new java.awt.Dimension(160, 30)); + + jLabel4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel4.setForeground(new java.awt.Color(102, 102, 102)); + jLabel4.setText(AppLocal.getIntString("label.DbPassword")); // NOI18N + jLabel4.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel4.setMinimumSize(new java.awt.Dimension(150, 30)); + jLabel4.setPreferredSize(new java.awt.Dimension(100, 30)); + + jLabel6.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + jLabel6.setForeground(new java.awt.Color(51, 51, 51)); + jLabel6.setText("Currently connected to :"); + jLabel6.setPreferredSize(new java.awt.Dimension(150, 30)); + + cbSource.setForeground(new java.awt.Color(51, 51, 51)); + cbSource.setToolTipText(bundle.getString("tooltip.transferfromdb")); // NOI18N + cbSource.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + cbSource.setPreferredSize(new java.awt.Dimension(150, 30)); + cbSource.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cbSourceActionPerformed(evt); + } + }); + + jtxtDbDriverLib.setForeground(new java.awt.Color(51, 51, 51)); + jtxtDbDriverLib.setToolTipText(bundle.getString("tootltip.transferlib")); // NOI18N + jtxtDbDriverLib.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtDbDriverLib.setPreferredSize(new java.awt.Dimension(360, 30)); + + jbtnDbDriverLib.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/fileopen.png"))); // NOI18N + jbtnDbDriverLib.setToolTipText(bundle.getString("tooltip.openfile")); // NOI18N + jbtnDbDriverLib.setMaximumSize(new java.awt.Dimension(64, 32)); + jbtnDbDriverLib.setMinimumSize(new java.awt.Dimension(64, 32)); + jbtnDbDriverLib.setPreferredSize(new java.awt.Dimension(60, 30)); + + jtxtDbDriver.setForeground(new java.awt.Color(51, 51, 51)); + jtxtDbDriver.setToolTipText(bundle.getString("tootltip.transferclass")); // NOI18N + jtxtDbDriver.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtDbDriver.setPreferredSize(new java.awt.Dimension(360, 30)); + + jtxtDbType.setForeground(new java.awt.Color(51, 51, 51)); + jtxtDbType.setToolTipText(bundle.getString("tootltip.transferdbtype")); // NOI18N + jtxtDbType.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtDbType.setPreferredSize(new java.awt.Dimension(150, 30)); + + txtDbUser.setForeground(new java.awt.Color(51, 51, 51)); + txtDbUser.setToolTipText(bundle.getString("tooltip.dbuser")); // NOI18N + txtDbUser.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtDbUser.setPreferredSize(new java.awt.Dimension(125, 30)); + + txtDbPass.setForeground(new java.awt.Color(51, 51, 51)); + txtDbPass.setToolTipText(bundle.getString("tooltip.dbpassword")); // NOI18N + txtDbPass.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + txtDbPass.setPreferredSize(new java.awt.Dimension(125, 30)); + + jScrollPane1.setBorder(null); + jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + jScrollPane1.setViewportBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204))); + jScrollPane1.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N + jScrollPane1.setHorizontalScrollBar(null); + jScrollPane1.setPreferredSize(new java.awt.Dimension(200, 350)); + + txtOut.setColumns(20); + txtOut.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + txtOut.setForeground(new java.awt.Color(0, 153, 255)); + txtOut.setRows(5); + txtOut.setToolTipText(bundle.getString("tooltip.transfertxtout")); // NOI18N + txtOut.setBorder(null); + jScrollPane1.setViewportView(txtOut); + + jLabel8.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + jLabel8.setForeground(new java.awt.Color(0, 153, 255)); + jLabel8.setText("PROGRESS"); + jLabel8.setPreferredSize(new java.awt.Dimension(150, 30)); + + jlblSource.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + jlblSource.setForeground(new java.awt.Color(0, 153, 255)); + jlblSource.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jlblSource.setPreferredSize(new java.awt.Dimension(150, 30)); + + jLabel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel9.setForeground(new java.awt.Color(102, 102, 102)); + jLabel9.setText(AppLocal.getIntString("label.DbUser")); // NOI18N + jLabel9.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel9.setMinimumSize(new java.awt.Dimension(150, 30)); + jLabel9.setPreferredSize(new java.awt.Dimension(160, 30)); + + jbtnConnect.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnConnect.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn1.png"))); // NOI18N + jbtnConnect.setText(bundle.getString("Button.Test")); // NOI18N + jbtnConnect.setToolTipText(bundle.getString("tooltip.dbtest")); // NOI18N + jbtnConnect.setActionCommand(bundle.getString("Button.Test")); // NOI18N + jbtnConnect.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jbtnConnect.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + jbtnConnect.setPreferredSize(new java.awt.Dimension(160, 45)); + jbtnConnect.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnConnectjButtonTestConnectionActionPerformed(evt); + } + }); + + webPBar.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N + webPBar.setHighlightDarkWhite(new java.awt.Color(204, 0, 0)); + webPBar.setPreferredSize(new java.awt.Dimension(240, 30)); + webPBar.setProgressBottomColor(new java.awt.Color(0, 153, 255)); + + jtxtDbServerPort.setForeground(new java.awt.Color(51, 51, 51)); + jtxtDbServerPort.setToolTipText(bundle.getString("tootltip.servernameport")); // NOI18N + jtxtDbServerPort.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtDbServerPort.setPreferredSize(new java.awt.Dimension(360, 30)); + + jLabel12.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel12.setForeground(new java.awt.Color(102, 102, 102)); + jLabel12.setText(bundle.getString("labelServerPort")); // NOI18N + jLabel12.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel12.setMinimumSize(new java.awt.Dimension(150, 30)); + jLabel12.setPreferredSize(new java.awt.Dimension(160, 30)); + + jLabel13.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel13.setForeground(new java.awt.Color(102, 102, 102)); + jLabel13.setText(bundle.getString("label.DbSource")); // NOI18N + jLabel13.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel13.setMinimumSize(new java.awt.Dimension(150, 30)); + jLabel13.setPreferredSize(new java.awt.Dimension(160, 30)); + + jCBSchema.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jCBSchema.setToolTipText(bundle.getString("tootltip.transferdbname")); // NOI18N + jCBSchema.setEnabled(false); + jCBSchema.setPreferredSize(new java.awt.Dimension(360, 30)); + + jLabel14.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel14.setForeground(new java.awt.Color(102, 102, 102)); + jLabel14.setText(bundle.getString("label.DBParameters")); // NOI18N + jLabel14.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel14.setMinimumSize(new java.awt.Dimension(150, 30)); + jLabel14.setPreferredSize(new java.awt.Dimension(160, 30)); + + jtxtDbParams.setForeground(new java.awt.Color(51, 51, 51)); + jtxtDbParams.setToolTipText(bundle.getString("tootltip.transferdbparams")); // NOI18N + jtxtDbParams.setEnabled(false); + jtxtDbParams.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtDbParams.setPreferredSize(new java.awt.Dimension(360, 30)); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setForeground(new java.awt.Color(102, 102, 102)); + jLabel7.setText("DB Version"); + jLabel7.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel7.setMinimumSize(new java.awt.Dimension(150, 30)); + jLabel7.setPreferredSize(new java.awt.Dimension(160, 30)); + + jlblVersion.setFont(new java.awt.Font("Arial", 0, 16)); // NOI18N + jlblVersion.setForeground(new java.awt.Color(0, 204, 255)); + jlblVersion.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jlblVersion.setToolTipText(bundle.getString("tooltip.transferdbversion")); // NOI18N + jlblVersion.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 204, 255))); + jlblVersion.setEnabled(false); + jlblVersion.setMaximumSize(new java.awt.Dimension(150, 30)); + jlblVersion.setMinimumSize(new java.awt.Dimension(150, 30)); + jlblVersion.setPreferredSize(new java.awt.Dimension(125, 30)); + + jLabel11.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel11.setForeground(new java.awt.Color(102, 102, 102)); + jLabel11.setText("DB Size"); + jLabel11.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel11.setMinimumSize(new java.awt.Dimension(150, 30)); + jLabel11.setPreferredSize(new java.awt.Dimension(100, 30)); + + jlblDBSize.setFont(new java.awt.Font("Arial", 0, 16)); // NOI18N + jlblDBSize.setForeground(new java.awt.Color(0, 204, 255)); + jlblDBSize.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jlblDBSize.setToolTipText(bundle.getString("tooltip.transferdbsize")); // NOI18N + jlblDBSize.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 204, 255))); + jlblDBSize.setEnabled(false); + jlblDBSize.setMaximumSize(new java.awt.Dimension(150, 30)); + jlblDBSize.setMinimumSize(new java.awt.Dimension(150, 30)); + jlblDBSize.setPreferredSize(new java.awt.Dimension(120, 30)); + + jtxtDbName.setForeground(new java.awt.Color(51, 51, 51)); + jtxtDbName.setToolTipText(bundle.getString("tootltip.transferdbname")); // NOI18N + jtxtDbName.setEnabled(false); + jtxtDbName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jtxtDbName.setOpaque(true); + jtxtDbName.setPreferredSize(new java.awt.Dimension(0, 0)); + + jbtnTransfer.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnTransfer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn3.png"))); // NOI18N + jbtnTransfer.setText(AppLocal.getIntString("button.transfer")); // NOI18N + jbtnTransfer.setToolTipText(bundle.getString("tooltip.transferdb")); // NOI18N + jbtnTransfer.setEnabled(false); + jbtnTransfer.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jbtnTransfer.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + jbtnTransfer.setMaximumSize(new java.awt.Dimension(70, 33)); + jbtnTransfer.setMinimumSize(new java.awt.Dimension(70, 33)); + jbtnTransfer.setPreferredSize(new java.awt.Dimension(160, 45)); + jbtnTransfer.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnTransferActionPerformed(evt); + } + }); + + webMemoryBar.setBackground(new java.awt.Color(153, 153, 153)); + webMemoryBar.setText("Text"); + webMemoryBar.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + webMemoryBar.setPreferredSize(new java.awt.Dimension(150, 30)); + webMemoryBar.setUsedBorderColor(new java.awt.Color(0, 204, 204)); + webMemoryBar.setUsedFillColor(new java.awt.Color(0, 204, 255)); + + jLabel10.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel10.setForeground(new java.awt.Color(102, 102, 102)); + jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel10.setText("Memory State"); + jLabel10.setMaximumSize(new java.awt.Dimension(150, 30)); + jLabel10.setMinimumSize(new java.awt.Dimension(150, 30)); + jLabel10.setPreferredSize(new java.awt.Dimension(160, 30)); + + jLabel15.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + jLabel15.setForeground(new java.awt.Color(0, 153, 255)); + jLabel15.setText("CHOOSE DATABASE TO TRANSFER FROM"); + jLabel15.setPreferredSize(new java.awt.Dimension(150, 30)); + + jbtnSet.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnSet.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/btn2.png"))); // NOI18N + jbtnSet.setText(AppLocal.getIntString("button.setTransfer")); // NOI18N + jbtnSet.setToolTipText(bundle.getString("tooltip.checkTransfer")); // NOI18N + jbtnSet.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jbtnSet.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); + jbtnSet.setMaximumSize(new java.awt.Dimension(70, 33)); + jbtnSet.setMinimumSize(new java.awt.Dimension(70, 33)); + jbtnSet.setPreferredSize(new java.awt.Dimension(160, 45)); + jbtnSet.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnSetActionPerformed(evt); + } + }); + + jbtnReset1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnReset1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jbtnReset1.setToolTipText(bundle.getString("tooltip.transferReset")); // NOI18N + jbtnReset1.setMaximumSize(new java.awt.Dimension(70, 33)); + jbtnReset1.setMinimumSize(new java.awt.Dimension(70, 33)); + jbtnReset1.setPreferredSize(new java.awt.Dimension(80, 45)); + jbtnReset1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnReset1ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jTransferPanelLayout = new javax.swing.GroupLayout(jTransferPanel); + jTransferPanel.setLayout(jTransferPanelLayout); + jTransferPanelLayout.setHorizontalGroup( + jTransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jTransferPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(jTransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jTransferPanelLayout.createSequentialGroup() + .addGroup(jTransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtDbName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(7, 7, 7) + .addGroup(jTransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(jTransferPanelLayout.createSequentialGroup() + .addComponent(jlblVersion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jlblDBSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jTransferPanelLayout.createSequentialGroup() + .addComponent(jbtnSet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jbtnTransfer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jbtnReset1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(jTransferPanelLayout.createSequentialGroup() + .addGroup(jTransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(jTransferPanelLayout.createSequentialGroup() + .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jCBSchema, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jTransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(webMemoryBar, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 1, Short.MAX_VALUE))) + .addGroup(jTransferPanelLayout.createSequentialGroup() + .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jtxtDbParams, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + ); + jTransferPanelLayout.setVerticalGroup( + jTransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jTransferPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(jTransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jTransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jCBSchema, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(webMemoryBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jTransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jtxtDbParams, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jTransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jlblVersion, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jlblDBSize, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(jTransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jTransferPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jbtnTransfer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnSet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtDbName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jbtnReset1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + jbtnReset.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jbtnReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + jbtnReset.setToolTipText(bundle.getString("tooltip.transferReset")); // NOI18N + jbtnReset.setMaximumSize(new java.awt.Dimension(70, 33)); + jbtnReset.setMinimumSize(new java.awt.Dimension(70, 33)); + jbtnReset.setPreferredSize(new java.awt.Dimension(80, 45)); + jbtnReset.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jbtnResetActionPerformed(evt); + } + }); + + jLabel16.setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N + jLabel16.setForeground(new java.awt.Color(153, 153, 153)); + jLabel16.setText("SET SERVER TO CONNECT TO"); + jLabel16.setPreferredSize(new java.awt.Dimension(150, 30)); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel9, 0, 0, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cbSource, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtxtDbType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtDbServerPort, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtxtDbDriver, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addComponent(jtxtDbDriverLib, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jbtnDbDriverLib, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGap(366, 366, 366) + .addComponent(jbtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jbtnConnect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addComponent(txtDbUser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(txtDbPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jTransferPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jlblSource, javax.swing.GroupLayout.PREFERRED_SIZE, 316, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 278, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(webPBar, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(18, 18, 18) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(webPBar, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jlblSource, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(cbSource, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtDbDriverLib, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jbtnDbDriverLib, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtDbDriver, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jtxtDbType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jtxtDbServerPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtDbUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtDbPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jbtnConnect, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jbtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jTransferPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + + jLabel1.getAccessibleContext().setAccessibleName("DBDriver"); + }// </editor-fold>//GEN-END:initComponents + + private void jbtnTransferActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnTransferActionPerformed + + if (JOptionPane.showConfirmDialog(this, + AppLocal.getIntString("message.transfer"), + AppLocal.getIntString("message.transfertitle"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { + + SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { + + @Override + protected Void doInBackground() throws Exception { + webPBar.setString("Starting..."); + doTransfer(); + return null; + } + }; + + worker.execute(); + + } + System.gc(); + + }//GEN-LAST:event_jbtnTransferActionPerformed + + private void jbtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnResetActionPerformed + + reset(); + deactivate(); + + }//GEN-LAST:event_jbtnResetActionPerformed + + private void jbtnConnectjButtonTestConnectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnConnectjButtonTestConnectionActionPerformed + + if (!jtxtDbName.getText().equalsIgnoreCase(jlblSource.getText())) { + try { + String driverlib = jtxtDbDriverLib.getText(); + String driver = jtxtDbDriver.getText(); + + if ("Derby".equals(cbSource.getSelectedItem())) { + jtxtDbName.setText("/unicentaopos-database"); + } + + String url = jtxtDbType.getText() + + jtxtDbServerPort.getText() + + jtxtDbName.getText() + + jtxtDbParams.getText(); + String user = txtDbUser.getText(); + String password = new String(txtDbPass.getPassword()); + + ClassLoader cloader = new URLClassLoader(new URL[]{ + new File(driverlib).toURI().toURL() + }); + + DriverManager.registerDriver( + new DriverWrapper((Driver) + Class.forName(driver, true, cloader).newInstance())); + + Session session_source = new Session(url, user, password); + Connection connection = session_source.getConnection(); + boolean isValid = (connection == null) + ? false : connection.isValid(1000); + + if (isValid) { + if (!"Derby".equals(cbSource.getSelectedItem())) { + jCBSchema.setEnabled(true); + fillSchema(); + } + + jtxtDbParams.setEnabled(true); + jlblVersion.setEnabled(true); + jlblDBSize.setEnabled(true); + jtxtDbName.setEnabled(true); + jbtnTransfer.setEnabled(true); + jbtnConnect.setEnabled(false); + + jTransferPanel.setVisible(true); + + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.databaseconnectsuccess"), + "Connection Test" + , JOptionPane.INFORMATION_MESSAGE); + } else { + reset(); + + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, "Connection Error")); + } + } catch (InstantiationException + | IllegalAccessException + | MalformedURLException + | ClassNotFoundException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.databasedrivererror"), e)); + + } catch (SQLException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.databaseconnectionerror"), e)); + + } catch (Exception e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, "Unknown exception", e)); + } + } else { + JOptionPane.showMessageDialog(this + , AppLocal.getIntString("message.transfercheck") + , AppLocal.getIntString("message.transfertitle") + , JOptionPane.WARNING_MESSAGE); + + jtxtDbName.setText(""); + } + + }//GEN-LAST:event_jbtnConnectjButtonTestConnectionActionPerformed + + private void cbSourceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSourceActionPerformed + + reset(); + + String dirname = System.getProperty("dirname.path"); + dirname = dirname == null ? "./" : dirname; + + if ("Derby".equals(cbSource.getSelectedItem())) { + jtxtDbDriverLib.setText(new File(new File(dirname) + , "/lib/derby-10.10.2.0.jar").getAbsolutePath()); + jtxtDbDriver.setText("org.apache.derby.jdbc.EmbeddedDriver"); + jtxtDbType.setText("jdbc:derby:"); + jtxtDbServerPort.setText("" + new File(new File(System.getProperty("user.home")) + , "")); + jtxtDbParams.setText(""); + } else if ("PostgreSQL".equals(cbSource.getSelectedItem())) { + jtxtDbDriverLib.setText(new File(new File(dirname) + , "/lib/postgresql-9.4-1208.jdbc4.jar").getAbsolutePath()); + jtxtDbDriver.setText("org.postgresql.Driver"); + jtxtDbType.setText("jdbc:postgresql://"); + jtxtDbServerPort.setText("localhost:5432/"); + jtxtDbParams.setText(""); + } else { + jtxtDbDriverLib.setText(new File(new File(dirname) + , "/lib/mysql-connector-java-5.1.39.jar").getAbsolutePath()); + jtxtDbDriver.setText("com.mysql.jdbc.Driver"); + jtxtDbType.setText("jdbc:mysql://"); + jtxtDbServerPort.setText("localhost:3306/"); + jtxtDbParams.setText("?zeroDateTimeBehavior=convertToNull"); + } + + txtDbUser.setText(""); + txtDbPass.setText(""); + jlblVersion.setText(""); + jlblDBSize.setText(""); + }//GEN-LAST:event_cbSourceActionPerformed + + private void jbtnSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSetActionPerformed + String driverlib; + String driver; + String url; + String user; + String password; + String selected = null; + + driverlib = jtxtDbDriverLib.getText(); + driver = jtxtDbDriver.getText(); + + if ("Derby".equals(cbSource.getSelectedItem())) { + url = jtxtDbType.getText() + + jtxtDbServerPort.getText() + + jtxtDbParams.getText() + + jtxtDbName.getText(); + } else { + url = jtxtDbType.getText() + + jtxtDbServerPort.getText() + + jCBSchema.getSelectedItem().toString() + + jtxtDbParams.getText(); + } + + user = txtDbUser.getText(); + password = new String(txtDbPass.getPassword()); + + try { + ClassLoader cloader = new URLClassLoader(new URL[]{ + new File(driverlib).toURI().toURL() + }); + + DriverManager.registerDriver( + new DriverWrapper((Driver) + Class.forName(driver, true, cloader).newInstance())); + + Session session_source1 = new Session(url, user, password); + Connection connection = session_source1.getConnection(); + + if (!"Derby".equals(cbSource.getSelectedItem())) { + selected = jCBSchema.getSelectedItem().toString(); + if (selected != null) { + jtxtDbName.setText(selected); + } + } + + SQL = "SELECT * FROM applications"; + Statement stmt = (Statement) connection.createStatement(); + rs = stmt.executeQuery(SQL); + rs.next(); + + jlblVersion.setText(rs.getString(3)); + + if (null != jtxtDbType.getText() && jtxtDbName.getText() != null) { + switch (jtxtDbType.getText()) { + case "jdbc:mysql://": + SQL = "SELECT sum(round(((data_length + index_length) " + + "/ 1024 / 1024), 2)), LEFT(VERSION(),3) " + + "FROM information_schema.TABLES " + + "WHERE table_schema = " + "'" + selected + "'"; + rs = stmt.executeQuery(SQL); + rs.next(); + jlblDBSize.setText(rs.getString(1) + "MB"); + break; + case "jdbc:derby:": + SQL = "SELECT SUM((numallocatedpages * pagesize) /1024) /1024 " + + "FROM SYS.SYSTABLES systabs, SYS.SYSSCHEMAS sysschemas, " + + "TABLE (SYSCS_DIAG.SPACE_TABLE()) AS T2 " + + "WHERE systabs.tabletype = 'T' " + + "AND sysschemas.schemaid = systabs.schemaid " + + "AND systabs.tableid = T2.tableid"; + rs = stmt.executeQuery(SQL); + rs.next(); + jlblDBSize.setText(rs.getString(1) + "MB"); + break; + case "jdbc:postgresql://": + SQL = "SELECT pg_size_pretty(pg_database_size(" + "'" + selected + "'" + "))"; + rs = stmt.executeQuery(SQL); + rs.next(); + jlblDBSize.setText(rs.getString(1)); + break; + default: + break; + } + } + + } catch (InstantiationException | IllegalAccessException | MalformedURLException | ClassNotFoundException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.databasedrivererror"), e)); + } catch (SQLException e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, + AppLocal.getIntString("message.databaseconnectionerror"), e)); + } catch (Exception e) { + JMessageDialog.showMessage(this, + new MessageInf(MessageInf.SGN_WARNING, "Unknown exception", e)); + } + }//GEN-LAST:event_jbtnSetActionPerformed + + private void jbtnReset1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnReset1ActionPerformed + + reset(); + deactivate(); + }//GEN-LAST:event_jbtnReset1ActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private com.alee.laf.combobox.WebComboBox cbSource; + private javax.swing.JComboBox<String> jCBSchema; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel15; + private javax.swing.JLabel jLabel16; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JPanel jTransferPanel; + private javax.swing.JButton jbtnConnect; + private javax.swing.JButton jbtnDbDriverLib; + private javax.swing.JButton jbtnReset; + private javax.swing.JButton jbtnReset1; + private javax.swing.JButton jbtnSet; + private javax.swing.JButton jbtnTransfer; + private javax.swing.JLabel jlblDBSize; + private javax.swing.JLabel jlblSource; + private javax.swing.JLabel jlblVersion; + private com.alee.laf.text.WebTextField jtxtDbDriver; + private com.alee.laf.text.WebTextField jtxtDbDriverLib; + private com.alee.laf.text.WebTextField jtxtDbName; + private com.alee.laf.text.WebTextField jtxtDbParams; + private com.alee.laf.text.WebTextField jtxtDbServerPort; + private com.alee.laf.text.WebTextField jtxtDbType; + private com.alee.laf.text.WebPasswordField txtDbPass; + private com.alee.laf.text.WebTextField txtDbUser; + private javax.swing.JTextArea txtOut; + private com.alee.extended.statusbar.WebMemoryBar webMemoryBar; + private com.alee.laf.progressbar.WebProgressBar webPBar; + // End of variables declaration//GEN-END:variables + +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/transfer/TransferPanel.form b/src/main/java/com/unicenta/pos/transfer/TransferPanel.form new file mode 100644 index 0000000..d8c97ed --- /dev/null +++ b/src/main/java/com/unicenta/pos/transfer/TransferPanel.form @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="0"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[900, 450]"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,27,0,0,3,-108"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> +</Form> diff --git a/src/main/java/com/unicenta/pos/transfer/TransferPanel.java b/src/main/java/com/unicenta/pos/transfer/TransferPanel.java new file mode 100644 index 0000000..b56d08e --- /dev/null +++ b/src/main/java/com/unicenta/pos/transfer/TransferPanel.java @@ -0,0 +1,115 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.transfer; + +import com.unicenta.basic.BasicException; +import com.unicenta.pos.forms.AppConfig; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppProperties; +import com.unicenta.pos.forms.JRootFrame; +import java.awt.BorderLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.IOException; +import javax.imageio.ImageIO; + +/** + * + * @author Jack Gerrard + */ +public class TransferPanel extends javax.swing.JFrame { + + private Transfer config; + + /** Creates new form JFrmTransfer + * @param props */ + public TransferPanel(AppProperties props) { + initComponents(); + + try { + this.setIconImage(ImageIO.read(JRootFrame + .class.getResourceAsStream("/com/unicenta/images/favicon.png"))); + } catch (IOException e) { + } + setTitle(AppLocal.APP_NAME + " - " + + AppLocal.APP_VERSION + " - " + + AppLocal.getIntString("Menu.Configuration")); + + addWindowListener(new MyFrameListener()); + + config = new Transfer(props); + + getContentPane().add(config, BorderLayout.CENTER); + + try { + config.activate(); + } catch (BasicException e) { + } + } + + private class MyFrameListener extends WindowAdapter{ + + @Override + public void windowClosing(WindowEvent evt) { + if (config.deactivate()) { + dispose(); + } + } + @Override + public void windowClosed(WindowEvent evt) { + System.exit(0); + } + } + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); + setPreferredSize(new java.awt.Dimension(900, 450)); + + setSize(new java.awt.Dimension(916, 539)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(final String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + + AppConfig config = new AppConfig(args); + config.load(); + + new TransferPanel(config).setVisible(true); + + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/util/AltEncrypter.java b/src/main/java/com/unicenta/pos/util/AltEncrypter.java new file mode 100644 index 0000000..d94ea3f --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/AltEncrypter.java @@ -0,0 +1,83 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.util; + +import java.io.UnsupportedEncodingException; +import java.security.*; +import javax.crypto.*; + +/** + * + * @author JG uniCenta + */ +public class AltEncrypter { + + private Cipher cipherDecrypt; + private Cipher cipherEncrypt; + + /** Creates a new instance of Encrypter + * @param passPhrase */ + public AltEncrypter(String passPhrase) { + + try { + SecureRandom sr = SecureRandom.getInstance("SHA1PRNG"); + sr.setSeed(passPhrase.getBytes("UTF8")); + KeyGenerator kGen = KeyGenerator.getInstance("DESEDE"); + kGen.init(168, sr); + Key key = kGen.generateKey(); + + cipherEncrypt = Cipher.getInstance("DESEDE/ECB/PKCS5Padding"); + cipherEncrypt.init(Cipher.ENCRYPT_MODE, key); + + cipherDecrypt = Cipher.getInstance("DESEDE/ECB/PKCS5Padding"); + cipherDecrypt.init(Cipher.DECRYPT_MODE, key); + } catch (UnsupportedEncodingException | NoSuchPaddingException + | NoSuchAlgorithmException | InvalidKeyException e) { + } + } + + /** + * + * @param str + * @return + */ + public String encrypt(String str) { + try { + return StringUtils.byte2hex(cipherEncrypt.doFinal(str.getBytes("UTF8"))); + } catch (UnsupportedEncodingException | BadPaddingException + | IllegalBlockSizeException e) { + } + return null; + } + + /** + * + * @param str + * @return + */ + public String decrypt(String str) { + try { + return new String(cipherDecrypt.doFinal(StringUtils.hex2byte(str)), "UTF8"); + } catch (UnsupportedEncodingException | BadPaddingException | IllegalBlockSizeException e) { + + } + return null; + } +} diff --git a/src/main/java/com/unicenta/pos/util/BarcodeImage.java b/src/main/java/com/unicenta/pos/util/BarcodeImage.java new file mode 100644 index 0000000..0610de7 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/BarcodeImage.java @@ -0,0 +1,164 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.unicenta.pos.util; + + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.image.BufferedImage; + +import org.krysalis.barcode4j.BarcodeDimension; +import org.krysalis.barcode4j.HumanReadablePlacement; +import org.krysalis.barcode4j.impl.AbstractBarcodeBean; +import org.krysalis.barcode4j.impl.codabar.CodabarBean; +import org.krysalis.barcode4j.impl.code128.Code128Bean; +import org.krysalis.barcode4j.impl.code39.Code39Bean; +import org.krysalis.barcode4j.impl.int2of5.Interleaved2Of5Bean; +import org.krysalis.barcode4j.impl.postnet.POSTNETBean; +import org.krysalis.barcode4j.impl.upcean.EAN13Bean; +import org.krysalis.barcode4j.impl.upcean.EAN8Bean; +import org.krysalis.barcode4j.impl.upcean.UPCABean; +import org.krysalis.barcode4j.impl.upcean.UPCEBean; +import org.krysalis.barcode4j.output.java2d.Java2DCanvasProvider; + +/** + * + * @author adrian + */ +public class BarcodeImage { + + /** + * + * @param value + * @return + */ + + public static Image getBarcodeCodabar(String value) { + AbstractBarcodeBean barcode = new CodabarBean(); + barcode.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); + return getBarcode(value, barcode); + } + + /** + * + * @param value + * @return + */ + public static Image getBarcodeCode39(String value) { + AbstractBarcodeBean barcode = new Code39Bean(); + barcode.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); + return getBarcode(value, barcode); + } + + /** + * + * @param value + * @return + */ + public static Image getBarcodeInterleaved2Of5(String value) { + AbstractBarcodeBean barcode = new Interleaved2Of5Bean(); + barcode.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); + return getBarcode(value, barcode); + } + + /** + * + * @param value + * @return + */ + public static Image getBarcodePOSTNET(String value) { + AbstractBarcodeBean barcode = new POSTNETBean(); + barcode.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); + return getBarcode(value, barcode); + } + + /** + * + * @param value + * @return + */ + public static Image getBarcodeUPCA(String value) { + AbstractBarcodeBean barcode = new UPCABean(); + barcode.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); + return getBarcode(value, barcode); + } + + /** + * + * @param value + * @return + */ + public static Image getBarcodeUPCE(String value) { + AbstractBarcodeBean barcode = new UPCEBean(); + barcode.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); + return getBarcode(value, barcode); + } + + /** + * + * @param value + * @return + */ + public static Image getBarcodeEAN13(String value) { + AbstractBarcodeBean barcode = new EAN13Bean(); + barcode.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); + return getBarcode(value, barcode); + } + + /** + * + * @param value + * @return + */ + public static Image getBarcodeEAN8(String value) { + AbstractBarcodeBean barcode = new EAN8Bean(); + barcode.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); + return getBarcode(value, barcode); + } + + /** + * + * @param value + * @return + */ + public static Image getBarcode128(String value) { + AbstractBarcodeBean barcode = new Code128Bean(); + barcode.setMsgPosition(HumanReadablePlacement.HRP_NONE); + return getBarcode(value, barcode); + } + + private static Image getBarcode(String value, AbstractBarcodeBean barcode) { + + barcode.setModuleWidth(1.0); + barcode.setBarHeight(40.0); + barcode.setFontSize(10.0); + barcode.setQuietZone(10.0); + barcode.doQuietZone(true); + BarcodeDimension dim = barcode.calcDimensions(value); + int width = (int) dim.getWidth(0) + 20; + int height = (int) dim.getHeight(0); + + BufferedImage imgtext = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + Graphics2D g2d = imgtext.createGraphics(); + + g2d.setColor(Color.WHITE); + g2d.fillRect(0, 0, width, height); + + g2d.setColor(Color.BLACK); + + try { + barcode.generateBarcode(new Java2DCanvasProvider(g2d, 0), value); + } catch (IllegalArgumentException e) { + g2d.drawRect(0, 0, width - 1, height - 1); + g2d.drawString(value, 2, height - 3); + } + + g2d.dispose(); + + return imgtext; + } +} diff --git a/src/main/java/com/unicenta/pos/util/Base64Encoder.java b/src/main/java/com/unicenta/pos/util/Base64Encoder.java new file mode 100644 index 0000000..411a46a --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/Base64Encoder.java @@ -0,0 +1,70 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.util; + +import java.io.UnsupportedEncodingException; +import org.apache.commons.codec.binary.Base64; + +/** + * + * @author JG uniCenta + */ +public class Base64Encoder { + + /** + * + * @param base64 + * @return + */ + public static byte[] decode(String base64) { + + try { + return Base64.decodeBase64(base64.getBytes("ASCII")); + } catch (UnsupportedEncodingException e) { + return null; + } + } + + /** + * + * @param raw + * @return + */ + public static String encode(byte[] raw) { + try { + return new String(Base64.encodeBase64(raw), "ASCII"); + } catch (UnsupportedEncodingException e) { + return null; + } + } + + /** + * + * @param raw + * @return + */ + public static String encodeChunked(byte[] raw) { + try { + return new String(Base64.encodeBase64Chunked(raw), "ASCII"); + } catch (UnsupportedEncodingException e) { + return null; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/util/DirectoryEvent.java b/src/main/java/com/unicenta/pos/util/DirectoryEvent.java new file mode 100644 index 0000000..ad70fc5 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/DirectoryEvent.java @@ -0,0 +1,75 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.util; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import javax.swing.JFileChooser; +import javax.swing.filechooser.FileFilter; +import javax.swing.text.JTextComponent; +import com.unicenta.pos.forms.AppLocal; + +/** + * + * @author JG uniCenta + */ +public class DirectoryEvent implements ActionListener { + + private JTextComponent m_jTxtField; + private JFileChooser m_fc; + + /** Creates a new instance of DirectoryChooser + * @param TxtField */ + public DirectoryEvent(JTextComponent TxtField) { + m_jTxtField = TxtField; + m_fc = new JFileChooser(); + + m_fc.resetChoosableFileFilters(); + m_fc.addChoosableFileFilter(new FileFilter() { + public boolean accept(File f) { + if (f.isDirectory()) { + return true; + } else { + String filename = f.getName(); + return filename.endsWith(".jar") + || filename.endsWith(".JAR") + || filename.endsWith(".zip") + || filename.endsWith(".ZIP"); + } + } + @Override + public String getDescription() { + return AppLocal.getIntString("filter.dbdriverlib"); + } + }); + m_fc.setFileSelectionMode(JFileChooser.FILES_ONLY ); + } + + @Override + public void actionPerformed(ActionEvent actionEvent) { + + m_fc.setCurrentDirectory(new File(m_jTxtField.getText())); + if (m_fc.showOpenDialog(m_jTxtField) == JFileChooser.APPROVE_OPTION) { + m_jTxtField.setText(m_fc.getSelectedFile().getAbsolutePath()); + } + } + +} diff --git a/src/main/java/com/unicenta/pos/util/ElapsedTimeBetweenDates.java b/src/main/java/com/unicenta/pos/util/ElapsedTimeBetweenDates.java new file mode 100644 index 0000000..4a71449 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/ElapsedTimeBetweenDates.java @@ -0,0 +1,47 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.util; + +/** + * + * @author user + */ + +import java.util.*; +import java.util.concurrent.TimeUnit; + +public class ElapsedTimeBetweenDates { + + public static void main(String []args) { + Date startDateTime = new Date(System.currentTimeMillis() - 123456789); + Date endDateTime = new Date(); + + Map<TimeUnit,Long> result = computeDiff(startDateTime, endDateTime); + System.out.println(result); + + System.out.println("Days: " + result.get(TimeUnit.DAYS)); + System.out.println("Hours: " + result.get(TimeUnit.HOURS)); + System.out.println("Minutes: " + result.get(TimeUnit.MINUTES)); + System.out.println("Seconds: " + result.get(TimeUnit.SECONDS)); + System.out.println("MilliSeconds: " + result.get(TimeUnit.MILLISECONDS)); + } + + public static Map<TimeUnit,Long> computeDiff(Date date1, Date date2) { + long diffInMilliSeconds = date2.getTime() - date1.getTime(); + List<TimeUnit> units = new ArrayList<>(EnumSet.allOf(TimeUnit.class)); + Collections.reverse(units); + Map<TimeUnit,Long> result = new LinkedHashMap<>(); + long milliSecondsRest = diffInMilliSeconds; + for (TimeUnit unit : units) { + long diff = unit.convert(milliSecondsRest,TimeUnit.MILLISECONDS); + long diffInMilliSecondsForUnit = unit.toMillis(diff); + milliSecondsRest = milliSecondsRest - diffInMilliSecondsForUnit; + result.put(unit,diff); + } + return result; + } + +} diff --git a/src/main/java/com/unicenta/pos/util/FXWeb.java b/src/main/java/com/unicenta/pos/util/FXWeb.java new file mode 100644 index 0000000..a3f10ae --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/FXWeb.java @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2016-2017 uniCenta <info at unicenta.com> + * + * This program 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. + * + * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + */ +package com.unicenta.pos.util; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javafx.application.Platform; +import javafx.collections.ObservableList; +import javafx.embed.swing.JFXPanel; +import javafx.scene.Group; +import javafx.scene.Node; +import javafx.scene.Scene; +import javafx.scene.web.WebEngine; +import javafx.scene.web.WebView; +import javafx.stage.Stage; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import com.sun.javafx.application.PlatformImpl; + +/** + * SwingFXWebView + */ +public class FXWeb extends JPanel +{ + private Stage stage; + private WebView browser; + private JFXPanel jfxPanel; + private JButton swingButton; + private WebEngine webEngine; + private Object geo; + + public FXWeb() + { + this.initComponents(); + } + + public static void main(final String... args) + { + // Run this later: + SwingUtilities.invokeLater(new Runnable() + { + @Override + public void run() + { + final JFrame frame = new JFrame(); + frame.getContentPane().add(new FXWeb()); + frame.setMinimumSize(new Dimension(640, 480)); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + } + }); + } + + private void initComponents() + { + this.jfxPanel = new JFXPanel(); + this.createScene(); + this.setLayout(new BorderLayout()); + this.add(this.jfxPanel, BorderLayout.CENTER); + this.swingButton = new JButton(); + this.swingButton.addActionListener(new ActionListener() + { + + @Override + public void actionPerformed(final ActionEvent e) + { + Platform.runLater(new Runnable() + { + + @Override + public void run() + { + FXWeb.this.webEngine.reload(); + } + }); + } + }); + this.swingButton.setText("Reload"); + this.add(this.swingButton, BorderLayout.SOUTH); + } + + /** + * createScene Note: Key is that Scene needs to be created and run on + * "FX user thread" NOT on the AWT-EventQueue Thread + */ + private void createScene() + { + PlatformImpl.startup(() -> { + FXWeb.this.stage = new Stage(); + FXWeb.this.stage.setTitle("Hello Java FX"); + FXWeb.this.stage.setResizable(true); + final Group root = new Group(); + final Scene scene = new Scene(root, 80, 20); + FXWeb.this.stage.setScene(scene); + FXWeb.this.browser = new WebView(); + FXWeb.this.webEngine = FXWeb.this.browser.getEngine(); + FXWeb.this.webEngine.load("https://unicenta.com/pages/configure-unicenta-opos/"); + final ObservableList<Node> children = root.getChildren(); + children.add(FXWeb.this.browser); + FXWeb.this.jfxPanel.setScene(scene); + }); + } +} diff --git a/src/main/java/com/unicenta/pos/util/FileChooserEvent.java b/src/main/java/com/unicenta/pos/util/FileChooserEvent.java new file mode 100644 index 0000000..3eeaf51 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/FileChooserEvent.java @@ -0,0 +1,75 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.util; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import javax.swing.JFileChooser; +import javax.swing.filechooser.FileFilter; +import javax.swing.text.JTextComponent; +import com.unicenta.pos.forms.AppLocal; + +/** + * + * @author JG uniCenta + */ +public class FileChooserEvent implements ActionListener { + + private JTextComponent m_jTxtField; + private JFileChooser m_fc; + + /** Creates a new instance of FileChooser + * @param TxtField */ + public FileChooserEvent(JTextComponent TxtField) { + m_jTxtField = TxtField; + m_fc = new JFileChooser(); + + m_fc.resetChoosableFileFilters(); + m_fc.addChoosableFileFilter(new FileFilter() { + public boolean accept(File f) { + if (f.isDirectory()) { + return true; + } else { + String filename = f.getName(); + return filename.endsWith(".jpg") + || filename.endsWith(".JPG") + || filename.endsWith(".png") + || filename.endsWith(".PNG"); + } + } + @Override + public String getDescription() { + return AppLocal.getIntString("filter.imgfile"); + } + }); + m_fc.setFileSelectionMode(JFileChooser.FILES_ONLY ); + } + + @Override + public void actionPerformed(ActionEvent actionEvent) { + + m_fc.setCurrentDirectory(new File(m_jTxtField.getText())); + if (m_fc.showOpenDialog(m_jTxtField) == JFileChooser.APPROVE_OPTION) { + m_jTxtField.setText(m_fc.getSelectedFile().getAbsolutePath()); + } + } + +} diff --git a/src/main/java/com/unicenta/pos/util/FlatLookAndFeel.java b/src/main/java/com/unicenta/pos/util/FlatLookAndFeel.java new file mode 100644 index 0000000..8ec0a39 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/FlatLookAndFeel.java @@ -0,0 +1,45 @@ +package com.unicenta.pos.util; + +import com.formdev.flatlaf.FlatLaf; +import lombok.extern.slf4j.Slf4j; +import org.reflections.Reflections; +import org.reflections.scanners.SubTypesScanner; + +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.stream.Collectors; + +@Slf4j +public class FlatLookAndFeel { + + + public static Map<String, String> getLafs(){ + Map<String, String> lafs = new TreeMap<>(); + Set<Class> classes = findAllClassesUsingReflectionsLibrary("com.formdev.flatlaf"); + classes.forEach((Class name) -> { + try { + Field[] declaredFields = name.getDeclaredFields(); + for (Field field: declaredFields) { + if (field.getName().equals("NAME")) { + lafs.put((String)field.get(null), name.getCanonicalName()); + } + } + } catch (Exception e) { + log.error("Error getting Flat Look and Feel "+e.getMessage()); + } + }); + + + return lafs; + } + + private static Set<Class> findAllClassesUsingReflectionsLibrary(String packageName) { + Reflections reflections = new Reflections(packageName, new SubTypesScanner(false)); + return reflections.getSubTypesOf(FlatLaf.class) + .stream() + .collect(Collectors.toSet()); + } +} diff --git a/src/main/java/com/unicenta/pos/util/FtpUpload.java b/src/main/java/com/unicenta/pos/util/FtpUpload.java new file mode 100644 index 0000000..86813ae --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/FtpUpload.java @@ -0,0 +1,69 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/> + +package com.unicenta.pos.util; + +import lombok.extern.slf4j.Slf4j; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.URL; +import java.net.URLConnection; + +@Slf4j +public class FtpUpload extends Thread { + + private static final int BUFFER_SIZE = 1024; + private static String sMachine; + + @Override + public void run() { + String ftpUrl = ""; + String host = ""; + String user = ""; + String pass = ""; + + try { + sMachine = InetAddress.getLocalHost().getHostName(); + + String filePath = System.getProperty("user.home") + "/" + sMachine + ".lau"; + String uploadPath = sMachine + ".lau"; + + ftpUrl = String.format(ftpUrl, user, pass, host, uploadPath); + + URL url = new URL(ftpUrl); + URLConnection conn = url.openConnection(); + try (OutputStream outputStream = conn.getOutputStream(); + FileInputStream inputStream = new FileInputStream(filePath)) { + + byte[] buffer = new byte[BUFFER_SIZE]; + int bytesRead = -1; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + + } + + } catch (IOException ex) { + log.error(ex.getMessage()); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/util/Hashcypher.java b/src/main/java/com/unicenta/pos/util/Hashcypher.java new file mode 100644 index 0000000..3f6fa05 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/Hashcypher.java @@ -0,0 +1,133 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.util; + +import java.awt.Component; +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import javax.swing.ImageIcon; +import javax.swing.JOptionPane; +import com.unicenta.beans.JPasswordDialog; +import com.unicenta.pos.forms.AppLocal; + +/** + * + * @author JG uniCenta + */ +public class Hashcypher { + + + /** Creates a new instance of Hashcypher */ + public Hashcypher() { + } + + /** + * + * @param sPassword + * @param sHashPassword + * @return + */ + public static boolean authenticate(String sPassword, String sHashPassword) { + if (sHashPassword == null || sHashPassword.equals("") || sHashPassword.startsWith("empty:")) { + return sPassword == null || sPassword.equals(""); + } else if (sHashPassword.startsWith("sha1:")) { + return sHashPassword.equals(hashString(sPassword)); + } else if (sHashPassword.startsWith("plain:")) { + return sHashPassword.equals("plain:" + sPassword); + } else { + return sHashPassword.equals(sPassword); + } + } + + /** + * + * @param sPassword + * @return + */ + public static String hashString(String sPassword) { + + if (sPassword == null || sPassword.equals("")) { + return "empty:"; + } else { + try { + MessageDigest md = MessageDigest.getInstance("SHA-1"); + md.update(sPassword.getBytes("UTF-8")); + byte[] res = md.digest(); + return "sha1:" + StringUtils.byte2hex(res); + } catch (NoSuchAlgorithmException e) { + return "plain:" + sPassword; + } catch (UnsupportedEncodingException e) { + return "plain:" + sPassword; + } + } + } + + /** + * + * @param parent + * @return + */ + public static String changePassword(Component parent) { + // Show the changePassword dialogs but do not check the old password + + String sPassword = JPasswordDialog.showEditPassword(parent, + AppLocal.getIntString("label.Password"), + AppLocal.getIntString("label.passwordnew"), + new ImageIcon(Hashcypher.class.getResource("/com/unicenta/images/password.png"))); + if (sPassword != null) { + String sPassword2 = JPasswordDialog.showEditPassword(parent, + AppLocal.getIntString("label.Password"), + AppLocal.getIntString("label.passwordrepeat"), + new ImageIcon(Hashcypher.class.getResource("/com/unicenta/images/password.png"))); + if (sPassword2 != null) { + if (sPassword.equals(sPassword2)) { + return Hashcypher.hashString(sPassword); + } else { + JOptionPane.showMessageDialog(parent, AppLocal.getIntString("message.changepassworddistinct"), AppLocal.getIntString("message.title"), JOptionPane.WARNING_MESSAGE); + } + } + } + + return null; + } + + /** + * + * @param parent + * @param sOldPassword + * @return + */ + public static String changePassword(Component parent, String sOldPassword) { + + String sPassword = JPasswordDialog.showEditPassword(parent, + AppLocal.getIntString("label.Password"), + AppLocal.getIntString("label.passwordold"), + new ImageIcon(Hashcypher.class.getResource("/com/unicenta/images/password.png"))); + if (sPassword != null) { + if (Hashcypher.authenticate(sPassword, sOldPassword)) { + return changePassword(parent); + } else { + JOptionPane.showMessageDialog(parent, AppLocal.getIntString("message.BadPassword"), AppLocal.getIntString("message.title"), JOptionPane.WARNING_MESSAGE); + } + } + return null; + } +} diff --git a/src/main/java/com/unicenta/pos/util/HtmlTester.java b/src/main/java/com/unicenta/pos/util/HtmlTester.java new file mode 100644 index 0000000..24f38d3 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/HtmlTester.java @@ -0,0 +1,67 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.util; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.SwingUtilities; +import javax.swing.text.Document; +import javax.swing.text.html.HTMLEditorKit; +import javax.swing.text.html.StyleSheet; + +/** + * HTML viewer with styles,* using the JEditorPane, HTMLTester, StyleSheet, and JFrame. + * + */ +public class HtmlTester +{ + public static void main(String[] args) + { + new HtmlTester(); + } + + public HtmlTester() + { + SwingUtilities.invokeLater(() -> { + JEditorPane jEditorPane = new JEditorPane(); + jEditorPane.setEditable(false); + JScrollPane scrollPane = new JScrollPane(jEditorPane); + + HTMLEditorKit kit = new HTMLEditorKit(); + jEditorPane.setEditorKit(kit); + + StyleSheet styleSheet = kit.getStyleSheet(); + styleSheet.addRule("body {color:#000; font-family:times; margin: 4px; }"); + styleSheet.addRule("h1 {color: blue;}"); + styleSheet.addRule("h2 {color: #ff0000;}"); + styleSheet.addRule("pre {font : 12px century gothic; color : black; background-color : #fafafa; }"); + + String htmlString = "<html>\n" + + "<body>\n" + + "<h1>Welcome!</h1>\n" + + "<h2>This is an H2 header</h2>\n" + + "<p>This is some sample text</p>\n" + + "<p><a href=\"https://unicenta.com/\">uniCenta site</a></p>\n" + + "</body>\n"; + + Document doc = kit.createDefaultDocument(); + jEditorPane.setDocument(doc); + jEditorPane.setText(htmlString); + + JFrame j = new JFrame("Html Test"); + j.getContentPane().add(scrollPane, BorderLayout.CENTER); + + j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + j.setSize(new Dimension(300,200)); + + j.setLocationRelativeTo(null); + j.setVisible(true); + }); + } +} diff --git a/src/main/java/com/unicenta/pos/util/HtmlTester2.java b/src/main/java/com/unicenta/pos/util/HtmlTester2.java new file mode 100644 index 0000000..6a17d15 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/HtmlTester2.java @@ -0,0 +1,33 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.util; + +import java.net.URL; + +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.JScrollPane; + +public class HtmlTester2 { + + public static void main(String[] a)throws Exception { + JFrame frame = new JFrame(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JEditorPane editorPane = new JEditorPane(); + + editorPane.setPage(new URL("https://unicenta.org/splasher.html")); + // Test LocalFile + + frame.add(new JScrollPane(editorPane)); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLocationRelativeTo(null); + frame.setSize(800, 400); + + frame.setVisible(true); + } + +} diff --git a/src/main/java/com/unicenta/pos/util/HtmlTester3.form b/src/main/java/com/unicenta/pos/util/HtmlTester3.form new file mode 100644 index 0000000..cbae086 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/HtmlTester3.form @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jScrollPane1" pref="760" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jScrollPane1" pref="556" max="32767" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JEditorPane" name="jEditorPane1"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + <Property name="page" type="java.net.URL" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="new URL("https://unicenta.org/splasher.html")" type="code"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[800, 600]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/util/HtmlTester3.java b/src/main/java/com/unicenta/pos/util/HtmlTester3.java new file mode 100644 index 0000000..5220260 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/HtmlTester3.java @@ -0,0 +1,114 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.util; + +import lombok.extern.slf4j.Slf4j; + +import java.io.IOException; +import java.net.URL; + +/** + * @author user + */ +@Slf4j +public class HtmlTester3 extends javax.swing.JDialog { + + /** + * Creates new form HtmlTester3 + * + * @param parent + * @param modal + */ + public HtmlTester3(java.awt.Frame parent, boolean modal) { + super(parent, modal); + initComponents(); + try { + jEditorPane1.setPage("https://unicenta.org/splasher.html"); + + } catch (IOException ex) { + log.error(ex.getMessage()); + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + jEditorPane1 = new javax.swing.JEditorPane(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + jEditorPane1.setEditable(false); + try { + jEditorPane1.setPage(new URL("https://unicenta.org/splasher.html")); + } catch (java.io.IOException e1) { + e1.printStackTrace(); + } + jEditorPane1.setPreferredSize(new java.awt.Dimension(800, 600)); + jScrollPane1.setViewportView(jEditorPane1); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 760, Short.MAX_VALUE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 556, Short.MAX_VALUE) + .addContainerGap()) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { +// if ("Nimbus".equals(info.getName())) { + if ("Windows".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException + | javax.swing.UnsupportedLookAndFeelException ex) { + log.error(ex.getMessage()); + } + + /* Create and display the dialog */ + java.awt.EventQueue.invokeLater(() -> { + HtmlTester3 dialog = new HtmlTester3(new javax.swing.JFrame(), true); + dialog.addWindowListener(new java.awt.event.WindowAdapter() { + @Override + public void windowClosing(java.awt.event.WindowEvent e) { + System.exit(0); + } + }); + dialog.setVisible(true); + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JEditorPane jEditorPane1; + private javax.swing.JScrollPane jScrollPane1; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/unicenta/pos/util/InactivityListener.java b/src/main/java/com/unicenta/pos/util/InactivityListener.java new file mode 100644 index 0000000..575ce83 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/InactivityListener.java @@ -0,0 +1,96 @@ +/* + * + * KEY_EVENTS + * MOUSE_EVENTS - which includes mouse motion events + * USER_EVENTS - includes KEY_EVENTS and MOUSE_EVENT (this is the default) + * + */ + +package com.unicenta.pos.util; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +/** + * + * @author JG uniCenta + */ +public class InactivityListener implements ActionListener, AWTEventListener { + + /** + * + */ + public final static long KEY_EVENTS = AWTEvent.KEY_EVENT_MASK; + + /** + * + */ + public final static long MOUSE_EVENTS = + AWTEvent.MOUSE_MOTION_EVENT_MASK + AWTEvent.MOUSE_EVENT_MASK; + + /** + * + */ + public final static long USER_EVENTS = KEY_EVENTS + MOUSE_EVENTS; + private Action action; + private int interval; + private long eventMask; + private Timer timer = new Timer(0, this); + +// Specify the inactivity interval and listen for USER_EVENTS + /** + * + * @param action + * @param seconds + */ + public InactivityListener(Action action, int seconds) { + this.action = action; + this.eventMask =USER_EVENTS; + timer.setInitialDelay(seconds); + } + + /** + * + */ + public void start() { + timer.setRepeats(false); + timer.start(); + Toolkit.getDefaultToolkit().addAWTEventListener(this, eventMask); + } + + /** + * + */ + public void stop() { + Toolkit.getDefaultToolkit().removeAWTEventListener(this); + timer.stop(); + } + +// Implement ActionListener for the Timer + public void actionPerformed(ActionEvent e) { + action.actionPerformed(e); + } + +// Implement AWTEventListener, all events are dispatched via this + public void eventDispatched(AWTEvent e) { + if (timer.isRunning()) + timer.restart(); + } + +// Implement a manually triggered restart + /** + * + */ + public void restart(){ + timer.restart(); + } + + /** + * + */ + public void setRunning() { + if (!timer.isRunning()) + timer.restart(); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/util/JRPrinterAWT300.java b/src/main/java/com/unicenta/pos/util/JRPrinterAWT300.java new file mode 100644 index 0000000..b7fc145 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/JRPrinterAWT300.java @@ -0,0 +1,308 @@ +/* + * ============================================================================ + * GNU Lesser General Public License + * ============================================================================ + * + * JasperReports - Free Java report-generating library. + * Copyright (c) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + * + * JasperSoft Corporation + * 303 Second Street, Suite 450 North + * San Francisco, CA 94107 + * http://www.jaspersoft.com + */ + +// Portions: +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta +// https://unicenta.com +// author Jack Gerrard +// This class is a copy of net.sf.jasperreports.engine.print.JRPrinterAWT +// The modifications are: +// Added to the constructor the service, instead of isDialog +// And the redesign of the design properties of the toolbar +// Nothing else. + +package com.unicenta.pos.util; + +import java.awt.Graphics; +import java.awt.HeadlessException; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.awt.print.*; +import javax.print.PrintService; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRExporterParameter; +import net.sf.jasperreports.engine.JasperPrint; +import net.sf.jasperreports.engine.export.*; +import net.sf.jasperreports.engine.export.JRGraphics2DExporter; +import net.sf.jasperreports.engine.export.JRGraphics2DExporterParameter; +import net.sf.jasperreports.engine.util.JRGraphEnvInitializer; +import org.apache.poi.hssf.usermodel.*; + + +/** + * @author Teodor Danciu (teodord@users.sourceforge.net) + * @version $Id: JRPrinterAWT.java 2123 2008-03-12 11:00:41Z teodord $ + */ +public class JRPrinterAWT300 implements Printable +{ + + + /** + * + */ + private JasperPrint jasperPrint = null; + private int pageOffset = 0; + + + /** + * + * @param jrPrint + * @param jrPrint + * @throws net.sf.jasperreports.engine.JRException + * @throws JRException + */ + protected JRPrinterAWT300(JasperPrint jrPrint) throws JRException + { + JRGraphEnvInitializer.initializeGraphEnv(); + + jasperPrint = jrPrint; + } + + + /** + * + * @param jrPrint + * @param firstPageIndex + * @param lastPageIndex + * @param service + * @return + * @return + * @throws JRException + */ + public static boolean printPages( + JasperPrint jrPrint, + int firstPageIndex, + int lastPageIndex, + PrintService service + ) throws JRException + { + JRPrinterAWT300 printer = new JRPrinterAWT300(jrPrint); + return printer.printPages( + firstPageIndex, + lastPageIndex, + service + ); + } + + + /** + * + * @param jrPrint + * @param pageIndex + * @param zoom + * @return + * @throws JRException + */ + public static Image printPageToImage( + JasperPrint jrPrint, + int pageIndex, + float zoom + ) throws JRException + { + JRPrinterAWT300 printer = new JRPrinterAWT300(jrPrint); + return printer.printPageToImage(pageIndex, zoom); + } + + + /** + * + */ + private boolean printPages( + int firstPageIndex, + int lastPageIndex, + PrintService service + ) throws JRException + { + boolean isOK = true; + + if ( + firstPageIndex < 0 || + firstPageIndex > lastPageIndex || + lastPageIndex >= jasperPrint.getPages().size() + ) + { + throw new JRException( + "Invalid page index range : " + + firstPageIndex + " - " + + lastPageIndex + " of " + + jasperPrint.getPages().size() + ); + } + + pageOffset = firstPageIndex; + + PrinterJob printJob = PrinterJob.getPrinterJob(); + + // fix for bug ID 6255588 from Sun bug database + initPrinterJobFields(printJob); + + PageFormat pageFormat = printJob.defaultPage(); + Paper paper = pageFormat.getPaper(); + + printJob.setJobName("uniCentaReport - " + jasperPrint.getName()); + + switch (jasperPrint.getOrientationValue()) + { + case LANDSCAPE : + { + pageFormat.setOrientation(PageFormat.LANDSCAPE); + paper.setSize(jasperPrint.getPageHeight(), jasperPrint.getPageWidth()); + paper.setImageableArea( + 0, + 0, + jasperPrint.getPageHeight(), + jasperPrint.getPageWidth() + ); + break; + } + case PORTRAIT : + default : + { + pageFormat.setOrientation(PageFormat.PORTRAIT); + paper.setSize(jasperPrint.getPageWidth(), jasperPrint.getPageHeight()); + paper.setImageableArea( + 0, + 0, + jasperPrint.getPageWidth(), + jasperPrint.getPageHeight() + ); + } + } + + pageFormat.setPaper(paper); + + Book book = new Book(); + book.append(this, pageFormat, lastPageIndex - firstPageIndex + 1); + printJob.setPageable(book); + try + { + if (service == null) { + if (printJob.printDialog()) { + printJob.print(); + } + } else { + printJob.setPrintService(service); + printJob.print(); + } + } + catch (HeadlessException | PrinterException ex) + { + throw new JRException("Error printing report.", ex); + } + + return isOK; + } + + + /** + * + */ + @Override + public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException + { + if (Thread.currentThread().isInterrupted()) + { + throw new PrinterException("Current thread interrupted."); + } + + pageIndex += pageOffset; + + if ( pageIndex < 0 || pageIndex >= jasperPrint.getPages().size() ) + { + return Printable.NO_SUCH_PAGE; + } + + try + { + JRGraphics2DExporter exporter = new JRGraphics2DExporter(); + exporter.setParameter(JRExporterParameter.JASPER_PRINT, this.jasperPrint); + exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, graphics); + exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex)); + exporter.exportReport(); + } + catch (JRException e) + { + throw new PrinterException(e.getMessage()); + } + + return Printable.PAGE_EXISTS; + } + + + /** + * + */ + private Image printPageToImage(int pageIndex, float zoom) throws JRException + { + Image pageImage = new BufferedImage( + (int)(jasperPrint.getPageWidth() * zoom) + 1, + (int)(jasperPrint.getPageHeight() * zoom) + 1, + BufferedImage.TYPE_INT_RGB + ); + + JRGraphics2DExporter exporter = new JRGraphics2DExporter(); + exporter.setParameter(JRExporterParameter.JASPER_PRINT, this.jasperPrint); + exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, pageImage.getGraphics()); + exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex)); + exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, new Float(zoom)); + + exporter.exportReport(); + + return pageImage; + } + + + /** + * Fix for bug ID 6255588 from Sun bug database + * @param job print job that the fix applies to + */ + public static void initPrinterJobFields(PrinterJob job) + { + try + { + job.setPrintService(job.getPrintService()); + } + catch (PrinterException e) + { + } + } + + /** + * + * @param jasperPrint + * @param zoom + * @return + */ + public static long getImageSize(JasperPrint jasperPrint, float zoom) + { + int width = (int) (jasperPrint.getPageWidth() * zoom) + 1; + int height = (int) (jasperPrint.getPageHeight() * zoom) + 1; + return width * height; + } +} diff --git a/src/main/java/com/unicenta/pos/util/JRViewer400.form b/src/main/java/com/unicenta/pos/util/JRViewer400.form new file mode 100644 index 0000000..77c2bda --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/JRViewer400.form @@ -0,0 +1,567 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 150]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[450, 150]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-20,0,0,2,77"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JToolBar" name="jToolBar"> + <Properties> + <Property name="floatable" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="btnSave"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/filesave.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getBundleString("save")" type="code"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnSaveActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + <Component class="javax.swing.JButton" name="btnPrint"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/yast_printer.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getBundleString("print")" type="code"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnPrintActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + <Component class="javax.swing.JButton" name="btnReload"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/reload.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getBundleString("reload")" type="code"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnReloadActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + <Component class="javax.swing.JToolBar$Separator" name="jSeparator1"> + </Component> + <Component class="javax.swing.JToggleButton" name="btnActualSize"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/mime.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getBundleString("actual.size")" type="code"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnActualSizeActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + <Component class="javax.swing.JToggleButton" name="btnFitPage"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/mime2.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getBundleString("fit.page")" type="code"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnFitPageActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + <Component class="javax.swing.JToggleButton" name="btnFitWidth"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/mime3.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getBundleString("fit.width")" type="code"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnFitWidthActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + <Component class="javax.swing.JToolBar$Separator" name="jSeparator2"> + </Component> + <Component class="javax.swing.JButton" name="btnZoomIn"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/viewmag+.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getBundleString("zoom.in")" type="code"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnZoomInActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + <Component class="javax.swing.JComboBox" name="cmbZoom"> + <Properties> + <Property name="editable" type="boolean" value="true"/> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getBundleString("zoom.ratio")" type="code"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 23]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 23]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 23]"/> + </Property> + </Properties> + <Events> + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="cmbZoomItemStateChanged"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmbZoomActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="DefaultComboBoxModel model = new DefaultComboBoxModel(); for(int i = 0; i < zooms.length; i++) { model.addElement("" + zooms[i] + "%"); } cmbZoom.setModel(model); "/> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + <Component class="javax.swing.JButton" name="btnZoomOut"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/viewmag-.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getBundleString("zoom.out")" type="code"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnZoomOutActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + <Component class="javax.swing.JToolBar$Separator" name="jSeparator3"> + </Component> + <Component class="javax.swing.JButton" name="btnFirst"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/2leftarrow.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getBundleString("first.page")" type="code"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnFirstActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + <Component class="javax.swing.JButton" name="btnPrevious"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/1leftarrow.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getBundleString("previous.page")" type="code"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnPreviousActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + <Component class="javax.swing.JTextField" name="txtGoTo"> + <Properties> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getBundleString("go.to.page")" type="code"/> + </Property> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 23]"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 23]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[40, 23]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txtGoToActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + <Component class="javax.swing.JButton" name="btnNext"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/1rightarrow.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getBundleString("next.page")" type="code"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnNextActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + <Component class="javax.swing.JButton" name="btnLast"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/2rightarrow.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="getBundleString("last.page")" type="code"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnLastActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="pnlMain"> + <Events> + <EventHandler event="componentResized" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="pnlMainComponentResized"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="scrollPane"> + <Properties> + <Property name="horizontalScrollBarPolicy" type="int" value="32"/> + <Property name="verticalScrollBarPolicy" type="int" value="22"/> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="scrollPane.getHorizontalScrollBar().setUnitIncrement(5); scrollPane.getVerticalScrollBar().setUnitIncrement(5); "/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="pnlInScroll"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="pnlPage"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 100]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 100]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="5" insetsLeft="5" insetsBottom="5" insetsRight="5" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 120]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 120]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="pnlLinks"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 5]"/> + </Property> + <Property name="opaque" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 5]"/> + </Property> + </Properties> + <Events> + <EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="pnlLinksMousePressed"/> + <EventHandler event="mouseReleased" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="pnlLinksMouseReleased"/> + <EventHandler event="mouseDragged" listener="java.awt.event.MouseMotionListener" parameters="java.awt.event.MouseEvent" handler="pnlLinksMouseDragged"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="0" gridWidth="2" gridHeight="2" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + </Container> + <Container class="javax.swing.JPanel" name="jPanel5"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="80" green="80" id="gray" palette="0" red="80" type="palette"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 5]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 5]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="2" gridY="1" gridWidth="1" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + </Container> + <Container class="javax.swing.JPanel" name="jPanel6"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 5]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 5]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + </Container> + <Container class="javax.swing.JPanel" name="jPanel7"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="80" green="80" id="gray" palette="0" red="80" type="palette"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 5]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 5]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="1" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + </Container> + <Container class="javax.swing.JPanel" name="jPanel8"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="80" green="80" id="gray" palette="0" red="80" type="palette"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 5]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 5]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="2" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="text" type="java.lang.String" value="jLabel1"/> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel9"> + <Properties> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 5]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[5, 5]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="2" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + </Container> + <Component class="javax.swing.JLabel" name="lblPage"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" id="white" palette="0" red="ff" type="palette"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Agency FB" size="12" style="0"/> + </Property> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder/> + </Border> + </Property> + <Property name="opaque" type="boolean" value="true"/> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new PageRenderer(this);"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="0" gridWidth="2" gridHeight="2" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JTabbedPane" name="pnlTabs"> + <Events> + <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="pnlTabsStateChanged"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="pnlStatus"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[59, 20]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="addKeyListener(keyNavigationListener);"/> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"> + <Property name="horizontalGap" type="int" value="0"/> + <Property name="verticalGap" type="int" value="0"/> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="lblStatus"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Page i of n"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[59, 18]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="4"/> + </AuxValues> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/util/JRViewer400.java b/src/main/java/com/unicenta/pos/util/JRViewer400.java new file mode 100644 index 0000000..ff256b6 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/JRViewer400.java @@ -0,0 +1,2410 @@ +/* + * JasperReports - Free Java Reporting Library. + * Copyright (C) 2001 - 2014 TIBCO Software Inc. All rights reserved. + * http://www.jaspersoft.com + * + * Unless you have purchased a commercial license agreement from Jaspersoft, + * the following license terms apply: + * + * This program is part of JasperReports. + * + * JasperReports is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * JasperReports 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with JasperReports. If not, see <http://www.gnu.org/licenses/>. + */ + +/* + * Contributors: + * Ryan Johnson - delscovich@users.sourceforge.net + * Carlton Moore - cmoore79@users.sourceforge.net + * Petr Michalek - pmichalek@users.sourceforge.net + */ +package com.unicenta.pos.util; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.InputStream; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.text.MessageFormat; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.ImageIcon; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JViewport; +import javax.swing.SwingUtilities; +import javax.swing.filechooser.FileFilter; + +import net.sf.jasperreports.engine.DefaultJasperReportsContext; +import net.sf.jasperreports.engine.ImageMapRenderable; +import net.sf.jasperreports.engine.JRConstants; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JRPrintAnchorIndex; +import net.sf.jasperreports.engine.JRPrintElement; +import net.sf.jasperreports.engine.JRPrintFrame; +import net.sf.jasperreports.engine.JRPrintHyperlink; +import net.sf.jasperreports.engine.JRPrintImage; +import net.sf.jasperreports.engine.JRPrintImageAreaHyperlink; +import net.sf.jasperreports.engine.JRPrintPage; +import net.sf.jasperreports.engine.JRPropertiesUtil; +import net.sf.jasperreports.engine.JRRuntimeException; +import net.sf.jasperreports.engine.JasperPrint; +import net.sf.jasperreports.engine.JasperPrintManager; +import net.sf.jasperreports.engine.JasperReportsContext; +import net.sf.jasperreports.engine.PrintPageFormat; +import net.sf.jasperreports.engine.PrintPart; +import net.sf.jasperreports.engine.PrintParts; +import net.sf.jasperreports.engine.Renderable; +import net.sf.jasperreports.engine.export.JRGraphics2DExporter; +import net.sf.jasperreports.engine.type.HyperlinkTypeEnum; +import net.sf.jasperreports.engine.util.JRLoader; +import net.sf.jasperreports.engine.util.LocalJasperReportsContext; +import net.sf.jasperreports.engine.util.SimpleFileResolver; +import net.sf.jasperreports.engine.xml.JRPrintXmlLoader; +import net.sf.jasperreports.export.SimpleExporterInput; +import net.sf.jasperreports.export.SimpleGraphics2DExporterOutput; +import net.sf.jasperreports.export.SimpleGraphics2DReportConfiguration; +import net.sf.jasperreports.view.JRHyperlinkListener; +import net.sf.jasperreports.view.JRSaveContributor; +import net.sf.jasperreports.view.SaveContributorUtils; +import net.sf.jasperreports.view.save.JRPrintSaveContributor; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Represents the built-in visual component for JasperReports. + * This class is different from the rest of the classes listed previously in that it is more like a + * pluggable component than a utility class. It can be used in Swing-based + * applications to view the reports generated by the JasperReports library. + * This visual component was included like a demo + * component to show how the core printing functionality can be used to display the reports + * in Swing-based applications. + * The preferred way to adapt this component to a particular application is by subclassing it. + * + * @author Teodor Danciu (teodord@users.sourceforge.net) + * @version $Id: JRViewer400.java 2160 2008-04-29 11:31:51Z lucianc $ + */ +public final class JRViewer400 extends javax.swing.JPanel implements JRHyperlinkListener +{ + private static final Log log = LogFactory.getLog(JRViewer400.class); + + private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; + + /** + * Maximum size (in pixels) of a buffered image that would be used to render a report page. + * If rendering a report page would require an image larger than this threshold + * (i.e. image width x image height greater maximum size), the report page will be rendered directly on the viewer component. + * If this property is zero or negative, buffered images will never be user to render a report page. + * By default, this property is set to 0. + */ + public static final String VIEWER_RENDER_BUFFER_MAX_SIZE + = JRPropertiesUtil.PROPERTY_PREFIX + "viewer.render.buffer.max.size"; + + /** + * + */ + protected static final int TYPE_FILE_NAME = 1; + protected static final int TYPE_INPUT_STREAM = 2; + protected static final int TYPE_OBJECT = 3; + + /** + * The DPI of the generated report. + */ + public static final int REPORT_RESOLUTION = 72; + + protected final float MIN_ZOOM = 0.5f; + protected final float MAX_ZOOM = 10f; + protected int zooms[] = {50, 75, 100, 125, 150, 175, 200, 250, 400, 800}; + protected int defaultZoomIndex = 2; + + protected int type = TYPE_FILE_NAME; + protected boolean isXML; + protected String reportFileName; + JasperPrint jasperPrint; + private int pageIndex; + private boolean pageError; + protected float zoom; + + private JRGraphics2DExporter exporter; + + /** + * the screen resolution. + */ + private int screenResolution = REPORT_RESOLUTION; + + /** + * the zoom ration adjusted to the screen resolution. + */ + protected float realZoom; + + private DecimalFormat zoomDecimalFormat; + protected JasperReportsContext jasperReportsContext; + protected LocalJasperReportsContext localJasperReportsContext; + private ResourceBundle resourceBundle; + + private int downX; + private int downY; + + private boolean pnlTabsChangeListenerEnabled = true; + + private List<JRHyperlinkListener> hyperlinkListeners = new ArrayList<JRHyperlinkListener>(); + private Map<JPanel,JRPrintHyperlink> linksMap = new HashMap<JPanel,JRPrintHyperlink>(); + private MouseListener mouseListener = + new java.awt.event.MouseAdapter() + { + public void mouseClicked(java.awt.event.MouseEvent evt) + { + hyperlinkClicked(evt); + } + }; + + protected KeyListener keyNavigationListener = + new KeyListener() { + public void keyTyped(KeyEvent evt) + { + } + public void keyPressed(KeyEvent evt) + { + keyNavigate(evt); + } + public void keyReleased(KeyEvent evt) + { + } + }; + + protected List<JRSaveContributor> saveContributors = new ArrayList<JRSaveContributor>(); + protected File lastFolder; + protected JRSaveContributor lastSaveContributor; + + /** + * @see #JRViewer(JasperReportsContext, String, boolean, Locale, ResourceBundle) + */ + public JRViewer400(String fileName, boolean isXML) throws JRException + { + this(fileName, isXML, null); + } + + + /** + * @see #JRViewer(JasperReportsContext, InputStream, boolean, Locale, ResourceBundle) + */ + public JRViewer400(InputStream is, boolean isXML) throws JRException + { + this(is, isXML, null); + } + + + /** + * @see #JRViewer(JasperReportsContext, JasperPrint, Locale, ResourceBundle) + */ + public JRViewer400(JasperPrint jrPrint) + { + this(jrPrint, null); + } + + + /** + * @see #JRViewer(JasperReportsContext, String, boolean, Locale, ResourceBundle) + */ + public JRViewer400(String fileName, boolean isXML, Locale locale) throws JRException + { + this(fileName, isXML, locale, null); + } + + + /** + * @see #JRViewer(JasperReportsContext, InputStream, boolean, Locale, ResourceBundle) + */ + public JRViewer400(InputStream is, boolean isXML, Locale locale) throws JRException + { + this(is, isXML, locale, null); + } + + + /** Creates new form JRViewer400 + * @param jrPrint + * @param locale */ + public JRViewer400(JasperPrint jrPrint, Locale locale) + { + this(jrPrint, locale, null); + } + + + /** + * @see #JRViewer(JasperReportsContext, String, boolean, Locale, ResourceBundle) + */ + public JRViewer400(String fileName, boolean isXML, Locale locale, ResourceBundle resBundle) throws JRException + { + this( + DefaultJasperReportsContext.getInstance(), + fileName, + isXML, + locale, + resBundle + ); + } + + + /** + * @see #JRViewer(JasperReportsContext, InputStream, boolean, Locale, ResourceBundle) + */ + public JRViewer400(InputStream is, boolean isXML, Locale locale, ResourceBundle resBundle) throws JRException + { + this( + DefaultJasperReportsContext.getInstance(), + is, + isXML, + locale, + resBundle + ); + } + + + /** + * @see #JRViewer(JasperReportsContext, JasperPrint, Locale, ResourceBundle) + */ + public JRViewer400(JasperPrint jrPrint, Locale locale, ResourceBundle resBundle) + { + this( + DefaultJasperReportsContext.getInstance(), + jrPrint, + locale, + resBundle + ); + } + + + /** + * + */ + public JRViewer400( + JasperReportsContext jasperReportsContext, + String fileName, + boolean isXML, + Locale locale, + ResourceBundle resBundle + ) throws JRException + { + this.jasperReportsContext = jasperReportsContext; + + initResources(locale, resBundle); + + setScreenDetails(); + + setZooms(); + + initComponents(); + + loadReport(fileName, isXML); + + cmbZoom.setSelectedIndex(defaultZoomIndex); + + initSaveContributors(); + + addHyperlinkListener(this); + } + + + /** + * + */ + public JRViewer400( + JasperReportsContext jasperReportsContext, + InputStream is, + boolean isXML, + Locale locale, + ResourceBundle resBundle + ) throws JRException + { + this.jasperReportsContext = jasperReportsContext; + + initResources(locale, resBundle); + + setScreenDetails(); + + setZooms(); + + initComponents(); + + loadReport(is, isXML); + + cmbZoom.setSelectedIndex(defaultZoomIndex); + + initSaveContributors(); + + addHyperlinkListener(this); + } + + + /** + * + */ + public JRViewer400( + JasperReportsContext jasperReportsContext, + JasperPrint jrPrint, + Locale locale, + ResourceBundle resBundle + ) + { + this.jasperReportsContext = jasperReportsContext; + + initResources(locale, resBundle); + + setScreenDetails(); + + setZooms(); + + initComponents(); + + loadReport(jrPrint); + + cmbZoom.setSelectedIndex(defaultZoomIndex); + + initSaveContributors(); + + addHyperlinkListener(this); + } + + /** + * + * @param jrPrint + */ + public void loadJasperPrint(JasperPrint jrPrint) { + + loadReport(jrPrint); + setZoomRatio(zooms[defaultZoomIndex] / 100f); + cmbZoomItemStateChanged(null); + refreshPage(); + } + + + private void setScreenDetails() + { + screenResolution = Toolkit.getDefaultToolkit().getScreenResolution(); + } + + + /** + * + */ + public void clear() + { + emptyContainer(this); + jasperPrint = null; + } + + + /** + * + */ + protected void setZooms() + { + } + + + /** + * + */ + public void addSaveContributor(JRSaveContributor contributor) + { + saveContributors.add(contributor); + } + + + /** + * + */ + public void removeSaveContributor(JRSaveContributor contributor) + { + saveContributors.remove(contributor); + } + + + /** + * + */ + public JRSaveContributor[] getSaveContributors() + { + return saveContributors.toArray(new JRSaveContributor[saveContributors.size()]); + } + + + /** + * Replaces the save contributors with the ones provided as parameter. + */ + public void setSaveContributors(JRSaveContributor[] saveContribs) + { + this.saveContributors = new ArrayList<JRSaveContributor>(); + if (saveContribs != null) + { + this.saveContributors.addAll(Arrays.asList(saveContribs)); + } + } + + + /** + * + */ + public void addHyperlinkListener(JRHyperlinkListener listener) + { + hyperlinkListeners.add(listener); + } + + + /** + * + */ + public void removeHyperlinkListener(JRHyperlinkListener listener) + { + hyperlinkListeners.remove(listener); + } + + + /** + * + */ + public JRHyperlinkListener[] getHyperlinkListeners() + { + return hyperlinkListeners.toArray(new JRHyperlinkListener[hyperlinkListeners.size()]); + } + + + /** + * + */ + protected void initResources(Locale locale, ResourceBundle resBundle) + { + //FIXME in theory, the setLocale method could be called after current Component was created, in which case all below should be reloaded + if (locale != null) + { + setLocale(locale); + } + else + { + setLocale(Locale.getDefault()); + } + if (resBundle == null) + { + this.resourceBundle = ResourceBundle.getBundle("net/sf/jasperreports/view/viewer", getLocale()); + } + else + { + this.resourceBundle = resBundle; + } + + zoomDecimalFormat = new DecimalFormat("#.##", DecimalFormatSymbols.getInstance(getLocale())); + } + + + /** + * + */ + protected JasperReportsContext getJasperReportsContext() + { + return jasperReportsContext; + } + + + /** + * + */ + protected String getBundleString(String key) + { + return resourceBundle.getString(key); + } + + + /** + * + */ + protected void initSaveContributors() + { + List<JRSaveContributor> builtinContributors = SaveContributorUtils.createBuiltinContributors( + jasperReportsContext, getLocale(), resourceBundle); + saveContributors.addAll(builtinContributors); + } + + + /** + * + */ + public void gotoHyperlink(JRPrintHyperlink hyperlink) + { + switch(hyperlink.getHyperlinkTypeValue()) + { + case REFERENCE : + { + if (isOnlyHyperlinkListener()) + { + System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference()); + System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); + } + break; + } + case LOCAL_ANCHOR : + { + if (hyperlink.getHyperlinkAnchor() != null) + { + Map<String,JRPrintAnchorIndex> anchorIndexes = jasperPrint.getAnchorIndexes(); + JRPrintAnchorIndex anchorIndex = anchorIndexes.get(hyperlink.getHyperlinkAnchor()); + if (anchorIndex.getPageIndex() != pageIndex) + { + setPageIndex(anchorIndex.getPageIndex()); + refreshPage(); + } + Container container = pnlInScroll.getParent(); + if (container instanceof JViewport) + { + JViewport viewport = (JViewport) container; + + int newX = (int)(anchorIndex.getElementAbsoluteX() * realZoom); + int newY = (int)(anchorIndex.getElementAbsoluteY() * realZoom); + + int maxX = pnlInScroll.getWidth() - viewport.getWidth(); + int maxY = pnlInScroll.getHeight() - viewport.getHeight(); + + if (newX < 0) + { + newX = 0; + } + if (newX > maxX) + { + newX = maxX; + } + if (newY < 0) + { + newY = 0; + } + if (newY > maxY) + { + newY = maxY; + } + + viewport.setViewPosition(new Point(newX, newY)); + } + } + + break; + } + case LOCAL_PAGE : + { + int page = pageIndex + 1; + if (hyperlink.getHyperlinkPage() != null) + { + page = hyperlink.getHyperlinkPage().intValue(); + } + + if (page >= 1 && page <= jasperPrint.getPages().size() && page != pageIndex + 1) + { + setPageIndex(page - 1); + refreshPage(); + Container container = pnlInScroll.getParent(); + if (container instanceof JViewport) + { + JViewport viewport = (JViewport) container; + viewport.setViewPosition(new Point(0, 0)); + } + } + + break; + } + case REMOTE_ANCHOR : + { + if (isOnlyHyperlinkListener()) + { + System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference()); + System.out.println("Hyperlink anchor : " + hyperlink.getHyperlinkAnchor()); + System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); + } + break; + } + case REMOTE_PAGE : + { + if (isOnlyHyperlinkListener()) + { + System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference()); + System.out.println("Hyperlink page : " + hyperlink.getHyperlinkPage()); + System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); + } + break; + } + case CUSTOM : + { + if (isOnlyHyperlinkListener()) + { + System.out.println("Hyperlink of type " + hyperlink.getLinkType()); + System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); + } + break; + } + case NONE : + default : + { + break; + } + } + } + + + protected boolean isOnlyHyperlinkListener() + { + int listenerCount; + if (hyperlinkListeners == null) + { + listenerCount = 0; + } + else + { + listenerCount = hyperlinkListeners.size(); + if (hyperlinkListeners.contains(this)) + { + --listenerCount; + } + } + return listenerCount == 0; + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + jToolBar = new javax.swing.JToolBar(); + btnSave = new javax.swing.JButton(); + btnPrint = new javax.swing.JButton(); + btnReload = new javax.swing.JButton(); + jSeparator1 = new javax.swing.JToolBar.Separator(); + btnActualSize = new javax.swing.JToggleButton(); + btnFitPage = new javax.swing.JToggleButton(); + btnFitWidth = new javax.swing.JToggleButton(); + jSeparator2 = new javax.swing.JToolBar.Separator(); + btnZoomIn = new javax.swing.JButton(); + cmbZoom = new javax.swing.JComboBox(); + DefaultComboBoxModel model = new DefaultComboBoxModel(); + for(int i = 0; i < zooms.length; i++) + { + model.addElement("" + zooms[i] + "%"); + } + cmbZoom.setModel(model); + btnZoomOut = new javax.swing.JButton(); + jSeparator3 = new javax.swing.JToolBar.Separator(); + btnFirst = new javax.swing.JButton(); + btnPrevious = new javax.swing.JButton(); + txtGoTo = new javax.swing.JTextField(); + btnNext = new javax.swing.JButton(); + btnLast = new javax.swing.JButton(); + pnlMain = new javax.swing.JPanel(); + scrollPane = new javax.swing.JScrollPane(); + scrollPane.getHorizontalScrollBar().setUnitIncrement(5); + scrollPane.getVerticalScrollBar().setUnitIncrement(5); + pnlInScroll = new javax.swing.JPanel(); + pnlPage = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + pnlLinks = new javax.swing.JPanel(); + jPanel5 = new javax.swing.JPanel(); + jPanel6 = new javax.swing.JPanel(); + jPanel7 = new javax.swing.JPanel(); + jPanel8 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jPanel9 = new javax.swing.JPanel(); + lblPage = new PageRenderer(this); + pnlTabs = new javax.swing.JTabbedPane(); + pnlStatus = new javax.swing.JPanel(); + lblStatus = new javax.swing.JLabel(); + + setMinimumSize(new java.awt.Dimension(450, 150)); + setPreferredSize(new java.awt.Dimension(450, 150)); + setLayout(new java.awt.BorderLayout()); + + jToolBar.setFloatable(false); + jToolBar.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + + btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/filesave.png"))); // NOI18N + btnSave.setToolTipText(getBundleString("save")); + btnSave.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnSaveActionPerformed(evt); + } + }); + jToolBar.add(btnSave); + + btnPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/yast_printer.png"))); // NOI18N + btnPrint.setToolTipText(getBundleString("print")); + btnPrint.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnPrintActionPerformed(evt); + } + }); + jToolBar.add(btnPrint); + + btnReload.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/reload.png"))); // NOI18N + btnReload.setToolTipText(getBundleString("reload")); + btnReload.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnReloadActionPerformed(evt); + } + }); + jToolBar.add(btnReload); + jToolBar.add(jSeparator1); + + btnActualSize.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/mime.png"))); // NOI18N + btnActualSize.setToolTipText(getBundleString("actual.size")); + btnActualSize.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnActualSizeActionPerformed(evt); + } + }); + jToolBar.add(btnActualSize); + + btnFitPage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/mime2.png"))); // NOI18N + btnFitPage.setToolTipText(getBundleString("fit.page")); + btnFitPage.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnFitPageActionPerformed(evt); + } + }); + jToolBar.add(btnFitPage); + + btnFitWidth.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/mime3.png"))); // NOI18N + btnFitWidth.setToolTipText(getBundleString("fit.width")); + btnFitWidth.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnFitWidthActionPerformed(evt); + } + }); + jToolBar.add(btnFitWidth); + jToolBar.add(jSeparator2); + + btnZoomIn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/viewmag+.png"))); // NOI18N + btnZoomIn.setToolTipText(getBundleString("zoom.in")); + btnZoomIn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnZoomInActionPerformed(evt); + } + }); + jToolBar.add(btnZoomIn); + + cmbZoom.setEditable(true); + cmbZoom.setToolTipText(getBundleString("zoom.ratio")); + cmbZoom.setMaximumSize(new java.awt.Dimension(80, 23)); + cmbZoom.setMinimumSize(new java.awt.Dimension(80, 23)); + cmbZoom.setPreferredSize(new java.awt.Dimension(80, 23)); + cmbZoom.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + cmbZoomItemStateChanged(evt); + } + }); + cmbZoom.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cmbZoomActionPerformed(evt); + } + }); + jToolBar.add(cmbZoom); + + btnZoomOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/viewmag-.png"))); // NOI18N + btnZoomOut.setToolTipText(getBundleString("zoom.out")); + btnZoomOut.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnZoomOutActionPerformed(evt); + } + }); + jToolBar.add(btnZoomOut); + jToolBar.add(jSeparator3); + + btnFirst.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/2leftarrow.png"))); // NOI18N + btnFirst.setToolTipText(getBundleString("first.page")); + btnFirst.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnFirstActionPerformed(evt); + } + }); + jToolBar.add(btnFirst); + + btnPrevious.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/1leftarrow.png"))); // NOI18N + btnPrevious.setToolTipText(getBundleString("previous.page")); + btnPrevious.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnPreviousActionPerformed(evt); + } + }); + jToolBar.add(btnPrevious); + + txtGoTo.setToolTipText(getBundleString("go.to.page")); + txtGoTo.setMaximumSize(new java.awt.Dimension(40, 23)); + txtGoTo.setMinimumSize(new java.awt.Dimension(40, 23)); + txtGoTo.setPreferredSize(new java.awt.Dimension(40, 23)); + txtGoTo.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txtGoToActionPerformed(evt); + } + }); + jToolBar.add(txtGoTo); + + btnNext.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/1rightarrow.png"))); // NOI18N + btnNext.setToolTipText(getBundleString("next.page")); + btnNext.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnNextActionPerformed(evt); + } + }); + jToolBar.add(btnNext); + + btnLast.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/2rightarrow.png"))); // NOI18N + btnLast.setToolTipText(getBundleString("last.page")); + btnLast.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnLastActionPerformed(evt); + } + }); + jToolBar.add(btnLast); + + add(jToolBar, java.awt.BorderLayout.NORTH); + + pnlMain.addComponentListener(new java.awt.event.ComponentAdapter() { + public void componentResized(java.awt.event.ComponentEvent evt) { + pnlMainComponentResized(evt); + } + }); + pnlMain.setLayout(new java.awt.BorderLayout()); + + scrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + scrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + + pnlInScroll.setLayout(new java.awt.GridBagLayout()); + + pnlPage.setMinimumSize(new java.awt.Dimension(100, 100)); + pnlPage.setPreferredSize(new java.awt.Dimension(100, 100)); + pnlPage.setLayout(new java.awt.BorderLayout()); + + jPanel4.setMinimumSize(new java.awt.Dimension(100, 120)); + jPanel4.setPreferredSize(new java.awt.Dimension(100, 120)); + jPanel4.setLayout(new java.awt.GridBagLayout()); + + pnlLinks.setMinimumSize(new java.awt.Dimension(5, 5)); + pnlLinks.setOpaque(false); + pnlLinks.setPreferredSize(new java.awt.Dimension(5, 5)); + pnlLinks.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(java.awt.event.MouseEvent evt) { + pnlLinksMousePressed(evt); + } + public void mouseReleased(java.awt.event.MouseEvent evt) { + pnlLinksMouseReleased(evt); + } + }); + pnlLinks.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { + public void mouseDragged(java.awt.event.MouseEvent evt) { + pnlLinksMouseDragged(evt); + } + }); + pnlLinks.setLayout(null); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.gridwidth = 2; + gridBagConstraints.gridheight = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + jPanel4.add(pnlLinks, gridBagConstraints); + + jPanel5.setMinimumSize(new java.awt.Dimension(5, 5)); + jPanel5.setPreferredSize(new java.awt.Dimension(5, 5)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; + jPanel4.add(jPanel5, gridBagConstraints); + + jPanel6.setMinimumSize(new java.awt.Dimension(5, 5)); + jPanel6.setPreferredSize(new java.awt.Dimension(5, 5)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + jPanel4.add(jPanel6, gridBagConstraints); + + jPanel7.setMinimumSize(new java.awt.Dimension(5, 5)); + jPanel7.setPreferredSize(new java.awt.Dimension(5, 5)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + jPanel4.add(jPanel7, gridBagConstraints); + + jPanel8.setMinimumSize(new java.awt.Dimension(5, 5)); + jPanel8.setPreferredSize(new java.awt.Dimension(5, 5)); + + jLabel1.setText("jLabel1"); + jPanel8.add(jLabel1); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 2; + jPanel4.add(jPanel8, gridBagConstraints); + + jPanel9.setMinimumSize(new java.awt.Dimension(5, 5)); + jPanel9.setPreferredSize(new java.awt.Dimension(5, 5)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 0; + jPanel4.add(jPanel9, gridBagConstraints); + + lblPage.setFont(new java.awt.Font("Agency FB", 0, 12)); // NOI18N + lblPage.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + lblPage.setOpaque(true); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.gridwidth = 2; + gridBagConstraints.gridheight = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.weighty = 1.0; + jPanel4.add(lblPage, gridBagConstraints); + + pnlPage.add(jPanel4, java.awt.BorderLayout.CENTER); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + pnlInScroll.add(pnlPage, gridBagConstraints); + + scrollPane.setViewportView(pnlInScroll); + + pnlMain.add(scrollPane, java.awt.BorderLayout.CENTER); + + pnlTabs.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + pnlTabsStateChanged(evt); + } + }); + pnlMain.add(pnlTabs, java.awt.BorderLayout.CENTER); + + add(pnlMain, java.awt.BorderLayout.CENTER); + + pnlStatus.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + pnlStatus.setPreferredSize(new java.awt.Dimension(59, 20)); + pnlStatus.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0)); + + lblStatus.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N + lblStatus.setText("Page i of n"); + lblStatus.setMaximumSize(new java.awt.Dimension(59, 18)); + pnlStatus.add(lblStatus); + + add(pnlStatus, java.awt.BorderLayout.SOUTH); + addKeyListener(keyNavigationListener); + }// </editor-fold>//GEN-END:initComponents + + void txtGoToActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtGoToActionPerformed + try + { + int pageNumber = Integer.parseInt(txtGoTo.getText()); + if ( + pageNumber != pageIndex + 1 + && pageNumber > 0 + && pageNumber <= jasperPrint.getPages().size() + ) + { + setPageIndex(pageNumber - 1); + refreshPage(); + } + } + catch(NumberFormatException e) + { + } + }//GEN-LAST:event_txtGoToActionPerformed + + void cmbZoomItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmbZoomItemStateChanged + // Add your handling code here: + btnActualSize.setSelected(false); + btnFitPage.setSelected(false); + btnFitWidth.setSelected(false); + }//GEN-LAST:event_cmbZoomItemStateChanged + + void pnlMainComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_pnlMainComponentResized + // Add your handling code here: + if (btnFitPage.isSelected()) + { + fitPage(); + btnFitPage.setSelected(true); + } + else if (btnFitWidth.isSelected()) + { + setRealZoomRatio(((float)pnlInScroll.getVisibleRect().getWidth() - 20f) / getPageFormat().getPageWidth()); + btnFitWidth.setSelected(true); + } + + }//GEN-LAST:event_pnlMainComponentResized + + void btnActualSizeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnActualSizeActionPerformed + // Add your handling code here: + if (btnActualSize.isSelected()) + { + btnFitPage.setSelected(false); + btnFitWidth.setSelected(false); + cmbZoom.setSelectedIndex(-1); + setZoomRatio(1); + btnActualSize.setSelected(true); + } + }//GEN-LAST:event_btnActualSizeActionPerformed + + void btnFitWidthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFitWidthActionPerformed + // Add your handling code here: + if (btnFitWidth.isSelected()) + { + btnActualSize.setSelected(false); + btnFitPage.setSelected(false); + cmbZoom.setSelectedIndex(-1); + setRealZoomRatio(((float)pnlInScroll.getVisibleRect().getWidth() - 20f) / getPageFormat().getPageWidth()); + btnFitWidth.setSelected(true); + } + }//GEN-LAST:event_btnFitWidthActionPerformed + + void btnFitPageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFitPageActionPerformed + // Add your handling code here: + if (btnFitPage.isSelected()) + { + btnActualSize.setSelected(false); + btnFitWidth.setSelected(false); + cmbZoom.setSelectedIndex(-1); + fitPage(); + btnFitPage.setSelected(true); + } + }//GEN-LAST:event_btnFitPageActionPerformed + + void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed + // Add your handling code here: + + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setLocale(this.getLocale()); + fileChooser.updateUI(); + for(int i = 0; i < saveContributors.size(); i++) + { + fileChooser.addChoosableFileFilter(saveContributors.get(i)); + } + + if (saveContributors.contains(lastSaveContributor)) + { + fileChooser.setFileFilter(lastSaveContributor); + } + else if (saveContributors.size() > 0) + { + fileChooser.setFileFilter(saveContributors.get(0)); + } + + if (lastFolder != null) + { + fileChooser.setCurrentDirectory(lastFolder); + } + + int retValue = fileChooser.showSaveDialog(this); + if (retValue == JFileChooser.APPROVE_OPTION) + { + FileFilter fileFilter = fileChooser.getFileFilter(); + File file = fileChooser.getSelectedFile(); + + lastFolder = file.getParentFile(); + + JRSaveContributor contributor = null; + + if (fileFilter instanceof JRSaveContributor) + { + contributor = (JRSaveContributor)fileFilter; + } + else + { + int i = 0; + while(contributor == null && i < saveContributors.size()) + { + contributor = saveContributors.get(i++); + if (!contributor.accept(file)) + { + contributor = null; + } + } + + if (contributor == null) + { + contributor = new JRPrintSaveContributor(this.jasperReportsContext, getLocale(), this.resourceBundle); + } + } + + lastSaveContributor = contributor; + + try + { + contributor.save(jasperPrint, file); + } + catch (JRException e) + { + if (log.isErrorEnabled()) + { + log.error("Save error.", e); + } + JOptionPane.showMessageDialog(this, getBundleString("error.saving")); + } + } + }//GEN-LAST:event_btnSaveActionPerformed + + void pnlLinksMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlLinksMouseDragged + // Add your handling code here: + + Container container = pnlInScroll.getParent(); + if (container instanceof JViewport) + { + JViewport viewport = (JViewport) container; + Point point = viewport.getViewPosition(); + int newX = point.x - (evt.getX() - downX); + int newY = point.y - (evt.getY() - downY); + + int maxX = pnlInScroll.getWidth() - viewport.getWidth(); + int maxY = pnlInScroll.getHeight() - viewport.getHeight(); + + if (newX < 0) + { + newX = 0; + } + if (newX > maxX) + { + newX = maxX; + } + if (newY < 0) + { + newY = 0; + } + if (newY > maxY) + { + newY = maxY; + } + + viewport.setViewPosition(new Point(newX, newY)); + } + }//GEN-LAST:event_pnlLinksMouseDragged + + void pnlLinksMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlLinksMouseReleased + // Add your handling code here: + pnlLinks.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + }//GEN-LAST:event_pnlLinksMouseReleased + + void pnlLinksMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlLinksMousePressed + // Add your handling code here: + pnlLinks.setCursor(new Cursor(Cursor.MOVE_CURSOR)); + + downX = evt.getX(); + downY = evt.getY(); + }//GEN-LAST:event_pnlLinksMousePressed + + void btnPrintActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPrintActionPerformed + {//GEN-HEADEREND:event_btnPrintActionPerformed +/** // Add your handling code here: + Thread thread = new Thread(new Runnable(){ + public void run(){ + try { + btnPrint.setEnabled(false); + JRViewer400.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + JasperPrintManager.getInstance(jasperReportsContext).print(jasperPrint, true); + } catch (Exception ex) { + if (log.isErrorEnabled()) { + log.error("Print error.", ex); + } + JOptionPane.showMessageDialog(JRViewer400.this, getBundleString("error.printing")); + } finally { + JRViewer400.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + btnPrint.setEnabled(true); + } + } + } + ); + thread.start(); +*/ + SwingUtilities.invokeLater( new Runnable() { + public void run() { + try { + btnPrint.setEnabled(false); + JRViewer400.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + JasperPrintManager.printReport(jasperPrint, true); + } catch (Exception ex) { + ex.printStackTrace(); + JOptionPane.showMessageDialog(JRViewer400.this, getBundleString("error.printing")); + } + finally { + JRViewer400.this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + btnPrint.setEnabled(true); + } + } + } + ); + }//GEN-LAST:event_btnPrintActionPerformed + + void btnLastActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnLastActionPerformed + {//GEN-HEADEREND:event_btnLastActionPerformed + // Add your handling code here: + setPageIndex(jasperPrint.getPages().size() - 1); + refreshPage(); + }//GEN-LAST:event_btnLastActionPerformed + + void btnNextActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnNextActionPerformed + {//GEN-HEADEREND:event_btnNextActionPerformed + // Add your handling code here: + setPageIndex(pageIndex + 1); + refreshPage(); + }//GEN-LAST:event_btnNextActionPerformed + + void btnPreviousActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPreviousActionPerformed + {//GEN-HEADEREND:event_btnPreviousActionPerformed + // Add your handling code here: + setPageIndex(pageIndex - 1); + refreshPage(); + }//GEN-LAST:event_btnPreviousActionPerformed + + void btnFirstActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnFirstActionPerformed + {//GEN-HEADEREND:event_btnFirstActionPerformed + // Add your handling code here: + setPageIndex(0); + refreshPage(); + }//GEN-LAST:event_btnFirstActionPerformed + + void btnReloadActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnReloadActionPerformed + {//GEN-HEADEREND:event_btnReloadActionPerformed + // Add your handling code here: + if (type == TYPE_FILE_NAME) + { + try + { + loadReport(reportFileName, isXML); + } + catch (JRException e) + { + if (log.isErrorEnabled()) + { + log.error("Reload error.", e); + } + jasperPrint = null; + refreshTabs(); + setPageIndex(0); + refreshPage(); + + JOptionPane.showMessageDialog(this, getBundleString("error.loading")); + } + + forceRefresh(); + } + }//GEN-LAST:event_btnReloadActionPerformed + + protected void forceRefresh() + { + zoom = 0;//force pageRefresh() + realZoom = 0f; + setZoomRatio(1); + } + + void btnZoomInActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnZoomInActionPerformed + {//GEN-HEADEREND:event_btnZoomInActionPerformed + // Add your handling code here: + btnActualSize.setSelected(false); + btnFitPage.setSelected(false); + btnFitWidth.setSelected(false); + + int newZoomInt = (int)(100 * getZoomRatio()); + int index = Arrays.binarySearch(zooms, newZoomInt); + if (index < 0) + { + setZoomRatio(zooms[- index - 1] / 100f); + } + else if (index < cmbZoom.getModel().getSize() - 1) + { + setZoomRatio(zooms[index + 1] / 100f); + } + }//GEN-LAST:event_btnZoomInActionPerformed + + void btnZoomOutActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnZoomOutActionPerformed + {//GEN-HEADEREND:event_btnZoomOutActionPerformed + // Add your handling code here: + btnActualSize.setSelected(false); + btnFitPage.setSelected(false); + btnFitWidth.setSelected(false); + + int newZoomInt = (int)(100 * getZoomRatio()); + int index = Arrays.binarySearch(zooms, newZoomInt); + if (index > 0) + { + setZoomRatio(zooms[index - 1] / 100f); + } + else if (index < -1) + { + setZoomRatio(zooms[- index - 2] / 100f); + } + }//GEN-LAST:event_btnZoomOutActionPerformed + + void cmbZoomActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_cmbZoomActionPerformed + {//GEN-HEADEREND:event_cmbZoomActionPerformed + // Add your handling code here: + float newZoom = getZoomRatio(); + + if (newZoom < MIN_ZOOM) + { + newZoom = MIN_ZOOM; + } + + if (newZoom > MAX_ZOOM) + { + newZoom = MAX_ZOOM; + } + + setZoomRatio(newZoom); + }//GEN-LAST:event_cmbZoomActionPerformed + + private void pnlTabsStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_pnlTabsStateChanged + if (pnlTabsChangeListenerEnabled) + { + ((JPanel)pnlTabs.getSelectedComponent()).add(scrollPane); + + Integer pgIdx = 0; + + Integer partIndex = pnlTabs.getSelectedIndex(); + if (partIndex > 0) + { + PrintParts parts = jasperPrint == null ? null : jasperPrint.getParts(); + + if (parts != null && parts.hasParts()) + { + partIndex = parts.startsAtZero() ? partIndex : partIndex - 1; + pgIdx = parts.getStartPageIndex(partIndex); + } + } + + setPageIndex(pgIdx); + refreshPage(); + } + }//GEN-LAST:event_pnlTabsStateChanged + +/* private void pnlTabsStateChanged(javax.swing.event.ChangeEvent evt) { + if (pnlTabsChangeListenerEnabled) + { + ((JPanel)pnlTabs.getSelectedComponent()).add(scrollPane); + + Integer pgIdx = 0; + + Integer partIndex = pnlTabs.getSelectedIndex(); + if (partIndex > 0) + { + PrintParts parts = jasperPrint == null ? null : jasperPrint.getParts(); + + if (parts != null && parts.hasParts()) + { + partIndex = parts.startsAtZero() ? partIndex : partIndex - 1; + pgIdx = parts.getStartPageIndex(partIndex); + } + } + + setPageIndex(pgIdx); + refreshPage(); + } + } +*/ + + /** + */ + void hyperlinkClicked(MouseEvent evt) + { + JPanel link = (JPanel)evt.getSource(); + JRPrintHyperlink element = linksMap.get(link); + hyperlinkClicked(element); + } + + + protected void hyperlinkClicked(JRPrintHyperlink hyperlink) + { + try + { + JRHyperlinkListener listener = null; + for(int i = 0; i < hyperlinkListeners.size(); i++) + { + listener = hyperlinkListeners.get(i); + listener.gotoHyperlink(hyperlink); + } + } + catch(JRException e) + { + if (log.isErrorEnabled()) + { + log.error("Hyperlink click error.", e); + } + JOptionPane.showMessageDialog(this, getBundleString("error.hyperlink")); + } + } + + + /** + */ + public int getPageIndex() + { + return pageIndex; + } + + + /** + */ + private void setPageIndex(int index) + { + if ( + jasperPrint != null && + jasperPrint.getPages() != null && + jasperPrint.getPages().size() > 0 + ) + { + if (index >= 0 && index < jasperPrint.getPages().size()) + { + pageIndex = index; + pageError = false; + btnFirst.setEnabled( (pageIndex > 0) ); + btnPrevious.setEnabled( (pageIndex > 0) ); + btnNext.setEnabled( (pageIndex < jasperPrint.getPages().size() - 1) ); + btnLast.setEnabled( (pageIndex < jasperPrint.getPages().size() - 1) ); + txtGoTo.setEnabled(btnFirst.isEnabled() || btnLast.isEnabled()); + txtGoTo.setText("" + (pageIndex + 1)); + lblStatus.setText( + MessageFormat.format( + getBundleString("page"), + new Object[]{Integer.valueOf(pageIndex + 1), Integer.valueOf(jasperPrint.getPages().size())} + ) + ); + + if (jasperPrint.hasParts()) + { + PrintParts parts = jasperPrint.getParts(); + int partIndex = parts.getPartIndex(pageIndex); + int tabIndex = partIndex - (parts.startsAtZero() ? 1 : 0); + if (tabIndex < pnlTabs.getComponentCount()) + { + pnlTabsChangeListenerEnabled = false; + pnlTabs.setSelectedIndex(tabIndex); + ((JPanel)pnlTabs.getSelectedComponent()).add(scrollPane); + pnlTabsChangeListenerEnabled = true; + } + } + } + } + else + { + btnFirst.setEnabled(false); + btnPrevious.setEnabled(false); + btnNext.setEnabled(false); + btnLast.setEnabled(false); + txtGoTo.setEnabled(false); + txtGoTo.setText(""); + lblStatus.setText(""); + } + } + + + /** + */ + private PrintPageFormat getPageFormat() + { + return jasperPrint.getPageFormat(pageIndex); + } + + + /** + */ + protected void loadReport(String fileName, boolean isXmlReport) throws JRException + { + if (isXmlReport) + { + jasperPrint = JRPrintXmlLoader.loadFromFile(jasperReportsContext, fileName); + } + else + { + jasperPrint = (JasperPrint)JRLoader.loadObjectFromFile(fileName); + } + + refreshTabs(); + + type = TYPE_FILE_NAME; + this.isXML = isXmlReport; + reportFileName = fileName; + + SimpleFileResolver fileResolver = new SimpleFileResolver(Arrays.asList(new File[]{new File(fileName).getParentFile(), new File(".")})); + fileResolver.setResolveAbsolutePath(true); + if (localJasperReportsContext == null) + { + localJasperReportsContext = new LocalJasperReportsContext(jasperReportsContext); + jasperReportsContext = localJasperReportsContext; + } + localJasperReportsContext.setFileResolver(fileResolver); + + btnReload.setEnabled(true); + setPageIndex(0); + } + + + /** + */ + protected void loadReport(InputStream is, boolean isXmlReport) throws JRException + { + if (isXmlReport) + { + jasperPrint = JRPrintXmlLoader.load(jasperReportsContext, is); + } + else + { + jasperPrint = (JasperPrint)JRLoader.loadObject(is); + } + + refreshTabs(); + + type = TYPE_INPUT_STREAM; + this.isXML = isXmlReport; + btnReload.setEnabled(false); + setPageIndex(0); + } + + + /** + */ + protected void loadReport(JasperPrint jrPrint) + { + jasperPrint = jrPrint; + + refreshTabs(); + + type = TYPE_OBJECT; + isXML = false; + btnReload.setEnabled(false); + setPageIndex(0); + } + + + /** + */ + protected void refreshTabs() + { + pnlTabsChangeListenerEnabled = false; + + pnlTabs.removeAll(); + pnlMain.removeAll(); + + if (jasperPrint == null || !jasperPrint.hasParts()) + { + pnlMain.add(scrollPane, java.awt.BorderLayout.CENTER); + } + else + { + PrintParts parts = jasperPrint.getParts(); + if (!parts.startsAtZero()) + { + JPanel partTab = new JPanel(); + partTab.setLayout(new BorderLayout()); + partTab.setName(jasperPrint.getName()); + pnlTabs.add(partTab); + } + + for (Iterator<Map.Entry<Integer, PrintPart>> it = parts.partsIterator(); it.hasNext();) + { + PrintPart part = it.next().getValue(); + JPanel partTab = new JPanel(); + partTab.setLayout(new BorderLayout()); + partTab.setName(part.getName()); + pnlTabs.add(partTab); + } + + pnlMain.add(pnlTabs, java.awt.BorderLayout.CENTER); + } + + pnlTabsChangeListenerEnabled = true; + } + + + /** + */ + protected void refreshPage() + { + if ( + jasperPrint == null || + jasperPrint.getPages() == null || + jasperPrint.getPages().size() == 0 + ) + { + pnlPage.setVisible(false); + btnSave.setEnabled(false); + btnPrint.setEnabled(false); + btnActualSize.setEnabled(false); + btnFitPage.setEnabled(false); + btnFitWidth.setEnabled(false); + btnZoomIn.setEnabled(false); + btnZoomOut.setEnabled(false); + cmbZoom.setEnabled(false); + + if (jasperPrint != null) + { + JOptionPane.showMessageDialog(this, getBundleString("no.pages")); + } + + return; + } + + pnlPage.setVisible(true); + btnSave.setEnabled(true); + btnPrint.setEnabled(true); + btnActualSize.setEnabled(true); + btnFitPage.setEnabled(true); + btnFitWidth.setEnabled(true); + btnZoomIn.setEnabled(zoom < MAX_ZOOM); + btnZoomOut.setEnabled(zoom > MIN_ZOOM); + cmbZoom.setEnabled(true); + + PrintPageFormat pageFormat = getPageFormat(); + + Dimension dim = new Dimension( + (int)(pageFormat.getPageWidth() * realZoom) + 8, // 2 from border, 5 from shadow and 1 extra pixel for image + (int)(pageFormat.getPageHeight() * realZoom) + 8 + ); + pnlPage.setMaximumSize(dim); + pnlPage.setMinimumSize(dim); + pnlPage.setPreferredSize(dim); + + long maxImageSize = JRPropertiesUtil.getInstance(jasperReportsContext).getLongProperty(VIEWER_RENDER_BUFFER_MAX_SIZE); + boolean renderImage; + if (maxImageSize <= 0) + { + renderImage = false; + } + else + { + long imageSize = ((int) (pageFormat.getPageWidth() * realZoom) + 1) * ((int) (pageFormat.getPageHeight() * realZoom) + 1); + renderImage = imageSize <= maxImageSize; + } + + ((PageRenderer)lblPage).setRenderImage(renderImage); + + if (renderImage) + { + setPageImage(); + } + + pnlLinks.removeAll(); + linksMap = new HashMap<JPanel,JRPrintHyperlink>(); + + createHyperlinks(); + + if (!renderImage) + { + lblPage.setIcon(null); + + pnlMain.validate(); + pnlMain.repaint(); + } + } + + + protected void setPageImage() + { + Image image; + if (pageError) + { + image = getPageErrorImage(); + } + else + { + try + { + image = JasperPrintManager.getInstance(jasperReportsContext).printToImage(jasperPrint, pageIndex, realZoom); + } + catch (Exception e) + { + if (log.isErrorEnabled()) + { + log.error("Print page to image error.", e); + } + pageError = true; + + image = getPageErrorImage(); + JOptionPane.showMessageDialog(this, java.util.ResourceBundle.getBundle("net/sf/jasperreports/view/viewer").getString("error.displaying")); + } + } + ImageIcon imageIcon = new ImageIcon(image); + lblPage.setIcon(imageIcon); + } + + protected Image getPageErrorImage() + { + PrintPageFormat pageFormat = getPageFormat(); + Image image = new BufferedImage( + (int) (pageFormat.getPageWidth() * realZoom) + 1, + (int) (pageFormat.getPageHeight() * realZoom) + 1, + BufferedImage.TYPE_INT_RGB + ); + + Graphics2D grx = (Graphics2D) image.getGraphics(); + AffineTransform transform = new AffineTransform(); + transform.scale(realZoom, realZoom); + grx.transform(transform); + + drawPageError(grx); + + return image; + } + + protected void createHyperlinks() + { + List<JRPrintPage> pages = jasperPrint.getPages(); + JRPrintPage page = pages.get(pageIndex); + createHyperlinks(page.getElements(), 0, 0); + } + + protected void createHyperlinks(List<JRPrintElement> elements, int offsetX, int offsetY) + { + if(elements != null && elements.size() > 0) + { + for(Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) + { + JRPrintElement element = it.next(); + + ImageMapRenderable imageMap = null; + if (element instanceof JRPrintImage) + { + Renderable renderer = ((JRPrintImage) element).getRenderable(); + if (renderer instanceof ImageMapRenderable) + { + imageMap = (ImageMapRenderable) renderer; + if (!imageMap.hasImageAreaHyperlinks()) + { + imageMap = null; + } + } + } + boolean hasImageMap = imageMap != null; + + JRPrintHyperlink hyperlink = null; + if (element instanceof JRPrintHyperlink) + { + hyperlink = (JRPrintHyperlink) element; + } + boolean hasHyperlink = !hasImageMap + && hyperlink != null && hyperlink.getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE; + boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null; + + if (hasHyperlink || hasImageMap || hasTooltip) + { + JPanel link; + if (hasImageMap) + { + Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight()); + link = new ImageMapPanel(renderingArea, imageMap); + } + else //hasImageMap + { + link = new JPanel(); + if (hasHyperlink) + { + link.addMouseListener(mouseListener); + } + } + + if (hasHyperlink) + { + link.setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + link.setLocation( + (int)((element.getX() + offsetX) * realZoom), + (int)((element.getY() + offsetY) * realZoom) + ); + link.setSize( + (int)(element.getWidth() * realZoom), + (int)(element.getHeight() * realZoom) + ); + link.setOpaque(false); + + String toolTip = getHyperlinkTooltip(hyperlink); + if (toolTip == null && hasImageMap) + { + toolTip = "";//not null to register the panel as having a tool tip + } + link.setToolTipText(toolTip); + + pnlLinks.add(link); + linksMap.put(link, hyperlink); + } + + if (element instanceof JRPrintFrame) + { + JRPrintFrame frame = (JRPrintFrame) element; + int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue(); + int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue(); + createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY); + } + } + } + } + + + protected class ImageMapPanel extends JPanel implements MouseListener, MouseMotionListener + { + private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; + + protected final List<JRPrintImageAreaHyperlink> imageAreaHyperlinks; + + public ImageMapPanel(Rectangle renderingArea, ImageMapRenderable imageMap) + { + try + { + imageAreaHyperlinks = imageMap.getImageAreaHyperlinks(renderingArea);//FIXMECHART + } + catch (JRException e) + { + throw new JRRuntimeException(e); + } + + addMouseListener(this); + addMouseMotionListener(this); + } + + public String getToolTipText(MouseEvent event) + { + String tooltip = null; + JRPrintImageAreaHyperlink imageMapArea = getImageMapArea(event); + if (imageMapArea != null) + { + tooltip = getHyperlinkTooltip(imageMapArea.getHyperlink()); + } + + if (tooltip == null) + { + tooltip = super.getToolTipText(event); + } + + return tooltip; + } + + public void mouseDragged(MouseEvent e) + { + pnlLinksMouseDragged(e); + } + + public void mouseMoved(MouseEvent e) + { + JRPrintImageAreaHyperlink imageArea = getImageMapArea(e); + if (imageArea != null + && imageArea.getHyperlink().getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE) + { + e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } + else + { + e.getComponent().setCursor(Cursor.getDefaultCursor()); + } + } + + protected JRPrintImageAreaHyperlink getImageMapArea(MouseEvent e) + { + return getImageMapArea((int) (e.getX() / realZoom), (int) (e.getY() / realZoom)); + } + + protected JRPrintImageAreaHyperlink getImageMapArea(int x, int y) + { + JRPrintImageAreaHyperlink image = null; + if (imageAreaHyperlinks != null) + { + for (ListIterator<JRPrintImageAreaHyperlink> it = imageAreaHyperlinks.listIterator(imageAreaHyperlinks.size()); image == null && it.hasPrevious();) + { + JRPrintImageAreaHyperlink area = it.previous(); + if (area.getArea().containsPoint(x, y)) + { + image = area; + } + } + } + return image; + } + + public void mouseClicked(MouseEvent e) + { + JRPrintImageAreaHyperlink imageMapArea = getImageMapArea(e); + if (imageMapArea != null) + { + hyperlinkClicked(imageMapArea.getHyperlink()); + } + } + + public void mouseEntered(MouseEvent e) + { + } + + public void mouseExited(MouseEvent e) + { + } + + public void mousePressed(MouseEvent e) + { + e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); + pnlLinksMousePressed(e); + } + + public void mouseReleased(MouseEvent e) + { + e.getComponent().setCursor(Cursor.getDefaultCursor()); + pnlLinksMouseReleased(e); + } + } + + + protected String getHyperlinkTooltip(JRPrintHyperlink hyperlink) + { + String toolTip; + toolTip = hyperlink.getHyperlinkTooltip(); + if (toolTip == null) + { + toolTip = getFallbackTooltip(hyperlink); + } + return toolTip; + } + + + protected String getFallbackTooltip(JRPrintHyperlink hyperlink) + { + String toolTip = null; + switch(hyperlink.getHyperlinkTypeValue()) + { + case REFERENCE : + { + toolTip = hyperlink.getHyperlinkReference(); + break; + } + case LOCAL_ANCHOR : + { + if (hyperlink.getHyperlinkAnchor() != null) + { + toolTip = "#" + hyperlink.getHyperlinkAnchor(); + } + break; + } + case LOCAL_PAGE : + { + if (hyperlink.getHyperlinkPage() != null) + { + toolTip = "#page " + hyperlink.getHyperlinkPage(); + } + break; + } + case REMOTE_ANCHOR : + { + toolTip = ""; + if (hyperlink.getHyperlinkReference() != null) + { + toolTip = toolTip + hyperlink.getHyperlinkReference(); + } + if (hyperlink.getHyperlinkAnchor() != null) + { + toolTip = toolTip + "#" + hyperlink.getHyperlinkAnchor(); + } + break; + } + case REMOTE_PAGE : + { + toolTip = ""; + if (hyperlink.getHyperlinkReference() != null) + { + toolTip = toolTip + hyperlink.getHyperlinkReference(); + } + if (hyperlink.getHyperlinkPage() != null) + { + toolTip = toolTip + "#page " + hyperlink.getHyperlinkPage(); + } + break; + } + default : + { + break; + } + } + return toolTip; + } + + + /** + */ + private void emptyContainer(Container container) + { + Component[] components = container.getComponents(); + + if (components != null) + { + for(int i = 0; i < components.length; i++) + { + if (components[i] instanceof Container) + { + emptyContainer((Container)components[i]); + } + } + } + + components = null; + container.removeAll(); + container = null; + } + + + /** + */ + private float getZoomRatio() + { + float newZoom = zoom; + + try + { + newZoom = + zoomDecimalFormat.parse( + String.valueOf(cmbZoom.getEditor().getItem()) + ).floatValue() / 100f; + } + catch(ParseException e) + { + } + + return newZoom; + } + + + /** + */ + public void setZoomRatio(float newZoom) + { + if (newZoom > 0) + { + cmbZoom.getEditor().setItem( + zoomDecimalFormat.format(newZoom * 100) + "%" + ); + + if (zoom != newZoom) + { + zoom = newZoom; + realZoom = zoom * screenResolution / REPORT_RESOLUTION; + + refreshPage(); + } + } + } + + + /** + */ + private void setRealZoomRatio(float newZoom) + { + if (newZoom > 0 && realZoom != newZoom) + { + zoom = newZoom * REPORT_RESOLUTION / screenResolution; + realZoom = newZoom; + + cmbZoom.getEditor().setItem( + zoomDecimalFormat.format(zoom * 100) + "%" + ); + + refreshPage(); + } + } + + + /** + * + */ + public void setFitWidthZoomRatio() + { + setRealZoomRatio(((float)pnlInScroll.getVisibleRect().getWidth() - 20f) / getPageFormat().getPageWidth()); + + } + + public void setFitPageZoomRatio() + { + setRealZoomRatio(((float)pnlInScroll.getVisibleRect().getHeight() - 20f) / getPageFormat().getPageHeight()); + } + + + /** + * + */ + protected JRGraphics2DExporter getGraphics2DExporter() throws JRException + { + return new JRGraphics2DExporter(jasperReportsContext); + } + + /** + * + */ + protected void paintPage(Graphics2D grx) + { + if (pageError) + { + paintPageError(grx); + return; + } + + try + { + if (exporter == null) + { + exporter = getGraphics2DExporter(); + } + else + { + exporter.reset(); + } + + exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); + SimpleGraphics2DExporterOutput output = new SimpleGraphics2DExporterOutput(); + output.setGraphics2D((Graphics2D)grx.create()); + exporter.setExporterOutput(output); + SimpleGraphics2DReportConfiguration configuration = new SimpleGraphics2DReportConfiguration(); + configuration.setPageIndex(pageIndex); + configuration.setZoomRatio(realZoom); + configuration.setOffsetX(1); //lblPage border + configuration.setOffsetY(1); + exporter.setConfiguration(configuration); + exporter.exportReport(); + } + catch(Exception e) + { + if (log.isErrorEnabled()) + { + log.error("Page paint error.", e); + } + pageError = true; + + paintPageError(grx); + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + JOptionPane.showMessageDialog(JRViewer400.this, getBundleString("error.displaying")); + } + }); + } + + } + + protected void paintPageError(Graphics2D grx) + { + AffineTransform origTransform = grx.getTransform(); + + AffineTransform transform = new AffineTransform(); + transform.translate(1, 1); + transform.scale(realZoom, realZoom); + grx.transform(transform); + + try + { + drawPageError(grx); + } + finally + { + grx.setTransform(origTransform); + } + } + + protected void drawPageError(Graphics grx) + { + PrintPageFormat pageFormat = getPageFormat(); + grx.setColor(Color.white); + grx.fillRect(0, 0, pageFormat.getPageWidth() + 1, pageFormat.getPageHeight() + 1); + } + + protected void keyNavigate(KeyEvent evt) + { + boolean refresh = true; + switch (evt.getKeyCode()) + { + case KeyEvent.VK_DOWN: + case KeyEvent.VK_PAGE_DOWN: + dnNavigate(evt); + break; + case KeyEvent.VK_UP: + case KeyEvent.VK_PAGE_UP: + upNavigate(evt); + break; + case KeyEvent.VK_HOME: + homeEndNavigate(0); + break; + case KeyEvent.VK_END: + homeEndNavigate(jasperPrint.getPages().size() - 1); + break; + default: + refresh = false; + } + + if (refresh) + { + refreshPage(); + } + } + + private void dnNavigate(KeyEvent evt) + { + int bottomPosition = scrollPane.getVerticalScrollBar().getValue(); + scrollPane.dispatchEvent(evt); + if((scrollPane.getViewport().getHeight() > pnlPage.getHeight() || + scrollPane.getVerticalScrollBar().getValue() == bottomPosition) && + pageIndex < jasperPrint.getPages().size() - 1) + { + setPageIndex(pageIndex + 1); + if(scrollPane.isEnabled()) + { + scrollPane.getVerticalScrollBar().setValue(0); + } + } + } + + private void upNavigate(KeyEvent evt) + { + if((scrollPane.getViewport().getHeight() > pnlPage.getHeight() || + scrollPane.getVerticalScrollBar().getValue() == 0) && + pageIndex > 0) + { + setPageIndex(pageIndex - 1); + if(scrollPane.isEnabled()) + { + scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum()); + } + } + else + { + scrollPane.dispatchEvent(evt); + } + } + + private void homeEndNavigate(int pageNumber) + { + setPageIndex(pageNumber); + if(scrollPane.isEnabled()) + { + scrollPane.getVerticalScrollBar().setValue(0); + } + } + + /** + * + */ + private void fitPage(){ + PrintPageFormat pageFormat = getPageFormat(); + float heightRatio = ((float)pnlInScroll.getVisibleRect().getHeight() - 20f) / pageFormat.getPageHeight(); + float widthRatio = ((float)pnlInScroll.getVisibleRect().getWidth() - 20f) / pageFormat.getPageWidth(); + setRealZoomRatio(heightRatio < widthRatio ? heightRatio : widthRatio); + } + + /** + */ + class PageRenderer extends JLabel + { + private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID; + + private boolean renderImage; + JRViewer400 viewer = null; + + public PageRenderer(JRViewer400 viewer) + { + this.viewer = viewer; + } + + public void paintComponent(Graphics g) + { + if (isRenderImage()) + { + super.paintComponent(g); + } + else + { + viewer.paintPage((Graphics2D)g.create()); + } + } + + public boolean isRenderImage() + { + return renderImage; + } + + public void setRenderImage(boolean renderImage) + { + this.renderImage = renderImage; + } + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + protected javax.swing.JToggleButton btnActualSize; + protected javax.swing.JButton btnFirst; + protected javax.swing.JToggleButton btnFitPage; + protected javax.swing.JToggleButton btnFitWidth; + protected javax.swing.JButton btnLast; + protected javax.swing.JButton btnNext; + protected javax.swing.JButton btnPrevious; + protected javax.swing.JButton btnPrint; + protected javax.swing.JButton btnReload; + protected javax.swing.JButton btnSave; + protected javax.swing.JButton btnZoomIn; + protected javax.swing.JButton btnZoomOut; + protected javax.swing.JComboBox cmbZoom; + private javax.swing.JLabel jLabel1; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JPanel jPanel7; + private javax.swing.JPanel jPanel8; + private javax.swing.JPanel jPanel9; + private javax.swing.JToolBar.Separator jSeparator1; + private javax.swing.JToolBar.Separator jSeparator2; + private javax.swing.JToolBar.Separator jSeparator3; + private javax.swing.JToolBar jToolBar; + private javax.swing.JLabel lblPage; + protected javax.swing.JLabel lblStatus; + private javax.swing.JPanel pnlInScroll; + private javax.swing.JPanel pnlLinks; + private javax.swing.JPanel pnlMain; + private javax.swing.JPanel pnlPage; + protected javax.swing.JPanel pnlStatus; + private javax.swing.JTabbedPane pnlTabs; + private javax.swing.JScrollPane scrollPane; + protected javax.swing.JTextField txtGoTo; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/util/LabelIcon.java b/src/main/java/com/unicenta/pos/util/LabelIcon.java new file mode 100644 index 0000000..4a8df97 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/LabelIcon.java @@ -0,0 +1,82 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.util; + +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import javax.swing.Icon; +import javax.swing.JLabel; + +/** + * + * @author adrianromero + */ +public class LabelIcon extends JLabel implements Icon { + + private int iconwidth; + private int iconheight; + + /** + * + * @param width + * @param height + */ + public LabelIcon(int width, int height) { + iconwidth = width; + iconheight = height; + } + + /** + * + * @param mywidth + * @param myheight + * @return + */ + public BufferedImage getImage(int mywidth, int myheight) { + + BufferedImage imgtext = new BufferedImage(mywidth, myheight, BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = imgtext.createGraphics(); + + setBounds(0, 0, mywidth, myheight); + paint(g2d); + g2d.dispose(); + + return imgtext; + } + + public void paintIcon(Component c, Graphics g, int x, int y) { + + setBounds(0, 0, iconwidth, iconheight); + g.translate(x, y); + paint(g); + g.translate(-x, -y); + } + + public int getIconWidth() { + return iconwidth; + } + + public int getIconHeight() { + return iconheight; + } + +} diff --git a/src/main/java/com/unicenta/pos/util/LuhnAlgorithm.java b/src/main/java/com/unicenta/pos/util/LuhnAlgorithm.java new file mode 100644 index 0000000..271f574 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/LuhnAlgorithm.java @@ -0,0 +1,62 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.util; + +/** + * + * @author Mikel Irurita + */ +public class LuhnAlgorithm { + + /** Creates a new instance of LuhnAlgorithm */ + private LuhnAlgorithm() { + } + + /** + * + * @param cardNumber + * @return + */ + public static boolean checkCC(String cardNumber){ + int sum = 0; + + int flip = 0; + + if ( !StringUtils.isNumber(cardNumber) ){ + return false; + } + + for (int i = cardNumber.length() -1; i >= 0; i--) { + int k = Character.digit(cardNumber.charAt(i), 10); + flip ++; + + if ( flip % 2 == 0 ) { + k *= 2; + if (k > 9) { + k -= 9; + } + } + sum += k; + } + return (sum % 10 == 0); + } + +} + diff --git a/src/main/java/com/unicenta/pos/util/NewFXMain.java b/src/main/java/com/unicenta/pos/util/NewFXMain.java new file mode 100644 index 0000000..dca5882 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/NewFXMain.java @@ -0,0 +1,51 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.util; + +import javafx.application.Application; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; + +/** + * + * @author user + */ +public class NewFXMain extends Application { + + @Override + public void start(Stage primaryStage) { + Button btn = new Button(); + btn.setText("Say 'Hello World'"); + btn.setOnAction(new EventHandler<ActionEvent>() { + + @Override + public void handle(ActionEvent event) { + System.out.println("Hello World!"); + } + }); + + StackPane root = new StackPane(); + root.getChildren().add(btn); + + Scene scene = new Scene(root, 300, 250); + + primaryStage.setTitle("Hello World!"); + primaryStage.setScene(scene); + primaryStage.show(); + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + launch(args); + } + +} diff --git a/src/main/java/com/unicenta/pos/util/NewFXSwingMain.java b/src/main/java/com/unicenta/pos/util/NewFXSwingMain.java new file mode 100644 index 0000000..fa0e1f5 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/NewFXSwingMain.java @@ -0,0 +1,98 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.util; + +import java.awt.BorderLayout; +import java.awt.Dimension; + +import com.formdev.flatlaf.FlatLightLaf; +import javafx.application.Platform; +import javafx.embed.swing.JFXPanel; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.layout.StackPane; +import lombok.extern.slf4j.Slf4j; + +import javax.swing.JApplet; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; + +/** + * + * @author user + */ +@Slf4j +public class NewFXSwingMain extends JApplet { + + private static final int JFXPANEL_WIDTH_INT = 300; + private static final int JFXPANEL_HEIGHT_INT = 250; + private static JFXPanel fxContainer; + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + try { + UIManager.setLookAndFeel(new FlatLightLaf()); + } catch (Exception e) { + log.error("Error setting LAF "+e.getMessage()); + } + + JFrame frame = new JFrame("JavaFX 2 in Swing"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JApplet applet = new NewFXSwingMain(); + applet.init(); + + frame.setContentPane(applet.getContentPane()); + + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + + applet.start(); + } + }); + } + + @Override + public void init() { + fxContainer = new JFXPanel(); + fxContainer.setPreferredSize(new Dimension(JFXPANEL_WIDTH_INT, JFXPANEL_HEIGHT_INT)); + add(fxContainer, BorderLayout.CENTER); + // create JavaFX scene + Platform.runLater(new Runnable() { + + @Override + public void run() { + createScene(); + } + }); + } + + private void createScene() { + Button btn = new Button(); + btn.setText("Say 'Hello World'"); + btn.setOnAction(new EventHandler<ActionEvent>() { + + @Override + public void handle(ActionEvent event) { + System.out.println("Hello World!"); + } + }); + StackPane root = new StackPane(); + root.getChildren().add(btn); + fxContainer.setScene(new Scene(root)); + } + +} diff --git a/src/main/java/com/unicenta/pos/util/OSValidator.java b/src/main/java/com/unicenta/pos/util/OSValidator.java new file mode 100644 index 0000000..53a0b00 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/OSValidator.java @@ -0,0 +1,76 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.util; + +/** + * + * @author JG uniCenta + */ +public class OSValidator { + + private String OS = System.getProperty("os.name").toLowerCase(); + + /** + * + */ + public OSValidator() { + + } + + /** + * + * @return + */ + public String getOS(){ + if (isWindows()) { + return("w"); + } else if (isMac()) { + return("m"); + } else if (isUnix()) { + return("l"); + } else if (isSolaris()) { + return("s"); + } else { + return("x"); + } + } + + /** + * + * @return + */ + public boolean isWindows() { + return (OS.contains("win")); + } + + /** + * + * @return + */ + public boolean isMac() { + return (OS.contains("mac")); + } + + /** + * + * @return + */ + public boolean isUnix() { + return (OS.contains("nix") || OS.contains("nux") || OS.indexOf("aix") > 0 ); + } + + /** + * + * @return + */ + public boolean isSolaris() { + return (OS.contains("sunos")); + } + + + + + +} diff --git a/src/main/java/com/unicenta/pos/util/PropertyUtils.java b/src/main/java/com/unicenta/pos/util/PropertyUtils.java new file mode 100644 index 0000000..18a4d66 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/PropertyUtils.java @@ -0,0 +1,98 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.util; + +/** +* +* @author Xibergy Systems +*/ + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +/** + * + * @author JG uniCenta + */ +public class PropertyUtils { + + private Properties m_propsconfig; + private File configFile; + private final String APP_ID = "upos-app"; + + /** + * + */ + public PropertyUtils() { + init(getDefaultConfig()); + } + + private void init(File configfile) { + this.configFile = configfile; + load(); + } + + private File getDefaultConfig() { + return new File(new File("C:\\Documents and Settings\\jack"), "unicentaopos.properties"); + } + + private void load() { + // Load Properties + try { + InputStream in = new FileInputStream(configFile); + if (in != null) { + m_propsconfig = new Properties(); + m_propsconfig.load(in); + in.close(); + } + } catch (IOException e) { + } + } + + /** + * + * @param sKey + * @return + */ + public String getProperty(String sKey) { + return m_propsconfig.getProperty(sKey); + } + + /** + * + * @return + */ + public String getDriverName() { + return m_propsconfig.getProperty("db.driver"); + } + + /** + * + * @return + */ + public String getUrl() { + return m_propsconfig.getProperty("db.URL"); + } + + /** + * + * @return + */ + public String getDBUser() { + return m_propsconfig.getProperty("db.user"); + } + + /** + * + * @return + */ + public String getDBPassword() { + String m_password = "[color=#FF0000]YourDBPassword[/color]"; + return m_password; + } +} diff --git a/src/main/java/com/unicenta/pos/util/ReportUtils.java b/src/main/java/com/unicenta/pos/util/ReportUtils.java new file mode 100644 index 0000000..f5bf5c0 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/ReportUtils.java @@ -0,0 +1,82 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + + +package com.unicenta.pos.util; + +import javax.print.DocFlavor; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; + +/** + * + * @author adrianromero + */ +public class ReportUtils { + + private ReportUtils() { + } + + /** + * + * @param printername + * @return + */ + public static PrintService getPrintService(String printername) { + + // Initalize print service + + if (printername == null) { + return PrintServiceLookup.lookupDefaultPrintService(); + } else { + + if ("(Show dialog)".equals(printername)) { + return null; // null means "you have to show the print dialog" + } else if ("(Default)".equals(printername)) { + return PrintServiceLookup.lookupDefaultPrintService(); + } else { + PrintService[] pservices = + PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE , null); + for (PrintService s : pservices) { + if (printername.equals(s.getName())) { + return s; + } + } + return PrintServiceLookup.lookupDefaultPrintService(); + } + } + } + + /** + * + * @return + */ + public static String[] getPrintNames() { + PrintService[] pservices = + PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE , null); + + String printers[] = new String[pservices.length]; + for (int i = 0; i < pservices.length; i++) { + printers[i] = pservices[i].getName(); + } + + return printers; + } + +} diff --git a/src/main/java/com/unicenta/pos/util/ReturnInfo.java b/src/main/java/com/unicenta/pos/util/ReturnInfo.java new file mode 100644 index 0000000..2bbe5eb --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/ReturnInfo.java @@ -0,0 +1,87 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.unicenta.pos.util; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.loader.SerializableRead; +import com.unicenta.data.loader.SerializerRead; + +/** + * + * @author JA - based on A Escartin Barcode + * 15 Dec 2013 + */ +public class ReturnInfo implements SerializableRead, IKeyed { + + private static final long serialVersionUID = 8906929819402L; + private Integer idret; + + /** + * + */ + public ReturnInfo() { + idret = null; + } + + /** + * + * @return + */ + @Override + public Object getKey() { + return idret; + } + + /** + * + * @param dr + * @throws BasicException + */ + @Override + public void readValues(DataRead dr) throws BasicException { + idret = dr.getInt(1); + } + + /** + * + * @param id + */ + public void setId(Integer id) { + idret = id; + } + + /** + * + * @return + */ + public Integer getId() { + return idret; + } + + /** + * + * @return + */ + public static SerializerRead getSerializerRead() { + return new SerializerRead() { + @Override + public Object readValues(DataRead dr) throws BasicException { + return new ReturnInfo( + dr.getInt(1)); + } + }; + } + + /** + * + * @param id + */ + public ReturnInfo(Integer id) { + this.idret = id; + } + +} diff --git a/src/main/java/com/unicenta/pos/util/RoundUtils.java b/src/main/java/com/unicenta/pos/util/RoundUtils.java new file mode 100644 index 0000000..5fc8832 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/RoundUtils.java @@ -0,0 +1,63 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2016 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.util; + +import com.unicenta.format.Formats; + +/** + * + * @author JG uniCenta + */ +public class RoundUtils { + + /** Creates a new instance of DoubleUtils */ + private RoundUtils() { + } + + /** + * + * @param dValue + * @return + */ + public static double round(double dValue) { + double fractionMultiplier = Math.pow(10.0, Formats.getCurrencyDecimals()); + return Math.rint(dValue * fractionMultiplier) / fractionMultiplier; + } + + /** + * + * @param d1 + * @param d2 + * @return + */ + public static int compare(double d1, double d2) { + + return Double.compare(round(d1), round(d2)); + } + + /** + * + * @param value + * @return + */ + public static double getValue(Double value) { + return value == null ? 0.0 : value.doubleValue(); + } +} diff --git a/src/main/java/com/unicenta/pos/util/SelectPrinter.form b/src/main/java/com/unicenta/pos/util/SelectPrinter.form new file mode 100644 index 0000000..bcd9b82 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/SelectPrinter.form @@ -0,0 +1,163 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="form.selectprintertitle" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-72,0,0,1,97"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jPanel2" min="-2" max="-2" attributes="0"/> + <Component id="jPanel8" alignment="0" min="-2" pref="345" max="-2" attributes="0"/> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jPanel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jPanel2" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="-2" attributes="0"/> + <Component id="jPanel8" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="jPanel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel8"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel7" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jPrinters" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jPrinters" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel7"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.MachinePrinter" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jPrinters"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 30]"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel1"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jcmdCancel"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdCancelActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jcmdOK"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="toolTipText" type="java.lang.String" value=""/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdOKActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/util/SelectPrinter.java b/src/main/java/com/unicenta/pos/util/SelectPrinter.java new file mode 100644 index 0000000..b5ea28b --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/SelectPrinter.java @@ -0,0 +1,228 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2016 +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.util; + +import com.unicenta.pos.forms.AppLocal; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.Window; +import javax.swing.SwingUtilities; + +/** + * + * @author adrian + */ +public class SelectPrinter extends javax.swing.JDialog { + + private String printservice; + private boolean ok; + + /** Creates new form SelectPrinter */ + private SelectPrinter(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + + /** Creates new form SelectPrinter */ + private SelectPrinter(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + /** + * + * @param parent + * @param printers + * @return + */ + public static SelectPrinter getSelectPrinter(Component parent, String[] printers) { + + Window window = SwingUtilities.windowForComponent(parent); + + SelectPrinter myMsg; + if (window instanceof Frame) { + myMsg = new SelectPrinter((Frame) window, true); + } else { + myMsg = new SelectPrinter((Dialog) window, true); + } + myMsg.init(printers); + myMsg.applyComponentOrientation(parent.getComponentOrientation()); + return myMsg; + } + + private void init(String[] printers) { + + initComponents(); + + jPrinters.removeAllItems(); + jPrinters.addItem("(Default)"); + for (String name : printers) { + jPrinters.addItem(name); + } + + jPrinters.setSelectedIndex(0); + + getRootPane().setDefaultButton(jcmdOK); + + ok = false; + printservice = null; + } + + /** + * + * @return + */ + public boolean isOK() { + return ok; + } + + /** + * + * @return + */ + public String getPrintService() { + return printservice; + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel8 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + jLabel7 = new javax.swing.JLabel(); + jPrinters = new javax.swing.JComboBox(); + jPanel1 = new javax.swing.JPanel(); + jcmdCancel = new javax.swing.JButton(); + jcmdOK = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("form.selectprintertitle")); // NOI18N + + jPanel8.setLayout(new java.awt.BorderLayout()); + + jLabel7.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel7.setText(AppLocal.getIntString("label.MachinePrinter")); // NOI18N + jLabel7.setPreferredSize(new java.awt.Dimension(150, 30)); + + jPrinters.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jPrinters.setPreferredSize(new java.awt.Dimension(150, 30)); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPrinters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jPrinters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setText(AppLocal.getIntString("button.cancel")); // NOI18N + jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdCancel.setPreferredSize(new java.awt.Dimension(80, 45)); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel1.add(jcmdCancel); + + jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setText(AppLocal.getIntString("button.OK")); // NOI18N + jcmdOK.setToolTipText(""); + jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdOK.setPreferredSize(new java.awt.Dimension(80, 45)); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel1.add(jcmdOK); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, 345, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + setSize(new java.awt.Dimension(353, 184)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + ok = true; + printservice = (String)jPrinters.getSelectedItem(); + dispose(); + + }//GEN-LAST:event_jcmdOKActionPerformed + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_jcmdCancelActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel7; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel8; + private javax.swing.JComboBox jPrinters; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/com/unicenta/pos/util/SessionKeepAlive.java b/src/main/java/com/unicenta/pos/util/SessionKeepAlive.java new file mode 100644 index 0000000..b895ac8 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/SessionKeepAlive.java @@ -0,0 +1,32 @@ +package com.unicenta.pos.util; + +import com.unicenta.pos.forms.DataLogicSystem; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class SessionKeepAlive extends Thread { + + private int wait = 60000; + private DataLogicSystem dataLogicSystem; + private Boolean keepAlive; + + public SessionKeepAlive(DataLogicSystem dataLogicSystem) { + this.dataLogicSystem = dataLogicSystem; + keepAlive = true; + } + + @Override + public void run() { + while (keepAlive) { + try { + log.info("Session Keep alive"); + dataLogicSystem.findVersion(); + Thread.sleep(wait); + } + catch (Exception ex) { + keepAlive = false; + log.error("Exception while keeping session alive: "+ex.getMessage()); + } + } + } +} diff --git a/src/main/java/com/unicenta/pos/util/StringParser.java b/src/main/java/com/unicenta/pos/util/StringParser.java new file mode 100644 index 0000000..4ceb3bd --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/StringParser.java @@ -0,0 +1,63 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2016 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.util; + +/** + * + * @author JG uniCenta + */ +public class StringParser { + + private int currentPosition; + private int maxPosition; + private String str; + + /** Creates a new instance of StringParser + * @param str */ + public StringParser(String str) { + this.str = str; + currentPosition = 0; + maxPosition = str == null ? 0 : str.length(); + } + + /** + * + * @param c + * @return + */ + public String nextToken(char c) { + + if (currentPosition < maxPosition) { + + int start = currentPosition; + while (currentPosition < maxPosition && c != str.charAt(currentPosition)) { + currentPosition ++; + } + + if (currentPosition < maxPosition) { + return str.substring(start, currentPosition++); + } else { + return str.substring(start); + } + } else { + return ""; + } + } +} diff --git a/src/main/java/com/unicenta/pos/util/StringUtils.java b/src/main/java/com/unicenta/pos/util/StringUtils.java new file mode 100644 index 0000000..d05ff4f --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/StringUtils.java @@ -0,0 +1,170 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2016 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.util; + +import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.Random; + +/** + * + * @author JG uniCenta + */ +public class StringUtils { + + private static final char [] hexchars = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + + private static final NumberFormat cardformat = new DecimalFormat("000000"); + private static final Random cardrandom = new Random(); + + /** Creates a new instance of StringUtils */ + private StringUtils() { + } + + /** + * + * @return + */ + public static String getCardNumber() { + return cardformat.format(Math.abs(System.currentTimeMillis()) % 1000000L) + + cardformat.format(Math.abs(cardrandom.nextLong()) % 1000000L); + } + + /** + * + * @param sValue + * @return + */ + public static String encodeXML(String sValue) { + + if (sValue == null) { + return null; + } else { + StringBuilder buffer = new StringBuilder(); + for (int i = 0; i < sValue.length(); i++) { + char charToCompare = sValue.charAt(i); + if (charToCompare == '&') { + buffer.append("&"); + } else if (charToCompare == '<') { + buffer.append("<"); + } else if (charToCompare == '>') { + buffer.append(">"); + } else if (charToCompare == '\"') { + buffer.append("""); + } else if (charToCompare == '\'') { + buffer.append("'"); + } else { + buffer.append(charToCompare); + } + } + return buffer.toString(); + } + } + + /** + * + * @param binput + * @return + */ + public static String byte2hex(byte[] binput) { + + StringBuilder sb = new StringBuilder(binput.length * 2); + for (int i = 0; i < binput.length; i++) { + int high = ((binput[i] & 0xF0) >> 4); + int low = (binput[i] & 0x0F); + sb.append(hexchars[high]); + sb.append(hexchars[low]); + } + return sb.toString(); + } + + /** + * + * @param sinput + * @return + */ + public static byte [] hex2byte(String sinput) { + int length = sinput.length(); + + if ((length & 0x01) != 0) { + throw new IllegalArgumentException("odd number of characters."); + } + + byte[] out = new byte[length >> 1]; + + // two characters form the hex value. + for (int i = 0, j = 0; j < length; i++) { + int f = Character.digit(sinput.charAt(j++), 16) << 4; + f = f | Character.digit(sinput.charAt(j++), 16); + out[i] = (byte) (f & 0xFF); + } + + return out; + } + + /** + * + * @param resource + * @return + * @throws IOException + */ + public static String readResource(String resource) throws IOException { + + InputStream in = StringUtils.class.getResourceAsStream(resource); + if (in == null) { + throw new FileNotFoundException(resource); + } + ByteArrayOutputStream out = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int len; + while ((len = in.read(buffer)) > 0) { + out.write(buffer, 0, len); + } + byte[] data = out.toByteArray(); + + return new String(data, "UTF-8"); + } + + /** + * + * @param sCardNumber + * @return + */ + public static boolean isNumber(String sCardNumber){ + + if ( (sCardNumber==null) || (sCardNumber.equals("")) ){ + return false; + } + + for (int i = 0; i < sCardNumber.length(); i++) { + char c = sCardNumber.charAt(i); + if (c != '0' && c != '1' && c != '2' && c != '3' && c != '4' + && c != '5' && c != '6' && c != '7' && c != '8' && c != '9') { + return false; + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/util/SwingUtils.java b/src/main/java/com/unicenta/pos/util/SwingUtils.java new file mode 100644 index 0000000..f86aa78 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/SwingUtils.java @@ -0,0 +1,152 @@ +package com.unicenta.pos.util; +import java.awt.FontMetrics; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JDialog; +import javax.swing.Timer; + +/** + * Swing utilities methods. Based on code from: + * http://www.aurelienribon.com/blog/2012/07/tutorial-beautifying-the-dialogs-in-swing-applications/ + * + * @author Harald Barsnes + */ +public class SwingUtils { + + // @TODO: requires java 7, hence not in use at the moment, see the lines that are commented out + + /** + * Creates an animation to fade the dialog opacity from 0 to 1. Using a + * default delay of 5 ms and an increment size of 0.05. + * + * @param dialog the dialog to fade in + */ + public static void fadeIn(final JDialog dialog) { + fadeIn(dialog, 5, 0.05f); + } + + /** + * Creates an animation to fade the dialog opacity from 0 to 1. + * + * @param dialog the dialog to fade in + * @param delay the delay in ms before starting and between each change + * @param incrementSize the increment size + */ + public static void fadeIn(final JDialog dialog, int delay, final float incrementSize) { + final Timer timer = new Timer(delay, null); + timer.setRepeats(true); + timer.addActionListener(new ActionListener() { + private float opacity = 0; + + @Override + public void actionPerformed(ActionEvent e) { + opacity += incrementSize; + dialog.setOpacity(Math.min(opacity, 1)); // requires java 1.7 + if (opacity >= 1) { + timer.stop(); + } + } + }); + + dialog.setOpacity(0); // requires java 1.7 + timer.start(); + dialog.setVisible(true); + } + + /** + * Creates an animation to fade the dialog opacity from 1 to 0. Using a + * default delay of 5 ms and an increment size of 0.05. + * + * @param dialog the dialog to fade out + */ + public static void fadeOut(final JDialog dialog) { + fadeOut(dialog, 5, 0.05f); + } + + /** + * Creates an animation to fade the dialog opacity from 1 to 0, and then + * dispose. + * + * @param dialog the dialog to fade out + * @param delay the delay in ms before starting and between each change + * @param incrementSize the increment size + */ + public static void fadeOut(final JDialog dialog, int delay, final float incrementSize) { + final Timer timer = new Timer(delay, null); + timer.setRepeats(true); + timer.addActionListener(new ActionListener() { + private float opacity = 1; + + @Override + public void actionPerformed(ActionEvent e) { + opacity -= incrementSize; + dialog.setOpacity(Math.max(opacity, 0)); // requires java 1.7 + if (opacity < 0) { + timer.stop(); + dialog.dispose(); + } + } + }); + + dialog.setOpacity(1); // requires java 1.7 + timer.start(); + } + + /** + * Creates an animation to fade the dialog opacity from 0 to 1, wait at 1 + * and then fade to 0. Default initial time of 50 ms, increment size of 0.05 + * and display time of 10000 ms. + * + * @param dialog the dialog to display + */ + public static void fadeInAndOut(final JDialog dialog) { + fadeInAndOut(dialog, 50, 0.05f, 10000); + } + + /** + * Creates an animation to fade the dialog opacity from 0 to 1, wait at 1 + * and then fade to 0 and dispose. + * + * @param dialog the dialog to display + * @param delay the delay in ms before starting and between each change + * @param incrementSize the increment size + * @param displayTime the time in ms the dialog is fully visible + */ + public static void fadeInAndOut(final JDialog dialog, final int delay, final float incrementSize, final int displayTime) { + final Timer timer = new Timer(delay, null); + timer.setRepeats(true); + timer.addActionListener(new ActionListener() { + private float opacity = 0; + private boolean displayed = false; + + @Override + public void actionPerformed(ActionEvent e) { + + if (!displayed) { + opacity += incrementSize; + dialog.setOpacity(Math.min(opacity, 1)); // requires java 1.7 + if (opacity >= 1) { + timer.setDelay(displayTime); + displayed = true; + } + } else { + timer.setDelay(delay); + opacity -= incrementSize; + dialog.setOpacity(Math.max(opacity, 0)); // requires java 1.7 + if (opacity < 0) { + timer.stop(); + dialog.dispose(); + } + } + } + }); + + dialog.setOpacity(0); // requires java 1.7 + timer.start(); + dialog.setVisible(true); + } + + static FontMetrics getDefaultLabelFontMetrics() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/util/SwingWorkerExample.java b/src/main/java/com/unicenta/pos/util/SwingWorkerExample.java new file mode 100644 index 0000000..f15172e --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/SwingWorkerExample.java @@ -0,0 +1,191 @@ +/* + * Copyright (C) 2016 uniCenta <info at unicenta.com> + * + * This program 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. + * + * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + */ +package com.unicenta.pos.util; + +/** + * + * @author uniCenta <info at unicenta.com> + */ + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.util.ArrayList; +import java.util.concurrent.ExecutionException; + +public class SwingWorkerExample extends JFrame implements ActionListener { + + private static final long serialVersionUID = 1L; + private final JButton startButton, stopButton; + private final JScrollPane scrollPane = new JScrollPane(); + private JList listBox = null; + private final DefaultListModel listModel = new DefaultListModel(); + private final JProgressBar progressBar; + private mySwingWorker swingWorker; + + public SwingWorkerExample() { + super("SwingWorkerExample"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + getContentPane().setLayout(new GridLayout(2, 2)); + startButton = makeButton("Start"); + stopButton = makeButton("Stop"); + stopButton.setEnabled(false); + progressBar = makeProgressBar(0, 99); + listBox = new JList(listModel); + scrollPane.setViewportView(listBox); + getContentPane().add(scrollPane); + //Display the window. + pack(); + setVisible(true); + } +//Class SwingWorker<T,V> T - the result type returned by this SwingWorker's doInBackground +//and get methods V - the type used for carrying out intermediate results by this SwingWorker's +//publish and process methods + + private class mySwingWorker extends javax.swing.SwingWorker<ArrayList<Integer>, Integer> { +//The first template argument, in this case, ArrayList<Integer>, is what s returned by doInBackground(), +//and by get(). The second template argument, in this case, Integer, is what is published with the +//publish method. It is also the data type which is stored by the java.util.List that is the parameter +//for the process method, which recieves the information published by the publish method. + + @Override + protected ArrayList<Integer> doInBackground() { +//Returns items of the type given as the first template argument to the SwingWorker class. + if (javax.swing.SwingUtilities.isEventDispatchThread()) { + System.out.println("javax.swing.SwingUtilities.isEventDispatchThread() returned true."); + } + Integer tmpValue = 1; + ArrayList<Integer> list = new ArrayList<>(); + for (int i = 0; i < 100; i++) { + for (int j = 0; j < 100; j++) { //find every 100th prime, just to make it slower + tmpValue = FindNextPrime(tmpValue); +//isCancelled() returns true if the cancel() method is invoked on this class. That is the proper way +//to stop this thread. See the actionPerformed method. + if (isCancelled()) { + System.out.println("SwingWorker - isCancelled"); + return list; + } + } +//Successive calls to publish are coalesced into a java.util.List, which is what is received by process, +//which in this case, isused to update the JProgressBar. Thus, the values passed to publish range from +//1 to 100. + publish(i); + list.add(tmpValue); + } + return list; + }//Note, always use java.util.List here, or it will use the wrong list. + + @Override + protected void process(java.util.List<Integer> progressList) { +//This method is processing a java.util.List of items given as successive arguments to the publish method. +//Note that these calls are coalesced into a java.util.List. This list holds items of the type given as the +//second template parameter type to SwingWorker. Note that the get method below has nothing to do with the +//SwingWorker get method; it is the List's get method. This would be a good place to update a progress bar. + if (!javax.swing.SwingUtilities.isEventDispatchThread()) { + System.out.println("javax.swing.SwingUtilities.isEventDispatchThread() + returned false."); + } + Integer percentComplete = progressList.get(progressList.size() - 1); + progressBar.setValue(percentComplete); + } + + @Override + protected void done() { + System.out.println("doInBackground is complete"); + if (!javax.swing.SwingUtilities.isEventDispatchThread()) { + System.out.println("javax.swing.SwingUtilities.isEventDispatchThread() + returned false."); + } + try { +//Here, the SwingWorker's get method returns an item of the same type as specified as the first type parameter +//given to the SwingWorker class. + ArrayList<Integer> results = get(); + results.stream().forEach((i) -> { + listModel.addElement(i.toString()); + }); + } catch (InterruptedException | ExecutionException e) { + System.out.println("Caught an exception: " + e); + } + startButton(); + } + + boolean IsPrime(int num) { //Checks whether a number is prime + int i; + for (i = 2; i <= num / 2; i++) { + if (num % i == 0) { + return false; + } + } + return true; + } + + protected Integer FindNextPrime(int num) { //Returns next prime number from passed arg. + do { + if (num % 2 == 0) { + num++; + } else { + num += 2; + } + } while (!IsPrime(num)); + return num; + } + } + + private JButton makeButton(String caption) { + JButton b = new JButton(caption); + b.setActionCommand(caption); + b.addActionListener(this); + getContentPane().add(b); + return b; + } + + private JProgressBar makeProgressBar(int min, int max) { + JProgressBar progressBar1 = new JProgressBar(); + progressBar1.setMinimum(min); + progressBar1.setMaximum(max); + progressBar1.setStringPainted(true); + progressBar1.setBorderPainted(true); + getContentPane().add(progressBar1); + return progressBar1; + } + + private void startButton() { + startButton.setEnabled(true); + stopButton.setEnabled(false); + System.out.println("SwingWorker - Done"); + } + + @Override + public void actionPerformed(ActionEvent e) { + if ("Start" == null ? e.getActionCommand() == null : "Start".equals(e.getActionCommand())) { + startButton.setEnabled(false); + stopButton.setEnabled(true); +// Note that it creates a new instance of the SwingWorker-derived class. Never reuse an old one. + (swingWorker = new mySwingWorker()).execute(); // new instance + } else if ("Stop" == null ? e.getActionCommand() == null : "Stop".equals(e.getActionCommand())) { + startButton.setEnabled(true); + stopButton.setEnabled(false); + swingWorker.cancel(true); // causes isCancelled to return true in doInBackground + swingWorker = null; + } + } + + public static void main(String[] args) { +// Notice that it kicks it off on the event-dispatching thread, not the main thread. + SwingUtilities.invokeLater(() -> { + SwingWorkerExample swingWorkerExample = new SwingWorkerExample(); + }); + } +} diff --git a/src/main/java/com/unicenta/pos/util/ThumbNailBuilder.java b/src/main/java/com/unicenta/pos/util/ThumbNailBuilder.java new file mode 100644 index 0000000..2dd7c64 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/ThumbNailBuilder.java @@ -0,0 +1,203 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2016 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.util; + +import java.awt.image.*; +import java.awt.*; +import javax.imageio.ImageIO; +import javax.swing.JLabel; + +/** + * + * @author JG uniCenta + */ +public class ThumbNailBuilder { + + private Image m_imgdefault; + private int m_width; + private int m_height; + + /** Creates a new instance of ThumbNailBuilder + * @param width + * @param height */ + public ThumbNailBuilder(int width, int height) { + init(width, height, null); + } + + /** + * + * @param width + * @param height + * @param imgdef + */ + public ThumbNailBuilder(int width, int height, Image imgdef) { + init(width, height, imgdef); + + } + + /** + * + * @param width + * @param height + * @param img + */ + public ThumbNailBuilder(int width, int height, String img) { + + Image defimg; + try { + init(width, height, ImageIO.read(getClass().getClassLoader().getResourceAsStream(img))); + } catch (Exception fnfe) { + init(width, height, null); + } + } + + private void init(int width, int height, Image imgdef) { + m_width = width; + m_height = height; + if (imgdef == null) { + m_imgdefault = null; + } else { + m_imgdefault = createThumbNail(imgdef); + } + } + + /** + * + * @param img + * @return + */ + public Image getThumbNail(Image img) { + + if (img == null) { + return m_imgdefault; + } else { + return createThumbNail(img); + } + } + + /** + * + * @param img + * @param text + * @return + */ + public Image getThumbNailText(Image img, String text) { + + img = getThumbNail(img); + + BufferedImage imgtext = new BufferedImage(img.getWidth(null), + img.getHeight(null), BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = imgtext.createGraphics(); + + // The text + JLabel label = new JLabel(); + label.setOpaque(false); + label.setText(text); + label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + label.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM); + + Dimension d = label.getPreferredSize(); + label.setBounds(0, 0, imgtext.getWidth(), d.height); + + + // The background + Color c1 = new Color(0xff, 0xff, 0xff, 0x40); + Color c2 = new Color(0xff, 0xff, 0xff, 0xd0); + + Paint gpaint = new GradientPaint(new Point(0,0), c1, new Point(label.getWidth() / 2, 0), c2, true); + + g2d.drawImage(img, 0, 0, null); + g2d.translate(0, imgtext.getHeight() - label.getHeight()); + g2d.setPaint(gpaint); +// g2d.fillRect(0 , 0, imgtext.getWidth(), label.getHeight()); + label.paint(g2d); + + g2d.dispose(); + + return imgtext; + } + + private Image createThumbNail(Image img) { + + int targetw; + int targeth; + + double scalex = (double) m_width / (double) img.getWidth(null); + double scaley = (double) m_height / (double) img.getHeight(null); + if (scalex < scaley) { + targetw = m_width; + targeth = (int) (img.getHeight(null) * scalex); + } else { + targetw = (int) (img.getWidth(null) * scaley); + targeth = (int) m_height; + } + + int midw = img.getWidth(null); + int midh = img.getHeight(null); + BufferedImage midimg = null; + Graphics2D g2d = null; + + Image previmg = img; + int prevw = img.getWidth(null); + int prevh = img.getHeight(null); + + do { + if (midw > targetw) { + midw /= 2; + if (midw < targetw) { + midw = targetw; + } + } else { + midw = targetw; + } + if (midh > targeth) { + midh /= 2; + if (midh < targeth) { + midh = targeth; + } + } else { + midh = targeth; + } + if (midimg == null) { + midimg = new BufferedImage(midw, midh, BufferedImage.TYPE_INT_ARGB); + g2d = midimg.createGraphics(); + g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + } + g2d.drawImage(previmg, 0, 0, midw, midh, 0, 0, prevw, prevh, null); + prevw = midw; + prevh = midh; + previmg = midimg; + } while (midw != targetw || midh != targeth); + + g2d.dispose(); + + if (m_width != midimg.getWidth() || m_height != midimg.getHeight()) { + midimg = new BufferedImage(m_width, m_height, BufferedImage.TYPE_INT_ARGB); + int x = (m_width > targetw) ? (m_width - targetw) / 2 : 0; + int y = (m_height > targeth) ? (m_height - targeth) / 2 : 0; + g2d = midimg.createGraphics(); + g2d.drawImage(previmg, x, y, x + targetw, y + targeth, + 0, 0, targetw, targeth, null); + g2d.dispose(); + previmg = midimg; + } + return previmg; + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/util/UniBrowser.java b/src/main/java/com/unicenta/pos/util/UniBrowser.java new file mode 100644 index 0000000..bbdc858 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/UniBrowser.java @@ -0,0 +1,173 @@ +/* + * Copyright (C) 2016 uniCenta <info at unicenta.com> + * + * This program 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. + * + * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + */ +package com.unicenta.pos.util; + +import javafx.application.Platform; +import javafx.beans.value.ObservableValue; +import javafx.embed.swing.JFXPanel; +import javafx.scene.Scene; +import javafx.scene.web.WebEngine; +import javafx.scene.web.WebEvent; +import javafx.scene.web.WebView; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.net.MalformedURLException; +import java.net.URL; + +import static javafx.concurrent.Worker.State.FAILED; + +public class UniBrowser extends JFrame { + + private final JFXPanel jfxPanel = new JFXPanel(); + private WebEngine engine; + + private final JPanel panel = new JPanel(new BorderLayout()); + private final JLabel lblStatus = new JLabel(); + + + private final JButton btnGo = new JButton("Go"); + private final JTextField txtURL = new JTextField(); + private final JProgressBar progressBar = new JProgressBar(); + + public UniBrowser() { + super(); + initComponents(); + } + + + private void initComponents() { + createScene(); + + ActionListener al = (ActionEvent e) -> { + loadURL(txtURL.getText()); + }; + + btnGo.addActionListener(al); + txtURL.addActionListener(al); + + progressBar.setPreferredSize(new Dimension(150, 18)); + progressBar.setStringPainted(true); + + JPanel topBar = new JPanel(new BorderLayout(5, 0)); + topBar.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5)); + topBar.add(txtURL, BorderLayout.CENTER); + topBar.add(btnGo, BorderLayout.EAST); + + JPanel statusBar = new JPanel(new BorderLayout(5, 0)); + statusBar.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5)); + statusBar.add(lblStatus, BorderLayout.CENTER); + statusBar.add(progressBar, BorderLayout.EAST); + + panel.add(topBar, BorderLayout.NORTH); + panel.add(jfxPanel, BorderLayout.CENTER); + panel.add(statusBar, BorderLayout.SOUTH); + + getContentPane().add(panel); + + setPreferredSize(new Dimension(1024, 600)); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + pack(); + + } + + private void createScene() { + + Platform.runLater(() -> { + WebView view = new WebView(); + engine = view.getEngine(); + + engine.titleProperty().addListener((ObservableValue<? extends String> observable, String oldValue, final String newValue) -> { + SwingUtilities.invokeLater(() -> { + UniBrowser.this.setTitle(newValue); + }); + }); + + engine.setOnStatusChanged((final WebEvent<String> event) -> { + SwingUtilities.invokeLater(() -> { + lblStatus.setText(event.getData()); + }); + }); + + engine.locationProperty().addListener((ObservableValue<? extends String> ov, String oldValue, final String newValue) -> { + SwingUtilities.invokeLater(() -> { + txtURL.setText(newValue); + }); + }); + + engine.getLoadWorker().workDoneProperty().addListener((ObservableValue<? extends Number> observableValue, Number oldValue, final Number newValue) -> { + SwingUtilities.invokeLater(() -> { + progressBar.setValue(newValue.intValue()); + }); + }); + + engine.getLoadWorker() + .exceptionProperty() + .addListener((ObservableValue<? extends Throwable> o, Throwable old, final Throwable value) -> { + if (engine.getLoadWorker().getState() == FAILED) { + SwingUtilities.invokeLater(() -> { + JOptionPane.showMessageDialog( + panel, + (value != null) ? + engine.getLocation() + "\n" + value.getMessage() : + engine.getLocation() + "\nUnexpected error.", + "Loading error...", + JOptionPane.ERROR_MESSAGE); + }); + } + }); + + jfxPanel.setScene(new Scene(view)); + }); + } + + public void loadURL(final String url) { + Platform.runLater(() -> { + String tmp = toURL(url); + + if (tmp == null) { + tmp = toURL("http://" + url); + } + + engine.load(tmp); + }); + } + + private static String toURL(String str) { + try { + return new URL(str).toExternalForm(); + } catch (MalformedURLException exception) { + return null; + } + } + + + + public static void main(String args[]) { + SwingUtilities.invokeLater(() -> { + UniBrowser browser = new UniBrowser(); + browser.setVisible(true); +// browser.loadURL("https://unicenta.com/pages/configure-unicenta-opos/"); + String[] s = args; + System.out.println(s); + String strURL ="https://unicenta.com/pages/configure-unicenta-opos/"; + System.out.println("s"); + UniBrowser.toURL(strURL); + }); + } +} \ No newline at end of file diff --git a/src/main/java/com/unicenta/pos/util/ValidateBuilder.java b/src/main/java/com/unicenta/pos/util/ValidateBuilder.java new file mode 100644 index 0000000..cb51408 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/ValidateBuilder.java @@ -0,0 +1,130 @@ + +package com.unicenta.pos.util; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.format.Formats; +import java.awt.Component; +import java.util.ArrayList; +import java.util.List; + + +public class ValidateBuilder { + + public static int IS_NOT_EMPTY = 1; + public static int IS_INT = 2; + public static int IS_DOUBLE = 3; + public static int IS_CURRENCY = 4; + public static int IS_DOUBLE_NULL = 5 ; + + private List<String> listMessage ; + private Component parent; + + public ValidateBuilder(Component _parent) { + parent = _parent; + listMessage = new ArrayList<>(); + } + + public void setValidate(Object value , int tipe , String message){ + if (value==null){ + listMessage.add(message); + } + } + + public void setValidate(String value , int tipe , String message){ + if(tipe == IS_NOT_EMPTY){ + if (value.equals("")){ + listMessage.add(message); + } + }else if (tipe == IS_INT){ + if (!isInt(value)){ + listMessage.add(message); + } + }else if (tipe == IS_DOUBLE){ + if (!isDouble(value)){ + listMessage.add(message); + } + }else if (tipe == IS_CURRENCY){ + if (!isCurrency(value)){ + listMessage.add(message); + } + }else if (tipe == IS_DOUBLE_NULL){ + if (!isDoubleNull(value)){ + listMessage.add(message); + } + } + } + + private void showMessage(){ + StringBuilder sb = new StringBuilder(); + sb.append("<br>"); + for (String message : listMessage){ + sb.append(message+"<br>"); + } + MessageInf msg = new MessageInf(MessageInf.SGN_NOTICE,sb.toString() , null); + msg.show(parent); + + } + + public boolean getValid(){ + boolean isValid = true; + if (listMessage.size()>0){ + isValid= false; + showMessage(); + } + return isValid; + } + + private boolean isInt(String n) { + try { + Object a = Formats.INT.parseValue(n); + if (a!=null){ + return true; + }else{ + return false; + } + } catch (BasicException ex) { + return false; + } + } + + + private boolean isDouble(String n) { + try { + Object a = Formats.DOUBLE.parseValue(n); + if (a!=null){ + return true; + }else{ + return false; + } + } catch (BasicException ex) { + return false; + } + } + + + + private boolean isDoubleNull(String n) { + try { + Object a = Formats.DOUBLE.parseValue(n); + return true; + } catch (BasicException ex) { + return false; + } + } + + + private boolean isCurrency(String n){ + try { + Object a = Formats.CURRENCY.parseValue(n); + if (a!=null){ + return true; + }else{ + return false; + } + + } catch (BasicException ex) { + return false; + } + } +} diff --git a/src/main/java/com/unicenta/pos/util/VideoPlayer.java b/src/main/java/com/unicenta/pos/util/VideoPlayer.java new file mode 100644 index 0000000..36d2253 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/VideoPlayer.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2016 uniCenta <info at unicenta.com> + * + * This program 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. + * + * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + */ +package com.unicenta.pos.util; + +import javafx.application.Application; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.media.Media; +import javafx.scene.media.MediaPlayer; +import javafx.scene.media.MediaView; +import javafx.stage.Stage; + +/** + * Provides JavaFX media player services + * @author uniCenta + */ + + +public class VideoPlayer extends Application { + public static void main(String[] args) { launch(args); } + private static final String MEDIA_URL = + "file:///C://temp//2017_07_14_12_20_37-ses.mp4"; // Test LocalFile + + +@Override + public void start(Stage primaryStage) { + primaryStage.setTitle("uniCenta Media Player"); + Group root = new Group(); + Scene scene = new Scene(root, 540, 310); +// create media player + Media media = new Media(MEDIA_URL); + MediaPlayer mediaPlayer = new MediaPlayer(media); + mediaPlayer.setAutoPlay(true); +// create mediaView and add media player to the viewer + MediaView mediaView = new MediaView(mediaPlayer); + ((Group)scene.getRoot()).getChildren().add(mediaView); + + primaryStage.setScene(scene); + primaryStage.show(); + } + +} diff --git a/src/main/java/com/unicenta/pos/util/uOWWatch.java b/src/main/java/com/unicenta/pos/util/uOWWatch.java new file mode 100644 index 0000000..6de3810 --- /dev/null +++ b/src/main/java/com/unicenta/pos/util/uOWWatch.java @@ -0,0 +1,151 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2016 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + + +/*--------------------------------------------------------------------------- + * Copyright (c) 1999,2000 Dallas Semiconductor Corporation, All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of Dallas Semiconductor + * shall not be used except as stated in the Dallas Semiconductor + * Branding Policy. + *--------------------------------------------------------------------------- + */ + +package com.unicenta.pos.util; + +import com.dalsemi.onewire.OneWireAccessProvider; +import com.dalsemi.onewire.adapter.DSPortAdapter; +import com.dalsemi.onewire.container.OneWireContainer; +import com.dalsemi.onewire.application.monitor.*; + + +/** + * @version 0.00, 25 September 2000 + * @author DS,BA,SH + * @modified JG uniCenta October 2017 + */ +public class uOWWatch + implements DeviceMonitorEventListener { + + public static String ibuttonid; + + /** + * Method main + */ + public static void iButtonOn () { + OneWireContainer owd; + + try { + DSPortAdapter adapter = OneWireAccessProvider.getDefaultAdapter(); + + adapter.setSearchAllDevices(); + adapter.targetAllFamilies(); + adapter.setSpeed(DSPortAdapter.SPEED_REGULAR); + + uOWWatch nw = new uOWWatch(adapter); + } catch (Exception e) { + + } + + return; + } + + /** Network Monitor instance */ + private DeviceMonitor dm; + + /** + * Create a 1-Wire Network Watcher + * @param adapter for 1-Wire Network to monitor + */ + public uOWWatch (DSPortAdapter adapter) { + + dm = new DeviceMonitor(adapter); + + try { + dm.addDeviceMonitorEventListener(this); + } catch (Exception e){ } + + Thread t = new Thread(dm); + t.start(); + } + + /** + * + */ + public void killWatch() { + dm.killMonitor(); + } + + /** + * Arrival event as a NetworkMonitorEventListener + * @param devt + */ + @Override + public void deviceArrival (DeviceMonitorEvent devt) { + int i; + + for(i=0; i<devt.getDeviceCount(); i++) { + ibuttonid = devt.getAddressAsStringAt(i); + } + } + + /** + * Depart event as a NetworkMonitorEventListener + * @param devt + */ + @Override + public void deviceDeparture (DeviceMonitorEvent devt) { + int i; + + for(i=0; i<devt.getDeviceCount(); i++) + ibuttonid = ""; + } + + /** + * Depart event as a NetworkMonitorEventListener + * @param dexc + */ + @Override + public void networkException (DeviceMonitorException dexc) { + + } + + public static String getibuttonid (){ + return ibuttonid; + } + +} diff --git a/src/main/java/com/unicenta/pos/voucher/JDialogReportPanel.form b/src/main/java/com/unicenta/pos/voucher/JDialogReportPanel.form new file mode 100644 index 0000000..88e765a --- /dev/null +++ b/src/main/java/com/unicenta/pos/voucher/JDialogReportPanel.form @@ -0,0 +1,132 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="form.customertitle" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Default Cursor"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-81,0,0,3,69"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel3"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel4"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="5" left="5" right="5" top="5"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + <Container class="javax.swing.JPanel" name="jPanel8"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="South"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="After"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="jcmdOK"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="Button.OK" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdOKActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jcmdCancel"> + <Properties> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/cancel.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="Button.Cancel" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 16, 8, 16]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdCancelActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="text" type="java.lang.String" value="jButton1"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/voucher/JDialogReportPanel.java b/src/main/java/com/unicenta/pos/voucher/JDialogReportPanel.java new file mode 100644 index 0000000..e020123 --- /dev/null +++ b/src/main/java/com/unicenta/pos/voucher/JDialogReportPanel.java @@ -0,0 +1,293 @@ + +package com.unicenta.pos.voucher; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.MessageInf; +import com.unicenta.data.loader.BaseSentence; +import com.unicenta.data.loader.Datas; +import com.unicenta.data.loader.QBFBuilder; +import com.unicenta.data.loader.SerializerReadBasic; +import com.unicenta.data.loader.StaticSentence; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.reports.ReportFields; +import com.unicenta.pos.reports.ReportFieldsArray; +// import com.unicenta.pos.util.FontUtil; +import com.unicenta.pos.util.JRViewer400; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Window; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import javax.swing.*; +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.JREmptyDataSource; +import net.sf.jasperreports.engine.JRException; +import net.sf.jasperreports.engine.JasperCompileManager; +import net.sf.jasperreports.engine.JasperFillManager; +import net.sf.jasperreports.engine.JasperPrint; +import net.sf.jasperreports.engine.JasperReport; +import net.sf.jasperreports.engine.design.JasperDesign; +import net.sf.jasperreports.engine.xml.JRXmlLoader; + +public abstract class JDialogReportPanel extends javax.swing.JDialog { + + + private JRViewer400 reportviewer = null; + private JasperReport jr = null; + private AppView m_App; + private List<String> paramnames = new ArrayList<>(); + private List<Datas> fielddatas = new ArrayList<>(); + private List<String> fieldnames = new ArrayList<>(); + private String sentence; + /** Creates new form JCustomerFinder */ + private JDialogReportPanel(java.awt.Frame parent, boolean modal) { + super(parent, modal); + } + + /** Creates new form JCustomerFinder */ + private JDialogReportPanel(java.awt.Dialog parent, boolean modal) { + super(parent, modal); + } + + public static JDialogReportPanel getDialog(Component parent,AppView _App,VoucherInfo voucherInfo,BufferedImage image) { + Window window = getWindow(parent); + + JDialogReportPanel myMsg; + if (window instanceof Frame) { + myMsg = new JDialogReportPanel((Frame) window, true) { + @Override + protected String getReport() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + }; + } else { + myMsg = new JDialogReportPanel((Dialog) window, true) { + @Override + protected String getReport() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + }; + } + myMsg.init(_App,voucherInfo,image); + myMsg.applyComponentOrientation(parent.getComponentOrientation()); + return myMsg; + } + + + protected BaseSentence getSentence() { + return new StaticSentence(m_App.getSession() + , new QBFBuilder(sentence, paramnames.toArray(new String[paramnames.size()])) + , null + , new SerializerReadBasic(fielddatas.toArray(new Datas[fielddatas.size()]))); + } + + + protected ReportFields getReportFields() { + return new ReportFieldsArray(fieldnames.toArray(new String[fieldnames.size()])); + } + + + private void launchreport(VoucherInfo voucherInfo,BufferedImage image) { + + + + if (jr != null) { + try { + + // Archivo de recursos + String res = "com/unicenta/reports/voucher_messages";//getResourceBundle(); + + // Parametros y los datos +// Object params = (editor == null) ? null : editor.createValue(); +// BaseSentence sql= getSentence() ; +// JRDataSource data = new JRDataSourceBasic(sql, getReportFields(), null); + + // Construyo el mapa de los parametros. + Map reportparams = new HashMap(); + reportparams.put("CUSTOMER_NAME", voucherInfo.getCustomerName()); + reportparams.put("LOGO", image); + reportparams.put("CODE", voucherInfo.getVoucherNumber()); + reportparams.put("ISSUED", new Date()); + reportparams.put("VALUE", voucherInfo.getAmount()); + if (res != null) { + reportparams.put("REPORT_RESOURCE_BUNDLE", ResourceBundle.getBundle(res)); + } + +// if (paramsreport.size()>0){ +// for (Map.Entry<String, String> entry : paramsreport.entrySet()) { +// reportparams.put(entry.getKey(), entry.getValue()); +// } +// } + + JasperPrint jp = JasperFillManager.fillReport(jr, reportparams, new JREmptyDataSource()); +// JasperExportManager.exportReportToPdfFile(jp,"E:\\report7.pdf"); + reportviewer.loadJasperPrint(jp); + + + } catch (MissingResourceException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadresourcedata"), e); + msg.show(this); + } catch (JRException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfillreport"), e); + msg.show(this); + } +// catch (BasicException e) { +// MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadreportdata"), e); +// msg.show(this); +// } + } + } + + + + private void init(AppView _App,VoucherInfo voucherInfo,BufferedImage image) { + m_App =_App; + initComponents(); + + reportviewer = new JRViewer400(null); + + jPanel4.add(reportviewer, BorderLayout.CENTER); + + try { + jr = JasperCompileManager.compileReport("com/unicenta/reports/voucher" + ".jrxml"); +// jr = JasperCompileManager.compileReport(getClass().getResourceAsStream("reports" + "/com/unicenta/reports/voucher" + ".jrxml")); + } catch (JRException e) { + MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadreport"), e); + msg.show(this); + jr = null; + } + + + + + launchreport(voucherInfo,image); + + + getRootPane().setDefaultButton(jcmdOK); + + + } + + /** + * + * @return + */ + protected abstract String getReport(); + + + + private static Window getWindow(Component parent) { + if (parent == null) { + return new JFrame(); + } else if (parent instanceof Frame || parent instanceof Dialog) { + return (Window) parent; + } else { + return getWindow(parent.getParent()); + } + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jPanel3 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + jPanel8 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jcmdOK = new javax.swing.JButton(); + jcmdCancel = new javax.swing.JButton(); + jButton1 = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setTitle(AppLocal.getIntString("form.customertitle")); // NOI18N + setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + + jPanel3.setLayout(new java.awt.BorderLayout()); + + jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + jPanel4.setLayout(new java.awt.BorderLayout()); + jPanel3.add(jPanel4, java.awt.BorderLayout.CENTER); + + jPanel8.setLayout(new java.awt.BorderLayout()); + + jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jcmdOK.setText(AppLocal.getIntString("Button.OK")); // NOI18N + jcmdOK.setEnabled(false); + jcmdOK.setFocusPainted(false); + jcmdOK.setFocusable(false); + jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdOK.setRequestFocusEnabled(false); + jcmdOK.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdOKActionPerformed(evt); + } + }); + jPanel1.add(jcmdOK); + + jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N + jcmdCancel.setText(AppLocal.getIntString("Button.Cancel")); // NOI18N + jcmdCancel.setFocusPainted(false); + jcmdCancel.setFocusable(false); + jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16)); + jcmdCancel.setRequestFocusEnabled(false); + jcmdCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jcmdCancelActionPerformed(evt); + } + }); + jPanel1.add(jcmdCancel); + + jPanel8.add(jPanel1, java.awt.BorderLayout.LINE_END); + + jButton1.setText("jButton1"); + jPanel8.add(jButton1, java.awt.BorderLayout.CENTER); + + jPanel3.add(jPanel8, java.awt.BorderLayout.SOUTH); + + getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER); + + setSize(new java.awt.Dimension(837, 687)); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed + + + dispose(); + + }//GEN-LAST:event_jcmdOKActionPerformed + + private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed + + dispose(); + + }//GEN-LAST:event_jcmdCancelActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel8; + private javax.swing.JButton jcmdCancel; + private javax.swing.JButton jcmdOK; + // End of variables declaration//GEN-END:variables + + } diff --git a/src/main/java/com/unicenta/pos/voucher/VoucherEditor.form b/src/main/java/com/unicenta/pos/voucher/VoucherEditor.form new file mode 100644 index 0000000..24fcef4 --- /dev/null +++ b/src/main/java/com/unicenta/pos/voucher/VoucherEditor.form @@ -0,0 +1,251 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLblStatus" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jStatus" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="m_jNumber" min="-2" max="-2" attributes="0"/> + <Component id="m_jAmount" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="m_jCustomer" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Component id="jCBCustomer" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace pref="19" max="32767" attributes="0"/> + </Group> + </Group> + </Group> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="32767" attributes="0"/> + <Component id="jButtonPrint" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jNumber" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jAmount" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="m_jCustomer" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jCBCustomer" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="m_jStatus" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLblStatus" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" pref="36" max="-2" attributes="0"/> + <Component id="jButtonPrint" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="21" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.Number" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jNumber"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[240, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.customer" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jCustomer"> + <Properties> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Text Cursor"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[240, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jAmount"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[240, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.paymenttotal" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jButtonPrint"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="12" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/printer24.png"/> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="button.print" replaceFormat="AppLocal.getIntString("button.print")"/> + </Property> + <Property name="focusPainted" type="boolean" value="false"/> + <Property name="focusable" type="boolean" value="false"/> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[8, 14, 8, 14]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[80, 45]"/> + </Property> + <Property name="requestFocusEnabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonPrintActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLblStatus"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/com/unicenta/images/ok.png"/> + </Property> + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="label.Status" replaceFormat="AppLocal.getIntString("{key}")"/> + </Property> + <Property name="horizontalTextPosition" type="int" value="10"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[100, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="m_jStatus"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[240, 30]"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jCBCustomer"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Arial" size="14" style="0"/> + </Property> + <Property name="maximumRowCount" type="int" value="2"/> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="2"> + <StringItem index="0" value="Find"/> + <StringItem index="1" value="Create"/> + </StringArray> + </Property> + <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> + <ResourceString bundle="pos_messages.properties" key="tooltip.vouchercustomer" replaceFormat="AppLocal.getIntString("label.voucherCustomer")"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[110, 30]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCBCustomerActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> + </AuxValues> + </Component> + </SubComponents> +</Form> diff --git a/src/main/java/com/unicenta/pos/voucher/VoucherEditor.java b/src/main/java/com/unicenta/pos/voucher/VoucherEditor.java new file mode 100644 index 0000000..434ef01 --- /dev/null +++ b/src/main/java/com/unicenta/pos/voucher/VoucherEditor.java @@ -0,0 +1,439 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.voucher; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.gui.ComboBoxValModel; +import com.unicenta.data.user.DirtyManager; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.customers.CustomerInfo; +import com.unicenta.pos.customers.DataLogicCustomers; +import com.unicenta.pos.customers.JCustomerFinder; +import com.unicenta.pos.customers.JDialogNewCustomer; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.forms.AppView; +import com.unicenta.pos.forms.DataLogicSystem; +import com.unicenta.pos.util.ValidateBuilder; + +import javax.swing.*; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.UUID; + +public final class VoucherEditor extends javax.swing.JPanel implements EditorRecord { + + private static final DateFormat m_simpledate = new SimpleDateFormat("MM-yy"); + private Object id; + private final DataLogicCustomers dlCustomers; + private final DataLogicSystem dlSystem; + private CustomerInfo customerInfo; + private final AppView m_app; + + private final ComboBoxValModel m_ReasonModel; + + public VoucherEditor(DirtyManager dirty,AppView app) { + m_app = app; + + initComponents(); + + dlCustomers = (DataLogicCustomers) + app.getBean("com.unicenta.pos.customers.DataLogicCustomers"); + dlSystem = (DataLogicSystem) + app.getBean("com.unicenta.pos.forms.DataLogicSystem"); + m_jNumber.getDocument().addDocumentListener(dirty); + m_jCustomer.getDocument().addDocumentListener(dirty); + m_jAmount.getDocument().addDocumentListener(dirty); + m_jStatus.getDocument().addDocumentListener(dirty); + + jButtonPrint.setVisible(false); + + m_ReasonModel = new ComboBoxValModel(); + m_ReasonModel.add(AppLocal.getIntString("cboption.find")); + m_ReasonModel.add(AppLocal.getIntString("cboption.create")); + jCBCustomer.setModel(m_ReasonModel); + jLblStatus.setIcon(null); + + writeValueEOF(); + } + + @Override + public void writeValueEOF() { + id = null; + m_jNumber.setText(null); + m_jNumber.setEnabled(false); + m_jCustomer.setText(null); + m_jCustomer.setEnabled(false); + m_jAmount.setText(null); + m_jAmount.setEnabled(false); + m_jStatus.setText(null); + m_jStatus.setEnabled(false); + + jButtonPrint.setEnabled(false); + } + + @Override + public void writeValueInsert() { + id = UUID.randomUUID().toString(); + m_jNumber.setText(generateVoucherNumber()); + m_jNumber.setEnabled(true); + m_jCustomer.setText(null); + m_jCustomer.setEnabled(true); + m_jAmount.setText(null); + m_jAmount.setEnabled(true); + m_jStatus.setText(null); + m_jStatus.setText("A"); + + jButtonPrint.setEnabled(false); + jButtonPrint.setEnabled(true); + } + + @Override + public void writeValueDelete(Object value) { + if ("A".equals(m_jStatus.getText())) { + Object[] attr = (Object[]) value; + id = attr[0]; + m_jNumber.setText(Formats.STRING.formatValue(attr[1])); + m_jNumber.setEnabled(false); +// customerInfo = dlCustomers.getCustomerInfo(attr[2].toString()); +// m_jCustomer.setText(customerInfo.getName()); + m_jCustomer.setText(Formats.STRING.formatValue(attr[2])); + m_jCustomer.setEnabled(false); + m_jAmount.setText(Formats.DOUBLE.formatValue(attr[3])); + m_jAmount.setEnabled(false); + m_jStatus.setText(Formats.STRING.formatValue(attr[4])); + m_jStatus.setEnabled(false); + jButtonPrint.setEnabled(false); + } else { + JOptionPane.showMessageDialog(this, + AppLocal.getIntString("message.voucherdelete"), + AppLocal.getIntString("Check"), + JOptionPane.WARNING_MESSAGE); + } + } + + @Override + public void writeValueEdit(Object value) { + + Object[] attr = (Object[]) value; + id = attr[0]; + m_jNumber.setText(Formats.STRING.formatValue(attr[1])); + m_jNumber.setEnabled(true); +// customerInfo = dlCustomers.getCustomerInfo(attr[2].toString()); +// m_jCustomer.setText(customerInfo.getName()); + m_jCustomer.setText(Formats.STRING.formatValue(attr[2])); + m_jCustomer.setEnabled(true); + m_jAmount.setText(Formats.DOUBLE.formatValue(attr[3])); + m_jAmount.setEnabled(true); + m_jStatus.setText(Formats.STRING.formatValue(attr[4])); + jButtonPrint.setEnabled(true); + + if (null == m_jStatus.getText()) { + jLblStatus.setIcon(null); + } else switch (m_jStatus.getText()) { + case "A": + jLblStatus.setIcon(new javax.swing.ImageIcon(getClass() + .getResource("/com/unicenta/images/OK.png"))); + m_jNumber.setEnabled(true); + m_jAmount.setEnabled(true); + m_jCustomer.setEnabled(true); + jCBCustomer.setEnabled(true); + m_jStatus.setText("A"); + break; + case "D": + jLblStatus.setIcon(new javax.swing.ImageIcon(getClass() + .getResource("/com/unicenta/images/refundit.png"))); + m_jNumber.setEnabled(false); + m_jAmount.setEnabled(false); + m_jCustomer.setEnabled(false); + jCBCustomer.setEnabled(false); + m_jStatus.setText("D"); + break; + default: + jLblStatus.setIcon(null); + break; + } + } + + @Override + public Object createValue() throws BasicException { + + Object[] attr = new Object[5]; + + attr[0] = id; + attr[1] = m_jNumber.getText(); +// attr[2] = customerInfo.getId(); + attr[2] = m_jCustomer.getText(); + attr[3] = Formats.DOUBLE.parseValue(m_jAmount.getText()); + attr[4] = m_jStatus.getText(); + + return attr; + } + + @Override + public Component getComponent() { + return this; + } + + @Override + public void refresh() { + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel2 = new javax.swing.JLabel(); + m_jNumber = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + m_jCustomer = new javax.swing.JTextField(); + m_jAmount = new javax.swing.JTextField(); + jLabel5 = new javax.swing.JLabel(); + jButtonPrint = new javax.swing.JButton(); + jLblStatus = new javax.swing.JLabel(); + m_jStatus = new javax.swing.JTextField(); + jCBCustomer = new javax.swing.JComboBox<>(); + + setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + + jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel2.setText(AppLocal.getIntString("label.Number")); // NOI18N + jLabel2.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jNumber.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jNumber.setPreferredSize(new java.awt.Dimension(240, 30)); + + jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel3.setText(AppLocal.getIntString("label.customer")); // NOI18N + jLabel3.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jCustomer.setBackground(new java.awt.Color(255, 255, 255)); + m_jCustomer.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jCustomer.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR)); + m_jCustomer.setPreferredSize(new java.awt.Dimension(240, 30)); + + m_jAmount.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jAmount.setPreferredSize(new java.awt.Dimension(240, 30)); + + jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLabel5.setText(AppLocal.getIntString("label.paymenttotal")); // NOI18N + jLabel5.setPreferredSize(new java.awt.Dimension(100, 30)); + + jButtonPrint.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N + jButtonPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/printer24.png"))); // NOI18N + jButtonPrint.setToolTipText(AppLocal.getIntString("button.print")); // NOI18N + jButtonPrint.setFocusPainted(false); + jButtonPrint.setFocusable(false); + jButtonPrint.setMargin(new java.awt.Insets(8, 14, 8, 14)); + jButtonPrint.setPreferredSize(new java.awt.Dimension(80, 45)); + jButtonPrint.setRequestFocusEnabled(false); + jButtonPrint.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButtonPrintActionPerformed(evt); + } + }); + + jLblStatus.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jLblStatus.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N + jLblStatus.setText(AppLocal.getIntString("label.Status")); // NOI18N + jLblStatus.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); + jLblStatus.setPreferredSize(new java.awt.Dimension(100, 30)); + + m_jStatus.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + m_jStatus.setPreferredSize(new java.awt.Dimension(240, 30)); + + jCBCustomer.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N + jCBCustomer.setMaximumRowCount(2); + jCBCustomer.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Find", "Create" })); + jCBCustomer.setToolTipText(AppLocal.getIntString("label.voucherCustomer")); // NOI18N + jCBCustomer.setPreferredSize(new java.awt.Dimension(110, 30)); + jCBCustomer.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jCBCustomerActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(m_jNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jAmount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(m_jCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jCBCustomer, 0, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(19, Short.MAX_VALUE)))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jButtonPrint, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jAmount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(m_jCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jCBCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(m_jStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(36, 36, 36) + .addComponent(jButtonPrint, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(21, 21, 21)) + ); + }// </editor-fold>//GEN-END:initComponents + +private void jButtonPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPrintActionPerformed + + try { + VoucherInfo voucherInfo = dlCustomers.getVoucherInfoAll(id.toString()); + BufferedImage image = dlSystem.getResourceAsImage("Window.Logo"); + if (voucherInfo!=null){ + JDialogReportPanel dialog = JDialogReportPanel + .getDialog(this,m_app,voucherInfo,image); + dialog.setVisible(true); + } + + } catch (BasicException ex) { + + } +}//GEN-LAST:event_jButtonPrintActionPerformed + + private void jCBCustomerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBCustomerActionPerformed + if(jCBCustomer.getSelectedIndex() == 0){ + + JCustomerFinder finder = JCustomerFinder.getCustomerFinder(this, dlCustomers); + finder.setVisible(true); + customerInfo = finder.getSelectedCustomer() ; + + if (finder.getSelectedCustomer()!=null){ + m_jCustomer.setText(customerInfo.getName()); + } + } else { + + JDialogNewCustomer dialog = JDialogNewCustomer.getDialog(this,m_app); + dialog.setVisible(true); + + customerInfo=dialog.getSelectedCustomer(); + if (dialog.getSelectedCustomer()!=null){ + m_jCustomer.setText(customerInfo.getName()); + } + } + + }//GEN-LAST:event_jCBCustomerActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButtonPrint; + private javax.swing.JComboBox<String> jCBCustomer; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLblStatus; + private javax.swing.JTextField m_jAmount; + private javax.swing.JTextField m_jCustomer; + private javax.swing.JTextField m_jNumber; + private javax.swing.JTextField m_jStatus; + // End of variables declaration//GEN-END:variables + + public boolean isDataValid() { + ValidateBuilder validate = new ValidateBuilder(this); + validate.setValidate(m_jNumber.getText(),ValidateBuilder.IS_NOT_EMPTY, + AppLocal.getIntString("message.message.emptynumber")); + validate.setValidate(m_jCustomer.getText(),ValidateBuilder.IS_NOT_EMPTY, + AppLocal.getIntString("message.emptycustomer")); + validate.setValidate(m_jAmount.getText(),ValidateBuilder.IS_DOUBLE, + AppLocal.getIntString("message.numericamount")); + validate.setValidate(m_jStatus.getText(),ValidateBuilder.IS_NOT_EMPTY, + AppLocal.getIntString("message.emptystatus")); + return validate.getValid(); + } + + + public String generateVoucherNumber(){ + String result=""; + + try { + result = "VO-"; + String date = m_simpledate.format(new Date()); + result = result + date; + String lastNumber= (String)dlCustomers.getVoucherNumber().find(result); + int newNumber = 1 ; + + if (lastNumber!=null){ + newNumber = Integer.parseInt(lastNumber) +1; + } + result = result + "-" + getNewNumber(newNumber); + + return result; + + } catch (BasicException ex) { + } + return result; + } + + + private String getNewNumber(int newNumber){ + String newNo = newNumber + ""; + String zero = ""; + for (int i=0;i< 3 - newNo.length();i++){ + zero = zero + "0"; + } + return zero+newNo; + } +} diff --git a/src/main/java/com/unicenta/pos/voucher/VoucherInfo.java b/src/main/java/com/unicenta/pos/voucher/VoucherInfo.java new file mode 100644 index 0000000..b5deec0 --- /dev/null +++ b/src/main/java/com/unicenta/pos/voucher/VoucherInfo.java @@ -0,0 +1,147 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2017 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +package com.unicenta.pos.voucher; + +import com.unicenta.basic.BasicException; +import com.unicenta.data.loader.DataRead; +import com.unicenta.data.loader.IKeyed; +import com.unicenta.data.loader.SerializerRead; + + +public class VoucherInfo implements IKeyed { + private String id; + private String voucherNumber; + private String customerName; + private double amount; + private String status; + + public VoucherInfo() { + } + + public VoucherInfo( + String id, + String voucherNumber, + String customerName, + double amount, + String status) + { + this.id = id; + this.voucherNumber = voucherNumber; + this.customerName = customerName; + this.amount = amount; + this.status = status; + } + + + @Override + public Object getKey() { + return getId(); + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(String id) { + this.id = id; + } + + /** + * @return the voucherNumber + */ + public String getVoucherNumber() { + return voucherNumber; + } + + /** + * @param voucherNumber the voucherNumber to set + */ + public void setVoucherNumber(String voucherNumber) { + this.voucherNumber = voucherNumber; + } + + /** + * @return the customerName + */ + public String getCustomerName() { + return customerName; + } + + /** + * @param customerName the customerName to set + */ + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + /** + * @return the amount + */ + public double getAmount() { + return amount; + } + + /** + * @param amount the amount to set + */ + public void setAmount(double amount) { + this.amount = amount; + } + + + @Override + public String toString() { + return voucherNumber; + } + + /** + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * @param status the status to set + */ + public void setStatus(String status) { + this.status = status; + } + + public static SerializerRead getSerializerRead() { + return new SerializerRead() + { + @Override + public Object readValues(DataRead dr) throws BasicException { + return new VoucherInfo( + dr.getString(1), + dr.getString(2), + dr.getString(3), + dr.getDouble(4), + dr.getString(5)); + }}; + } +} diff --git a/src/main/java/com/unicenta/pos/voucher/VoucherPanel.java b/src/main/java/com/unicenta/pos/voucher/VoucherPanel.java new file mode 100644 index 0000000..0e7ba38 --- /dev/null +++ b/src/main/java/com/unicenta/pos/voucher/VoucherPanel.java @@ -0,0 +1,49 @@ + + +package com.unicenta.pos.voucher; + +import com.unicenta.data.loader.Datas; +import com.unicenta.data.model.*; +import com.unicenta.data.user.EditorRecord; +import com.unicenta.format.Formats; +import com.unicenta.pos.forms.AppLocal; +import com.unicenta.pos.panels.JPanelTable2; + +public class VoucherPanel extends JPanelTable2 { + + private VoucherEditor editor; + + @Override + protected void init() { + row = new Row( + new Field("ID", Datas.STRING, Formats.STRING), + new Field(AppLocal.getIntString("label.Number"), Datas.STRING, Formats.STRING, true, true, true), + new Field(AppLocal.getIntString("label.customer"), Datas.STRING, Formats.STRING), + new Field(AppLocal.getIntString("label.paymenttotal"), Datas.DOUBLE, Formats.DOUBLE), + new Field(AppLocal.getIntString("label.status"), Datas.STRING, Formats.STRING) + + ); + Table table = new Table( + "vouchers", + new PrimaryKey("ID"), + new Column("VOUCHER_NUMBER"), + new Column("CUSTOMER"), + new Column("AMOUNT"), + new Column("STATUS")); + lpr = row.getListProvider(app.getSession(), table); + spr = row.getSaveProvider(app.getSession(), table); + + editor = new VoucherEditor(dirty,app); + } + + + @Override + public EditorRecord getEditor() { + return editor; + } + + @Override + public String getTitle() { + return AppLocal.getIntString("Menu.Vouchers"); + } +} diff --git a/src/main/java/net/proteanit/sql/DbUtils.java b/src/main/java/net/proteanit/sql/DbUtils.java new file mode 100644 index 0000000..d373b30 --- /dev/null +++ b/src/main/java/net/proteanit/sql/DbUtils.java @@ -0,0 +1,55 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package net.proteanit.sql; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.util.Vector; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; + +/** + * + * @author JG uniCenta + */ +public class DbUtils { + + /** + * + * @param rs + * @return + */ + public static TableModel resultSetToTableModel(ResultSet rs) { + try { + ResultSetMetaData metaData = rs.getMetaData(); + int numberOfColumns = metaData.getColumnCount(); + Vector columnNames = new Vector(); + + // Get the column names + for (int column = 0; column < numberOfColumns; column++) { + columnNames.addElement(metaData.getColumnLabel(column + 1)); + } + + // Get all rows. + Vector rows = new Vector(); + + while (rs.next()) { + Vector newRow = new Vector(); + + for (int i = 1; i <= numberOfColumns; i++) { + newRow.addElement(rs.getObject(i)); + } + + rows.addElement(newRow); + } + + return new DefaultTableModel(rows, columnNames); + } catch (Exception e) { + e.printStackTrace(); + + return null; + } + } + } + diff --git a/src/main/java/org/usb4java/examples/ListDevices.java b/src/main/java/org/usb4java/examples/ListDevices.java new file mode 100644 index 0000000..68e7381 --- /dev/null +++ b/src/main/java/org/usb4java/examples/ListDevices.java @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2016 jack + * + * This program 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. + * + * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + */ +/* + * Copyright (C) 2014 Klaus Reimer <k@ailis.de> + * See LICENSE.txt for licensing information. + */ + +package org.usb4java.examples; + +import org.usb4java.Context; +import org.usb4java.Device; +import org.usb4java.DeviceDescriptor; +import org.usb4java.DeviceList; +import org.usb4java.LibUsb; +import org.usb4java.LibUsbException; + +/** + * Simply lists all available USB devices. + * + * @author Klaus Reimer <k@ailis.de> + */ +public class ListDevices +{ + /** + * Main method. + * + * @param args + * Command-line arguments (Ignored) + */ + public static void main(String[] args) + { + // Create the libusb context + Context context = new Context(); + + // Initialize the libusb context + int result = LibUsb.init(context); + if (result < 0) + { + throw new LibUsbException("Unable to initialize libusb", result); + } + + // Read the USB device list + DeviceList list = new DeviceList(); + result = LibUsb.getDeviceList(context, list); + if (result < 0) + { + throw new LibUsbException("Unable to get device list", result); + } + + try + { + // Iterate over all devices and list them + for (Device device: list) + { + int address = LibUsb.getDeviceAddress(device); + int busNumber = LibUsb.getBusNumber(device); + DeviceDescriptor descriptor = new DeviceDescriptor(); + result = LibUsb.getDeviceDescriptor(device, descriptor); + if (result < 0) + { + throw new LibUsbException( + "Unable to read device descriptor", result); + } + System.out.format( + "Bus %03d, Device %03d: Vendor %04x, Product %04x%n", + busNumber, address, descriptor.idVendor(), + descriptor.idProduct()); + } + } + finally + { + // Ensure the allocated device list is freed + LibUsb.freeDeviceList(list, true); + } + + // Deinitialize the libusb context + LibUsb.exit(context); + } +} \ No newline at end of file diff --git a/src/main/resources/beans_messages.properties b/src/main/resources/beans_messages.properties new file mode 100644 index 0000000..16480aa --- /dev/null +++ b/src/main/resources/beans_messages.properties @@ -0,0 +1,7 @@ + +button.cancel=Cancel +button.OK=OK +button.Today=Today +title.calendar=Select a Date +Button.Today=Today +button.ok=OK diff --git a/src/main/resources/beans_messages_al_SQ.properties b/src/main/resources/beans_messages_al_SQ.properties new file mode 100644 index 0000000..6c53487 --- /dev/null +++ b/src/main/resources/beans_messages_al_SQ.properties @@ -0,0 +1,19 @@ +# uniCenta oPOS -Touch Friendly Point Of Sale +# Copyright (c) 2009-2013 uniCenta & previous Openbravo POS works +# This file is part of uniCenta oPOS +# uniCenta oPOS 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. +# uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +button.cancel=Anulo +button.OK=OK +button.Today=Sot +title.calendar=Zgjidhe Daten +Button.Today=Sot diff --git a/src/main/resources/beans_messages_ar.properties b/src/main/resources/beans_messages_ar.properties new file mode 100644 index 0000000..0991376 --- /dev/null +++ b/src/main/resources/beans_messages_ar.properties @@ -0,0 +1,19 @@ +# uniCenta oPOS -Touch Friendly Point Of Sale +# Copyright (c) 2009-2010 uniCenta +# This file is part of uniCenta oPOS +# uniCenta oPOS 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. +# uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +button.cancel=\u0627\u0644\u063a\u0627\u0621 \u0627\u0644\u0627\u0645\u0631 +button.OK=\u0645\u0648\u0627\u0641\u0642 +button.Today=\u0627\u0644\u064a\u0648\u0645 +title.calendar=\u062d\u062f\u062f \u0627\u0644\u064a\u0648\u0645 +button.ok=\u0645\u0648\u0627\u0641\u0642 diff --git a/src/main/resources/beans_messages_da.properties b/src/main/resources/beans_messages_da.properties new file mode 100644 index 0000000..cd7097a --- /dev/null +++ b/src/main/resources/beans_messages_da.properties @@ -0,0 +1,23 @@ +# uniCenta oPOS - Touch Friendly Point Of Sale +# Copyright (c) 2009-2016 uniCenta +# https://unicenta.com +# This file is part of uniCenta oPOS. +# uniCenta oPOS 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. +# uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +# +# Translation kindly done by Jess Larsen 2016 + +button.cancel=Annuller +button.OK=OK +button.Today=I dag +title.calendar=V\u00e6lg en dato +Button.Today=I dag +button.ok=OK diff --git a/src/main/resources/beans_messages_de.properties b/src/main/resources/beans_messages_de.properties new file mode 100644 index 0000000..e8b9935 --- /dev/null +++ b/src/main/resources/beans_messages_de.properties @@ -0,0 +1,27 @@ +# Openbravo POS is a point of sales application designed for touch screens. +# Copyright (C) 2008 Openbravo, S.L. +# http://sourceforge.net/projects/ +# +# This program 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 2 of the License, or +# (at your option) any later version. +# +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Translations by Sebastian Muszytowski S.Muszytowski@googlemail.com +Button.Today=Heute + +button.ok=Ok + +button.cancel=Abbrechen + +title.calendar=W\u00e4hle einen Datum +button.Today=Heute diff --git a/src/main/resources/beans_messages_el.properties b/src/main/resources/beans_messages_el.properties new file mode 100644 index 0000000..3c58047 --- /dev/null +++ b/src/main/resources/beans_messages_el.properties @@ -0,0 +1,19 @@ +# uniCenta oPOS -Touch Friendly Point Of Sale +# Copyright (c) 2009-2012 uniCenta +# This file is part of uniCenta oPOS +# uniCenta oPOS 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. +# uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +button.cancel=\u0391\u039a\u03a5\u03a1\u039f +button.ok=\u0395\u039d\u03a4\u0391\u039e\u0395\u0399 +button.Today=\u03a3\u03ae\u03bc\u03b5\u03c1\u03b1 +title.calendar=\u0395\u03c0\u03b9\u03bb\u03ad\u03be\u03c4\u03b5 \u0397\u03bc\u03b5\u03c1\u03bf\u03bc\u03b7\u03bd\u03af\u03b1 +Button.Today=\u03a3\u03ae\u03bc\u03b5\u03c1\u03b1 \ No newline at end of file diff --git a/src/main/resources/beans_messages_en_US.properties b/src/main/resources/beans_messages_en_US.properties new file mode 100644 index 0000000..2dcacee --- /dev/null +++ b/src/main/resources/beans_messages_en_US.properties @@ -0,0 +1,20 @@ +# uniCenta oPOS -Touch Friendly Point Of Sale +# Copyright (c) 2009-2012 uniCenta +# This file is part of uniCenta oPOS +# uniCenta oPOS 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. +# uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +button.cancel=Cancel +button.OK=OK +button.Today=Today +title.calendar=Select a Date +Button.Today=Today +button.ok=OK diff --git a/src/main/resources/beans_messages_es.properties b/src/main/resources/beans_messages_es.properties new file mode 100644 index 0000000..4de8e39 --- /dev/null +++ b/src/main/resources/beans_messages_es.properties @@ -0,0 +1,20 @@ +# uniCenta oPOS -Touch Friendly Point Of Sale +# Copyright (c) 2009-2013 uniCenta & previous Openbravo POS works +# This file is part of uniCenta oPOS +# uniCenta oPOS 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. +# uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +title.calendar=Seleccione una fecha +button.cancel=Cancelar +Button.Today=Hoy +button.OK=Aceptar +button.Today=Hoy +button.ok=Aceptar diff --git a/src/main/resources/beans_messages_es_AR.properties b/src/main/resources/beans_messages_es_AR.properties new file mode 100644 index 0000000..3a2d915 --- /dev/null +++ b/src/main/resources/beans_messages_es_AR.properties @@ -0,0 +1,27 @@ +# Openbravo POS is a point of sales application designed for touch screens. +# Copyright (C) 2007-2009 Openbravo, S.L. +# http://sourceforge.net/projects/openbravopos +# +# This file is part of Openbravo POS. +# +# Openbravo 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. +# +# Openbravo 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 Openbravo POS. If not, see <http://www.gnu.org/licenses/>. + +Button.Today=Hoy + +button.OK=Aceptar + +button.cancel=Cancelar + +title.calendar=Seleccione una fecha +button.ok=Aceptar diff --git a/src/main/resources/beans_messages_es_MX.properties b/src/main/resources/beans_messages_es_MX.properties new file mode 100644 index 0000000..3679b4a --- /dev/null +++ b/src/main/resources/beans_messages_es_MX.properties @@ -0,0 +1,28 @@ +# Openbravo POS is a point of sales application designed for touch screens. +# Copyright (C) 2007-2009 Openbravo, S.L. +# http://sourceforge.net/projects/openbravopos +# +# Author: Juan Carlos Gast\u00e9lum +# Translation derived from Spanish Translation by Adrian Romero. +# +# This program 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. +# +# This program 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 Openbravo POS. If not, see <http://www.gnu.org/licenses/>. + +Button.Today=Hoy + +button.OK=Aceptar + +button.cancel=Cancelar + +title.calendar=Seleccione una fecha +button.ok=Aceptar diff --git a/src/main/resources/beans_messages_et.properties b/src/main/resources/beans_messages_et.properties new file mode 100644 index 0000000..971dea8 --- /dev/null +++ b/src/main/resources/beans_messages_et.properties @@ -0,0 +1,20 @@ +# uniCenta oPOS -Touch Friendly Point Of Sale +# Copyright (c) 2009-2010 uniCenta +# This file is part of uniCenta oPOS +# uniCenta oPOS 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. +# uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +button.cancel=T\u00fchista +button.OK=OK +button.Today=N\u00fc\u00fcd! +title.calendar=Vali kuup\u00e4ev +Button.Today=N\u00fc\u00fcd! +button.ok=OK diff --git a/src/main/resources/beans_messages_fr.properties b/src/main/resources/beans_messages_fr.properties new file mode 100644 index 0000000..d32b27c --- /dev/null +++ b/src/main/resources/beans_messages_fr.properties @@ -0,0 +1,28 @@ +# Openbravo POS is a point of sales application designed for touch screens. +# Copyright (C) 2007-2009 Openbravo, S.L. +# http://sourceforge.net/projects/openbravopos +# +# This file is part of Openbravo POS. +# +# Openbravo 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. +# +# Openbravo 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 Openbravo POS. If not, see <http://www.gnu.org/licenses/>. + +Button.Today=Aujourd'hui + +button.OK=OK +button.ok=OK + +button.cancel=Annuler + +title.calendar=Choisir une date +button.Today=Aujourd'hui diff --git a/src/main/resources/beans_messages_hr.properties b/src/main/resources/beans_messages_hr.properties new file mode 100644 index 0000000..8d9dc6d --- /dev/null +++ b/src/main/resources/beans_messages_hr.properties @@ -0,0 +1,29 @@ +# Openbravo POS je PC kasa koja ima podr\u0161ku i za touch screen monitore. +# Copyright (C) 2007-2009 Openbravo, S.L. +# http://sourceforge.net/projects/openbravopos +# +# Preveo na hrvatski: Pro-Sistemi <http://www.pro-sistemi.com/> +# +# Ova datoteka je dio Openbravo POS sistema. +# +# Openbravo POS je besplatan software: mo\u017eete ga distribuirati i/ili +# modificirati pod uvjetima GNU General Public Licence koja je objavljena +# od strane Free Software Foundation, bilo licencne verzije 3, ili bilo +# koje kasnije verzije ( mo\u017eda u Va\u0161em slu\u010daju ). +# +# Openbravo POS se distribuira u nadi da \u0107e biti od koristi, ali +# BEZ IKAKVE GARANCIJE; \u010dak i ako je slu\u010daj da je KUPLJEN kao roba ili +# je PREPRAVLJEN radi specifi\u010dnih potreba. Pogledajte +# GNU General Public Licencu za vi\u0161e detalja o tome. +# +# Uz Openbravo POS ste trebali dobiti kopiju GNU General Public Licence. +# Ako niste, pogledajte je na <http://www.gnu.org/licenses/>. + +Button.Today=Danas + +button.OK=U redu + +button.cancel=Odustani + +title.calendar=Izaberi datum i vrijeme +button.Today=Danas diff --git a/src/main/resources/beans_messages_it.properties b/src/main/resources/beans_messages_it.properties new file mode 100644 index 0000000..fe069f3 --- /dev/null +++ b/src/main/resources/beans_messages_it.properties @@ -0,0 +1,19 @@ +# uniCenta oPOS -Touch Friendly Point Of Sale +# Copyright (c) 2009-2013 uniCenta & previous Openbravo POS works +# This file is part of uniCenta oPOS +# uniCenta oPOS 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. +# uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +button.cancel=Annulla +button.ok=OK +button.Today=Oggi +title.calendar=Seleziona una Data +Button.Today=Oggi diff --git a/src/main/resources/beans_messages_nl.properties b/src/main/resources/beans_messages_nl.properties new file mode 100644 index 0000000..bf76b0c --- /dev/null +++ b/src/main/resources/beans_messages_nl.properties @@ -0,0 +1,6 @@ +button.cancel=Annuleer +button.OK=OK +button.Today=Vandaag +title.calendar=Kies een datum +Button.Today=Vandaag +button.ok=OK diff --git a/src/main/resources/beans_messages_pt.properties b/src/main/resources/beans_messages_pt.properties new file mode 100644 index 0000000..3ba0454 --- /dev/null +++ b/src/main/resources/beans_messages_pt.properties @@ -0,0 +1,20 @@ +# uniCenta oPOS -Touch Friendly Point Of Sale +# Copyright (c) 2009-2012 uniCenta +# This file is part of uniCenta oPOS +# uniCenta oPOS 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. +# uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +Button.Today=Hoje +button.OK=Aceitar +button.cancel=Cancelar +title.calendar=Selecione uma data +button.Today=Hoje +button.ok=Aceitar diff --git a/src/main/resources/beans_messages_pt_BR.properties b/src/main/resources/beans_messages_pt_BR.properties new file mode 100644 index 0000000..5efa791 --- /dev/null +++ b/src/main/resources/beans_messages_pt_BR.properties @@ -0,0 +1,20 @@ +# uniCenta oPOS -Touch Friendly Point Of Sale +# Copyright (c) 2009-2012 uniCenta +# This file is part of uniCenta oPOS +# uniCenta oPOS 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. +# uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +Button.Today=Hoje +button.OK=OK +button.cancel=Cancelar +title.calendar=Selecione uma data +button.Today=Hoje +button.ok=OK diff --git a/src/main/resources/com/unicenta/images/.01.png b/src/main/resources/com/unicenta/images/.01.png new file mode 100644 index 0000000..66ea00f Binary files /dev/null and b/src/main/resources/com/unicenta/images/.01.png differ diff --git a/src/main/resources/com/unicenta/images/.02.png b/src/main/resources/com/unicenta/images/.02.png new file mode 100644 index 0000000..a2c1008 Binary files /dev/null and b/src/main/resources/com/unicenta/images/.02.png differ diff --git a/src/main/resources/com/unicenta/images/.05.png b/src/main/resources/com/unicenta/images/.05.png new file mode 100644 index 0000000..0aed539 Binary files /dev/null and b/src/main/resources/com/unicenta/images/.05.png differ diff --git a/src/main/resources/com/unicenta/images/.10.png b/src/main/resources/com/unicenta/images/.10.png new file mode 100644 index 0000000..6715d75 Binary files /dev/null and b/src/main/resources/com/unicenta/images/.10.png differ diff --git a/src/main/resources/com/unicenta/images/.20.png b/src/main/resources/com/unicenta/images/.20.png new file mode 100644 index 0000000..79134cf Binary files /dev/null and b/src/main/resources/com/unicenta/images/.20.png differ diff --git a/src/main/resources/com/unicenta/images/.25.png b/src/main/resources/com/unicenta/images/.25.png new file mode 100644 index 0000000..f8ead91 Binary files /dev/null and b/src/main/resources/com/unicenta/images/.25.png differ diff --git a/src/main/resources/com/unicenta/images/.50.png b/src/main/resources/com/unicenta/images/.50.png new file mode 100644 index 0000000..fd72742 Binary files /dev/null and b/src/main/resources/com/unicenta/images/.50.png differ diff --git a/src/main/resources/com/unicenta/images/1.00.png b/src/main/resources/com/unicenta/images/1.00.png new file mode 100644 index 0000000..f8db435 Binary files /dev/null and b/src/main/resources/com/unicenta/images/1.00.png differ diff --git a/src/main/resources/com/unicenta/images/10.00.png b/src/main/resources/com/unicenta/images/10.00.png new file mode 100644 index 0000000..afb27f2 Binary files /dev/null and b/src/main/resources/com/unicenta/images/10.00.png differ diff --git a/src/main/resources/com/unicenta/images/100.00.png b/src/main/resources/com/unicenta/images/100.00.png new file mode 100644 index 0000000..0bad2db Binary files /dev/null and b/src/main/resources/com/unicenta/images/100.00.png differ diff --git a/src/main/resources/com/unicenta/images/1000.00.png b/src/main/resources/com/unicenta/images/1000.00.png new file mode 100644 index 0000000..e462a6e Binary files /dev/null and b/src/main/resources/com/unicenta/images/1000.00.png differ diff --git a/src/main/resources/com/unicenta/images/1downarrow.png b/src/main/resources/com/unicenta/images/1downarrow.png new file mode 100644 index 0000000..be595bb Binary files /dev/null and b/src/main/resources/com/unicenta/images/1downarrow.png differ diff --git a/src/main/resources/com/unicenta/images/1leftarrow.png b/src/main/resources/com/unicenta/images/1leftarrow.png new file mode 100644 index 0000000..be39dab Binary files /dev/null and b/src/main/resources/com/unicenta/images/1leftarrow.png differ diff --git a/src/main/resources/com/unicenta/images/1rightarrow.png b/src/main/resources/com/unicenta/images/1rightarrow.png new file mode 100644 index 0000000..6896b3f Binary files /dev/null and b/src/main/resources/com/unicenta/images/1rightarrow.png differ diff --git a/src/main/resources/com/unicenta/images/1uparrow.png b/src/main/resources/com/unicenta/images/1uparrow.png new file mode 100644 index 0000000..c925aad Binary files /dev/null and b/src/main/resources/com/unicenta/images/1uparrow.png differ diff --git a/src/main/resources/com/unicenta/images/2.00.png b/src/main/resources/com/unicenta/images/2.00.png new file mode 100644 index 0000000..0949cd6 Binary files /dev/null and b/src/main/resources/com/unicenta/images/2.00.png differ diff --git a/src/main/resources/com/unicenta/images/20.00.png b/src/main/resources/com/unicenta/images/20.00.png new file mode 100644 index 0000000..1b57579 Binary files /dev/null and b/src/main/resources/com/unicenta/images/20.00.png differ diff --git a/src/main/resources/com/unicenta/images/200.00.png b/src/main/resources/com/unicenta/images/200.00.png new file mode 100644 index 0000000..04a64ea Binary files /dev/null and b/src/main/resources/com/unicenta/images/200.00.png differ diff --git a/src/main/resources/com/unicenta/images/2downarrow.png b/src/main/resources/com/unicenta/images/2downarrow.png new file mode 100644 index 0000000..4d615c2 Binary files /dev/null and b/src/main/resources/com/unicenta/images/2downarrow.png differ diff --git a/src/main/resources/com/unicenta/images/2leftarrow.png b/src/main/resources/com/unicenta/images/2leftarrow.png new file mode 100644 index 0000000..2ed8968 Binary files /dev/null and b/src/main/resources/com/unicenta/images/2leftarrow.png differ diff --git a/src/main/resources/com/unicenta/images/2rightarrow.png b/src/main/resources/com/unicenta/images/2rightarrow.png new file mode 100644 index 0000000..8657601 Binary files /dev/null and b/src/main/resources/com/unicenta/images/2rightarrow.png differ diff --git a/src/main/resources/com/unicenta/images/2uparrow.png b/src/main/resources/com/unicenta/images/2uparrow.png new file mode 100644 index 0000000..2690aa2 Binary files /dev/null and b/src/main/resources/com/unicenta/images/2uparrow.png differ diff --git a/src/main/resources/com/unicenta/images/5.00.png b/src/main/resources/com/unicenta/images/5.00.png new file mode 100644 index 0000000..d71e711 Binary files /dev/null and b/src/main/resources/com/unicenta/images/5.00.png differ diff --git a/src/main/resources/com/unicenta/images/50.00.png b/src/main/resources/com/unicenta/images/50.00.png new file mode 100644 index 0000000..1d53b25 Binary files /dev/null and b/src/main/resources/com/unicenta/images/50.00.png differ diff --git a/src/main/resources/com/unicenta/images/500.00.png b/src/main/resources/com/unicenta/images/500.00.png new file mode 100644 index 0000000..2592e87 Binary files /dev/null and b/src/main/resources/com/unicenta/images/500.00.png differ diff --git a/src/main/resources/com/unicenta/images/ark2.png b/src/main/resources/com/unicenta/images/ark2.png new file mode 100644 index 0000000..159b05b Binary files /dev/null and b/src/main/resources/com/unicenta/images/ark2.png differ diff --git a/src/main/resources/com/unicenta/images/attributes.png b/src/main/resources/com/unicenta/images/attributes.png new file mode 100644 index 0000000..09ccae8 Binary files /dev/null and b/src/main/resources/com/unicenta/images/attributes.png differ diff --git a/src/main/resources/com/unicenta/images/auxiliary.png b/src/main/resources/com/unicenta/images/auxiliary.png new file mode 100644 index 0000000..f744096 Binary files /dev/null and b/src/main/resources/com/unicenta/images/auxiliary.png differ diff --git a/src/main/resources/com/unicenta/images/bank.png b/src/main/resources/com/unicenta/images/bank.png new file mode 100644 index 0000000..ad2f26c Binary files /dev/null and b/src/main/resources/com/unicenta/images/bank.png differ diff --git a/src/main/resources/com/unicenta/images/barcode.png b/src/main/resources/com/unicenta/images/barcode.png new file mode 100644 index 0000000..8d76ccf Binary files /dev/null and b/src/main/resources/com/unicenta/images/barcode.png differ diff --git a/src/main/resources/com/unicenta/images/bookmark.png b/src/main/resources/com/unicenta/images/bookmark.png new file mode 100644 index 0000000..5e8222e Binary files /dev/null and b/src/main/resources/com/unicenta/images/bookmark.png differ diff --git a/src/main/resources/com/unicenta/images/btn0.png b/src/main/resources/com/unicenta/images/btn0.png new file mode 100644 index 0000000..05566c6 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn0.png differ diff --git a/src/main/resources/com/unicenta/images/btn00.png b/src/main/resources/com/unicenta/images/btn00.png new file mode 100644 index 0000000..aa10ec5 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn00.png differ diff --git a/src/main/resources/com/unicenta/images/btn1.png b/src/main/resources/com/unicenta/images/btn1.png new file mode 100644 index 0000000..80af89b Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn1.png differ diff --git a/src/main/resources/com/unicenta/images/btn2.png b/src/main/resources/com/unicenta/images/btn2.png new file mode 100644 index 0000000..2f79ea7 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn2.png differ diff --git a/src/main/resources/com/unicenta/images/btn2a.png b/src/main/resources/com/unicenta/images/btn2a.png new file mode 100644 index 0000000..f72d6c9 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn2a.png differ diff --git a/src/main/resources/com/unicenta/images/btn3.png b/src/main/resources/com/unicenta/images/btn3.png new file mode 100644 index 0000000..537bf6c Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn3.png differ diff --git a/src/main/resources/com/unicenta/images/btn3a.png b/src/main/resources/com/unicenta/images/btn3a.png new file mode 100644 index 0000000..c2740eb Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn3a.png differ diff --git a/src/main/resources/com/unicenta/images/btn4.png b/src/main/resources/com/unicenta/images/btn4.png new file mode 100644 index 0000000..710c162 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn4.png differ diff --git a/src/main/resources/com/unicenta/images/btn4a.png b/src/main/resources/com/unicenta/images/btn4a.png new file mode 100644 index 0000000..b87c531 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn4a.png differ diff --git a/src/main/resources/com/unicenta/images/btn5.png b/src/main/resources/com/unicenta/images/btn5.png new file mode 100644 index 0000000..7645163 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn5.png differ diff --git a/src/main/resources/com/unicenta/images/btn5a.png b/src/main/resources/com/unicenta/images/btn5a.png new file mode 100644 index 0000000..60c0625 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn5a.png differ diff --git a/src/main/resources/com/unicenta/images/btn6.png b/src/main/resources/com/unicenta/images/btn6.png new file mode 100644 index 0000000..125d16f Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn6.png differ diff --git a/src/main/resources/com/unicenta/images/btn6a.png b/src/main/resources/com/unicenta/images/btn6a.png new file mode 100644 index 0000000..2aafde2 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn6a.png differ diff --git a/src/main/resources/com/unicenta/images/btn7.png b/src/main/resources/com/unicenta/images/btn7.png new file mode 100644 index 0000000..2ccde08 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn7.png differ diff --git a/src/main/resources/com/unicenta/images/btn7a.png b/src/main/resources/com/unicenta/images/btn7a.png new file mode 100644 index 0000000..062ee2b Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn7a.png differ diff --git a/src/main/resources/com/unicenta/images/btn8.png b/src/main/resources/com/unicenta/images/btn8.png new file mode 100644 index 0000000..0c54cf4 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn8.png differ diff --git a/src/main/resources/com/unicenta/images/btn8a.png b/src/main/resources/com/unicenta/images/btn8a.png new file mode 100644 index 0000000..22065f9 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn8a.png differ diff --git a/src/main/resources/com/unicenta/images/btn9.png b/src/main/resources/com/unicenta/images/btn9.png new file mode 100644 index 0000000..c2b7b55 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn9.png differ diff --git a/src/main/resources/com/unicenta/images/btn9a.png b/src/main/resources/com/unicenta/images/btn9a.png new file mode 100644 index 0000000..5cbea83 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btn9a.png differ diff --git a/src/main/resources/com/unicenta/images/btnback.png b/src/main/resources/com/unicenta/images/btnback.png new file mode 100644 index 0000000..601cc3f Binary files /dev/null and b/src/main/resources/com/unicenta/images/btnback.png differ diff --git a/src/main/resources/com/unicenta/images/btnce.png b/src/main/resources/com/unicenta/images/btnce.png new file mode 100644 index 0000000..4331ec1 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btnce.png differ diff --git a/src/main/resources/com/unicenta/images/btndiv.png b/src/main/resources/com/unicenta/images/btndiv.png new file mode 100644 index 0000000..a992455 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btndiv.png differ diff --git a/src/main/resources/com/unicenta/images/btndot.png b/src/main/resources/com/unicenta/images/btndot.png new file mode 100644 index 0000000..78b00c5 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btndot.png differ diff --git a/src/main/resources/com/unicenta/images/btnequals.png b/src/main/resources/com/unicenta/images/btnequals.png new file mode 100644 index 0000000..d528e42 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btnequals.png differ diff --git a/src/main/resources/com/unicenta/images/btnminus.png b/src/main/resources/com/unicenta/images/btnminus.png new file mode 100644 index 0000000..9ce3c83 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btnminus.png differ diff --git a/src/main/resources/com/unicenta/images/btnmult.png b/src/main/resources/com/unicenta/images/btnmult.png new file mode 100644 index 0000000..1381680 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btnmult.png differ diff --git a/src/main/resources/com/unicenta/images/btnplus.png b/src/main/resources/com/unicenta/images/btnplus.png new file mode 100644 index 0000000..84f0170 Binary files /dev/null and b/src/main/resources/com/unicenta/images/btnplus.png differ diff --git a/src/main/resources/com/unicenta/images/bundle.png b/src/main/resources/com/unicenta/images/bundle.png new file mode 100644 index 0000000..5547876 Binary files /dev/null and b/src/main/resources/com/unicenta/images/bundle.png differ diff --git a/src/main/resources/com/unicenta/images/calculator.png b/src/main/resources/com/unicenta/images/calculator.png new file mode 100644 index 0000000..c5e154a Binary files /dev/null and b/src/main/resources/com/unicenta/images/calculator.png differ diff --git a/src/main/resources/com/unicenta/images/camera.png b/src/main/resources/com/unicenta/images/camera.png new file mode 100644 index 0000000..dc93e8e Binary files /dev/null and b/src/main/resources/com/unicenta/images/camera.png differ diff --git a/src/main/resources/com/unicenta/images/cancel.png b/src/main/resources/com/unicenta/images/cancel.png new file mode 100644 index 0000000..3a282a7 Binary files /dev/null and b/src/main/resources/com/unicenta/images/cancel.png differ diff --git a/src/main/resources/com/unicenta/images/cash.png b/src/main/resources/com/unicenta/images/cash.png new file mode 100644 index 0000000..0136cd5 Binary files /dev/null and b/src/main/resources/com/unicenta/images/cash.png differ diff --git a/src/main/resources/com/unicenta/images/cashdrawer.png b/src/main/resources/com/unicenta/images/cashdrawer.png new file mode 100644 index 0000000..3f1c43e Binary files /dev/null and b/src/main/resources/com/unicenta/images/cashdrawer.png differ diff --git a/src/main/resources/com/unicenta/images/category.png b/src/main/resources/com/unicenta/images/category.png new file mode 100644 index 0000000..8f6f8a8 Binary files /dev/null and b/src/main/resources/com/unicenta/images/category.png differ diff --git a/src/main/resources/com/unicenta/images/ccard.png b/src/main/resources/com/unicenta/images/ccard.png new file mode 100644 index 0000000..16348e5 Binary files /dev/null and b/src/main/resources/com/unicenta/images/ccard.png differ diff --git a/src/main/resources/com/unicenta/images/chart.png b/src/main/resources/com/unicenta/images/chart.png new file mode 100644 index 0000000..7e3ed86 Binary files /dev/null and b/src/main/resources/com/unicenta/images/chart.png differ diff --git a/src/main/resources/com/unicenta/images/cheque.png b/src/main/resources/com/unicenta/images/cheque.png new file mode 100644 index 0000000..1967a79 Binary files /dev/null and b/src/main/resources/com/unicenta/images/cheque.png differ diff --git a/src/main/resources/com/unicenta/images/coffee.png b/src/main/resources/com/unicenta/images/coffee.png new file mode 100644 index 0000000..2951c8b Binary files /dev/null and b/src/main/resources/com/unicenta/images/coffee.png differ diff --git a/src/main/resources/com/unicenta/images/configuration.png b/src/main/resources/com/unicenta/images/configuration.png new file mode 100644 index 0000000..144fb58 Binary files /dev/null and b/src/main/resources/com/unicenta/images/configuration.png differ diff --git a/src/main/resources/com/unicenta/images/customer.png b/src/main/resources/com/unicenta/images/customer.png new file mode 100644 index 0000000..29c318c Binary files /dev/null and b/src/main/resources/com/unicenta/images/customer.png differ diff --git a/src/main/resources/com/unicenta/images/customer_add_sml.png b/src/main/resources/com/unicenta/images/customer_add_sml.png new file mode 100644 index 0000000..5ef52c8 Binary files /dev/null and b/src/main/resources/com/unicenta/images/customer_add_sml.png differ diff --git a/src/main/resources/com/unicenta/images/customer_sml.png b/src/main/resources/com/unicenta/images/customer_sml.png new file mode 100644 index 0000000..7dcb34d Binary files /dev/null and b/src/main/resources/com/unicenta/images/customer_sml.png differ diff --git a/src/main/resources/com/unicenta/images/customerpay.png b/src/main/resources/com/unicenta/images/customerpay.png new file mode 100644 index 0000000..e078303 Binary files /dev/null and b/src/main/resources/com/unicenta/images/customerpay.png differ diff --git a/src/main/resources/com/unicenta/images/database.png b/src/main/resources/com/unicenta/images/database.png new file mode 100644 index 0000000..7996410 Binary files /dev/null and b/src/main/resources/com/unicenta/images/database.png differ diff --git a/src/main/resources/com/unicenta/images/date.png b/src/main/resources/com/unicenta/images/date.png new file mode 100644 index 0000000..624b3ca Binary files /dev/null and b/src/main/resources/com/unicenta/images/date.png differ diff --git a/src/main/resources/com/unicenta/images/discount.png b/src/main/resources/com/unicenta/images/discount.png new file mode 100644 index 0000000..00b55c9 Binary files /dev/null and b/src/main/resources/com/unicenta/images/discount.png differ diff --git a/src/main/resources/com/unicenta/images/discount_b.png b/src/main/resources/com/unicenta/images/discount_b.png new file mode 100644 index 0000000..ae5ad48 Binary files /dev/null and b/src/main/resources/com/unicenta/images/discount_b.png differ diff --git a/src/main/resources/com/unicenta/images/display.png b/src/main/resources/com/unicenta/images/display.png new file mode 100644 index 0000000..4a9ed1e Binary files /dev/null and b/src/main/resources/com/unicenta/images/display.png differ diff --git a/src/main/resources/com/unicenta/images/edit.png b/src/main/resources/com/unicenta/images/edit.png new file mode 100644 index 0000000..90c0bf8 Binary files /dev/null and b/src/main/resources/com/unicenta/images/edit.png differ diff --git a/src/main/resources/com/unicenta/images/edit_group.png b/src/main/resources/com/unicenta/images/edit_group.png new file mode 100644 index 0000000..abd4278 Binary files /dev/null and b/src/main/resources/com/unicenta/images/edit_group.png differ diff --git a/src/main/resources/com/unicenta/images/edit_group_sm.png b/src/main/resources/com/unicenta/images/edit_group_sm.png new file mode 100644 index 0000000..bcf4ada Binary files /dev/null and b/src/main/resources/com/unicenta/images/edit_group_sm.png differ diff --git a/src/main/resources/com/unicenta/images/editdelete.png b/src/main/resources/com/unicenta/images/editdelete.png new file mode 100644 index 0000000..a0c6907 Binary files /dev/null and b/src/main/resources/com/unicenta/images/editdelete.png differ diff --git a/src/main/resources/com/unicenta/images/editnew.png b/src/main/resources/com/unicenta/images/editnew.png new file mode 100644 index 0000000..7547acf Binary files /dev/null and b/src/main/resources/com/unicenta/images/editnew.png differ diff --git a/src/main/resources/com/unicenta/images/empty.png b/src/main/resources/com/unicenta/images/empty.png new file mode 100644 index 0000000..3c076d6 Binary files /dev/null and b/src/main/resources/com/unicenta/images/empty.png differ diff --git a/src/main/resources/com/unicenta/images/encrypted.png b/src/main/resources/com/unicenta/images/encrypted.png new file mode 100644 index 0000000..4ac0119 Binary files /dev/null and b/src/main/resources/com/unicenta/images/encrypted.png differ diff --git a/src/main/resources/com/unicenta/images/exit.png b/src/main/resources/com/unicenta/images/exit.png new file mode 100644 index 0000000..1c7d8fb Binary files /dev/null and b/src/main/resources/com/unicenta/images/exit.png differ diff --git a/src/main/resources/com/unicenta/images/favicon.png b/src/main/resources/com/unicenta/images/favicon.png new file mode 100644 index 0000000..c59bdd5 Binary files /dev/null and b/src/main/resources/com/unicenta/images/favicon.png differ diff --git a/src/main/resources/com/unicenta/images/fileclose.png b/src/main/resources/com/unicenta/images/fileclose.png new file mode 100644 index 0000000..65d4e23 Binary files /dev/null and b/src/main/resources/com/unicenta/images/fileclose.png differ diff --git a/src/main/resources/com/unicenta/images/fileopen.png b/src/main/resources/com/unicenta/images/fileopen.png new file mode 100644 index 0000000..e307360 Binary files /dev/null and b/src/main/resources/com/unicenta/images/fileopen.png differ diff --git a/src/main/resources/com/unicenta/images/filesave.png b/src/main/resources/com/unicenta/images/filesave.png new file mode 100644 index 0000000..47a4864 Binary files /dev/null and b/src/main/resources/com/unicenta/images/filesave.png differ diff --git a/src/main/resources/com/unicenta/images/floors.png b/src/main/resources/com/unicenta/images/floors.png new file mode 100644 index 0000000..8ac4e90 Binary files /dev/null and b/src/main/resources/com/unicenta/images/floors.png differ diff --git a/src/main/resources/com/unicenta/images/gohome.png b/src/main/resources/com/unicenta/images/gohome.png new file mode 100644 index 0000000..a179790 Binary files /dev/null and b/src/main/resources/com/unicenta/images/gohome.png differ diff --git a/src/main/resources/com/unicenta/images/heart.png b/src/main/resources/com/unicenta/images/heart.png new file mode 100644 index 0000000..e9d841d Binary files /dev/null and b/src/main/resources/com/unicenta/images/heart.png differ diff --git a/src/main/resources/com/unicenta/images/img.discount.png b/src/main/resources/com/unicenta/images/img.discount.png new file mode 100644 index 0000000..00b55c9 Binary files /dev/null and b/src/main/resources/com/unicenta/images/img.discount.png differ diff --git a/src/main/resources/com/unicenta/images/img.discount_b.png b/src/main/resources/com/unicenta/images/img.discount_b.png new file mode 100644 index 0000000..ae5ad48 Binary files /dev/null and b/src/main/resources/com/unicenta/images/img.discount_b.png differ diff --git a/src/main/resources/com/unicenta/images/img.keyboard_32.png b/src/main/resources/com/unicenta/images/img.keyboard_32.png new file mode 100644 index 0000000..6a0ef7b Binary files /dev/null and b/src/main/resources/com/unicenta/images/img.keyboard_32.png differ diff --git a/src/main/resources/com/unicenta/images/img.ticket_print.png b/src/main/resources/com/unicenta/images/img.ticket_print.png new file mode 100644 index 0000000..5b28b70 Binary files /dev/null and b/src/main/resources/com/unicenta/images/img.ticket_print.png differ diff --git a/src/main/resources/com/unicenta/images/import.png b/src/main/resources/com/unicenta/images/import.png new file mode 100644 index 0000000..a3ed6dc Binary files /dev/null and b/src/main/resources/com/unicenta/images/import.png differ diff --git a/src/main/resources/com/unicenta/images/inbox.png b/src/main/resources/com/unicenta/images/inbox.png new file mode 100644 index 0000000..3f882e7 Binary files /dev/null and b/src/main/resources/com/unicenta/images/inbox.png differ diff --git a/src/main/resources/com/unicenta/images/info.png b/src/main/resources/com/unicenta/images/info.png new file mode 100644 index 0000000..2c33db0 Binary files /dev/null and b/src/main/resources/com/unicenta/images/info.png differ diff --git a/src/main/resources/com/unicenta/images/keyboard_32.png b/src/main/resources/com/unicenta/images/keyboard_32.png new file mode 100644 index 0000000..6a0ef7b Binary files /dev/null and b/src/main/resources/com/unicenta/images/keyboard_32.png differ diff --git a/src/main/resources/com/unicenta/images/keyboard_48.png b/src/main/resources/com/unicenta/images/keyboard_48.png new file mode 100644 index 0000000..8e32e36 Binary files /dev/null and b/src/main/resources/com/unicenta/images/keyboard_48.png differ diff --git a/src/main/resources/com/unicenta/images/kit_print.png b/src/main/resources/com/unicenta/images/kit_print.png new file mode 100644 index 0000000..bf41ce5 Binary files /dev/null and b/src/main/resources/com/unicenta/images/kit_print.png differ diff --git a/src/main/resources/com/unicenta/images/leaves.png b/src/main/resources/com/unicenta/images/leaves.png new file mode 100644 index 0000000..ba3eefa Binary files /dev/null and b/src/main/resources/com/unicenta/images/leaves.png differ diff --git a/src/main/resources/com/unicenta/images/location.png b/src/main/resources/com/unicenta/images/location.png new file mode 100644 index 0000000..cf0714a Binary files /dev/null and b/src/main/resources/com/unicenta/images/location.png differ diff --git a/src/main/resources/com/unicenta/images/logo.png b/src/main/resources/com/unicenta/images/logo.png new file mode 100644 index 0000000..acc2d2e Binary files /dev/null and b/src/main/resources/com/unicenta/images/logo.png differ diff --git a/src/main/resources/com/unicenta/images/logout.png b/src/main/resources/com/unicenta/images/logout.png new file mode 100644 index 0000000..ec87d85 Binary files /dev/null and b/src/main/resources/com/unicenta/images/logout.png differ diff --git a/src/main/resources/com/unicenta/images/mail24.png b/src/main/resources/com/unicenta/images/mail24.png new file mode 100644 index 0000000..8a48306 Binary files /dev/null and b/src/main/resources/com/unicenta/images/mail24.png differ diff --git a/src/main/resources/com/unicenta/images/maintain.png b/src/main/resources/com/unicenta/images/maintain.png new file mode 100644 index 0000000..71f72b1 Binary files /dev/null and b/src/main/resources/com/unicenta/images/maintain.png differ diff --git a/src/main/resources/com/unicenta/images/menu-left.png b/src/main/resources/com/unicenta/images/menu-left.png new file mode 100644 index 0000000..e67e315 Binary files /dev/null and b/src/main/resources/com/unicenta/images/menu-left.png differ diff --git a/src/main/resources/com/unicenta/images/menu-right.png b/src/main/resources/com/unicenta/images/menu-right.png new file mode 100644 index 0000000..b71ad6f Binary files /dev/null and b/src/main/resources/com/unicenta/images/menu-right.png differ diff --git a/src/main/resources/com/unicenta/images/mime.png b/src/main/resources/com/unicenta/images/mime.png new file mode 100644 index 0000000..7101838 Binary files /dev/null and b/src/main/resources/com/unicenta/images/mime.png differ diff --git a/src/main/resources/com/unicenta/images/mime2.png b/src/main/resources/com/unicenta/images/mime2.png new file mode 100644 index 0000000..7f633a5 Binary files /dev/null and b/src/main/resources/com/unicenta/images/mime2.png differ diff --git a/src/main/resources/com/unicenta/images/mime3.png b/src/main/resources/com/unicenta/images/mime3.png new file mode 100644 index 0000000..182fa01 Binary files /dev/null and b/src/main/resources/com/unicenta/images/mime3.png differ diff --git a/src/main/resources/com/unicenta/images/movetable.png b/src/main/resources/com/unicenta/images/movetable.png new file mode 100644 index 0000000..f534112 Binary files /dev/null and b/src/main/resources/com/unicenta/images/movetable.png differ diff --git a/src/main/resources/com/unicenta/images/no_photo.png b/src/main/resources/com/unicenta/images/no_photo.png new file mode 100644 index 0000000..7d07484 Binary files /dev/null and b/src/main/resources/com/unicenta/images/no_photo.png differ diff --git a/src/main/resources/com/unicenta/images/notes.png b/src/main/resources/com/unicenta/images/notes.png new file mode 100644 index 0000000..b1aa35f Binary files /dev/null and b/src/main/resources/com/unicenta/images/notes.png differ diff --git a/src/main/resources/com/unicenta/images/null.png b/src/main/resources/com/unicenta/images/null.png new file mode 100644 index 0000000..536141d Binary files /dev/null and b/src/main/resources/com/unicenta/images/null.png differ diff --git a/src/main/resources/com/unicenta/images/ok.png b/src/main/resources/com/unicenta/images/ok.png new file mode 100644 index 0000000..ee82d90 Binary files /dev/null and b/src/main/resources/com/unicenta/images/ok.png differ diff --git a/src/main/resources/com/unicenta/images/package.png b/src/main/resources/com/unicenta/images/package.png new file mode 100644 index 0000000..aecf41d Binary files /dev/null and b/src/main/resources/com/unicenta/images/package.png differ diff --git a/src/main/resources/com/unicenta/images/package_big.png b/src/main/resources/com/unicenta/images/package_big.png new file mode 100644 index 0000000..2e9dc09 Binary files /dev/null and b/src/main/resources/com/unicenta/images/package_big.png differ diff --git a/src/main/resources/com/unicenta/images/padlock_open_icon&24.pdn b/src/main/resources/com/unicenta/images/padlock_open_icon&24.pdn new file mode 100644 index 0000000..1e97af1 Binary files /dev/null and b/src/main/resources/com/unicenta/images/padlock_open_icon&24.pdn differ diff --git a/src/main/resources/com/unicenta/images/paperboard960_600.png b/src/main/resources/com/unicenta/images/paperboard960_600.png new file mode 100644 index 0000000..078336e Binary files /dev/null and b/src/main/resources/com/unicenta/images/paperboard960_600.png differ diff --git a/src/main/resources/com/unicenta/images/password.png b/src/main/resources/com/unicenta/images/password.png new file mode 100644 index 0000000..cb8e31e Binary files /dev/null and b/src/main/resources/com/unicenta/images/password.png differ diff --git a/src/main/resources/com/unicenta/images/pay.png b/src/main/resources/com/unicenta/images/pay.png new file mode 100644 index 0000000..ac9663b Binary files /dev/null and b/src/main/resources/com/unicenta/images/pay.png differ diff --git a/src/main/resources/com/unicenta/images/payments.png b/src/main/resources/com/unicenta/images/payments.png new file mode 100644 index 0000000..61de8a6 Binary files /dev/null and b/src/main/resources/com/unicenta/images/payments.png differ diff --git a/src/main/resources/com/unicenta/images/plugin.png b/src/main/resources/com/unicenta/images/plugin.png new file mode 100644 index 0000000..7def8ce Binary files /dev/null and b/src/main/resources/com/unicenta/images/plugin.png differ diff --git a/src/main/resources/com/unicenta/images/poweredby_uni.png b/src/main/resources/com/unicenta/images/poweredby_uni.png new file mode 100644 index 0000000..843579b Binary files /dev/null and b/src/main/resources/com/unicenta/images/poweredby_uni.png differ diff --git a/src/main/resources/com/unicenta/images/printer.png b/src/main/resources/com/unicenta/images/printer.png new file mode 100644 index 0000000..5b28b70 Binary files /dev/null and b/src/main/resources/com/unicenta/images/printer.png differ diff --git a/src/main/resources/com/unicenta/images/printer.ticket.logo.jpg b/src/main/resources/com/unicenta/images/printer.ticket.logo.jpg new file mode 100644 index 0000000..a632c34 Binary files /dev/null and b/src/main/resources/com/unicenta/images/printer.ticket.logo.jpg differ diff --git a/src/main/resources/com/unicenta/images/printer24.png b/src/main/resources/com/unicenta/images/printer24.png new file mode 100644 index 0000000..c1f30d9 Binary files /dev/null and b/src/main/resources/com/unicenta/images/printer24.png differ diff --git a/src/main/resources/com/unicenta/images/printer24_off.png b/src/main/resources/com/unicenta/images/printer24_off.png new file mode 100644 index 0000000..bb7de6a Binary files /dev/null and b/src/main/resources/com/unicenta/images/printer24_off.png differ diff --git a/src/main/resources/com/unicenta/images/printer24_on.png b/src/main/resources/com/unicenta/images/printer24_on.png new file mode 100644 index 0000000..5065b90 Binary files /dev/null and b/src/main/resources/com/unicenta/images/printer24_on.png differ diff --git a/src/main/resources/com/unicenta/images/products.png b/src/main/resources/com/unicenta/images/products.png new file mode 100644 index 0000000..43e1025 Binary files /dev/null and b/src/main/resources/com/unicenta/images/products.png differ diff --git a/src/main/resources/com/unicenta/images/products24.png b/src/main/resources/com/unicenta/images/products24.png new file mode 100644 index 0000000..3d3048c Binary files /dev/null and b/src/main/resources/com/unicenta/images/products24.png differ diff --git a/src/main/resources/com/unicenta/images/receive.png b/src/main/resources/com/unicenta/images/receive.png new file mode 100644 index 0000000..ecfe322 Binary files /dev/null and b/src/main/resources/com/unicenta/images/receive.png differ diff --git a/src/main/resources/com/unicenta/images/refundit.png b/src/main/resources/com/unicenta/images/refundit.png new file mode 100644 index 0000000..f94f0db Binary files /dev/null and b/src/main/resources/com/unicenta/images/refundit.png differ diff --git a/src/main/resources/com/unicenta/images/reload.png b/src/main/resources/com/unicenta/images/reload.png new file mode 100644 index 0000000..49e19e1 Binary files /dev/null and b/src/main/resources/com/unicenta/images/reload.png differ diff --git a/src/main/resources/com/unicenta/images/remote_print.png b/src/main/resources/com/unicenta/images/remote_print.png new file mode 100644 index 0000000..a3612a4 Binary files /dev/null and b/src/main/resources/com/unicenta/images/remote_print.png differ diff --git a/src/main/resources/com/unicenta/images/reports.png b/src/main/resources/com/unicenta/images/reports.png new file mode 100644 index 0000000..d6be2e8 Binary files /dev/null and b/src/main/resources/com/unicenta/images/reports.png differ diff --git a/src/main/resources/com/unicenta/images/reprint24.png b/src/main/resources/com/unicenta/images/reprint24.png new file mode 100644 index 0000000..866c68c Binary files /dev/null and b/src/main/resources/com/unicenta/images/reprint24.png differ diff --git a/src/main/resources/com/unicenta/images/resources.png b/src/main/resources/com/unicenta/images/resources.png new file mode 100644 index 0000000..af85da3 Binary files /dev/null and b/src/main/resources/com/unicenta/images/resources.png differ diff --git a/src/main/resources/com/unicenta/images/restaurant_floor.png b/src/main/resources/com/unicenta/images/restaurant_floor.png new file mode 100644 index 0000000..03e3cda Binary files /dev/null and b/src/main/resources/com/unicenta/images/restaurant_floor.png differ diff --git a/src/main/resources/com/unicenta/images/restaurant_floor_sml.png b/src/main/resources/com/unicenta/images/restaurant_floor_sml.png new file mode 100644 index 0000000..f631057 Binary files /dev/null and b/src/main/resources/com/unicenta/images/restaurant_floor_sml.png differ diff --git a/src/main/resources/com/unicenta/images/roles.png b/src/main/resources/com/unicenta/images/roles.png new file mode 100644 index 0000000..d9194e6 Binary files /dev/null and b/src/main/resources/com/unicenta/images/roles.png differ diff --git a/src/main/resources/com/unicenta/images/run_script.png b/src/main/resources/com/unicenta/images/run_script.png new file mode 100644 index 0000000..36c2e0c Binary files /dev/null and b/src/main/resources/com/unicenta/images/run_script.png differ diff --git a/src/main/resources/com/unicenta/images/sale.png b/src/main/resources/com/unicenta/images/sale.png new file mode 100644 index 0000000..85e0074 Binary files /dev/null and b/src/main/resources/com/unicenta/images/sale.png differ diff --git a/src/main/resources/com/unicenta/images/sale_delete.png b/src/main/resources/com/unicenta/images/sale_delete.png new file mode 100644 index 0000000..bafc2c9 Binary files /dev/null and b/src/main/resources/com/unicenta/images/sale_delete.png differ diff --git a/src/main/resources/com/unicenta/images/sale_editline.png b/src/main/resources/com/unicenta/images/sale_editline.png new file mode 100644 index 0000000..b74d944 Binary files /dev/null and b/src/main/resources/com/unicenta/images/sale_editline.png differ diff --git a/src/main/resources/com/unicenta/images/sale_new.png b/src/main/resources/com/unicenta/images/sale_new.png new file mode 100644 index 0000000..7545f1e Binary files /dev/null and b/src/main/resources/com/unicenta/images/sale_new.png differ diff --git a/src/main/resources/com/unicenta/images/sale_pending.png b/src/main/resources/com/unicenta/images/sale_pending.png new file mode 100644 index 0000000..277b372 Binary files /dev/null and b/src/main/resources/com/unicenta/images/sale_pending.png differ diff --git a/src/main/resources/com/unicenta/images/sale_split_sml.png b/src/main/resources/com/unicenta/images/sale_split_sml.png new file mode 100644 index 0000000..1804dc6 Binary files /dev/null and b/src/main/resources/com/unicenta/images/sale_split_sml.png differ diff --git a/src/main/resources/com/unicenta/images/saleedit.png b/src/main/resources/com/unicenta/images/saleedit.png new file mode 100644 index 0000000..80b182d Binary files /dev/null and b/src/main/resources/com/unicenta/images/saleedit.png differ diff --git a/src/main/resources/com/unicenta/images/sales.png b/src/main/resources/com/unicenta/images/sales.png new file mode 100644 index 0000000..faafa86 Binary files /dev/null and b/src/main/resources/com/unicenta/images/sales.png differ diff --git a/src/main/resources/com/unicenta/images/scale.png b/src/main/resources/com/unicenta/images/scale.png new file mode 100644 index 0000000..e5c0dc3 Binary files /dev/null and b/src/main/resources/com/unicenta/images/scale.png differ diff --git a/src/main/resources/com/unicenta/images/search24.png b/src/main/resources/com/unicenta/images/search24.png new file mode 100644 index 0000000..cb8a8aa Binary files /dev/null and b/src/main/resources/com/unicenta/images/search24.png differ diff --git a/src/main/resources/com/unicenta/images/search32.png b/src/main/resources/com/unicenta/images/search32.png new file mode 100644 index 0000000..8f098c5 Binary files /dev/null and b/src/main/resources/com/unicenta/images/search32.png differ diff --git a/src/main/resources/com/unicenta/images/slip.png b/src/main/resources/com/unicenta/images/slip.png new file mode 100644 index 0000000..ca87493 Binary files /dev/null and b/src/main/resources/com/unicenta/images/slip.png differ diff --git a/src/main/resources/com/unicenta/images/sort_incr.png b/src/main/resources/com/unicenta/images/sort_incr.png new file mode 100644 index 0000000..4595ddc Binary files /dev/null and b/src/main/resources/com/unicenta/images/sort_incr.png differ diff --git a/src/main/resources/com/unicenta/images/stockdiary.png b/src/main/resources/com/unicenta/images/stockdiary.png new file mode 100644 index 0000000..11e390e Binary files /dev/null and b/src/main/resources/com/unicenta/images/stockdiary.png differ diff --git a/src/main/resources/com/unicenta/images/stockmaint.png b/src/main/resources/com/unicenta/images/stockmaint.png new file mode 100644 index 0000000..de2374b Binary files /dev/null and b/src/main/resources/com/unicenta/images/stockmaint.png differ diff --git a/src/main/resources/com/unicenta/images/subcategory.png b/src/main/resources/com/unicenta/images/subcategory.png new file mode 100644 index 0000000..40c6219 Binary files /dev/null and b/src/main/resources/com/unicenta/images/subcategory.png differ diff --git a/src/main/resources/com/unicenta/images/supplier_sml.png b/src/main/resources/com/unicenta/images/supplier_sml.png new file mode 100644 index 0000000..7dcb34d Binary files /dev/null and b/src/main/resources/com/unicenta/images/supplier_sml.png differ diff --git a/src/main/resources/com/unicenta/images/tables.png b/src/main/resources/com/unicenta/images/tables.png new file mode 100644 index 0000000..1fbefc2 Binary files /dev/null and b/src/main/resources/com/unicenta/images/tables.png differ diff --git a/src/main/resources/com/unicenta/images/ticket_print.png b/src/main/resources/com/unicenta/images/ticket_print.png new file mode 100644 index 0000000..5b28b70 Binary files /dev/null and b/src/main/resources/com/unicenta/images/ticket_print.png differ diff --git a/src/main/resources/com/unicenta/images/timer.png b/src/main/resources/com/unicenta/images/timer.png new file mode 100644 index 0000000..7aaa1f2 Binary files /dev/null and b/src/main/resources/com/unicenta/images/timer.png differ diff --git a/src/main/resources/com/unicenta/images/uniCenta_logo_vert_100.png b/src/main/resources/com/unicenta/images/uniCenta_logo_vert_100.png new file mode 100644 index 0000000..5b0e3dd Binary files /dev/null and b/src/main/resources/com/unicenta/images/uniCenta_logo_vert_100.png differ diff --git a/src/main/resources/com/unicenta/images/uniCenta_splash_dark.png b/src/main/resources/com/unicenta/images/uniCenta_splash_dark.png new file mode 100644 index 0000000..f7557f1 Binary files /dev/null and b/src/main/resources/com/unicenta/images/uniCenta_splash_dark.png differ diff --git a/src/main/resources/com/unicenta/images/unicenta.png b/src/main/resources/com/unicenta/images/unicenta.png new file mode 100644 index 0000000..acc2d2e Binary files /dev/null and b/src/main/resources/com/unicenta/images/unicenta.png differ diff --git a/src/main/resources/com/unicenta/images/unicentaopos.ico b/src/main/resources/com/unicenta/images/unicentaopos.ico new file mode 100644 index 0000000..5060327 Binary files /dev/null and b/src/main/resources/com/unicenta/images/unicentaopos.ico differ diff --git a/src/main/resources/com/unicenta/images/unicentaopos.png b/src/main/resources/com/unicenta/images/unicentaopos.png new file mode 100644 index 0000000..c5f9a87 Binary files /dev/null and b/src/main/resources/com/unicenta/images/unicentaopos.png differ diff --git a/src/main/resources/com/unicenta/images/user.png b/src/main/resources/com/unicenta/images/user.png new file mode 100644 index 0000000..05ed9d2 Binary files /dev/null and b/src/main/resources/com/unicenta/images/user.png differ diff --git a/src/main/resources/com/unicenta/images/user_sml.png b/src/main/resources/com/unicenta/images/user_sml.png new file mode 100644 index 0000000..7dcb34d Binary files /dev/null and b/src/main/resources/com/unicenta/images/user_sml.png differ diff --git a/src/main/resources/com/unicenta/images/users.png b/src/main/resources/com/unicenta/images/users.png new file mode 100644 index 0000000..d9194e6 Binary files /dev/null and b/src/main/resources/com/unicenta/images/users.png differ diff --git a/src/main/resources/com/unicenta/images/utilities.png b/src/main/resources/com/unicenta/images/utilities.png new file mode 100644 index 0000000..38d0ed1 Binary files /dev/null and b/src/main/resources/com/unicenta/images/utilities.png differ diff --git a/src/main/resources/com/unicenta/images/viewmag+.png b/src/main/resources/com/unicenta/images/viewmag+.png new file mode 100644 index 0000000..7547acf Binary files /dev/null and b/src/main/resources/com/unicenta/images/viewmag+.png differ diff --git a/src/main/resources/com/unicenta/images/viewmag-.png b/src/main/resources/com/unicenta/images/viewmag-.png new file mode 100644 index 0000000..a0c6907 Binary files /dev/null and b/src/main/resources/com/unicenta/images/viewmag-.png differ diff --git a/src/main/resources/com/unicenta/images/voucher.png b/src/main/resources/com/unicenta/images/voucher.png new file mode 100644 index 0000000..ca87493 Binary files /dev/null and b/src/main/resources/com/unicenta/images/voucher.png differ diff --git a/src/main/resources/com/unicenta/images/wallet.png b/src/main/resources/com/unicenta/images/wallet.png new file mode 100644 index 0000000..71e6986 Binary files /dev/null and b/src/main/resources/com/unicenta/images/wallet.png differ diff --git a/src/main/resources/com/unicenta/images/window.logo.png b/src/main/resources/com/unicenta/images/window.logo.png new file mode 100644 index 0000000..bb8344a Binary files /dev/null and b/src/main/resources/com/unicenta/images/window.logo.png differ diff --git a/src/main/resources/com/unicenta/images/yast_printer.png b/src/main/resources/com/unicenta/images/yast_printer.png new file mode 100644 index 0000000..c1f30d9 Binary files /dev/null and b/src/main/resources/com/unicenta/images/yast_printer.png differ diff --git a/src/main/resources/com/unicenta/pos/config/Bundle.properties b/src/main/resources/com/unicenta/pos/config/Bundle.properties new file mode 100644 index 0000000..6e8a2c6 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/config/Bundle.properties @@ -0,0 +1,25 @@ +# To change this license header, choose License Headers in Project Properties. +# To change this template file, choose Tools | Templates +# and open the template in the editor. + +label.ticketheader1=Header 1 +label.ticketheader2=Header 2 +label.ticketheader3=Header 3 +label.ticketheader4=Header 4 +label.ticketheader5=Header 5 +label.ticketheader6=Header 6 +label.ticketfooter1=Footer 1 +label.ticketfooter2=Footer 2 +label.ticketfooter3=Footer 3 +label.ticketfooter4=Footer 4 +label.ticketfooter5=Footer 5 +label.ticketfooter6=Footer 6 +# To change this license header, choose License Headers in Project Properties. +# To change this template file, choose Tools | Templates +# and open the template in the editor. +label.tktheader1=Header 1 +label.tktheader2=Header 2 +label.tktheader3=Header 3 +label.tktheader4=Header 4 +label.tktheader5=Header 5 +label.tktheader6=Header 6 diff --git a/src/main/resources/com/unicenta/pos/customers/Bundle.properties b/src/main/resources/com/unicenta/pos/customers/Bundle.properties new file mode 100644 index 0000000..9c41ba4 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/customers/Bundle.properties @@ -0,0 +1,4 @@ +# To change this license header, choose License Headers in Project Properties. +# To change this template file, choose Tools | Templates +# and open the template in the editor. + diff --git a/src/main/resources/com/unicenta/pos/scripts/Derby-create.sql b/src/main/resources/com/unicenta/pos/scripts/Derby-create.sql new file mode 100644 index 0000000..89b610f --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/Derby-create.sql @@ -0,0 +1,699 @@ + +CREATE TABLE applications ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + version varchar(255) NOT NULL, + instdate timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP , + PRIMARY KEY (id) +); + +CREATE TABLE attribute ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE attributeinstance ( + id varchar(255) NOT NULL, + attributesetinstance_id varchar(255) NOT NULL, + attribute_id varchar(255) NOT NULL, + value varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE attributeset ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE attributesetinstance ( + id varchar(255) NOT NULL, + attributeset_id varchar(255) NOT NULL, + description varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE attributeuse ( + id varchar(255) NOT NULL, + attributeset_id varchar(255) NOT NULL, + attribute_id varchar(255) NOT NULL, + lineno smallint default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE attributevalue ( + id varchar(255) NOT NULL, + attribute_id varchar(255) NOT NULL, + value varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE breaks ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + visible smallint NOT NULL default 1 , + notes varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE categories ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + parentid varchar(255) default NULL, + image blob default NULL, + texttip varchar(255) default NULL, + catshowname smallint NOT NULL default 1 , + catorder varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE closedcash ( + money varchar(255) NOT NULL, + host varchar(255) NOT NULL, + hostsequence smallint NOT NULL, + datestart timestamp NOT NULL, + dateend timestamp default NULL, + nosales smallint NOT NULL default 0 , + PRIMARY KEY (money) +); + +CREATE TABLE csvimport ( + id varchar(255) NOT NULL, + rownumber varchar(255) default NULL, + csverror varchar(255) default NULL, + reference varchar(255) default NULL, + code varchar(255) default NULL, + name varchar(255) default NULL, + pricebuy double default NULL, + pricesell double default NULL, + previousbuy double default NULL, + previoussell double default NULL, + category varchar(255) default NULL, + tax varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE customers ( + id varchar(255) NOT NULL, + searchkey varchar(255) NOT NULL, + taxid varchar(255) default NULL, + name varchar(255) NOT NULL, + taxcategory varchar(255) default NULL, + card varchar(255) default NULL, + maxdebt double NOT NULL default 0 , + address varchar(255) default NULL, + address2 varchar(255) default NULL, + postal varchar(255) default NULL, + city varchar(255) default NULL, + region varchar(255) default NULL, + country varchar(255) default NULL, + firstname varchar(255) default NULL, + lastname varchar(255) default NULL, + email varchar(255) default NULL, + phone varchar(255) default NULL, + phone2 varchar(255) default NULL, + fax varchar(255) default NULL, + notes varchar(255) default NULL, + visible smallint NOT NULL default 1 , + curdate timestamp default NULL, + curdebt double default 0 , + image blob default NULL, + isvip smallint NOT NULL default 0 , + discount double default 0 , + memodate timestamp default CURRENT_TIMESTAMP , + PRIMARY KEY (id) +); + +CREATE TABLE draweropened ( + opendate timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP , + name varchar(255) default NULL, + ticketid varchar(255) default NULL +); + +CREATE TABLE floors ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + image blob default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE leaves ( + id varchar(255) NOT NULL, + pplid varchar(255) NOT NULL, + name varchar(255) NOT NULL, + startdate timestamp NOT NULL, + enddate timestamp NOT NULL, + notes varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE lineremoved ( + removeddate timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP , + name varchar(255) default NULL, + ticketid varchar(255) default NULL, + productid varchar(255) default NULL, + productname varchar(255) default NULL, + units double NOT NULL +); + +CREATE TABLE locations ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + address varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE moorers ( + vesselname varchar(255) default NULL, + size smallint default NULL, + days smallint default NULL, + power smallint NOT NULL default 0 +); + +CREATE TABLE orders ( + id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY(Start with 1, Increment by 1), + orderid varchar(50) DEFAULT NULL, + qty smallint DEFAULT 1 , + details varchar(255) DEFAULT NULL, + attributes varchar(255) DEFAULT NULL, + notes varchar(255) DEFAULT NULL, + ticketid varchar(50) DEFAULT NULL, + ordertime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP , + displayid smallint DEFAULT 1 , + auxiliary smallint DEFAULT NULL, + completetime timestamp DEFAULT NULL +); + +CREATE TABLE payments ( + id varchar(255) NOT NULL, + receipt varchar(255) NOT NULL, + payment varchar(255) NOT NULL, + total double NOT NULL default 0 , + tip double default 0 , + transid varchar(255) default NULL, + isprocessed smallint default 0 , + returnmsg blob default NULL, + notes varchar(255) default NULL, + tendered double default NULL, + cardname varchar(255) default NULL, + voucher varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE people ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + apppassword varchar(255) default NULL, + card varchar(255) default NULL, + role varchar(255) NOT NULL, + visible smallint NOT NULL, + image blob default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE pickup_number ( + id smallint NOT NULL default 0 +); + +CREATE TABLE places ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + seats varchar(6) NOT NULL DEFAULT '1' , + x smallint NOT NULL, + y smallint NOT NULL, + floor varchar(255) NOT NULL, + customer varchar(255) default NULL, + waiter varchar(255) default NULL, + ticketid varchar(255) default NULL, + tablemoved smallint NOT NULL default 0 , + width smallint NOT NULL, + height smallint NOT NULL, + guests smallint DEFAULT 0, + occupied timestamp DEFAULT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE products ( + id varchar(255) NOT NULL, + reference varchar(255) NOT NULL, + code varchar(255) NOT NULL, + codetype varchar(255) default NULL, + name varchar(255) NOT NULL, + pricebuy double NOT NULL default 0 , + pricesell double NOT NULL default 0 , + category varchar(255) NOT NULL, + taxcat varchar(255) NOT NULL, + attributeset_id varchar(255) default NULL, + stockcost double NOT NULL default 0 , + stockvolume double NOT NULL default 0 , + image blob default NULL, + iscom smallint NOT NULL default 0 , + isscale smallint NOT NULL default 0 , + isconstant smallint NOT NULL default 0 , + printkb smallint NOT NULL default 0 , + sendstatus smallint NOT NULL default 0 , + isservice smallint NOT NULL default 0 , + attributes blob default NULL, + display varchar(255) default NULL, + isvprice smallint NOT NULL default 0 , + isverpatrib smallint NOT NULL default 0 , + texttip varchar(255) default NULL, + warranty smallint NOT NULL default 0 , + stockunits double NOT NULL default 0 , + printto varchar(255) default '1' , + supplier varchar(255) default NULL, + uom varchar(255) default '0' , + memodate timestamp default '2018-01-01 00:00:01' , + PRIMARY KEY (id) +); + +CREATE TABLE products_bundle ( + id varchar(255) NOT NULL, + product VARCHAR(255) NOT NULL, + product_bundle VARCHAR(255) NOT NULL, + quantity DOUBLE NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE products_cat ( + product varchar(255) NOT NULL, + catorder smallint default NULL, + PRIMARY KEY (product) +); + +CREATE TABLE products_com ( + id varchar(255) NOT NULL, + product varchar(255) NOT NULL, + product2 varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE receipts ( + id varchar(255) NOT NULL, + money varchar(255) NOT NULL, + datenew timestamp NOT NULL, + attributes blob default NULL, + person varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE reservation_customers ( + id varchar(255) NOT NULL, + customer varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE reservations ( + id varchar(255) NOT NULL, + created timestamp NOT NULL, + datenew timestamp NOT NULL default '2018-01-01 00:00:00' , + title varchar(255) NOT NULL, + chairs smallint NOT NULL, + isdone smallint NOT NULL, + description varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE resources ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + restype smallint NOT NULL, + content blob default NULL, + version varchar(10) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE roles ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + permissions blob default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE sharedtickets ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + content blob default NULL, + appuser varchar(255) default NULL, + pickupid smallint NOT NULL default 0 , + locked varchar(20) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE shift_breaks ( + id varchar(255) NOT NULL, + shiftid varchar(255) NOT NULL, + breakid varchar(255) NOT NULL, + starttime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP , + endtime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP , + PRIMARY KEY (id) +); + +CREATE TABLE shifts ( + id varchar(255) NOT NULL, + startshift timestamp NOT NULL, + endshift timestamp default NULL, + pplid varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE stockcurrent ( + location varchar(255) NOT NULL, + product varchar(255) NOT NULL, + attributesetinstance_id varchar(255) default NULL, + units double NOT NULL +); + +CREATE TABLE stockdiary ( + id varchar(255) NOT NULL, + datenew timestamp NOT NULL, + reason smallint NOT NULL, + location varchar(255) NOT NULL, + product varchar(255) NOT NULL, + attributesetinstance_id varchar(255) default NULL, + units double NOT NULL, + price double NOT NULL, + appuser varchar(255) default NULL, + supplier varchar(255) default NULL, + supplierdoc varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE stocklevel ( + id varchar(255) NOT NULL, + location varchar(255) NOT NULL, + product varchar(255) NOT NULL, + stocksecurity double default NULL, + stockmaximum double default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE suppliers ( + id varchar(255) NOT NULL, + searchkey varchar(255) NOT NULL, + taxid varchar(255) default NULL, + name varchar(255) NOT NULL, + maxdebt double NOT NULL default 0 , + address varchar(255) default NULL, + address2 varchar(255) default NULL, + postal varchar(255) default NULL, + city varchar(255) default NULL, + region varchar(255) default NULL, + country varchar(255) default NULL, + firstname varchar(255) default NULL, + lastname varchar(255) default NULL, + email varchar(255) default NULL, + phone varchar(255) default NULL, + phone2 varchar(255) default NULL, + fax varchar(255) default NULL, + notes varchar(255) default NULL, + visible smallint NOT NULL default 1 , + curdate timestamp default NULL, + curdebt double default 0 , + vatid varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE taxcategories ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE taxcustcategories ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE taxes ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + category varchar(255) NOT NULL, + custcategory varchar(255) default NULL, + parentid varchar(255) default NULL, + rate double NOT NULL default 0 , + ratecascade smallint NOT NULL default 0 , + rateorder smallint default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE taxlines ( + id varchar(255) NOT NULL, + receipt varchar(255) NOT NULL, + taxid varchar(255) NOT NULL, + base double NOT NULL default 0 , + amount double NOT NULL default 0 , + PRIMARY KEY (id) +); + +CREATE TABLE taxsuppcategories ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE thirdparties ( + id varchar(255) NOT NULL, + cif varchar(255) NOT NULL, + name varchar(255) NOT NULL, + address varchar(255) default NULL, + contactcomm varchar(255) default NULL, + contactfact varchar(255) default NULL, + payrule varchar(255) default NULL, + faxnumber varchar(255) default NULL, + phonenumber varchar(255) default NULL, + mobilenumber varchar(255) default NULL, + email varchar(255) default NULL, + webpage varchar(255) default NULL, + notes varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE ticketlines ( + ticket varchar(255) NOT NULL, + line smallint NOT NULL, + product varchar(255) default NULL, + attributesetinstance_id varchar(255) default NULL, + units double NOT NULL, + price double NOT NULL, + taxid varchar(255) NOT NULL, + attributes blob default NULL, + PRIMARY KEY (ticket , line) +); + +CREATE TABLE tickets ( + id varchar(255) NOT NULL, + tickettype smallint NOT NULL default 0 , + ticketid smallint NOT NULL, + person varchar(255) NOT NULL, + customer varchar(255) default NULL, + status smallint NOT NULL default 0 , + PRIMARY KEY (id) +); + +CREATE TABLE ticketsnum ( + id smallint NOT NULL +); + +CREATE TABLE ticketsnum_payment ( + id smallint NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE ticketsnum_refund ( + id smallint NOT NULL +); + +CREATE TABLE uom ( + id VARCHAR(255) NOT NULL, + name VARCHAR(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE vouchers ( + id VARCHAR(100) NOT NULL, + voucher_number VARCHAR(100) DEFAULT NULL, + customer VARCHAR(100) DEFAULT NULL, + amount DOUBLE DEFAULT NULL, + status CHAR(1) DEFAULT 'A' , + PRIMARY KEY (id) +); + +-- ADD roles +INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); +INSERT INTO roles(id, name, permissions) VALUES('1', 'Manager role', $FILE{/com/unicenta/pos/templates/Role.Manager.xml} ); +INSERT INTO roles(id, name, permissions) VALUES('2', 'Employee role', $FILE{/com/unicenta/pos/templates/Role.Employee.xml} ); +INSERT INTO roles(id, name, permissions) VALUES('3', 'Guest role', $FILE{/com/unicenta/pos/templates/Role.Guest.xml} ); + +-- ADD people +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('0', 'Administrator', NULL, '0', 1, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('1', 'Manager', NULL, '1', 1, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('2', 'Employee', NULL, '2', 1, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('3', 'Guest', NULL, '3', 1, NULL); + +-- ADD resources -- +-- SYSTEM +INSERT INTO resources(id, name, restype, content) VALUES('00', 'Menu.Root', 0, $FILE{/com/unicenta/pos/templates/Menu.Root.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('02', 'Cash.Close', 0, $FILE{/com/unicenta/pos/templates/Cash.Close.xml}); +INSERT INTO resources(ID, name, restype, content) VALUES('03', 'Customer.Created', 0, $FILE{/com/unicenta/pos/templates/customer.created.xml}); +INSERT INTO resources(ID, name, restype, content) VALUES('04', 'Customer.Deleted', 0, $FILE{/com/unicenta/pos/templates/customer.deleted.xml}); +INSERT INTO resources(ID, name, restype, content) VALUES('05', 'Customer.Updated', 0, $FILE{/com/unicenta/pos/templates/customer.updated.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('06', 'payment.cash', 0, $FILE{/com/unicenta/pos/templates/payment.cash.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('07', 'Ticket.Buttons', 0, $FILE{/com/unicenta/pos/templates/Ticket.Buttons.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('08', 'Ticket.Close', 0, $FILE{/com/unicenta/pos/templates/Ticket.Close.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('09', 'Ticket.Line', 0, $FILE{/com/unicenta/pos/templates/Ticket.Line.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('10', 'Window.Title', 0, $FILE{/com/unicenta/pos/templates/Window.Title.txt}); + +-- IMAGES +INSERT INTO resources(id, name, restype, content) VALUES('11', 'img.001', 1, $FILE{/com/unicenta/images/.01.png}); +INSERT INTO resources(id, name, restype, content) VALUES('12', 'img.002', 1, $FILE{/com/unicenta/images/.02.png}); +INSERT INTO resources(id, name, restype, content) VALUES('13', 'img.005', 1, $FILE{/com/unicenta/images/.05.png}); +INSERT INTO resources(id, name, restype, content) VALUES('14', 'img.010', 1, $FILE{/com/unicenta/images/.10.png}); +INSERT INTO resources(id, name, restype, content) VALUES('15', 'img.020', 1, $FILE{/com/unicenta/images/.20.png}); +INSERT INTO resources(id, name, restype, content) VALUES('16', 'img.025', 1, $FILE{/com/unicenta/images/.25.png}); +INSERT INTO resources(id, name, restype, content) VALUES('17', 'img.050', 1, $FILE{/com/unicenta/images/.50.png}); +INSERT INTO resources(id, name, restype, content) VALUES('18', 'img.1', 1, $FILE{/com/unicenta/images/1.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('19', 'img.2', 1, $FILE{/com/unicenta/images/2.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('20', 'img.5', 1, $FILE{/com/unicenta/images/5.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('21', 'img.10', 1, $FILE{/com/unicenta/images/10.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('22', 'img.20', 1, $FILE{/com/unicenta/images/20.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('23', 'img.50', 1, $FILE{/com/unicenta/images/50.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('24', 'img.100', 1, $FILE{/com/unicenta/images/100.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('25', 'img.200', 1, $FILE{/com/unicenta/images/200.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('26', 'img.500', 1, $FILE{/com/unicenta/images/500.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('27', 'img.1000', 1, $FILE{/com/unicenta/images/1000.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('28', 'img.cash', 1, $FILE{/com/unicenta/images/cash.png}); +INSERT INTO resources(id, name, restype, content) VALUES('29', 'img.cashdrawer', 1, $FILE{/com/unicenta/images/cashdrawer.png}); +INSERT INTO resources(id, name, restype, content) VALUES('30', 'img.discount', 1, $FILE{/com/unicenta/images/discount.png}); +INSERT INTO resources(id, name, restype, content) VALUES('31', 'img.discount_b', 1, $FILE{/com/unicenta/images/discount_b.png}); +INSERT INTO resources(id, name, restype, content) VALUES('32', 'img.heart', 1, $FILE{/com/unicenta/images/heart.png}); +INSERT INTO resources(id, name, restype, content) VALUES('33', 'img.keyboard_48', 1, $FILE{/com/unicenta/images/keyboard_48.png}); +INSERT INTO resources(id, name, restype, content) VALUES('34', 'img.kit_print', 1, $FILE{/com/unicenta/images/kit_print.png}); +INSERT INTO resources(id, name, restype, content) VALUES('35', 'img.no_photo', 1, $FILE{/com/unicenta/images/no_photo.png}); +INSERT INTO resources(id, name, restype, content) VALUES('36', 'img.refundit', 1, $FILE{/com/unicenta/images/refundit.png}); +INSERT INTO resources(id, name, restype, content) VALUES('37', 'img.run_script', 1, $FILE{/com/unicenta/images/run_script.png}); +INSERT INTO resources(id, name, restype, content) VALUES('38', 'img.ticket_print', 1, $FILE{/com/unicenta/images/ticket_print.png}); +INSERT INTO resources(id, name, restype, content) VALUES('40', 'Printer.Ticket.Logo', 1, $FILE{/com/unicenta/images/printer.ticket.logo.jpg}); + +-- PRINTER +INSERT INTO resources(id, name, restype, content) VALUES('41', 'Printer.CloseCash.Preview', 0, $FILE{/com/unicenta/pos/templates/Printer.CloseCash.Preview.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('42', 'Printer.CloseCash', 0, $FILE{/com/unicenta/pos/templates/Printer.CloseCash.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('43', 'Printer.CustomerPaid', 0, $FILE{/com/unicenta/pos/templates/Printer.CustomerPaid.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('44', 'Printer.CustomerPaid2', 0, $FILE{/com/unicenta/pos/templates/Printer.CustomerPaid2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('45', 'Printer.FiscalTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.FiscalTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('46', 'Printer.Inventory', 0, $FILE{/com/unicenta/pos/templates/Printer.Inventory.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('47', 'Printer.OpenDrawer', 0, $FILE{/com/unicenta/pos/templates/Printer.OpenDrawer.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('48', 'Printer.PartialCash', 0, $FILE{/com/unicenta/pos/templates/Printer.PartialCash.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('49', 'Printer.PrintLastTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.PrintLastTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('50', 'Printer.Product', 0, $FILE{/com/unicenta/pos/templates/Printer.Product.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('52', 'Printer.ReprintTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.ReprintTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('53', 'Printer.Start', 0, $FILE{/com/unicenta/pos/templates/Printer.Start.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('54', 'Printer.Ticket.P1', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P1.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('55', 'Printer.Ticket.P2', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('56', 'Printer.Ticket.P3', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P3.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('57', 'Printer.Ticket.P4', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P4.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('58', 'Printer.Ticket.P5', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P5.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('59', 'Printer.Ticket.P6', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P6.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('60', 'Printer.Ticket', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('61', 'Printer.Ticket2', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('62', 'Printer.TicketClose', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketClose.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('63', 'Printer.TicketLine', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketLine.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('64', 'Printer.TicketNew', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketLine.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('65', 'Printer.TicketPreview', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketPreview.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('66', 'Printer.Ticket_A4', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket_A4.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('67', 'Printer.TicketPreview_A4', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketPreview_A4.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('68', 'Printer.TicketRemote', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketRemote.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('69', 'Printer.TicketTotal', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketTotal.xml}); + +-- SCRIPTS +INSERT INTO resources(id, name, restype, content) VALUES('70', 'script.Keyboard', 0, $FILE{/com/unicenta/pos/templates/script.Keyboard.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('71', 'script.Linediscount', 0, $FILE{/com/unicenta/pos/templates/script.Linediscount.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('73', 'script.SendOrder', 0, $FILE{/com/unicenta/pos/templates/script.SendOrder.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('74', 'script.Totaldiscount', 0, $FILE{/com/unicenta/pos/templates/script.Totaldiscount.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('75', 'script.multibuy', 0, $FILE{/com/unicenta/pos/templates/script.multibuy.txt}); + +-- ADD CATEGORIES +INSERT INTO categories(id, name) VALUES ('000', 'Category Standard'); + +-- ADD TAXCATEGORIES +/* 002 added 31/01/2017 00:00:00. */ +INSERT INTO taxcategories(id, name) VALUES ('000', 'Tax Exempt'); +INSERT INTO taxcategories(id, name) VALUES ('001', 'Tax Standard'); +INSERT INTO taxcategories(id, name) VALUES ('002', 'Tax Other'); + +-- ADD TAXES +/* 002 added 31/01/2017 00:00:00. */ +INSERT INTO taxes(id, name, category, custcategory, parentid, rate, ratecascade, rateorder) VALUES ('000', 'Tax Exempt', '000', NULL, NULL, 0, 0, NULL); +INSERT INTO taxes(id, name, category, custcategory, parentid, rate, ratecascade, rateorder) VALUES ('001', 'Tax Standard', '001', NULL, NULL, 0.20, 0, NULL); +INSERT INTO taxes(id, name, category, custcategory, parentid, rate, ratecascade, rateorder) VALUES ('002', 'Tax Other', '002', NULL, NULL, 0, 0, NULL); + +-- ADD PRODUCTS +INSERT INTO products(id, reference, code, name, category, taxcat, isservice, display, printto) +VALUES ('xxx999_999xxx_x9x9x9', 'xxx999', 'xxx999', 'Free Line entry', '000', '001', 1, '<html><center>Free Line entry', '1'); +INSERT INTO products(id, reference, code, name, category, taxcat, isservice, display, printto) +VALUES ('xxx998_998xxx_x8x8x8', 'xxx998', 'xxx998', 'Service Charge', '000', '001', 1, '<html><center>Service Charge', '1'); + +-- ADD PRODUCTS_CAT +INSERT INTO products_cat(product) VALUES ('xxx999_999xxx_x9x9x9'); +INSERT INTO products_cat(product) VALUES ('xxx998_998xxx_x8x8x8'); + +-- ADD LOCATION +INSERT INTO locations(id, name, address) VALUES ('0','Location 1','Local'); + +-- ADD SUPPLIERS +INSERT INTO suppliers(id, searchkey, name) VALUES ('0','unicenta','unicenta'); + +-- ADD UOM +INSERT INTO uom(id, name) VALUES ('0','Each'); + +-- ADD FLOORS +INSERT INTO floors(id, name, image) VALUES ('0', 'Restaurant floor', $FILE{/com/unicenta/images/paperboard960_600.png}); + +-- ADD PLACES +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('1', 'Table 1', 100, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('2', 'Table 2', 250, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('3', 'Table 3', 400, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('4', 'Table 4', 550, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('5', 'Table 5', 700, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('6', 'Table 6', 850, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('7', 'Table 7', 100, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('8', 'Table 8', 250, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('9', 'Table 9', 400, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('10', 'Table 10', 550, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('11', 'Table 11', 700, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('12', 'Table 12', 850, 150, '0', '1', 90, 45); + +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('13', 'Table 13', 100, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('14', 'Table 14', 250, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('15', 'Table 15', 400, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('16', 'Table 16', 550, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('17', 'Table 17', 700, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('18', 'Table 18', 850, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('19', 'Table 19', 100, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('20', 'Table 20', 250, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('21', 'Table 21', 400, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('22', 'Table 22', 550, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('23', 'Table 23', 700, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('24', 'Table 24', 850, 350, '0', '1', 90, 45); + +-- ADD SHIFTS +INSERT INTO shifts(id, startshift, endshift, pplid) VALUES ('0', '2018-01-01 00:00:00.001', '2018-01-01 00:00:00.002','0'); + +-- ADD BREAKS +INSERT INTO breaks(id, name, visible, notes) VALUES ('0', 'Lunch Break', 1, NULL); +INSERT INTO breaks(id, name, visible, notes) VALUES ('1', 'Tea Break', 1, NULL); +INSERT INTO breaks(id, name, visible, notes) VALUES ('2', 'Mid Break', 1, NULL); + +-- ADD SHIFT_BREAKS +INSERT INTO shift_breaks(id, shiftid, breakid, starttime, endtime) VALUES ('0', '0', '0', '2018-01-01 00:00:00.003', '2018-01-01 00:00:00.004'); + +-- ADD SEQUENCES +INSERT INTO pickup_number VALUES(1); +INSERT INTO ticketsnum VALUES(1); +INSERT INTO ticketsnum_refund VALUES(1); +INSERT INTO ticketsnum_payment VALUES(1); + +-- ADD APPLICATION VERSION +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); diff --git a/src/main/resources/com/unicenta/pos/scripts/MariaDB-create.sql b/src/main/resources/com/unicenta/pos/scripts/MariaDB-create.sql new file mode 100644 index 0000000..76e76f6 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MariaDB-create.sql @@ -0,0 +1,1003 @@ +-- uniCenta oPOS - Touch Friendly Point Of Sale +-- Copyright (c) 2009-2018 uniCenta +-- https://unicenta.com +-- +-- This file is part of uniCenta oPOS. +-- +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +/* + * Script created by Jack, uniCenta 23/01/2018 08:00:00 + * + * Creating for version unicentaopos45. Jan 2018 +*/ + +/* Header line. Object: applications. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `instdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: attribute. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `attribute` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: attributeinstance. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `attributeinstance` ( + `id` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `value` varchar(255) default NULL, + KEY `attinst_att` ( `attribute_id` ), + KEY `attinst_set` ( `attributesetinstance_id` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: attributeset. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `attributeset` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: attributesetinstance. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `attributesetinstance` ( + `id` varchar(255) NOT NULL, + `attributeset_id` varchar(255) NOT NULL, + `description` varchar(255) default NULL, + KEY `attsetinst_set` ( `attributeset_id` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: attributeuse. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `attributeuse` ( + `id` varchar(255) NOT NULL, + `attributeset_id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `lineno` int(11) default NULL, + KEY `attuse_att` ( `attribute_id` ), + UNIQUE INDEX `attuse_line` ( `attributeset_id`, `lineno` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: attributevalue. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `attributevalue` ( + `id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `value` varchar(255) default NULL, + KEY `attval_att` ( `attribute_id` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: breaks. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `breaks` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `visible` tinyint(1) NOT NULL default '1', + `notes` varchar(255) default NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: categories. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `categories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `parentid` varchar(255) default NULL, + `image` mediumblob default NULL, + `texttip` varchar(255) default NULL, + `catshowname` smallint(6) NOT NULL default '1', + `catorder` varchar(255) default NULL, + KEY `categories_fk_1` ( `parentid` ), + UNIQUE INDEX `categories_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: closedcash. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `closedcash` ( + `money` varchar(255) NOT NULL, + `host` varchar(255) NOT NULL, + `hostsequence` int(11) NOT NULL, + `datestart` datetime NOT NULL, + `dateend` datetime default NULL, + `nosales` int(11) NOT NULL default '0', + KEY `closedcash_inx_1` ( `datestart` ), + UNIQUE INDEX `closedcash_inx_seq` ( `host`, `hostsequence` ), + PRIMARY KEY ( `money` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: csvimport. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `csvimport` ( + `id` varchar(255) NOT NULL, + `rownumber` varchar(255) default NULL, + `csverror` varchar(255) default NULL, + `reference` varchar(255) default NULL, + `code` varchar(255) default NULL, + `name` varchar(255) default NULL, + `pricebuy` double default NULL, + `pricesell` double default NULL, + `previousbuy` double default NULL, + `previoussell` double default NULL, + `category` varchar(255) default NULL, + `tax` varchar(255) default NULL, + `searchkey` varchar(255) default NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: customers. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `customers` ( + `id` varchar(255) NOT NULL, + `searchkey` varchar(255) NOT NULL, + `taxid` varchar(255) default NULL, + `name` varchar(255) NOT NULL, + `taxcategory` varchar(255) default NULL, + `card` varchar(255) default NULL, + `maxdebt` double NOT NULL default '0', + `address` varchar(255) default NULL, + `address2` varchar(255) default NULL, + `postal` varchar(255) default NULL, + `city` varchar(255) default NULL, + `region` varchar(255) default NULL, + `country` varchar(255) default NULL, + `firstname` varchar(255) default NULL, + `lastname` varchar(255) default NULL, + `email` varchar(255) default NULL, + `phone` varchar(255) default NULL, + `phone2` varchar(255) default NULL, + `fax` varchar(255) default NULL, + `notes` varchar(255) default NULL, + `visible` bit(1) NOT NULL default b'1', + `curdate` datetime default NULL, + `curdebt` double default '0', + `image` mediumblob default NULL, + `isvip` bit(1) NOT NULL default b'0', + `discount` double default '0', + `memodate` datetime default '2000-01-01 00:00:01', + KEY `customers_card_inx` ( `card` ), + KEY `customers_name_inx` ( `name` ), + UNIQUE INDEX `customers_skey_inx` ( `searchkey` ), + KEY `customers_taxcat` ( `taxcategory` ), + KEY `customers_taxid_inx` ( `taxid` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: draweropened. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `draweropened` ( + `opendate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `name` varchar(255) default NULL, + `ticketid` varchar(255) default NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: floors. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `floors` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `image` mediumblob default NULL, + UNIQUE INDEX `floors_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: leaves. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `leaves` ( + `id` varchar(255) NOT NULL, + `pplid` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `startdate` datetime NOT NULL, + `enddate` datetime NOT NULL, + `notes` varchar(255) default NULL, + KEY `leaves_pplid` ( `pplid` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: lineremoved. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `lineremoved` ( + `removeddate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `name` varchar(255) default NULL, + `ticketid` varchar(255) default NULL, + `productid` varchar(255) default NULL, + `productname` varchar(255) default NULL, + `units` double NOT NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: locations. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `locations` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `address` varchar(255) default NULL, + UNIQUE INDEX `locations_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: moorers. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `moorers` ( + `vesselname` varchar(255) default NULL, + `size` int(11) default NULL, + `days` int(11) default NULL, + `power` bit(1) NOT NULL default b'0' +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +CREATE TABLE IF NOT EXISTS `orders` ( + `id` MEDIUMINT NOT NULL AUTO_INCREMENT, + `orderid` varchar(50) DEFAULT NULL, + `qty` int(11) DEFAULT '1', + `details` varchar(255) DEFAULT NULL, + `attributes` varchar(255) DEFAULT NULL, + `notes` varchar(255) DEFAULT NULL, + `ticketid` varchar(50) DEFAULT NULL, + `ordertime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `displayid` int(11) DEFAULT '1', + `auxiliary` int(11) DEFAULT NULL, + `completetime` timestamp NULL, + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: payments. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `payments` ( + `id` varchar(255) NOT NULL, + `receipt` varchar(255) NOT NULL, + `payment` varchar(255) NOT NULL, + `total` double NOT NULL default '0', + `tip` double default '0', + `transid` varchar(255) default NULL, + `isprocessed` bit(1) default b'0', + `returnmsg` mediumblob default NULL, + `notes` varchar(255) default NULL, + `tendered` double default NULL, + `cardname` varchar(255) default NULL, + `voucher` varchar(255) default NULL, + KEY `payments_fk_receipt` ( `receipt` ), + KEY `payments_inx_1` ( `payment` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: people. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `people` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `apppassword` varchar(255) default NULL, + `card` varchar(255) default NULL, + `role` varchar(255) NOT NULL, + `visible` bit(1) NOT NULL, + `image` mediumblob default NULL, + KEY `people_card_inx` ( `card` ), + KEY `people_fk_1` ( `role` ), + UNIQUE INDEX `people_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: pickup_number. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `pickup_number` ( + `id` int(11) NOT NULL default '0' +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: places. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `places` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `seats` varchar(6) NOT NULL DEFAULT '1', + `x` int(11) NOT NULL, + `y` int(11) NOT NULL, + `floor` varchar(255) NOT NULL, + `customer` varchar(255) default NULL, + `waiter` varchar(255) default NULL, + `ticketid` varchar(255) default NULL, + `tablemoved` smallint(6) NOT NULL default '0', + `width` int(11) NOT NULL, + `height` int(11) NOT NULL, + `guests` int(11) DEFAULT 0, + `occupied` datetime DEFAULT NULL, + UNIQUE INDEX `places_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: products. Script date: 02/04/2016 10:53:00. */ +CREATE TABLE `products` ( + `id` varchar(255) NOT NULL, + `reference` varchar(255) NOT NULL, + `code` varchar(255) NOT NULL, + `codetype` varchar(255) default NULL, + `name` varchar(255) NOT NULL, + `pricebuy` double NOT NULL default '0', + `pricesell` double NOT NULL default '0', + `category` varchar(255) NOT NULL, + `taxcat` varchar(255) NOT NULL, + `attributeset_id` varchar(255) default NULL, + `stockcost` double NOT NULL default '0', + `stockvolume` double NOT NULL default '0', + `image` mediumblob default NULL, + `iscom` bit(1) NOT NULL default b'0', + `isscale` bit(1) NOT NULL default b'0', + `isconstant` bit(1) NOT NULL default b'0', + `printkb` bit(1) NOT NULL default b'0', + `sendstatus` bit(1) NOT NULL default b'0', + `isservice` bit(1) NOT NULL default b'0', + `attributes` mediumblob default NULL, + `display` varchar(255) default NULL, + `isvprice` smallint(6) NOT NULL default '0', + `isverpatrib` smallint(6) NOT NULL default '0', + `texttip` varchar(255) default NULL, + `warranty` smallint(6) NOT NULL default '0', + `stockunits` double NOT NULL default '0', + `printto` varchar(255) default '1', + `supplier` varchar(255) default NULL, + `uom` varchar(255) default '0', + `memodate` datetime default '2018-01-01 00:00:01', + + PRIMARY KEY ( `id` ), + KEY `products_attrset_fx` ( `attributeset_id` ), + KEY `products_fk_1` ( `category` ), + UNIQUE INDEX `products_inx_0` ( `reference` ), + UNIQUE INDEX `products_inx_1` ( `code` ), + INDEX `products_name_inx` ( `name` ), + KEY `products_taxcat_fk` ( `taxcat` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +/* Header line. Object: products_cat. Script date: 11/05/2016 05:25:00. */ +CREATE TABLE `products_bundle` ( + `id` varchar(255) NOT NULL, + `product` VARCHAR(255) NOT NULL, + `product_bundle` VARCHAR(255) NOT NULL, + `quantity` DOUBLE NOT NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `pbundle_inx_prod` ( `product` , `product_bundle` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +/* Header line. Object: products_cat. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `products_cat` ( + `product` varchar(255) NOT NULL, + `catorder` int(11) default NULL, + PRIMARY KEY ( `product` ), + KEY `products_cat_inx_1` ( `catorder` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: products_com. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `products_com` ( + `id` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `product2` varchar(255) NOT NULL, + UNIQUE INDEX `pcom_inx_prod` ( `product`, `product2` ), + PRIMARY KEY ( `id` ), + KEY `products_com_fk_2` ( `product2` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: receipts. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `receipts` ( + `id` varchar(255) NOT NULL, + `money` varchar(255) NOT NULL, + `datenew` datetime NOT NULL, + `attributes` mediumblob default NULL, + `person` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `receipts_fk_money` ( `money` ), + KEY `receipts_inx_1` ( `datenew` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: reservation_customers. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `reservation_customers` ( + `id` varchar(255) NOT NULL, + `customer` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ), + KEY `res_cust_fk_2` ( `customer` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +/* Header line. Object: reservations. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `reservations` ( + `id` varchar(255) NOT NULL, + `created` datetime NOT NULL, + `datenew` datetime NOT NULL default '2018-01-01 00:00:00', + `title` varchar(255) NOT NULL, + `chairs` int(11) NOT NULL, + `isdone` bit(1) NOT NULL, + `description` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `reservations_inx_1` ( `datenew` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: resources. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `resources` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `restype` int(11) NOT NULL, + `content` mediumblob default NULL, + `version` varchar(10) default NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `resources_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: roles. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `roles` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `permissions` mediumblob default NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `roles_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: sharedtickets. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `sharedtickets` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `content` mediumblob default NULL, + `appuser` varchar(255) default NULL, + `pickupid` int(11) NOT NULL default '0', + `locked` varchar(20) default NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +/* Header line. Object: shift_breaks. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `shift_breaks` ( + `id` varchar(255) NOT NULL, + `shiftid` varchar(255) NOT NULL, + `breakid` varchar(255) NOT NULL, + `starttime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `endtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ), + KEY `shift_breaks_breakid` ( `breakid` ), + KEY `shift_breaks_shiftid` ( `shiftid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: shifts. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `shifts` ( + `id` varchar(255) NOT NULL, + `startshift` datetime NOT NULL, + `endshift` datetime default NULL, + `pplid` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: stockcurrent. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `stockcurrent` ( + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) default NULL, + `units` double NOT NULL, + KEY `stockcurrent_attsetinst` ( `attributesetinstance_id` ), + KEY `stockcurrent_fk_1` ( `product` ), + UNIQUE INDEX `stockcurrent_inx` ( `location`, `product`, `attributesetinstance_id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: stockdiary. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `stockdiary` ( + `id` varchar(255) NOT NULL, + `datenew` datetime NOT NULL, + `reason` int(11) NOT NULL, + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) default NULL, + `units` double NOT NULL, + `price` double NOT NULL, + `appuser` varchar(255) default NULL, + `supplier` varchar(255) default NULL, + `supplierdoc` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `stockdiary_attsetinst` ( `attributesetinstance_id` ), + KEY `stockdiary_fk_1` ( `product` ), + KEY `stockdiary_fk_2` ( `location` ), + KEY `stockdiary_inx_1` ( `datenew` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: stocklevel. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `stocklevel` ( + `id` varchar(255) NOT NULL, + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `stocksecurity` double default NULL, + `stockmaximum` double default NULL, + PRIMARY KEY ( `id` ), + KEY `stocklevel_location` ( `location` ), + KEY `stocklevel_product` ( `product` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: suppliers. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `suppliers` ( + `id` varchar(255) NOT NULL, + `searchkey` varchar(255) NOT NULL, + `taxid` varchar(255) default NULL, + `name` varchar(255) NOT NULL, + `maxdebt` double NOT NULL default '0', + `address` varchar(255) default NULL, + `address2` varchar(255) default NULL, + `postal` varchar(255) default NULL, + `city` varchar(255) default NULL, + `region` varchar(255) default NULL, + `country` varchar(255) default NULL, + `firstname` varchar(255) default NULL, + `lastname` varchar(255) default NULL, + `email` varchar(255) default NULL, + `phone` varchar(255) default NULL, + `phone2` varchar(255) default NULL, + `fax` varchar(255) default NULL, + `notes` varchar(255) default NULL, + `visible` bit(1) NOT NULL default b'1', + `curdate` datetime default NULL, + `curdebt` double default '0', + `vatid` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `suppliers_name_inx` ( `name` ), + UNIQUE INDEX `suppliers_skey_inx` ( `searchkey` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +/* Header line. Object: taxcategories. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `taxcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `taxcat_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +/* Header line. Object: taxcustcategories. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `taxcustcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `taxcustcat_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: taxes. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `taxes` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `category` varchar(255) NOT NULL, + `custcategory` varchar(255) default NULL, + `parentid` varchar(255) default NULL, + `rate` double NOT NULL default '0', + `ratecascade` bit(1) NOT NULL default b'0', + `rateorder` int(11) default NULL, + PRIMARY KEY ( `id` ), + KEY `taxes_cat_fk` ( `category` ), + KEY `taxes_custcat_fk` ( `custcategory` ), + UNIQUE INDEX `taxes_name_inx` ( `name` ), + KEY `taxes_taxes_fk` ( `parentid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: taxlines. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `taxlines` ( + `id` varchar(255) NOT NULL, + `receipt` varchar(255) NOT NULL, + `taxid` varchar(255) NOT NULL, + `base` double NOT NULL default '0', + `amount` double NOT NULL default '0', + PRIMARY KEY ( `id` ), + KEY `taxlines_receipt` ( `receipt` ), + KEY `taxlines_tax` ( `taxid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +/* Header line. Object: taxsuppcategories. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `taxsuppcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +/* Header line. Object: thirdparties. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `thirdparties` ( + `id` varchar(255) NOT NULL, + `cif` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `address` varchar(255) default NULL, + `contactcomm` varchar(255) default NULL, + `contactfact` varchar(255) default NULL, + `payrule` varchar(255) default NULL, + `faxnumber` varchar(255) default NULL, + `phonenumber` varchar(255) default NULL, + `mobilenumber` varchar(255) default NULL, + `email` varchar(255) default NULL, + `webpage` varchar(255) default NULL, + `notes` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `thirdparties_cif_inx` ( `cif` ), + UNIQUE INDEX `thirdparties_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: ticketlines. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `ticketlines` ( + `ticket` varchar(255) NOT NULL, + `line` int(11) NOT NULL, + `product` varchar(255) default NULL, + `attributesetinstance_id` varchar(255) default NULL, + `units` double NOT NULL, + `price` double NOT NULL, + `taxid` varchar(255) NOT NULL, + `attributes` mediumblob default NULL, + PRIMARY KEY ( `ticket`, `line` ), + KEY `ticketlines_attsetinst` ( `attributesetinstance_id` ), + KEY `ticketlines_fk_2` ( `product` ), + KEY `ticketlines_fk_3` ( `taxid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +/* Header line. Object: tickets. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `tickets` ( + `id` varchar(255) NOT NULL, + `tickettype` int(11) NOT NULL default '0', + `ticketid` int(11) NOT NULL, + `person` varchar(255) NOT NULL, + `customer` varchar(255) default NULL, + `status` int(11) NOT NULL default '0', + PRIMARY KEY ( `id` ), + KEY `tickets_customers_fk` ( `customer` ), + KEY `tickets_fk_2` ( `person` ), + KEY `tickets_ticketid` ( `tickettype`, `ticketid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +/* Header line. Object: ticketsnum. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `ticketsnum` ( + `id` int(11) NOT NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: ticketsnum_payment. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `ticketsnum_payment` ( + `id` int(11) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: ticketsnum_refund. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `ticketsnum_refund` ( + `id` int(11) NOT NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: uom. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `uom` ( + `id` VARCHAR(255) NOT NULL, + `name` VARCHAR(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +/* Header line. Object: vouchers. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `vouchers` ( + `id` VARCHAR(100) NOT NULL, + `voucher_number` VARCHAR(100) DEFAULT NULL, + `customer` VARCHAR(100) DEFAULT NULL, + `amount` DOUBLE DEFAULT NULL, + `status` CHAR(1) DEFAULT 'A', + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ; + +-- Update foreign keys of attributeinstance +ALTER TABLE `attributeinstance` ADD CONSTRAINT `attinst_att` + FOREIGN KEY ( `attribute_id` ) REFERENCES `attribute` ( `id` ); + +ALTER TABLE `attributeinstance` ADD CONSTRAINT `attinst_set` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of attributesetinstance +ALTER TABLE `attributesetinstance` ADD CONSTRAINT `attsetinst_set` + FOREIGN KEY ( `attributeset_id` ) REFERENCES `attributeset` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of attributeuse +ALTER TABLE `attributeuse` ADD CONSTRAINT `attuse_att` + FOREIGN KEY ( `attribute_id` ) REFERENCES `attribute` ( `id` ); + +ALTER TABLE `attributeuse` ADD CONSTRAINT `attuse_set` + FOREIGN KEY ( `attributeset_id` ) REFERENCES `attributeset` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of attributevalue +ALTER TABLE `attributevalue` ADD CONSTRAINT `attval_att` + FOREIGN KEY ( `attribute_id` ) REFERENCES `attribute` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of categories +ALTER TABLE `categories` ADD CONSTRAINT `categories_fk_1` + FOREIGN KEY ( `parentid` ) REFERENCES `categories` ( `id` ); + +-- Update foreign keys of customers + ALTER TABLE `customers` ADD CONSTRAINT `customers_taxcat` + FOREIGN KEY ( `taxcategory` ) REFERENCES `taxcustcategories` ( `id` ); + +-- Update foreign keys of leaves +ALTER TABLE `leaves` ADD CONSTRAINT `leaves_pplid` + FOREIGN KEY ( `pplid` ) REFERENCES `people` ( `id` ); + +-- Update foreign keys of payments +ALTER TABLE `payments` ADD CONSTRAINT `payments_fk_receipt` + FOREIGN KEY ( `receipt` ) REFERENCES `receipts` ( `id` ); + +-- Update foreign keys of people +ALTER TABLE `people` ADD CONSTRAINT `people_fk_1` + FOREIGN KEY ( `role` ) REFERENCES `roles` ( `id` ); + +-- Update foreign keys of products +ALTER TABLE `products` ADD CONSTRAINT `products_attrset_fk` + FOREIGN KEY ( `attributeset_id` ) REFERENCES `attributeset` ( `id` ); + +ALTER TABLE `products` ADD CONSTRAINT `products_fk_1` + FOREIGN KEY ( `category` ) REFERENCES `categories` ( `id` ); + +ALTER TABLE `products` ADD CONSTRAINT `products_taxcat_fk` + FOREIGN KEY ( `taxcat` ) REFERENCES `taxcategories` ( `id` ); + +-- Update foreign keys of product_bundle +ALTER TABLE `products_bundle` ADD CONSTRAINT `products_bundle_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products`( `id` ); + +ALTER TABLE `products_bundle` ADD CONSTRAINT `products_bundle_fk_2` + FOREIGN KEY ( `product_bundle` ) REFERENCES `products`( `id` ); + +-- Update foreign keys of products_cat +ALTER TABLE `products_cat` ADD CONSTRAINT `products_cat_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +-- Update foreign keys of products_com +ALTER TABLE `products_com` ADD CONSTRAINT `products_com_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `products_com` ADD CONSTRAINT `products_com_fk_2` + FOREIGN KEY ( `product2` ) REFERENCES `products` ( `id` ); + +-- Update foreign keys of receipts +ALTER TABLE `receipts` ADD CONSTRAINT `receipts_fk_money` + FOREIGN KEY ( `money` ) REFERENCES `closedcash` ( `money` ); + +-- Update foreign keys of reservation_customers +ALTER TABLE `reservation_customers` ADD CONSTRAINT `res_cust_fk_1` + FOREIGN KEY ( `id` ) REFERENCES `reservations` ( `id` ); + +ALTER TABLE `reservation_customers` ADD CONSTRAINT `res_cust_fk_2` + FOREIGN KEY ( `customer` ) REFERENCES `customers` ( `id` ); + +-- Update foreign keys of shift_breaks +ALTER TABLE `shift_breaks` ADD CONSTRAINT `shift_breaks_breakid` + FOREIGN KEY ( `breakid` ) REFERENCES `breaks` ( `id` ); + +ALTER TABLE `shift_breaks` ADD CONSTRAINT `shift_breaks_shiftid` + FOREIGN KEY ( `shiftid` ) REFERENCES `shifts` ( `id` ); + +-- Update foreign keys of stockcurrent +ALTER TABLE `stockcurrent` ADD CONSTRAINT `stockcurrent_attsetinst` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ); + +ALTER TABLE `stockcurrent` ADD CONSTRAINT `stockcurrent_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `stockcurrent` ADD CONSTRAINT `stockcurrent_fk_2` + FOREIGN KEY ( `location` ) REFERENCES `locations` ( `id` ); + +-- Update foreign keys of stockdiary +ALTER TABLE `stockdiary` ADD CONSTRAINT `stockdiary_attsetinst` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ); + +ALTER TABLE `stockdiary` ADD CONSTRAINT `stockdiary_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `stockdiary` ADD CONSTRAINT `stockdiary_fk_2` + FOREIGN KEY ( `location` ) REFERENCES `locations` ( `id` ); + +-- Update foreign keys of stocklevel +ALTER TABLE `stocklevel` ADD CONSTRAINT `stocklevel_location` + FOREIGN KEY ( `location` ) REFERENCES `locations` ( `id` ); + +ALTER TABLE `stocklevel` ADD CONSTRAINT `stocklevel_product` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +-- Update foreign keys of taxes +ALTER TABLE `taxes` ADD CONSTRAINT `taxes_cat_fk` + FOREIGN KEY ( `category` ) REFERENCES `taxcategories` ( `id` ); + +ALTER TABLE `taxes` ADD CONSTRAINT `taxes_custcat_fk` + FOREIGN KEY ( `custcategory` ) REFERENCES `taxcustcategories` ( `id` ); + +ALTER TABLE `taxes` ADD CONSTRAINT `taxes_taxes_fk` + FOREIGN KEY ( `parentid` ) REFERENCES `taxes` ( `id` ); + +-- Update foreign keys of taxlines +ALTER TABLE `taxlines` ADD CONSTRAINT `taxlines_receipt` + FOREIGN KEY ( `receipt` ) REFERENCES `receipts` ( `id` ); + +ALTER TABLE `taxlines` ADD CONSTRAINT `taxlines_tax` + FOREIGN KEY ( `taxid` ) REFERENCES `taxes` ( `id` ); + +-- Update foreign keys of ticketlines +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_attsetinst` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ); + +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_fk_2` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_fk_3` + FOREIGN KEY ( `taxid` ) REFERENCES `taxes` ( `id` ); + +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_fk_ticket` + FOREIGN KEY ( `ticket` ) REFERENCES `tickets` ( `id` ); + +-- Update foreign keys of tickets +ALTER TABLE `tickets` ADD CONSTRAINT `tickets_customers_fk` + FOREIGN KEY ( `customer` ) REFERENCES `customers` ( `id` ); + +ALTER TABLE `tickets` ADD CONSTRAINT `tickets_fk_2` + FOREIGN KEY ( `person` ) REFERENCES `people` ( `id` ); + +ALTER TABLE `tickets` ADD CONSTRAINT `tickets_fk_id` + FOREIGN KEY ( `id` ) REFERENCES `receipts` ( `id` ); + +-- ***************************************************************************** + +-- ADD roles +INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); +INSERT INTO roles(id, name, permissions) VALUES('1', 'Manager role', $FILE{/com/unicenta/pos/templates/Role.Manager.xml} ); +INSERT INTO roles(id, name, permissions) VALUES('2', 'Employee role', $FILE{/com/unicenta/pos/templates/Role.Employee.xml} ); +INSERT INTO roles(id, name, permissions) VALUES('3', 'Guest role', $FILE{/com/unicenta/pos/templates/Role.Guest.xml} ); + +-- ADD people +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('0', 'Administrator', NULL, '0', TRUE, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('1', 'Manager', NULL, '1', TRUE, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('2', 'Employee', NULL, '2', TRUE, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('3', 'Guest', NULL, '3', TRUE, NULL); + +-- ADD resources -- +-- SYSTEM +INSERT INTO resources(id, name, restype, content) VALUES('00', 'Menu.Root', 0, $FILE{/com/unicenta/pos/templates/Menu.Root.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('02', 'Cash.Close', 0, $FILE{/com/unicenta/pos/templates/Cash.Close.xml}); +INSERT INTO resources(ID, name, restype, content) VALUES('03', 'Customer.Created', 0, $FILE{/com/unicenta/pos/templates/customer.created.xml}); +INSERT INTO resources(ID, name, restype, content) VALUES('04', 'Customer.Deleted', 0, $FILE{/com/unicenta/pos/templates/customer.deleted.xml}); +INSERT INTO resources(ID, name, restype, content) VALUES('05', 'Customer.Updated', 0, $FILE{/com/unicenta/pos/templates/customer.updated.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('06', 'payment.cash', 0, $FILE{/com/unicenta/pos/templates/payment.cash.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('07', 'Ticket.Buttons', 0, $FILE{/com/unicenta/pos/templates/Ticket.Buttons.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('08', 'Ticket.Close', 0, $FILE{/com/unicenta/pos/templates/Ticket.Close.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('09', 'Ticket.Line', 0, $FILE{/com/unicenta/pos/templates/Ticket.Line.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('10', 'Window.Title', 0, $FILE{/com/unicenta/pos/templates/Window.Title.txt}); + +-- IMAGES +INSERT INTO resources(id, name, restype, content) VALUES('11', 'img.001', 1, $FILE{/com/unicenta/images/.01.png}); +INSERT INTO resources(id, name, restype, content) VALUES('12', 'img.002', 1, $FILE{/com/unicenta/images/.02.png}); +INSERT INTO resources(id, name, restype, content) VALUES('13', 'img.005', 1, $FILE{/com/unicenta/images/.05.png}); +INSERT INTO resources(id, name, restype, content) VALUES('14', 'img.010', 1, $FILE{/com/unicenta/images/.10.png}); +INSERT INTO resources(id, name, restype, content) VALUES('15', 'img.020', 1, $FILE{/com/unicenta/images/.20.png}); +INSERT INTO resources(id, name, restype, content) VALUES('16', 'img.025', 1, $FILE{/com/unicenta/images/.25.png}); +INSERT INTO resources(id, name, restype, content) VALUES('17', 'img.050', 1, $FILE{/com/unicenta/images/.50.png}); +INSERT INTO resources(id, name, restype, content) VALUES('18', 'img.1', 1, $FILE{/com/unicenta/images/1.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('19', 'img.2', 1, $FILE{/com/unicenta/images/2.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('20', 'img.5', 1, $FILE{/com/unicenta/images/5.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('21', 'img.10', 1, $FILE{/com/unicenta/images/10.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('22', 'img.20', 1, $FILE{/com/unicenta/images/20.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('23', 'img.50', 1, $FILE{/com/unicenta/images/50.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('24', 'img.100', 1, $FILE{/com/unicenta/images/100.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('25', 'img.200', 1, $FILE{/com/unicenta/images/200.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('26', 'img.500', 1, $FILE{/com/unicenta/images/500.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('27', 'img.1000', 1, $FILE{/com/unicenta/images/1000.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('28', 'img.cash', 1, $FILE{/com/unicenta/images/cash.png}); +INSERT INTO resources(id, name, restype, content) VALUES('29', 'img.cashdrawer', 1, $FILE{/com/unicenta/images/cashdrawer.png}); +INSERT INTO resources(id, name, restype, content) VALUES('30', 'img.discount', 1, $FILE{/com/unicenta/images/discount.png}); +INSERT INTO resources(id, name, restype, content) VALUES('31', 'img.discount_b', 1, $FILE{/com/unicenta/images/discount_b.png}); +INSERT INTO resources(id, name, restype, content) VALUES('32', 'img.heart', 1, $FILE{/com/unicenta/images/heart.png}); +INSERT INTO resources(id, name, restype, content) VALUES('33', 'img.keyboard_48', 1, $FILE{/com/unicenta/images/keyboard_48.png}); +INSERT INTO resources(id, name, restype, content) VALUES('34', 'img.kit_print', 1, $FILE{/com/unicenta/images/kit_print.png}); +INSERT INTO resources(id, name, restype, content) VALUES('35', 'img.no_photo', 1, $FILE{/com/unicenta/images/no_photo.png}); +INSERT INTO resources(id, name, restype, content) VALUES('36', 'img.refundit', 1, $FILE{/com/unicenta/images/refundit.png}); +INSERT INTO resources(id, name, restype, content) VALUES('37', 'img.run_script', 1, $FILE{/com/unicenta/images/run_script.png}); +INSERT INTO resources(id, name, restype, content) VALUES('38', 'img.ticket_print', 1, $FILE{/com/unicenta/images/ticket_print.png}); +INSERT INTO resources(id, name, restype, content) VALUES('39', 'Printer.Ticket.Logo', 1, $FILE{/com/unicenta/images/printer.ticket.logo.jpg}); + +-- PRINTER +INSERT INTO resources(id, name, restype, content) VALUES('41', 'Printer.CloseCash.Preview', 0, $FILE{/com/unicenta/pos/templates/Printer.CloseCash.Preview.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('42', 'Printer.CloseCash', 0, $FILE{/com/unicenta/pos/templates/Printer.CloseCash.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('43', 'Printer.CustomerPaid', 0, $FILE{/com/unicenta/pos/templates/Printer.CustomerPaid.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('44', 'Printer.CustomerPaid2', 0, $FILE{/com/unicenta/pos/templates/Printer.CustomerPaid2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('45', 'Printer.FiscalTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.FiscalTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('46', 'Printer.Inventory', 0, $FILE{/com/unicenta/pos/templates/Printer.Inventory.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('47', 'Printer.OpenDrawer', 0, $FILE{/com/unicenta/pos/templates/Printer.OpenDrawer.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('48', 'Printer.PartialCash', 0, $FILE{/com/unicenta/pos/templates/Printer.PartialCash.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('49', 'Printer.PrintLastTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.PrintLastTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('50', 'Printer.Product', 0, $FILE{/com/unicenta/pos/templates/Printer.Product.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('52', 'Printer.ReprintTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.ReprintTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('53', 'Printer.Start', 0, $FILE{/com/unicenta/pos/templates/Printer.Start.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('54', 'Printer.Ticket.P1', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P1.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('55', 'Printer.Ticket.P2', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('56', 'Printer.Ticket.P3', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P3.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('57', 'Printer.Ticket.P4', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P4.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('58', 'Printer.Ticket.P5', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P5.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('59', 'Printer.Ticket.P6', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P6.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('60', 'Printer.Ticket', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('61', 'Printer.Ticket2', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('62', 'Printer.TicketClose', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketClose.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('63', 'Printer.TicketLine', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketLine.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('64', 'Printer.TicketNew', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketLine.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('65', 'Printer.TicketPreview', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketPreview.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('66', 'Printer.Ticket_A4', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket_A4.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('67', 'Printer.TicketPreview_A4', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketPreview_A4.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('68', 'Printer.TicketRemote', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketRemote.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('69', 'Printer.TicketTotal', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketTotal.xml}); + +-- SCRIPTS +INSERT INTO resources(id, name, restype, content) VALUES('70', 'script.Keyboard', 0, $FILE{/com/unicenta/pos/templates/script.Keyboard.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('71', 'script.Linediscount', 0, $FILE{/com/unicenta/pos/templates/script.Linediscount.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('72', 'script.SendOrder', 0, $FILE{/com/unicenta/pos/templates/script.SendOrder.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('73', 'script.Totaldiscount', 0, $FILE{/com/unicenta/pos/templates/script.Totaldiscount.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('74', 'script.multibuy', 0, $FILE{/com/unicenta/pos/templates/script.multibuy.txt}); + +-- ADD CATEGORIES +INSERT INTO categories(id, name) VALUES ('000', 'Category Standard'); + +-- ADD TAXCATEGORIES +/* 002 added 31/01/2017 00:00:00. */ +INSERT INTO taxcategories(id, name) VALUES ('000', 'Tax Exempt'); +INSERT INTO taxcategories(id, name) VALUES ('001', 'Tax Standard'); +INSERT INTO taxcategories(id, name) VALUES ('002', 'Tax Other'); + +-- ADD TAXES +/* 002 added 31/01/2017 00:00:00. */ +INSERT INTO taxes(id, name, category, custcategory, parentid, rate, ratecascade, rateorder) VALUES ('000', 'Tax Exempt', '000', NULL, NULL, 0, FALSE, NULL); +INSERT INTO taxes(id, name, category, custcategory, parentid, rate, ratecascade, rateorder) VALUES ('001', 'Tax Standard', '001', NULL, NULL, 0.20, FALSE, NULL); +INSERT INTO taxes(id, name, category, custcategory, parentid, rate, ratecascade, rateorder) VALUES ('002', 'Tax Other', '002', NULL, NULL, 0, FALSE, NULL); + +-- ADD PRODUCTS +INSERT INTO products(id, reference, code, name, category, taxcat, isservice, display, printto) +VALUES ('xxx999_999xxx_x9x9x9', 'xxx999', 'xxx999', 'Free Line entry', '000', '001', 1, '<html><center>Free Line entry', '1'); +INSERT INTO products(id, reference, code, name, category, taxcat, isservice, display, printto) +VALUES ('xxx998_998xxx_x8x8x8', 'xxx998', 'xxx998', 'Service Charge', '000', '001', 1, '<html><center>Service Charge', '1'); + +-- ADD PRODUCTS_CAT +INSERT INTO products_cat(product) VALUES ('xxx999_999xxx_x9x9x9'); +INSERT INTO products_cat(product) VALUES ('xxx998_998xxx_x8x8x8'); + +-- ADD LOCATION +INSERT INTO locations(id, name, address) VALUES ('0','Location 1','Local'); + +-- ADD SUPPLIERS +INSERT INTO suppliers(id, searchkey, name) VALUES ('0','uniCenta','uniCenta'); + +-- ADD UOM +INSERT INTO uom(id, name) VALUES ('0','Each'); + +-- ADD FLOORS +INSERT INTO floors(id, name, image) VALUES ('0', 'Restaurant floor', $FILE{/com/unicenta/images/paperboard960_600.png}); + +-- ADD PLACES +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('1', 'Table 1', 100, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('2', 'Table 2', 250, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('3', 'Table 3', 400, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('4', 'Table 4', 550, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('5', 'Table 5', 700, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('6', 'Table 6', 850, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('7', 'Table 7', 100, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('8', 'Table 8', 250, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('9', 'Table 9', 400, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('10', 'Table 10', 550, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('11', 'Table 11', 700, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('12', 'Table 12', 850, 150, '0', '1', 90, 45); + +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('13', 'Table 13', 100, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('14', 'Table 14', 250, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('15', 'Table 15', 400, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('16', 'Table 16', 550, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('17', 'Table 17', 700, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('18', 'Table 18', 850, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('19', 'Table 19', 100, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('20', 'Table 20', 250, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('21', 'Table 21', 400, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('22', 'Table 22', 550, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('23', 'Table 23', 700, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('24', 'Table 24', 850, 350, '0', '1', 90, 45); + +-- ADD SHIFTS +INSERT INTO shifts(id, startshift, endshift, pplid) VALUES ('0', '2018-01-01 00:00:00.001', '2018-01-01 00:00:00.002','0'); + +-- ADD BREAKS +INSERT INTO breaks(id, name, visible, notes) VALUES ('0', 'Lunch Break', TRUE, NULL); +INSERT INTO breaks(id, name, visible, notes) VALUES ('1', 'Tea Break', TRUE, NULL); +INSERT INTO breaks(id, name, visible, notes) VALUES ('2', 'Mid Break', TRUE, NULL); + +-- ADD SHIFT_BREAKS +INSERT INTO shift_breaks(id, shiftid, breakid, starttime, endtime) VALUES ('0', '0', '0', '2018-01-01 00:00:00.003', '2018-01-01 00:00:00.004'); + +-- ADD SEQUENCES +INSERT INTO pickup_number VALUES(1); +INSERT INTO ticketsnum VALUES(1); +INSERT INTO ticketsnum_refund VALUES(1); +INSERT INTO ticketsnum_payment VALUES(1); + +-- ADD APPLICATION VERSION +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MariaDB-upgrade_master.sql b/src/main/resources/com/unicenta/pos/scripts/MariaDB-upgrade_master.sql new file mode 100644 index 0000000..c6ee72d --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MariaDB-upgrade_master.sql @@ -0,0 +1,61 @@ +-- CLEAR THE DECKS +DELETE FROM sharedtickets; + +-- Switch OFF table foreign key relationships +set foreign_key_checks = 0; + +-- RECREATE applications table +DROP TABLE `applications`; +CREATE TABLE IF NOT EXISTS `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `instdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + + +-- SYSTEM +DELETE FROM resources WHERE name = 'script.posapps'; + + +DELETE FROM resources WHERE id = '0'; +DELETE FROM resources WHERE id = '00'; +INSERT INTO resources(id, name, restype, content) VALUES('00', 'Menu.Root', 0, $FILE{/com/unicenta/pos/templates/Menu.Root.txt}); + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Ticket.Buttons.xml} WHERE name = 'Ticket.Buttons'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Printer.Ticket.xml} WHERE name = 'Printer.Ticket'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Ticket.Close.xml} WHERE name = 'Ticket.Close'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Cash.Close.xml} WHERE name = 'Cash.Close'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.created.xml} WHERE name = 'Customer.Created'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.deleted.xml} WHERE name = 'Customer.Deleted'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.updated.xml} WHERE name = 'Customer.Updated'; +COMMIT; + +-- ROLES +DELETE FROM roles WHERE id = '0'; +INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); +DELETE FROM roles WHERE id = '1'; +INSERT INTO roles(id, name, permissions) VALUES('1', 'Manager role', $FILE{/com/unicenta/pos/templates/Role.Manager.xml} ); +DELETE FROM roles WHERE id = '2'; +INSERT INTO roles(id, name, permissions) VALUES('2', 'Employee role', $FILE{/com/unicenta/pos/templates/Role.Employee.xml} ); + + +-- Switch ON table foreign key relationships +set foreign_key_checks = 1; + +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); + +COMMIT; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-FKeys.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-FKeys.sql new file mode 100644 index 0000000..40ac764 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-FKeys.sql @@ -0,0 +1,191 @@ +-- uniCenta oPOS - Touch Friendly Point Of Sale +-- Copyright (c) 2009-2017 uniCenta +-- https://unicenta.com +-- +-- This file is part of uniCenta oPOS. +-- +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +/* + * Script created by Jack, uniCenta 07/08/2016 08:00:00 + * Modified 10 Sept 2017 + * Called by Transfer for v4.4 after data complete +*/ + +-- ---------------------------- +-- FOREIGN KEYS AND CONSTRAINTS +-- ---------------------------- +set foreign_key_checks = 1; +set foreign_key_checks = 0; + +-- Update foreign keys of attributeinstance +ALTER TABLE `attributeinstance` ADD CONSTRAINT `attinst_att` + FOREIGN KEY ( `attribute_id` ) REFERENCES `attribute` ( `id` ); + +ALTER TABLE `attributeinstance` ADD CONSTRAINT `attinst_set` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of attributesetinstance +ALTER TABLE `attributesetinstance` ADD CONSTRAINT `attsetinst_set` + FOREIGN KEY ( `attributeset_id` ) REFERENCES `attributeset` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of attributeuse +ALTER TABLE `attributeuse` ADD CONSTRAINT `attuse_att` + FOREIGN KEY ( `attribute_id` ) REFERENCES `attribute` ( `id` ); + +ALTER TABLE `attributeuse` ADD CONSTRAINT `attuse_set` + FOREIGN KEY ( `attributeset_id` ) REFERENCES `attributeset` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of attributevalue +ALTER TABLE `attributevalue` ADD CONSTRAINT `attval_att` + FOREIGN KEY ( `attribute_id` ) REFERENCES `attribute` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of categories +ALTER TABLE `categories` ADD CONSTRAINT `categories_fk_1` + FOREIGN KEY ( `parentid` ) REFERENCES `categories` ( `id` ); + +-- Update foreign keys of customers +ALTER TABLE `customers` ADD CONSTRAINT `customers_taxcat` + FOREIGN KEY ( `taxcategory` ) REFERENCES `taxcustcategories` ( `id` ); + +-- Update foreign keys of leaves +ALTER TABLE `leaves` ADD CONSTRAINT `leaves_pplid` + FOREIGN KEY ( `pplid` ) REFERENCES `people` ( `id` ); + +-- Update foreign keys of payments +ALTER TABLE `payments` ADD CONSTRAINT `payments_fk_receipt` + FOREIGN KEY ( `receipt` ) REFERENCES `receipts` ( `id` ); + +-- Update foreign keys of people +ALTER TABLE `people` ADD CONSTRAINT `people_fk_1` + FOREIGN KEY ( `role` ) REFERENCES `roles` ( `id` ); + +-- Update Indeces of products +ALTER TABLE `products` ADD UNIQUE INDEX `products_inx_0` ( `reference` ); +ALTER TABLE `products` ADD UNIQUE INDEX `products_inx_1` ( `code` ); +ALTER TABLE `products` ADD INDEX `products_name_inx` ( `name` ); +-- Update foreign keys of products +ALTER TABLE `products` ADD CONSTRAINT `products_attrset_fk` + FOREIGN KEY ( `attributeset_id` ) REFERENCES `attributeset` ( `id` ); +ALTER TABLE `products` ADD CONSTRAINT `products_fk_1` + FOREIGN KEY ( `category` ) REFERENCES `categories` ( `id` ); +ALTER TABLE `products` ADD CONSTRAINT `products_taxcat_fk` + FOREIGN KEY ( `taxcat` ) REFERENCES `taxcategories` ( `id` ); + +-- Update foreign keys of product_bundle +ALTER TABLE `products_bundle` ADD CONSTRAINT `products_bundle_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products`( `id` ); + +ALTER TABLE `products_bundle` ADD CONSTRAINT `products_bundle_fk_2` + FOREIGN KEY ( `product_bundle` ) REFERENCES `products`( `id` ); + +-- Update foreign keys of products_cat +ALTER TABLE `products_cat` ADD CONSTRAINT `products_cat_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +-- Update foreign keys of products_com +ALTER TABLE `products_com` ADD CONSTRAINT `products_com_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `products_com` ADD CONSTRAINT `products_com_fk_2` + FOREIGN KEY ( `product2` ) REFERENCES `products` ( `id` ); + +-- Update foreign keys of receipts +ALTER TABLE `receipts` ADD CONSTRAINT `receipts_fk_money` + FOREIGN KEY ( `money` ) REFERENCES `closedcash` ( `money` ); + +-- Update foreign keys of reservation_customers +ALTER TABLE `reservation_customers` ADD CONSTRAINT `res_cust_fk_1` + FOREIGN KEY ( `id` ) REFERENCES `reservations` ( `id` ); + +ALTER TABLE `reservation_customers` ADD CONSTRAINT `res_cust_fk_2` + FOREIGN KEY ( `customer` ) REFERENCES `customers` ( `id` ); + +-- Update foreign keys of shift_breaks +ALTER TABLE `shift_breaks` ADD CONSTRAINT `shift_breaks_breakid` + FOREIGN KEY ( `breakid` ) REFERENCES `breaks` ( `id` ); + +ALTER TABLE `shift_breaks` ADD CONSTRAINT `shift_breaks_shiftid` + FOREIGN KEY ( `shiftid` ) REFERENCES `shifts` ( `id` ); + +-- Update foreign keys of stockcurrent +ALTER TABLE `stockcurrent` ADD CONSTRAINT `stockcurrent_attsetinst` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ); + +ALTER TABLE `stockcurrent` ADD CONSTRAINT `stockcurrent_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `stockcurrent` ADD CONSTRAINT `stockcurrent_fk_2` + FOREIGN KEY ( `location` ) REFERENCES `locations` ( `id` ); + +-- Update foreign keys of stockdiary +ALTER TABLE `stockdiary` ADD CONSTRAINT `stockdiary_attsetinst` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ); + +ALTER TABLE `stockdiary` ADD CONSTRAINT `stockdiary_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `stockdiary` ADD CONSTRAINT `stockdiary_fk_2` + FOREIGN KEY ( `location` ) REFERENCES `locations` ( `id` ); + +-- Update foreign keys of stocklevel +ALTER TABLE `stocklevel` ADD CONSTRAINT `stocklevel_location` + FOREIGN KEY ( `location` ) REFERENCES `locations` ( `id` ); + +ALTER TABLE `stocklevel` ADD CONSTRAINT `stocklevel_product` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +-- Update foreign keys of taxes +ALTER TABLE `taxes` ADD CONSTRAINT `taxes_cat_fk` + FOREIGN KEY ( `category` ) REFERENCES `taxcategories` ( `id` ); + +ALTER TABLE `taxes` ADD CONSTRAINT `taxes_custcat_fk` + FOREIGN KEY ( `custcategory` ) REFERENCES `taxcustcategories` ( `id` ); + +ALTER TABLE `taxes` ADD CONSTRAINT `taxes_taxes_fk` + FOREIGN KEY ( `parentid` ) REFERENCES `taxes` ( `id` ); + +-- Update foreign keys of taxlines +ALTER TABLE `taxlines` ADD CONSTRAINT `taxlines_receipt` + FOREIGN KEY ( `receipt` ) REFERENCES `receipts` ( `id` ); + +ALTER TABLE `taxlines` ADD CONSTRAINT `taxlines_tax` + FOREIGN KEY ( `taxid` ) REFERENCES `taxes` ( `id` ); + +-- Update foreign keys of ticketlines +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_attsetinst` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ); + +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_fk_2` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_fk_3` + FOREIGN KEY ( `taxid` ) REFERENCES `taxes` ( `id` ); + +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_fk_ticket` + FOREIGN KEY ( `ticket` ) REFERENCES `tickets` ( `id` ); + +-- Update foreign keys of tickets +ALTER TABLE `tickets` ADD CONSTRAINT `tickets_customers_fk` + FOREIGN KEY ( `customer` ) REFERENCES `customers` ( `id` ); + +ALTER TABLE `tickets` ADD CONSTRAINT `tickets_fk_2` + FOREIGN KEY ( `person` ) REFERENCES `people` ( `id` ); + +ALTER TABLE `tickets` ADD CONSTRAINT `tickets_fk_id` + FOREIGN KEY ( `id` ) REFERENCES `receipts` ( `id` ); + +set foreign_key_checks = 1; + +-- ***************************************************************************** diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-check-tables.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-check-tables.sql new file mode 100644 index 0000000..cc3c10a --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-check-tables.sql @@ -0,0 +1,818 @@ +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +/* + * Script created by Jack, uniCenta 23/07/2016 08:00:00 + * + * Check DB tables. +*/ + +/* Header line. Object: applications. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `instdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: attribute. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `attribute` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: attributeinstance. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `attributeinstance` ( + `id` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `value` varchar(255) default NULL, + KEY `attinst_att` ( `attribute_id` ), + KEY `attinst_set` ( `attributesetinstance_id` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: attributeset. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `attributeset` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: attributesetinstance. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `attributesetinstance` ( + `id` varchar(255) NOT NULL, + `attributeset_id` varchar(255) NOT NULL, + `description` varchar(255) default NULL, + KEY `attsetinst_set` ( `attributeset_id` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: attributeuse. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `attributeuse` ( + `id` varchar(255) NOT NULL, + `attributeset_id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `lineno` int(11) default NULL, + KEY `attuse_att` ( `attribute_id` ), + UNIQUE INDEX `attuse_line` ( `attributeset_id`, `lineno` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: attributevalue. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `attributevalue` ( + `id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `value` varchar(255) default NULL, + KEY `attval_att` ( `attribute_id` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: breaks. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `breaks` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `visible` tinyint(1) NOT NULL default '1', + `notes` varchar(255) default NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: categories. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `categories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `parentid` varchar(255) default NULL, + `image` mediumblob default NULL, + `texttip` varchar(255) default NULL, + `catshowname` smallint(6) NOT NULL default '1', + `catorder` varchar(255) default NULL, + KEY `categories_fk_1` ( `parentid` ), + UNIQUE INDEX `categories_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: closedcash. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `closedcash` ( + `money` varchar(255) NOT NULL, + `host` varchar(255) NOT NULL, + `hostsequence` int(11) NOT NULL, + `datestart` datetime NOT NULL, + `dateend` datetime default NULL, + `nosales` int(11) NOT NULL default '0', + KEY `closedcash_inx_1` ( `datestart` ), + UNIQUE INDEX `closedcash_inx_seq` ( `host`, `hostsequence` ), + PRIMARY KEY ( `money` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: csvimport. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `csvimport` ( + `id` varchar(255) NOT NULL, + `rownumber` varchar(255) default NULL, + `csverror` varchar(255) default NULL, + `reference` varchar(255) default NULL, + `code` varchar(255) default NULL, + `name` varchar(255) default NULL, + `pricebuy` double default NULL, + `pricesell` double default NULL, + `previousbuy` double default NULL, + `previoussell` double default NULL, + `category` varchar(255) default NULL, + `tax` varchar(255) default NULL, + `searchkey` varchar(255) default NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: customers. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `customers` ( + `id` varchar(255) NOT NULL, + `searchkey` varchar(255) NOT NULL, + `taxid` varchar(255) default NULL, + `name` varchar(255) NOT NULL, + `taxcategory` varchar(255) default NULL, + `card` varchar(255) default NULL, + `maxdebt` double NOT NULL default '0', + `address` varchar(255) default NULL, + `address2` varchar(255) default NULL, + `postal` varchar(255) default NULL, + `city` varchar(255) default NULL, + `region` varchar(255) default NULL, + `country` varchar(255) default NULL, + `firstname` varchar(255) default NULL, + `lastname` varchar(255) default NULL, + `email` varchar(255) default NULL, + `phone` varchar(255) default NULL, + `phone2` varchar(255) default NULL, + `fax` varchar(255) default NULL, + `notes` varchar(255) default NULL, + `visible` bit(1) NOT NULL default b'1', + `curdate` datetime default NULL, + `curdebt` double default '0', + `image` mediumblob default NULL, + `isvip` bit(1) NOT NULL default b'0', + `discount` double default '0', + `memodate` datetime default '1900-01-01 00:00:01', + KEY `customers_card_inx` ( `card` ), + KEY `customers_name_inx` ( `name` ), + UNIQUE INDEX `customers_skey_inx` ( `searchkey` ), + KEY `customers_taxcat` ( `taxcategory` ), + KEY `customers_taxid_inx` ( `taxid` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: draweropened. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `draweropened` ( + `opendate` timestamp NOT NULL, + `name` varchar(255) default NULL, + `ticketid` varchar(255) default NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: floors. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `floors` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `image` mediumblob default NULL, + UNIQUE INDEX `floors_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: leaves. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `leaves` ( + `id` varchar(255) NOT NULL, + `pplid` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `startdate` datetime NOT NULL, + `enddate` datetime NOT NULL, + `notes` varchar(255) default NULL, + KEY `leaves_pplid` ( `pplid` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: lineremoved. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `lineremoved` ( + `removeddate` timestamp NOT NULL, + `name` varchar(255) default NULL, + `ticketid` varchar(255) default NULL, + `productid` varchar(255) default NULL, + `productname` varchar(255) default NULL, + `units` double NOT NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: locations. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `locations` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `address` varchar(255) default NULL, + UNIQUE INDEX `locations_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: moorers. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `moorers` ( + `vesselname` varchar(255) default NULL, + `size` int(11) default NULL, + `days` int(11) default NULL, + `power` bit(1) NOT NULL default b'0' +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: orders. Script date: 01/01/2017 00:00:01. */ +CREATE TABLE IF NOT EXISTS `orders` ( + `id` int(11) NOT NULL, + `orderid` varchar(50) DEFAULT NULL, + `qty` int(11) DEFAULT '1', + `details` varchar(255) DEFAULT NULL, + `attributes` varchar(255) DEFAULT NULL, + `notes` varchar(255) DEFAULT NULL, + `ticketid` varchar(50) DEFAULT NULL, + `ordertime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `displayid` int(11) DEFAULT '1', + `auxiliary` int(11) DEFAULT NULL, + `completetime` timestamp, + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: payments. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `payments` ( + `id` varchar(255) NOT NULL, + `receipt` varchar(255) NOT NULL, + `payment` varchar(255) NOT NULL, + `total` double NOT NULL default '0', + `tip` double default '0', + `transid` varchar(255) default NULL, + `isprocessed` bit(1) default b'0', + `returnmsg` mediumblob default NULL, + `notes` varchar(255) default NULL, + `tendered` double default NULL, + `cardname` varchar(255) default NULL, + `voucher` varchar(255) default NULL, + KEY `payments_fk_receipt` ( `receipt` ), + KEY `payments_inx_1` ( `payment` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: people. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `people` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `apppassword` varchar(255) default NULL, + `card` varchar(255) default NULL, + `role` varchar(255) NOT NULL, + `visible` bit(1) NOT NULL, + `image` mediumblob default NULL, + KEY `people_card_inx` ( `card` ), + KEY `people_fk_1` ( `role` ), + UNIQUE INDEX `people_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: pickup_number. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `pickup_number` ( + `id` int(11) NOT NULL default '0' +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: places. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `places` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `x` int(11) NOT NULL, + `y` int(11) NOT NULL, + `floor` varchar(255) NOT NULL, + `customer` varchar(255) default NULL, + `waiter` varchar(255) default NULL, + `ticketid` varchar(255) default NULL, + `tablemoved` smallint(6) NOT NULL default '0', + UNIQUE INDEX `places_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: products. Script date: 02/04/2016 10:53:00. */ +CREATE TABLE IF NOT EXISTS `products` ( + `id` varchar(255) NOT NULL, + `reference` varchar(255) NOT NULL, + `code` varchar(255) NOT NULL, + `codetype` varchar(255) default NULL, + `name` varchar(255) NOT NULL, + `pricebuy` double NOT NULL default '0', + `pricesell` double NOT NULL default '0', + `category` varchar(255) NOT NULL, + `taxcat` varchar(255) NOT NULL, + `attributeset_id` varchar(255) default NULL, + `stockcost` double NOT NULL default '0', + `stockvolume` double NOT NULL default '0', + `image` mediumblob default NULL, + `iscom` bit(1) NOT NULL default b'0', + `isscale` bit(1) NOT NULL default b'0', + `isconstant` bit(1) NOT NULL default b'0', + `printkb` bit(1) NOT NULL default b'0', + `sendstatus` bit(1) NOT NULL default b'0', + `isservice` bit(1) NOT NULL default b'0', + `attributes` mediumblob default NULL, + `display` varchar(255) default NULL, + `isvprice` smallint(6) NOT NULL default '0', + `isverpatrib` smallint(6) NOT NULL default '0', + `texttip` varchar(255) default NULL, + `warranty` smallint(6) NOT NULL default '0', + `stockunits` double NOT NULL default '0', + `printto` varchar(255) default '1', + `supplier` varchar(255) default NULL, + `uom` varchar(255) default '0', + `memodate` datetime default '1900-01-01 00:00:01', + + PRIMARY KEY ( `id` ), + KEY `products_attrset_fx` ( `attributeset_id` ), + KEY `products_fk_1` ( `category` ), + UNIQUE INDEX `products_inx_0` ( `reference` ), + UNIQUE INDEX `products_inx_1` ( `code` ), + INDEX `products_name_inx` ( `name` ), + KEY `products_taxcat_fk` ( `taxcat` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: products_cat. Script date: 11/05/2016 05:25:00. */ +CREATE TABLE IF NOT EXISTS `products_bundle` ( + `id` varchar(255) NOT NULL, + `product` VARCHAR(255) NOT NULL, + `product_bundle` VARCHAR(255) NOT NULL, + `quantity` DOUBLE NOT NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `pbundle_inx_prod` ( `product` , `product_bundle` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: products_cat. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `products_cat` ( + `product` varchar(255) NOT NULL, + `catorder` int(11) default NULL, + PRIMARY KEY ( `product` ), + KEY `products_cat_inx_1` ( `catorder` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: products_com. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `products_com` ( + `id` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `product2` varchar(255) NOT NULL, + UNIQUE INDEX `pcom_inx_prod` ( `product`, `product2` ), + PRIMARY KEY ( `id` ), + KEY `products_com_fk_2` ( `product2` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: receipts. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `receipts` ( + `id` varchar(255) NOT NULL, + `money` varchar(255) NOT NULL, + `datenew` datetime NOT NULL, + `attributes` mediumblob default NULL, + `person` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `receipts_fk_money` ( `money` ), + KEY `receipts_inx_1` ( `datenew` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: reservation_customers. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `reservation_customers` ( + `id` varchar(255) NOT NULL, + `customer` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ), + KEY `res_cust_fk_2` ( `customer` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: reservations. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `reservations` ( + `id` varchar(255) NOT NULL, + `created` datetime NOT NULL, + `datenew` datetime NOT NULL default '2016-01-01 00:00:00', + `title` varchar(255) NOT NULL, + `chairs` int(11) NOT NULL, + `isdone` bit(1) NOT NULL, + `description` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `reservations_inx_1` ( `datenew` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: resources. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `resources` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `restype` int(11) NOT NULL, + `content` mediumblob default NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `resources_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: roles. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `roles` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `permissions` mediumblob default NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `roles_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: sharedtickets. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `sharedtickets` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `content` mediumblob default NULL, + `appuser` varchar(255) default NULL, + `pickupid` int(11) NOT NULL default '0', + `locked` varchar(20) default NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: shift_breaks. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `shift_breaks` ( + `id` varchar(255) NOT NULL, + `shiftid` varchar(255) NOT NULL, + `breakid` varchar(255) NOT NULL, + `starttime` timestamp NOT NULL, + `endtime` timestamp NOT NULL, + PRIMARY KEY ( `id` ), + KEY `shift_breaks_breakid` ( `breakid` ), + KEY `shift_breaks_shiftid` ( `shiftid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: shifts. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `shifts` ( + `id` varchar(255) NOT NULL, + `startshift` datetime NOT NULL, + `endshift` datetime default NULL, + `pplid` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: stockcurrent. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `stockcurrent` ( + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) default NULL, + `units` double NOT NULL, + KEY `stockcurrent_attsetinst` ( `attributesetinstance_id` ), + KEY `stockcurrent_fk_1` ( `product` ), + UNIQUE INDEX `stockcurrent_inx` ( `location`, `product`, `attributesetinstance_id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: stockdiary. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `stockdiary` ( + `id` varchar(255) NOT NULL, + `datenew` datetime NOT NULL, + `reason` int(11) NOT NULL, + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) default NULL, + `units` double NOT NULL, + `price` double NOT NULL, + `appuser` varchar(255) default NULL, + `supplier` varchar(255) default NULL, + `supplierdoc` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `stockdiary_attsetinst` ( `attributesetinstance_id` ), + KEY `stockdiary_fk_1` ( `product` ), + KEY `stockdiary_fk_2` ( `location` ), + KEY `stockdiary_inx_1` ( `datenew` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: stocklevel. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `stocklevel` ( + `id` varchar(255) NOT NULL, + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `stocksecurity` double default NULL, + `stockmaximum` double default NULL, + PRIMARY KEY ( `id` ), + KEY `stocklevel_location` ( `location` ), + KEY `stocklevel_product` ( `product` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: suppliers. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `suppliers` ( + `id` varchar(255) NOT NULL, + `searchkey` varchar(255) NOT NULL, + `taxid` varchar(255) default NULL, + `name` varchar(255) NOT NULL, + `maxdebt` double NOT NULL default '0', + `address` varchar(255) default NULL, + `address2` varchar(255) default NULL, + `postal` varchar(255) default NULL, + `city` varchar(255) default NULL, + `region` varchar(255) default NULL, + `country` varchar(255) default NULL, + `firstname` varchar(255) default NULL, + `lastname` varchar(255) default NULL, + `email` varchar(255) default NULL, + `phone` varchar(255) default NULL, + `phone2` varchar(255) default NULL, + `fax` varchar(255) default NULL, + `notes` varchar(255) default NULL, + `visible` bit(1) NOT NULL default b'1', + `curdate` datetime default NULL, + `curdebt` double default '0', + `vatid` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `suppliers_name_inx` ( `name` ), + UNIQUE INDEX `suppliers_skey_inx` ( `searchkey` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: taxcategories. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `taxcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `taxcat_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: taxcustcategories. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `taxcustcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `taxcustcat_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: taxes. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `taxes` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `category` varchar(255) NOT NULL, + `custcategory` varchar(255) default NULL, + `parentid` varchar(255) default NULL, + `rate` double NOT NULL default '0', + `ratecascade` bit(1) NOT NULL default b'0', + `rateorder` int(11) default NULL, + PRIMARY KEY ( `id` ), + KEY `taxes_cat_fk` ( `category` ), + KEY `taxes_custcat_fk` ( `custcategory` ), + UNIQUE INDEX `taxes_name_inx` ( `name` ), + KEY `taxes_taxes_fk` ( `parentid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: taxlines. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `taxlines` ( + `id` varchar(255) NOT NULL, + `receipt` varchar(255) NOT NULL, + `taxid` varchar(255) NOT NULL, + `base` double NOT NULL default '0', + `amount` double NOT NULL default '0', + PRIMARY KEY ( `id` ), + KEY `taxlines_receipt` ( `receipt` ), + KEY `taxlines_tax` ( `taxid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: taxsuppcategories. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `taxsuppcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: thirdparties. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `thirdparties` ( + `id` varchar(255) NOT NULL, + `cif` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `address` varchar(255) default NULL, + `contactcomm` varchar(255) default NULL, + `contactfact` varchar(255) default NULL, + `payrule` varchar(255) default NULL, + `faxnumber` varchar(255) default NULL, + `phonenumber` varchar(255) default NULL, + `mobilenumber` varchar(255) default NULL, + `email` varchar(255) default NULL, + `webpage` varchar(255) default NULL, + `notes` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `thirdparties_cif_inx` ( `cif` ), + UNIQUE INDEX `thirdparties_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: ticketlines. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `ticketlines` ( + `ticket` varchar(255) NOT NULL, + `line` int(11) NOT NULL, + `product` varchar(255) default NULL, + `attributesetinstance_id` varchar(255) default NULL, + `units` double NOT NULL, + `price` double NOT NULL, + `taxid` varchar(255) NOT NULL, + `attributes` mediumblob default NULL, + PRIMARY KEY ( `ticket`, `line` ), + KEY `ticketlines_attsetinst` ( `attributesetinstance_id` ), + KEY `ticketlines_fk_2` ( `product` ), + KEY `ticketlines_fk_3` ( `taxid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: tickets. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `tickets` ( + `id` varchar(255) NOT NULL, + `tickettype` int(11) NOT NULL default '0', + `ticketid` int(11) NOT NULL, + `person` varchar(255) NOT NULL, + `customer` varchar(255) default NULL, + `status` int(11) NOT NULL default '0', + PRIMARY KEY ( `id` ), + KEY `tickets_customers_fk` ( `customer` ), + KEY `tickets_fk_2` ( `person` ), + KEY `tickets_ticketid` ( `tickettype`, `ticketid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: ticketsnum. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `ticketsnum` ( + `id` int(11) NOT NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: ticketsnum_payment. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `ticketsnum_payment` ( + `id` int(11) NOT NULL auto_increment, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: ticketsnum_refund. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `ticketsnum_refund` ( + `id` int(11) NOT NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: uom. Script date: 30/09/2015 13:07:00. */ +CREATE TABLE IF NOT EXISTS `uom` ( + `id` VARCHAR(255) NOT NULL, + `name` VARCHAR(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: vouchers. Script date: 30/09/2015 09:33:33. */ +CREATE TABLE IF NOT EXISTS `vouchers` ( + `id` VARCHAR(100) NOT NULL, + `voucher_number` VARCHAR(100) DEFAULT NULL, + `customer` VARCHAR(100) DEFAULT NULL, + `amount` DOUBLE DEFAULT NULL, + `status` CHAR(1) DEFAULT 'A', + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +-- ---------------------------- +-- FOREIGN KEYS AND CONSTRAINTS +-- ---------------------------- +-- Update foreign keys of attributeinstance +ALTER TABLE `attributeinstance` ADD CONSTRAINT `attinst_att` + FOREIGN KEY ( `attribute_id` ) REFERENCES `attribute` ( `id` ); + +ALTER TABLE `attributeinstance` ADD CONSTRAINT `attinst_set` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of attributesetinstance +ALTER TABLE `attributesetinstance` ADD CONSTRAINT `attsetinst_set` + FOREIGN KEY ( `attributeset_id` ) REFERENCES `attributeset` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of attributeuse +ALTER TABLE `attributeuse` ADD CONSTRAINT `attuse_att` + FOREIGN KEY ( `attribute_id` ) REFERENCES `attribute` ( `id` ); + +ALTER TABLE `attributeuse` ADD CONSTRAINT `attuse_set` + FOREIGN KEY ( `attributeset_id` ) REFERENCES `attributeset` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of attributevalue +ALTER TABLE `attributevalue` ADD CONSTRAINT `attval_att` + FOREIGN KEY ( `attribute_id` ) REFERENCES `attribute` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of categories +ALTER TABLE `categories` ADD CONSTRAINT `categories_fk_1` + FOREIGN KEY ( `parentid` ) REFERENCES `categories` ( `id` ); + +-- Update foreign keys of customers +ALTER TABLE `customers` ADD CONSTRAINT `customers_taxcat` + FOREIGN KEY ( `taxcategory` ) REFERENCES `taxcustcategories` ( `id` ); + +-- Update foreign keys of leaves +ALTER TABLE `leaves` ADD CONSTRAINT `leaves_pplid` + FOREIGN KEY ( `pplid` ) REFERENCES `people` ( `id` ); + +-- Update foreign keys of payments +ALTER TABLE `payments` ADD CONSTRAINT `payments_fk_receipt` + FOREIGN KEY ( `receipt` ) REFERENCES `receipts` ( `id` ); + +-- Update foreign keys of people +ALTER TABLE `people` ADD CONSTRAINT `people_fk_1` + FOREIGN KEY ( `role` ) REFERENCES `roles` ( `id` ); + +-- Update foreign keys of products +ALTER TABLE `products` ADD CONSTRAINT `products_attrset_fk` + FOREIGN KEY ( `attributeset_id` ) REFERENCES `attributeset` ( `id` ); + +ALTER TABLE `products` ADD CONSTRAINT `products_fk_1` + FOREIGN KEY ( `category` ) REFERENCES `categories` ( `id` ); + +ALTER TABLE `products` ADD CONSTRAINT `products_taxcat_fk` + FOREIGN KEY ( `taxcat` ) REFERENCES `taxcategories` ( `id` ); + +-- Update foreign keys of product_bundle +ALTER TABLE `products_bundle` ADD CONSTRAINT `products_bundle_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products`( `id` ); + +ALTER TABLE `products_bundle` ADD CONSTRAINT `products_bundle_fk_2` + FOREIGN KEY ( `product_bundle` ) REFERENCES `products`( `id` ); + +-- Update foreign keys of products_cat +ALTER TABLE `products_cat` ADD CONSTRAINT `products_cat_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +-- Update foreign keys of products_com +ALTER TABLE `products_com` ADD CONSTRAINT `products_com_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `products_com` ADD CONSTRAINT `products_com_fk_2` + FOREIGN KEY ( `product2` ) REFERENCES `products` ( `id` ); + +-- Update foreign keys of receipts +ALTER TABLE `receipts` ADD CONSTRAINT `receipts_fk_money` + FOREIGN KEY ( `money` ) REFERENCES `closedcash` ( `money` ); + +-- Update foreign keys of reservation_customers +ALTER TABLE `reservation_customers` ADD CONSTRAINT `res_cust_fk_1` + FOREIGN KEY ( `id` ) REFERENCES `reservations` ( `id` ); + +ALTER TABLE `reservation_customers` ADD CONSTRAINT `res_cust_fk_2` + FOREIGN KEY ( `customer` ) REFERENCES `customers` ( `id` ); + +-- Update foreign keys of shift_breaks +ALTER TABLE `shift_breaks` ADD CONSTRAINT `shift_breaks_breakid` + FOREIGN KEY ( `breakid` ) REFERENCES `breaks` ( `id` ); + +ALTER TABLE `shift_breaks` ADD CONSTRAINT `shift_breaks_shiftid` + FOREIGN KEY ( `shiftid` ) REFERENCES `shifts` ( `id` ); + +-- Update foreign keys of stockcurrent +ALTER TABLE `stockcurrent` ADD CONSTRAINT `stockcurrent_attsetinst` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ); + +ALTER TABLE `stockcurrent` ADD CONSTRAINT `stockcurrent_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `stockcurrent` ADD CONSTRAINT `stockcurrent_fk_2` + FOREIGN KEY ( `location` ) REFERENCES `locations` ( `id` ); + +-- Update foreign keys of stockdiary +ALTER TABLE `stockdiary` ADD CONSTRAINT `stockdiary_attsetinst` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ); + +ALTER TABLE `stockdiary` ADD CONSTRAINT `stockdiary_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `stockdiary` ADD CONSTRAINT `stockdiary_fk_2` + FOREIGN KEY ( `location` ) REFERENCES `locations` ( `id` ); + +-- Update foreign keys of stocklevel +ALTER TABLE `stocklevel` ADD CONSTRAINT `stocklevel_location` + FOREIGN KEY ( `location` ) REFERENCES `locations` ( `id` ); + +ALTER TABLE `stocklevel` ADD CONSTRAINT `stocklevel_product` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +-- Update foreign keys of taxes +ALTER TABLE `taxes` ADD CONSTRAINT `taxes_cat_fk` + FOREIGN KEY ( `category` ) REFERENCES `taxcategories` ( `id` ); + +ALTER TABLE `taxes` ADD CONSTRAINT `taxes_custcat_fk` + FOREIGN KEY ( `custcategory` ) REFERENCES `taxcustcategories` ( `id` ); + +ALTER TABLE `taxes` ADD CONSTRAINT `taxes_taxes_fk` + FOREIGN KEY ( `parentid` ) REFERENCES `taxes` ( `id` ); + +-- Update foreign keys of taxlines +ALTER TABLE `taxlines` ADD CONSTRAINT `taxlines_receipt` + FOREIGN KEY ( `receipt` ) REFERENCES `receipts` ( `id` ); + +ALTER TABLE `taxlines` ADD CONSTRAINT `taxlines_tax` + FOREIGN KEY ( `taxid` ) REFERENCES `taxes` ( `id` ); + +-- Update foreign keys of ticketlines +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_attsetinst` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ); + +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_fk_2` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_fk_3` + FOREIGN KEY ( `taxid` ) REFERENCES `taxes` ( `id` ); + +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_fk_ticket` + FOREIGN KEY ( `ticket` ) REFERENCES `tickets` ( `id` ); + +-- Update foreign keys of tickets +ALTER TABLE `tickets` ADD CONSTRAINT `tickets_customers_fk` + FOREIGN KEY ( `customer` ) REFERENCES `customers` ( `id` ); + +ALTER TABLE `tickets` ADD CONSTRAINT `tickets_fk_2` + FOREIGN KEY ( `person` ) REFERENCES `people` ( `id` ); + +ALTER TABLE `tickets` ADD CONSTRAINT `tickets_fk_id` + FOREIGN KEY ( `id` ) REFERENCES `receipts` ( `id` ); + +-- ***************************************************************************** \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-clearData.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-clearData.sql new file mode 100644 index 0000000..2039502 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-clearData.sql @@ -0,0 +1,57 @@ +-- uniCenta oPOS - Touch Friendly Point Of Sale +-- Copyright (c) 2009-2017 uniCenta +-- https://unicenta.com +-- +-- This file is part of uniCenta oPOS. +-- +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +/* + * Script created by Jack, uniCenta 21/04/2017 08:00:00 + * Modified 21 Apr 2017 to lowercase + * Called by Transfer for v4.2 after MySQL-create-transfer.sql +*/ + +set foreign_key_checks = 0; + +-- drop default data +delete from people where `id` not in ('0'); +delete from categories; +delete from taxcategories; +delete from taxcustcategories; +delete from taxes; +delete from locations; +delete from floors; +delete from places; +delete from shifts; +delete from breaks; +delete from shift_breaks; +delete from closedcash; +delete from csvimport; +-- delete from customers; +delete FROM draweropened; +delete FROM leaves; +delete FROM lineremoved; +delete FROM payments; +delete FROM products_cat; +delete FROM products_com; +delete FROM products; +delete FROM receipts; +delete FROM roles; +delete FROM stockcurrent; +delete FROM stockdiary; +delete FROM stocklevel; +-- delete FROM suppliers; + +set foreign_key_checks = 0; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-create-sp.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-create-sp.sql new file mode 100644 index 0000000..2b4e011 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-create-sp.sql @@ -0,0 +1,45 @@ + +-- ADD STORED PROCEDURES + +-- Example: +-- call AddTblNotExist(Database(), 'atest'); + +CREATE PROCEDURE `AddTblNotExist`( + IN dbName tinytext, + IN tblName tinytext) +begin + IF NOT EXISTS ( + SELECT * FROM information_schema.TABLES + WHERE table_name=tblName + and table_schema=dbName + ) + THEN + set @ddl=CONCAT('CREATE TABLE ',dbName,'.',tblName); + prepare stmt from @ddl; + execute stmt; + END IF; +end + + +-- Example: +-- call AddColNotExist(Database(), 'atest', 'b', 'int unsigned not null default 1'); + +CREATE PROCEDURE `AddColNotExist`( + IN dbName tinytext, + IN tblName tinytext, + IN fldName tinytext, + IN fldDef text) +begin + IF NOT EXISTS ( + SELECT * FROM information_schema.COLUMNS + WHERE column_name=fldName + and table_name=tblName + and table_schema=dbName + ) + THEN + set @ddl=CONCAT('ALTER TABLE ',dbName,'.',tblName, + ' ADD COLUMN ',fldName,' ',fldDef); + prepare stmt from @ddl; + execute stmt; + END IF; +end \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-create-transfer.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-create-transfer.sql new file mode 100644 index 0000000..6dbfb11 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-create-transfer.sql @@ -0,0 +1,666 @@ +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +/* + * Script created by Jack, uniCenta 23/07/2016 08:00:00 + * + * Create tables IF NOT EXISTS tablename. +*/ + +-- DROP DATABASE IF EXISTS `unitest`; +-- CREATE DATABASE IF NOT EXISTS `unitest`; +-- USE `unitest`; + +/* Header line. Object: applications. Script date: 23/07/2016 08:00:00 */ +-- RECREATE applications -- +DROP TABLE `applications`; +CREATE TABLE IF NOT EXISTS `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `instdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + + +/* Header line. Object: attribute. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `attribute` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: attributeinstance. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `attributeinstance` ( + `id` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `value` varchar(255) default NULL, + KEY `attinst_att` ( `attribute_id` ), + KEY `attinst_set` ( `attributesetinstance_id` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: attributeset. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `attributeset` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: attributesetinstance. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `attributesetinstance` ( + `id` varchar(255) NOT NULL, + `attributeset_id` varchar(255) NOT NULL, + `description` varchar(255) default NULL, + KEY `attsetinst_set` ( `attributeset_id` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: attributeuse. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `attributeuse` ( + `id` varchar(255) NOT NULL, + `attributeset_id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `lineno` int(11) default NULL, + KEY `attuse_att` ( `attribute_id` ), + UNIQUE INDEX `attuse_line` ( `attributeset_id`, `lineno` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: attributevalue. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `attributevalue` ( + `id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `value` varchar(255) default NULL, + KEY `attval_att` ( `attribute_id` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: breaks. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `breaks` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `visible` tinyint(1) NOT NULL default '1', + `notes` varchar(255) default NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: categories. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `categories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `parentid` varchar(255) default NULL, + `image` mediumblob default NULL, + `texttip` varchar(255) default NULL, + `catshowname` smallint(6) NOT NULL default '1', + `catorder` varchar(255) default NULL, + KEY `categories_fk_1` ( `parentid` ), + UNIQUE INDEX `categories_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: closedcash. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `closedcash` ( + `money` varchar(255) NOT NULL, + `host` varchar(255) NOT NULL, + `hostsequence` int(11) NOT NULL, + `datestart` datetime NOT NULL, + `dateend` datetime default NULL, + `nosales` int(11) NOT NULL default '0', + KEY `closedcash_inx_1` ( `datestart` ), + UNIQUE INDEX `closedcash_inx_seq` ( `host`, `hostsequence` ), + PRIMARY KEY ( `money` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: csvimport. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `csvimport` ( + `id` varchar(255) NOT NULL, + `rownumber` varchar(255) default NULL, + `csverror` varchar(255) default NULL, + `reference` varchar(255) default NULL, + `code` varchar(255) default NULL, + `name` varchar(255) default NULL, + `pricebuy` double default NULL, + `pricesell` double default NULL, + `previousbuy` double default NULL, + `previoussell` double default NULL, + `category` varchar(255) default NULL, + `tax` varchar(255) default NULL, + `searchkey` varchar(255) default NULL + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: customers. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `customers` ( + `id` varchar(255) NOT NULL, + `searchkey` varchar(255) NOT NULL, + `taxid` varchar(255) default NULL, + `name` varchar(255) NOT NULL, + `taxcategory` varchar(255) default NULL, + `card` varchar(255) default NULL, + `maxdebt` double NOT NULL default '0', + `address` varchar(255) default NULL, + `address2` varchar(255) default NULL, + `postal` varchar(255) default NULL, + `city` varchar(255) default NULL, + `region` varchar(255) default NULL, + `country` varchar(255) default NULL, + `firstname` varchar(255) default NULL, + `lastname` varchar(255) default NULL, + `email` varchar(255) default NULL, + `phone` varchar(255) default NULL, + `phone2` varchar(255) default NULL, + `fax` varchar(255) default NULL, + `notes` varchar(255) default NULL, + `visible` bit(1) NOT NULL default b'1', + `curdate` datetime default NULL, + `curdebt` double default '0', + `image` mediumblob default NULL, + `isvip` bit(1) NOT NULL default b'0', + `discount` double default '0', + `memodate` datetime default NULL, + KEY `customers_card_inx` ( `card` ), + KEY `customers_name_inx` ( `name` ), + UNIQUE INDEX `customers_skey_inx` ( `searchkey` ), + KEY `customers_taxcat` ( `taxcategory` ), + KEY `customers_taxid_inx` ( `taxid` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: draweropened. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `draweropened` ( + `opendate` timestamp NOT NULL, + `name` varchar(255) default NULL, + `ticketid` varchar(255) default NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: floors. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `floors` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `image` mediumblob default NULL, + UNIQUE INDEX `floors_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: leaves. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `leaves` ( + `id` varchar(255) NOT NULL, + `pplid` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `startdate` datetime NOT NULL, + `enddate` datetime NOT NULL, + `notes` varchar(255) default NULL, + KEY `leaves_pplid` ( `pplid` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: lineremoved. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `lineremoved` ( + `removeddate` timestamp NOT NULL, + `name` varchar(255) default NULL, + `ticketid` varchar(255) default NULL, + `productid` varchar(255) default NULL, + `productname` varchar(255) default NULL, + `units` double NOT NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: locations. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `locations` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `address` varchar(255) default NULL, + UNIQUE INDEX `locations_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: moorers. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `moorers` ( + `vesselname` varchar(255) default NULL, + `size` int(11) default NULL, + `days` int(11) default NULL, + `power` bit(1) NOT NULL default b'0' +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: orders. Script date: 01/01/2017 00:00:01. */ +CREATE TABLE `orders` ( + `id` int(11) NOT NULL, + `orderid` varchar(50) DEFAULT NULL, + `qty` int(11) DEFAULT '1', + `details` varchar(255) DEFAULT NULL, + `attributes` varchar(255) DEFAULT NULL, + `notes` varchar(255) DEFAULT NULL, + `ticketid` varchar(50) DEFAULT NULL, + `ordertime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `displayid` int(11) DEFAULT '1', + `auxiliary` int(11) DEFAULT NULL, + `completetime` timestamp, + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: payments. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `payments` ( + `id` varchar(255) NOT NULL, + `receipt` varchar(255) NOT NULL, + `payment` varchar(255) NOT NULL, + `total` double NOT NULL default '0', + `tip` double default '0', + `transid` varchar(255) default NULL, + `isprocessed` bit(1) default b'0', + `returnmsg` mediumblob default NULL, + `notes` varchar(255) default NULL, + `tendered` double default NULL, + `cardname` varchar(255) default NULL, + `voucher` varchar(255) default NULL, + KEY `payments_fk_receipt` ( `receipt` ), + KEY `payments_inx_1` ( `payment` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: people. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `people` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `apppassword` varchar(255) default NULL, + `card` varchar(255) default NULL, + `role` varchar(255) NOT NULL, + `visible` bit(1) NOT NULL, + `image` mediumblob default NULL, + KEY `people_card_inx` ( `card` ), + KEY `people_fk_1` ( `role` ), + UNIQUE INDEX `people_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: pickup_number. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `pickup_number` ( + `id` int(11) NOT NULL default '0' +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: places. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `places` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `x` int(11) NOT NULL, + `y` int(11) NOT NULL, + `floor` varchar(255) NOT NULL, + `customer` varchar(255) default NULL, + `waiter` varchar(255) default NULL, + `ticketid` varchar(255) default NULL, + `tablemoved` smallint(6) NOT NULL default '0', + UNIQUE INDEX `places_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: products. Script date: 02/04/2016 10:53:00. */ +CREATE TABLE IF NOT EXISTS `products` ( + `id` varchar(255) NOT NULL, + `reference` varchar(255) NOT NULL, + `code` varchar(255) NOT NULL, + `codetype` varchar(255) default NULL, + `name` varchar(255) NOT NULL, + `pricebuy` double NOT NULL default '0', + `pricesell` double NOT NULL default '0', + `category` varchar(255) NOT NULL, + `taxcat` varchar(255) NOT NULL, + `attributeset_id` varchar(255) default NULL, + `stockcost` double NOT NULL default '0', + `stockvolume` double NOT NULL default '0', + `image` mediumblob default NULL, + `iscom` bit(1) NOT NULL default b'0', + `isscale` bit(1) NOT NULL default b'0', + `isconstant` bit(1) NOT NULL default b'0', + `printkb` bit(1) NOT NULL default b'0', + `sendstatus` bit(1) NOT NULL default b'0', + `isservice` bit(1) NOT NULL default b'0', + `attributes` mediumblob default NULL, + `display` varchar(255) default NULL, + `isvprice` smallint(6) NOT NULL default '0', + `isverpatrib` smallint(6) NOT NULL default '0', + `texttip` varchar(255) default NULL, + `warranty` smallint(6) NOT NULL default '0', + `stockunits` double NOT NULL default '0', + `printto` varchar(255) default '1', + `supplier` varchar(255) default NULL, + `uom` varchar(255) default '0', + `memodate` datetime default NULL, + + PRIMARY KEY ( `id` ), + KEY `products_attrset_fx` ( `attributeset_id` ), + KEY `products_fk_1` ( `category` ), + UNIQUE INDEX `products_inx_0` ( `reference` ), + UNIQUE INDEX `products_inx_1` ( `code` ), + INDEX `products_name_inx` ( `name` ), + KEY `products_taxcat_fk` ( `taxcat` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: products_cat. Script date: 11/05/2016 05:25:00. */ +CREATE TABLE IF NOT EXISTS `products_bundle` ( + `id` varchar(255) NOT NULL, + `product` VARCHAR(255) NOT NULL, + `product_bundle` VARCHAR(255) NOT NULL, + `quantity` DOUBLE NOT NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `pbundle_inx_prod` ( `product` , `product_bundle` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: products_cat. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `products_cat` ( + `product` varchar(255) NOT NULL, + `catorder` int(11) default NULL, + PRIMARY KEY ( `product` ), + KEY `products_cat_inx_1` ( `catorder` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: products_com. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `products_com` ( + `id` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `product2` varchar(255) NOT NULL, + UNIQUE INDEX `pcom_inx_prod` ( `product`, `product2` ), + PRIMARY KEY ( `id` ), + KEY `products_com_fk_2` ( `product2` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: receipts. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `receipts` ( + `id` varchar(255) NOT NULL, + `money` varchar(255) NOT NULL, + `datenew` datetime NOT NULL, + `attributes` mediumblob default NULL, + `person` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `receipts_fk_money` ( `money` ), + KEY `receipts_inx_1` ( `datenew` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: reservation_customers. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `reservation_customers` ( + `id` varchar(255) NOT NULL, + `customer` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ), + KEY `res_cust_fk_2` ( `customer` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: reservations. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `reservations` ( + `id` varchar(255) NOT NULL, + `created` datetime NOT NULL, + `datenew` datetime NOT NULL default '2015-01-01 00:00:00', + `title` varchar(255) NOT NULL, + `chairs` int(11) NOT NULL, + `isdone` bit(1) NOT NULL, + `description` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `reservations_inx_1` ( `datenew` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: resources. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `resources` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `restype` int(11) NOT NULL, + `content` mediumblob default NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `resources_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: roles. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `roles` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `permissions` mediumblob default NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `roles_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: sharedtickets. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `sharedtickets` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `content` mediumblob default NULL, + `appuser` varchar(255) default NULL, + `pickupid` int(11) NOT NULL default '0', + `locked` varchar(20) default NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: shift_breaks. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `shift_breaks` ( + `id` varchar(255) NOT NULL, + `shiftid` varchar(255) NOT NULL, + `breakid` varchar(255) NOT NULL, + `starttime` timestamp NOT NULL, + `endtime` timestamp NOT NULL, + PRIMARY KEY ( `id` ), + KEY `shift_breaks_breakid` ( `breakid` ), + KEY `shift_breaks_shiftid` ( `shiftid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: shifts. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `shifts` ( + `id` varchar(255) NOT NULL, + `startshift` datetime NOT NULL, + `endshift` datetime default NULL, + `pplid` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: stockcurrent. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `stockcurrent` ( + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) default NULL, + `units` double NOT NULL, + KEY `stockcurrent_attsetinst` ( `attributesetinstance_id` ), + KEY `stockcurrent_fk_1` ( `product` ), + UNIQUE INDEX `stockcurrent_inx` ( `location`, `product`, `attributesetinstance_id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: stockdiary. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `stockdiary` ( + `id` varchar(255) NOT NULL, + `datenew` datetime NOT NULL, + `reason` int(11) NOT NULL, + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) default NULL, + `units` double NOT NULL, + `price` double NOT NULL, + `appuser` varchar(255) default NULL, + `supplier` varchar(255) default NULL, + `supplierdoc` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `stockdiary_attsetinst` ( `attributesetinstance_id` ), + KEY `stockdiary_fk_1` ( `product` ), + KEY `stockdiary_fk_2` ( `location` ), + KEY `stockdiary_inx_1` ( `datenew` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: stocklevel. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `stocklevel` ( + `id` varchar(255) NOT NULL, + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `stocksecurity` double default NULL, + `stockmaximum` double default NULL, + PRIMARY KEY ( `id` ), + KEY `stocklevel_location` ( `location` ), + KEY `stocklevel_product` ( `product` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: suppliers. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `suppliers` ( + `id` varchar(255) NOT NULL, + `searchkey` varchar(255) NOT NULL, + `taxid` varchar(255) default NULL, + `name` varchar(255) NOT NULL, + `maxdebt` double NOT NULL default '0', + `address` varchar(255) default NULL, + `address2` varchar(255) default NULL, + `postal` varchar(255) default NULL, + `city` varchar(255) default NULL, + `region` varchar(255) default NULL, + `country` varchar(255) default NULL, + `firstname` varchar(255) default NULL, + `lastname` varchar(255) default NULL, + `email` varchar(255) default NULL, + `phone` varchar(255) default NULL, + `phone2` varchar(255) default NULL, + `fax` varchar(255) default NULL, + `notes` varchar(255) default NULL, + `visible` bit(1) NOT NULL default b'1', + `curdate` datetime default NULL, + `curdebt` double default '0', + `vatid` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `suppliers_name_inx` ( `name` ), + UNIQUE INDEX `suppliers_skey_inx` ( `searchkey` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: taxcategories. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `taxcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `taxcat_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: taxcustcategories. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `taxcustcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `taxcustcat_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: taxes. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `taxes` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `category` varchar(255) NOT NULL, + `custcategory` varchar(255) default NULL, + `parentid` varchar(255) default NULL, + `rate` double NOT NULL default '0', + `ratecascade` bit(1) NOT NULL default b'0', + `rateorder` int(11) default NULL, + PRIMARY KEY ( `id` ), + KEY `taxes_cat_fk` ( `category` ), + KEY `taxes_custcat_fk` ( `custcategory` ), + UNIQUE INDEX `taxes_name_inx` ( `name` ), + KEY `taxes_taxes_fk` ( `parentid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: taxlines. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `taxlines` ( + `id` varchar(255) NOT NULL, + `receipt` varchar(255) NOT NULL, + `taxid` varchar(255) NOT NULL, + `base` double NOT NULL default '0', + `amount` double NOT NULL default '0', + PRIMARY KEY ( `id` ), + KEY `taxlines_receipt` ( `receipt` ), + KEY `taxlines_tax` ( `taxid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: taxsuppcategories. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `taxsuppcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: thirdparties. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `thirdparties` ( + `id` varchar(255) NOT NULL, + `cif` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `address` varchar(255) default NULL, + `contactcomm` varchar(255) default NULL, + `contactfact` varchar(255) default NULL, + `payrule` varchar(255) default NULL, + `faxnumber` varchar(255) default NULL, + `phonenumber` varchar(255) default NULL, + `mobilenumber` varchar(255) default NULL, + `email` varchar(255) default NULL, + `webpage` varchar(255) default NULL, + `notes` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `thirdparties_cif_inx` ( `cif` ), + UNIQUE INDEX `thirdparties_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: ticketlines. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `ticketlines` ( + `ticket` varchar(255) NOT NULL, + `line` int(11) NOT NULL, + `product` varchar(255) default NULL, + `attributesetinstance_id` varchar(255) default NULL, + `units` double NOT NULL, + `price` double NOT NULL, + `taxid` varchar(255) NOT NULL, + `attributes` mediumblob default NULL, + PRIMARY KEY ( `ticket`, `line` ), + KEY `ticketlines_attsetinst` ( `attributesetinstance_id` ), + KEY `ticketlines_fk_2` ( `product` ), + KEY `ticketlines_fk_3` ( `taxid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: tickets. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `tickets` ( + `id` varchar(255) NOT NULL, + `tickettype` int(11) NOT NULL default '0', + `ticketid` int(11) NOT NULL, + `person` varchar(255) NOT NULL, + `customer` varchar(255) default NULL, + `status` int(11) NOT NULL default '0', + PRIMARY KEY ( `id` ), + KEY `tickets_customers_fk` ( `customer` ), + KEY `tickets_fk_2` ( `person` ), + KEY `tickets_ticketid` ( `tickettype`, `ticketid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: ticketsnum. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `ticketsnum` ( + `id` int(11) NOT NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: ticketsnum_payment. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `ticketsnum_payment` ( +-- `id` int(11) NOT NULL auto_increment, + `id` int(11) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: ticketsnum_refund. Script date: 23/07/2016 08:00:00 */ +CREATE TABLE IF NOT EXISTS `ticketsnum_refund` ( + `id` int(11) NOT NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: uom. Script date: 30/09/2015 13:07:00. */ +CREATE TABLE IF NOT EXISTS `uom` ( + `id` VARCHAR(255) NOT NULL, + `name` VARCHAR(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +/* Header line. Object: vouchers. Script date: 30/09/2015 09:33:33. */ +CREATE TABLE IF NOT EXISTS `vouchers` ( + `id` VARCHAR(100) NOT NULL, + `voucher_number` VARCHAR(100) DEFAULT NULL, + `customer` VARCHAR(100) DEFAULT NULL, + `amount` DOUBLE DEFAULT NULL, + `status` CHAR(1) DEFAULT 'A', + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-create.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-create.sql new file mode 100644 index 0000000..3148f6c --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-create.sql @@ -0,0 +1,978 @@ +/* Header line. Object: applications. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `instdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: attribute. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `attribute` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: attributeinstance. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `attributeinstance` ( + `id` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `value` varchar(255) default NULL, + KEY `attinst_att` ( `attribute_id` ), + KEY `attinst_set` ( `attributesetinstance_id` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: attributeset. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `attributeset` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: attributesetinstance. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `attributesetinstance` ( + `id` varchar(255) NOT NULL, + `attributeset_id` varchar(255) NOT NULL, + `description` varchar(255) default NULL, + KEY `attsetinst_set` ( `attributeset_id` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: attributeuse. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `attributeuse` ( + `id` varchar(255) NOT NULL, + `attributeset_id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `lineno` int(11) default NULL, + KEY `attuse_att` ( `attribute_id` ), + UNIQUE INDEX `attuse_line` ( `attributeset_id`, `lineno` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: attributevalue. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `attributevalue` ( + `id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `value` varchar(255) default NULL, + KEY `attval_att` ( `attribute_id` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: breaks. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `breaks` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `visible` tinyint(1) NOT NULL default '1', + `notes` varchar(255) default NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: categories. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `categories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `parentid` varchar(255) default NULL, + `image` mediumblob default NULL, + `texttip` varchar(255) default NULL, + `catshowname` smallint(6) NOT NULL default '1', + `catorder` varchar(255) default NULL, + KEY `categories_fk_1` ( `parentid` ), + UNIQUE INDEX `categories_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: closedcash. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `closedcash` ( + `money` varchar(255) NOT NULL, + `host` varchar(255) NOT NULL, + `hostsequence` int(11) NOT NULL, + `datestart` datetime NOT NULL, + `dateend` datetime default NULL, + `nosales` int(11) NOT NULL default '0', + KEY `closedcash_inx_1` ( `datestart` ), + UNIQUE INDEX `closedcash_inx_seq` ( `host`, `hostsequence` ), + PRIMARY KEY ( `money` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: csvimport. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `csvimport` ( + `id` varchar(255) NOT NULL, + `rownumber` varchar(255) default NULL, + `csverror` varchar(255) default NULL, + `reference` varchar(255) default NULL, + `code` varchar(255) default NULL, + `name` varchar(255) default NULL, + `pricebuy` double default NULL, + `pricesell` double default NULL, + `previousbuy` double default NULL, + `previoussell` double default NULL, + `category` varchar(255) default NULL, + `tax` varchar(255) default NULL, + `searchkey` varchar(255) default NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: customers. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `customers` ( + `id` varchar(255) NOT NULL, + `searchkey` varchar(255) NOT NULL, + `taxid` varchar(255) default NULL, + `name` varchar(255) NOT NULL, + `taxcategory` varchar(255) default NULL, + `card` varchar(255) default NULL, + `maxdebt` double NOT NULL default '0', + `address` varchar(255) default NULL, + `address2` varchar(255) default NULL, + `postal` varchar(255) default NULL, + `city` varchar(255) default NULL, + `region` varchar(255) default NULL, + `country` varchar(255) default NULL, + `firstname` varchar(255) default NULL, + `lastname` varchar(255) default NULL, + `email` varchar(255) default NULL, + `phone` varchar(255) default NULL, + `phone2` varchar(255) default NULL, + `fax` varchar(255) default NULL, + `notes` varchar(255) default NULL, + `visible` bit(1) NOT NULL default b'1', + `curdate` datetime default NULL, + `curdebt` double default '0', + `image` mediumblob default NULL, + `isvip` bit(1) NOT NULL default b'0', + `discount` double default '0', + `memodate` datetime default '2000-01-01 00:00:01', + KEY `customers_card_inx` ( `card` ), + KEY `customers_name_inx` ( `name` ), + UNIQUE INDEX `customers_skey_inx` ( `searchkey` ), + KEY `customers_taxcat` ( `taxcategory` ), + KEY `customers_taxid_inx` ( `taxid` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: draweropened. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `draweropened` ( + `opendate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `name` varchar(255) default NULL, + `ticketid` varchar(255) default NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: floors. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `floors` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `image` mediumblob default NULL, + UNIQUE INDEX `floors_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: leaves. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `leaves` ( + `id` varchar(255) NOT NULL, + `pplid` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `startdate` datetime NOT NULL, + `enddate` datetime NOT NULL, + `notes` varchar(255) default NULL, + KEY `leaves_pplid` ( `pplid` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: lineremoved. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `lineremoved` ( + `removeddate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `name` varchar(255) default NULL, + `ticketid` varchar(255) default NULL, + `productid` varchar(255) default NULL, + `productname` varchar(255) default NULL, + `units` double NOT NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: locations. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `locations` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `address` varchar(255) default NULL, + UNIQUE INDEX `locations_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: moorers. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `moorers` ( + `vesselname` varchar(255) default NULL, + `size` int(11) default NULL, + `days` int(11) default NULL, + `power` bit(1) NOT NULL default b'0' +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +CREATE TABLE IF NOT EXISTS `orders` ( + `id` MEDIUMINT NOT NULL AUTO_INCREMENT, + `orderid` varchar(50) DEFAULT NULL, + `qty` int(11) DEFAULT '1', + `details` varchar(255) DEFAULT NULL, + `attributes` varchar(255) DEFAULT NULL, + `notes` varchar(255) DEFAULT NULL, + `ticketid` varchar(50) DEFAULT NULL, + `ordertime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `displayid` int(11) DEFAULT '1', + `auxiliary` int(11) DEFAULT NULL, + `completetime` timestamp NULL, + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: payments. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `payments` ( + `id` varchar(255) NOT NULL, + `receipt` varchar(255) NOT NULL, + `payment` varchar(255) NOT NULL, + `total` double NOT NULL default '0', + `tip` double default '0', + `transid` varchar(255) default NULL, + `isprocessed` bit(1) default b'0', + `returnmsg` mediumblob default NULL, + `notes` varchar(255) default NULL, + `tendered` double default NULL, + `cardname` varchar(255) default NULL, + `voucher` varchar(255) default NULL, + KEY `payments_fk_receipt` ( `receipt` ), + KEY `payments_inx_1` ( `payment` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: people. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `people` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `apppassword` varchar(255) default NULL, + `card` varchar(255) default NULL, + `role` varchar(255) NOT NULL, + `visible` bit(1) NOT NULL, + `image` mediumblob default NULL, + KEY `people_card_inx` ( `card` ), + KEY `people_fk_1` ( `role` ), + UNIQUE INDEX `people_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: pickup_number. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `pickup_number` ( + `id` int(11) NOT NULL default '0' +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: places. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `places` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `seats` varchar(6) NOT NULL DEFAULT '1', + `x` int(11) NOT NULL, + `y` int(11) NOT NULL, + `floor` varchar(255) NOT NULL, + `customer` varchar(255) default NULL, + `waiter` varchar(255) default NULL, + `ticketid` varchar(255) default NULL, + `tablemoved` smallint(6) NOT NULL default '0', + `width` int(11) NOT NULL, + `height` int(11) NOT NULL, + `guests` int(11) DEFAULT 0, + `occupied` datetime DEFAULT NULL, + UNIQUE INDEX `places_name_inx` ( `name` ), + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: products. Script date: 02/04/2016 10:53:00. */ +CREATE TABLE `products` ( + `id` varchar(255) NOT NULL, + `reference` varchar(255) NOT NULL, + `code` varchar(255) NOT NULL, + `codetype` varchar(255) default NULL, + `name` varchar(255) NOT NULL, + `pricebuy` double NOT NULL default '0', + `pricesell` double NOT NULL default '0', + `category` varchar(255) NOT NULL, + `taxcat` varchar(255) NOT NULL, + `attributeset_id` varchar(255) default NULL, + `stockcost` double NOT NULL default '0', + `stockvolume` double NOT NULL default '0', + `image` mediumblob default NULL, + `iscom` bit(1) NOT NULL default b'0', + `isscale` bit(1) NOT NULL default b'0', + `isconstant` bit(1) NOT NULL default b'0', + `printkb` bit(1) NOT NULL default b'0', + `sendstatus` bit(1) NOT NULL default b'0', + `isservice` bit(1) NOT NULL default b'0', + `attributes` mediumblob default NULL, + `display` varchar(255) default NULL, + `isvprice` smallint(6) NOT NULL default '0', + `isverpatrib` smallint(6) NOT NULL default '0', + `texttip` varchar(255) default NULL, + `warranty` smallint(6) NOT NULL default '0', + `stockunits` double NOT NULL default '0', + `printto` varchar(255) default '1', + `supplier` varchar(255) default NULL, + `uom` varchar(255) default '0', + `memodate` datetime default '2018-01-01 00:00:01', + + PRIMARY KEY ( `id` ), + KEY `products_attrset_fx` ( `attributeset_id` ), + KEY `products_fk_1` ( `category` ), + UNIQUE INDEX `products_inx_0` ( `reference` ), + UNIQUE INDEX `products_inx_1` ( `code` ), + INDEX `products_name_inx` ( `name` ), + KEY `products_taxcat_fk` ( `taxcat` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: products_cat. Script date: 11/05/2016 05:25:00. */ +CREATE TABLE `products_bundle` ( + `id` varchar(255) NOT NULL, + `product` VARCHAR(255) NOT NULL, + `product_bundle` VARCHAR(255) NOT NULL, + `quantity` DOUBLE NOT NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `pbundle_inx_prod` ( `product` , `product_bundle` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: products_cat. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `products_cat` ( + `product` varchar(255) NOT NULL, + `catorder` int(11) default NULL, + PRIMARY KEY ( `product` ), + KEY `products_cat_inx_1` ( `catorder` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: products_com. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `products_com` ( + `id` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `product2` varchar(255) NOT NULL, + UNIQUE INDEX `pcom_inx_prod` ( `product`, `product2` ), + PRIMARY KEY ( `id` ), + KEY `products_com_fk_2` ( `product2` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: receipts. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `receipts` ( + `id` varchar(255) NOT NULL, + `money` varchar(255) NOT NULL, + `datenew` datetime NOT NULL, + `attributes` mediumblob default NULL, + `person` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `receipts_fk_money` ( `money` ), + KEY `receipts_inx_1` ( `datenew` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: reservation_customers. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `reservation_customers` ( + `id` varchar(255) NOT NULL, + `customer` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ), + KEY `res_cust_fk_2` ( `customer` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: reservations. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `reservations` ( + `id` varchar(255) NOT NULL, + `created` datetime NOT NULL, + `datenew` datetime NOT NULL default '2018-01-01 00:00:00', + `title` varchar(255) NOT NULL, + `chairs` int(11) NOT NULL, + `isdone` bit(1) NOT NULL, + `description` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `reservations_inx_1` ( `datenew` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: resources. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `resources` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `restype` int(11) NOT NULL, + `content` mediumblob default NULL, + `version` varchar(10) default NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `resources_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: roles. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `roles` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `permissions` mediumblob default NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `roles_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: sharedtickets. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `sharedtickets` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `content` mediumblob default NULL, + `appuser` varchar(255) default NULL, + `pickupid` int(11) NOT NULL default '0', + `locked` varchar(20) default NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: shift_breaks. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `shift_breaks` ( + `id` varchar(255) NOT NULL, + `shiftid` varchar(255) NOT NULL, + `breakid` varchar(255) NOT NULL, + `starttime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `endtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ), + KEY `shift_breaks_breakid` ( `breakid` ), + KEY `shift_breaks_shiftid` ( `shiftid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: shifts. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `shifts` ( + `id` varchar(255) NOT NULL, + `startshift` datetime NOT NULL, + `endshift` datetime default NULL, + `pplid` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: stockcurrent. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `stockcurrent` ( + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) default NULL, + `units` double NOT NULL, + KEY `stockcurrent_attsetinst` ( `attributesetinstance_id` ), + KEY `stockcurrent_fk_1` ( `product` ), + UNIQUE INDEX `stockcurrent_inx` ( `location`, `product`, `attributesetinstance_id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: stockdiary. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `stockdiary` ( + `id` varchar(255) NOT NULL, + `datenew` datetime NOT NULL, + `reason` int(11) NOT NULL, + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) default NULL, + `units` double NOT NULL, + `price` double NOT NULL, + `appuser` varchar(255) default NULL, + `supplier` varchar(255) default NULL, + `supplierdoc` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `stockdiary_attsetinst` ( `attributesetinstance_id` ), + KEY `stockdiary_fk_1` ( `product` ), + KEY `stockdiary_fk_2` ( `location` ), + KEY `stockdiary_inx_1` ( `datenew` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: stocklevel. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `stocklevel` ( + `id` varchar(255) NOT NULL, + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `stocksecurity` double default NULL, + `stockmaximum` double default NULL, + PRIMARY KEY ( `id` ), + KEY `stocklevel_location` ( `location` ), + KEY `stocklevel_product` ( `product` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: suppliers. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `suppliers` ( + `id` varchar(255) NOT NULL, + `searchkey` varchar(255) NOT NULL, + `taxid` varchar(255) default NULL, + `name` varchar(255) NOT NULL, + `maxdebt` double NOT NULL default '0', + `address` varchar(255) default NULL, + `address2` varchar(255) default NULL, + `postal` varchar(255) default NULL, + `city` varchar(255) default NULL, + `region` varchar(255) default NULL, + `country` varchar(255) default NULL, + `firstname` varchar(255) default NULL, + `lastname` varchar(255) default NULL, + `email` varchar(255) default NULL, + `phone` varchar(255) default NULL, + `phone2` varchar(255) default NULL, + `fax` varchar(255) default NULL, + `notes` varchar(255) default NULL, + `visible` bit(1) NOT NULL default b'1', + `curdate` datetime default NULL, + `curdebt` double default '0', + `vatid` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + KEY `suppliers_name_inx` ( `name` ), + UNIQUE INDEX `suppliers_skey_inx` ( `searchkey` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: taxcategories. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `taxcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `taxcat_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: taxcustcategories. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `taxcustcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `taxcustcat_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: taxes. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `taxes` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `category` varchar(255) NOT NULL, + `custcategory` varchar(255) default NULL, + `parentid` varchar(255) default NULL, + `rate` double NOT NULL default '0', + `ratecascade` bit(1) NOT NULL default b'0', + `rateorder` int(11) default NULL, + PRIMARY KEY ( `id` ), + KEY `taxes_cat_fk` ( `category` ), + KEY `taxes_custcat_fk` ( `custcategory` ), + UNIQUE INDEX `taxes_name_inx` ( `name` ), + KEY `taxes_taxes_fk` ( `parentid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: taxlines. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `taxlines` ( + `id` varchar(255) NOT NULL, + `receipt` varchar(255) NOT NULL, + `taxid` varchar(255) NOT NULL, + `base` double NOT NULL default '0', + `amount` double NOT NULL default '0', + PRIMARY KEY ( `id` ), + KEY `taxlines_receipt` ( `receipt` ), + KEY `taxlines_tax` ( `taxid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: taxsuppcategories. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `taxsuppcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: thirdparties. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `thirdparties` ( + `id` varchar(255) NOT NULL, + `cif` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `address` varchar(255) default NULL, + `contactcomm` varchar(255) default NULL, + `contactfact` varchar(255) default NULL, + `payrule` varchar(255) default NULL, + `faxnumber` varchar(255) default NULL, + `phonenumber` varchar(255) default NULL, + `mobilenumber` varchar(255) default NULL, + `email` varchar(255) default NULL, + `webpage` varchar(255) default NULL, + `notes` varchar(255) default NULL, + PRIMARY KEY ( `id` ), + UNIQUE INDEX `thirdparties_cif_inx` ( `cif` ), + UNIQUE INDEX `thirdparties_name_inx` ( `name` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: ticketlines. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `ticketlines` ( + `ticket` varchar(255) NOT NULL, + `line` int(11) NOT NULL, + `product` varchar(255) default NULL, + `attributesetinstance_id` varchar(255) default NULL, + `units` double NOT NULL, + `price` double NOT NULL, + `taxid` varchar(255) NOT NULL, + `attributes` mediumblob default NULL, + PRIMARY KEY ( `ticket`, `line` ), + KEY `ticketlines_attsetinst` ( `attributesetinstance_id` ), + KEY `ticketlines_fk_2` ( `product` ), + KEY `ticketlines_fk_3` ( `taxid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: tickets. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `tickets` ( + `id` varchar(255) NOT NULL, + `tickettype` int(11) NOT NULL default '0', + `ticketid` int(11) NOT NULL, + `person` varchar(255) NOT NULL, + `customer` varchar(255) default NULL, + `status` int(11) NOT NULL default '0', + PRIMARY KEY ( `id` ), + KEY `tickets_customers_fk` ( `customer` ), + KEY `tickets_fk_2` ( `person` ), + KEY `tickets_ticketid` ( `tickettype`, `ticketid` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: ticketsnum. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `ticketsnum` ( + `id` int(11) NOT NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: ticketsnum_payment. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `ticketsnum_payment` ( + `id` int(11) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: ticketsnum_refund. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `ticketsnum_refund` ( + `id` int(11) NOT NULL +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: uom. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `uom` ( + `id` VARCHAR(255) NOT NULL, + `name` VARCHAR(255) NOT NULL, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +/* Header line. Object: vouchers. Script date: 23/01/2018 08:00:00 */ +CREATE TABLE `vouchers` ( + `id` VARCHAR(100) NOT NULL, + `voucher_number` VARCHAR(100) DEFAULT NULL, + `customer` VARCHAR(100) DEFAULT NULL, + `amount` DOUBLE DEFAULT NULL, + `status` CHAR(1) DEFAULT 'A', + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; + +-- Update foreign keys of attributeinstance +ALTER TABLE `attributeinstance` ADD CONSTRAINT `attinst_att` + FOREIGN KEY ( `attribute_id` ) REFERENCES `attribute` ( `id` ); + +ALTER TABLE `attributeinstance` ADD CONSTRAINT `attinst_set` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of attributesetinstance +ALTER TABLE `attributesetinstance` ADD CONSTRAINT `attsetinst_set` + FOREIGN KEY ( `attributeset_id` ) REFERENCES `attributeset` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of attributeuse +ALTER TABLE `attributeuse` ADD CONSTRAINT `attuse_att` + FOREIGN KEY ( `attribute_id` ) REFERENCES `attribute` ( `id` ); + +ALTER TABLE `attributeuse` ADD CONSTRAINT `attuse_set` + FOREIGN KEY ( `attributeset_id` ) REFERENCES `attributeset` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of attributevalue +ALTER TABLE `attributevalue` ADD CONSTRAINT `attval_att` + FOREIGN KEY ( `attribute_id` ) REFERENCES `attribute` ( `id` ) ON DELETE CASCADE; + +-- Update foreign keys of categories +ALTER TABLE `categories` ADD CONSTRAINT `categories_fk_1` + FOREIGN KEY ( `parentid` ) REFERENCES `categories` ( `id` ); + +-- Update foreign keys of customers + ALTER TABLE `customers` ADD CONSTRAINT `customers_taxcat` + FOREIGN KEY ( `taxcategory` ) REFERENCES `taxcustcategories` ( `id` ); + +-- Update foreign keys of leaves +ALTER TABLE `leaves` ADD CONSTRAINT `leaves_pplid` + FOREIGN KEY ( `pplid` ) REFERENCES `people` ( `id` ); + +-- Update foreign keys of payments +ALTER TABLE `payments` ADD CONSTRAINT `payments_fk_receipt` + FOREIGN KEY ( `receipt` ) REFERENCES `receipts` ( `id` ); + +-- Update foreign keys of people +ALTER TABLE `people` ADD CONSTRAINT `people_fk_1` + FOREIGN KEY ( `role` ) REFERENCES `roles` ( `id` ); + +-- Update foreign keys of products +ALTER TABLE `products` ADD CONSTRAINT `products_attrset_fk` + FOREIGN KEY ( `attributeset_id` ) REFERENCES `attributeset` ( `id` ); + +ALTER TABLE `products` ADD CONSTRAINT `products_fk_1` + FOREIGN KEY ( `category` ) REFERENCES `categories` ( `id` ); + +ALTER TABLE `products` ADD CONSTRAINT `products_taxcat_fk` + FOREIGN KEY ( `taxcat` ) REFERENCES `taxcategories` ( `id` ); + +-- Update foreign keys of product_bundle +ALTER TABLE `products_bundle` ADD CONSTRAINT `products_bundle_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products`( `id` ); + +ALTER TABLE `products_bundle` ADD CONSTRAINT `products_bundle_fk_2` + FOREIGN KEY ( `product_bundle` ) REFERENCES `products`( `id` ); + +-- Update foreign keys of products_cat +ALTER TABLE `products_cat` ADD CONSTRAINT `products_cat_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +-- Update foreign keys of products_com +ALTER TABLE `products_com` ADD CONSTRAINT `products_com_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `products_com` ADD CONSTRAINT `products_com_fk_2` + FOREIGN KEY ( `product2` ) REFERENCES `products` ( `id` ); + +-- Update foreign keys of receipts +ALTER TABLE `receipts` ADD CONSTRAINT `receipts_fk_money` + FOREIGN KEY ( `money` ) REFERENCES `closedcash` ( `money` ); + +-- Update foreign keys of reservation_customers +ALTER TABLE `reservation_customers` ADD CONSTRAINT `res_cust_fk_1` + FOREIGN KEY ( `id` ) REFERENCES `reservations` ( `id` ); + +ALTER TABLE `reservation_customers` ADD CONSTRAINT `res_cust_fk_2` + FOREIGN KEY ( `customer` ) REFERENCES `customers` ( `id` ); + +-- Update foreign keys of shift_breaks +ALTER TABLE `shift_breaks` ADD CONSTRAINT `shift_breaks_breakid` + FOREIGN KEY ( `breakid` ) REFERENCES `breaks` ( `id` ); + +ALTER TABLE `shift_breaks` ADD CONSTRAINT `shift_breaks_shiftid` + FOREIGN KEY ( `shiftid` ) REFERENCES `shifts` ( `id` ); + +-- Update foreign keys of stockcurrent +ALTER TABLE `stockcurrent` ADD CONSTRAINT `stockcurrent_attsetinst` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ); + +ALTER TABLE `stockcurrent` ADD CONSTRAINT `stockcurrent_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `stockcurrent` ADD CONSTRAINT `stockcurrent_fk_2` + FOREIGN KEY ( `location` ) REFERENCES `locations` ( `id` ); + +-- Update foreign keys of stockdiary +ALTER TABLE `stockdiary` ADD CONSTRAINT `stockdiary_attsetinst` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ); + +ALTER TABLE `stockdiary` ADD CONSTRAINT `stockdiary_fk_1` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `stockdiary` ADD CONSTRAINT `stockdiary_fk_2` + FOREIGN KEY ( `location` ) REFERENCES `locations` ( `id` ); + +-- Update foreign keys of stocklevel +ALTER TABLE `stocklevel` ADD CONSTRAINT `stocklevel_location` + FOREIGN KEY ( `location` ) REFERENCES `locations` ( `id` ); + +ALTER TABLE `stocklevel` ADD CONSTRAINT `stocklevel_product` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +-- Update foreign keys of taxes +ALTER TABLE `taxes` ADD CONSTRAINT `taxes_cat_fk` + FOREIGN KEY ( `category` ) REFERENCES `taxcategories` ( `id` ); + +ALTER TABLE `taxes` ADD CONSTRAINT `taxes_custcat_fk` + FOREIGN KEY ( `custcategory` ) REFERENCES `taxcustcategories` ( `id` ); + +ALTER TABLE `taxes` ADD CONSTRAINT `taxes_taxes_fk` + FOREIGN KEY ( `parentid` ) REFERENCES `taxes` ( `id` ); + +-- Update foreign keys of taxlines +ALTER TABLE `taxlines` ADD CONSTRAINT `taxlines_receipt` + FOREIGN KEY ( `receipt` ) REFERENCES `receipts` ( `id` ); + +ALTER TABLE `taxlines` ADD CONSTRAINT `taxlines_tax` + FOREIGN KEY ( `taxid` ) REFERENCES `taxes` ( `id` ); + +-- Update foreign keys of ticketlines +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_attsetinst` + FOREIGN KEY ( `attributesetinstance_id` ) REFERENCES `attributesetinstance` ( `id` ); + +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_fk_2` + FOREIGN KEY ( `product` ) REFERENCES `products` ( `id` ); + +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_fk_3` + FOREIGN KEY ( `taxid` ) REFERENCES `taxes` ( `id` ); + +ALTER TABLE `ticketlines` ADD CONSTRAINT `ticketlines_fk_ticket` + FOREIGN KEY ( `ticket` ) REFERENCES `tickets` ( `id` ); + +-- Update foreign keys of tickets +ALTER TABLE `tickets` ADD CONSTRAINT `tickets_customers_fk` + FOREIGN KEY ( `customer` ) REFERENCES `customers` ( `id` ); + +ALTER TABLE `tickets` ADD CONSTRAINT `tickets_fk_2` + FOREIGN KEY ( `person` ) REFERENCES `people` ( `id` ); + +ALTER TABLE `tickets` ADD CONSTRAINT `tickets_fk_id` + FOREIGN KEY ( `id` ) REFERENCES `receipts` ( `id` ); + +-- ***************************************************************************** + +-- ADD roles +INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); +INSERT INTO roles(id, name, permissions) VALUES('1', 'Manager role', $FILE{/com/unicenta/pos/templates/Role.Manager.xml} ); +INSERT INTO roles(id, name, permissions) VALUES('2', 'Employee role', $FILE{/com/unicenta/pos/templates/Role.Employee.xml} ); +INSERT INTO roles(id, name, permissions) VALUES('3', 'Guest role', $FILE{/com/unicenta/pos/templates/Role.Guest.xml} ); + +-- ADD people +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('0', 'Administrator', NULL, '0', TRUE, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('1', 'Manager', NULL, '1', TRUE, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('2', 'Employee', NULL, '2', TRUE, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('3', 'Guest', NULL, '3', TRUE, NULL); + +-- ADD resources -- +-- SYSTEM +INSERT INTO resources(id, name, restype, content) VALUES('00', 'Menu.Root', 0, $FILE{/com/unicenta/pos/templates/Menu.Root.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('02', 'Cash.Close', 0, $FILE{/com/unicenta/pos/templates/Cash.Close.xml}); +INSERT INTO resources(ID, name, restype, content) VALUES('03', 'Customer.Created', 0, $FILE{/com/unicenta/pos/templates/customer.created.xml}); +INSERT INTO resources(ID, name, restype, content) VALUES('04', 'Customer.Deleted', 0, $FILE{/com/unicenta/pos/templates/customer.deleted.xml}); +INSERT INTO resources(ID, name, restype, content) VALUES('05', 'Customer.Updated', 0, $FILE{/com/unicenta/pos/templates/customer.updated.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('06', 'payment.cash', 0, $FILE{/com/unicenta/pos/templates/payment.cash.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('07', 'Ticket.Buttons', 0, $FILE{/com/unicenta/pos/templates/Ticket.Buttons.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('08', 'Ticket.Close', 0, $FILE{/com/unicenta/pos/templates/Ticket.Close.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('09', 'Ticket.Line', 0, $FILE{/com/unicenta/pos/templates/Ticket.Line.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('10', 'Window.Title', 0, $FILE{/com/unicenta/pos/templates/Window.Title.txt}); + +-- IMAGES +INSERT INTO resources(id, name, restype, content) VALUES('11', 'img.001', 1, $FILE{/com/unicenta/images/.01.png}); +INSERT INTO resources(id, name, restype, content) VALUES('12', 'img.002', 1, $FILE{/com/unicenta/images/.02.png}); +INSERT INTO resources(id, name, restype, content) VALUES('13', 'img.005', 1, $FILE{/com/unicenta/images/.05.png}); +INSERT INTO resources(id, name, restype, content) VALUES('14', 'img.010', 1, $FILE{/com/unicenta/images/.10.png}); +INSERT INTO resources(id, name, restype, content) VALUES('15', 'img.020', 1, $FILE{/com/unicenta/images/.20.png}); +INSERT INTO resources(id, name, restype, content) VALUES('16', 'img.025', 1, $FILE{/com/unicenta/images/.25.png}); +INSERT INTO resources(id, name, restype, content) VALUES('17', 'img.050', 1, $FILE{/com/unicenta/images/.50.png}); +INSERT INTO resources(id, name, restype, content) VALUES('18', 'img.1', 1, $FILE{/com/unicenta/images/1.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('19', 'img.2', 1, $FILE{/com/unicenta/images/2.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('20', 'img.5', 1, $FILE{/com/unicenta/images/5.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('21', 'img.10', 1, $FILE{/com/unicenta/images/10.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('22', 'img.20', 1, $FILE{/com/unicenta/images/20.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('23', 'img.50', 1, $FILE{/com/unicenta/images/50.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('24', 'img.100', 1, $FILE{/com/unicenta/images/100.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('25', 'img.200', 1, $FILE{/com/unicenta/images/200.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('26', 'img.500', 1, $FILE{/com/unicenta/images/500.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('27', 'img.1000', 1, $FILE{/com/unicenta/images/1000.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('28', 'img.cash', 1, $FILE{/com/unicenta/images/cash.png}); +INSERT INTO resources(id, name, restype, content) VALUES('29', 'img.cashdrawer', 1, $FILE{/com/unicenta/images/cashdrawer.png}); +INSERT INTO resources(id, name, restype, content) VALUES('30', 'img.discount', 1, $FILE{/com/unicenta/images/discount.png}); +INSERT INTO resources(id, name, restype, content) VALUES('31', 'img.discount_b', 1, $FILE{/com/unicenta/images/discount_b.png}); +INSERT INTO resources(id, name, restype, content) VALUES('32', 'img.heart', 1, $FILE{/com/unicenta/images/heart.png}); +INSERT INTO resources(id, name, restype, content) VALUES('33', 'img.keyboard_48', 1, $FILE{/com/unicenta/images/keyboard_48.png}); +INSERT INTO resources(id, name, restype, content) VALUES('34', 'img.kit_print', 1, $FILE{/com/unicenta/images/kit_print.png}); +INSERT INTO resources(id, name, restype, content) VALUES('35', 'img.no_photo', 1, $FILE{/com/unicenta/images/no_photo.png}); +INSERT INTO resources(id, name, restype, content) VALUES('36', 'img.refundit', 1, $FILE{/com/unicenta/images/refundit.png}); +INSERT INTO resources(id, name, restype, content) VALUES('37', 'img.run_script', 1, $FILE{/com/unicenta/images/run_script.png}); +INSERT INTO resources(id, name, restype, content) VALUES('38', 'img.ticket_print', 1, $FILE{/com/unicenta/images/ticket_print.png}); +INSERT INTO resources(id, name, restype, content) VALUES('40', 'Printer.Ticket.Logo', 1, $FILE{/com/unicenta/images/printer.ticket.logo.jpg}); + +-- PRINTER +INSERT INTO resources(id, name, restype, content) VALUES('41', 'Printer.CloseCash.Preview', 0, $FILE{/com/unicenta/pos/templates/Printer.CloseCash.Preview.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('42', 'Printer.CloseCash', 0, $FILE{/com/unicenta/pos/templates/Printer.CloseCash.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('43', 'Printer.CustomerPaid', 0, $FILE{/com/unicenta/pos/templates/Printer.CustomerPaid.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('44', 'Printer.CustomerPaid2', 0, $FILE{/com/unicenta/pos/templates/Printer.CustomerPaid2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('45', 'Printer.FiscalTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.FiscalTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('46', 'Printer.Inventory', 0, $FILE{/com/unicenta/pos/templates/Printer.Inventory.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('47', 'Printer.OpenDrawer', 0, $FILE{/com/unicenta/pos/templates/Printer.OpenDrawer.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('48', 'Printer.PartialCash', 0, $FILE{/com/unicenta/pos/templates/Printer.PartialCash.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('49', 'Printer.PrintLastTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.PrintLastTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('50', 'Printer.Product', 0, $FILE{/com/unicenta/pos/templates/Printer.Product.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('52', 'Printer.ReprintTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.ReprintTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('53', 'Printer.Start', 0, $FILE{/com/unicenta/pos/templates/Printer.Start.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('54', 'Printer.Ticket.P1', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P1.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('55', 'Printer.Ticket.P2', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('56', 'Printer.Ticket.P3', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P3.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('57', 'Printer.Ticket.P4', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P4.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('58', 'Printer.Ticket.P5', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P5.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('59', 'Printer.Ticket.P6', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P6.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('60', 'Printer.Ticket', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('61', 'Printer.Ticket2', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('62', 'Printer.TicketClose', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketClose.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('63', 'Printer.TicketLine', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketLine.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('64', 'Printer.TicketNew', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketLine.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('65', 'Printer.TicketPreview', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketPreview.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('66', 'Printer.Ticket_A4', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket_A4.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('67', 'Printer.TicketPreview_A4', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketPreview_A4.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('68', 'Printer.TicketRemote', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketRemote.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('69', 'Printer.TicketTotal', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketTotal.xml}); + +-- SCRIPTS +INSERT INTO resources(id, name, restype, content) VALUES('70', 'script.Keyboard', 0, $FILE{/com/unicenta/pos/templates/script.Keyboard.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('71', 'script.Linediscount', 0, $FILE{/com/unicenta/pos/templates/script.Linediscount.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('72', 'script.SendOrder', 0, $FILE{/com/unicenta/pos/templates/script.SendOrder.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('73', 'script.Totaldiscount', 0, $FILE{/com/unicenta/pos/templates/script.Totaldiscount.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('74', 'script.multibuy', 0, $FILE{/com/unicenta/pos/templates/script.multibuy.txt}); + +-- ADD CATEGORIES +INSERT INTO categories(id, name) VALUES ('000', 'Category Standard'); + +-- ADD TAXCATEGORIES +/* 002 added 31/01/2017 00:00:00. */ +INSERT INTO taxcategories(id, name) VALUES ('000', 'Tax Exempt'); +INSERT INTO taxcategories(id, name) VALUES ('001', 'Tax Standard'); +INSERT INTO taxcategories(id, name) VALUES ('002', 'Tax Other'); + +-- ADD TAXES +/* 002 added 31/01/2017 00:00:00. */ +INSERT INTO taxes(id, name, category, custcategory, parentid, rate, ratecascade, rateorder) VALUES ('000', 'Tax Exempt', '000', NULL, NULL, 0, FALSE, NULL); +INSERT INTO taxes(id, name, category, custcategory, parentid, rate, ratecascade, rateorder) VALUES ('001', 'Tax Standard', '001', NULL, NULL, 0.20, FALSE, NULL); +INSERT INTO taxes(id, name, category, custcategory, parentid, rate, ratecascade, rateorder) VALUES ('002', 'Tax Other', '002', NULL, NULL, 0, FALSE, NULL); + +-- ADD PRODUCTS +INSERT INTO products(id, reference, code, name, category, taxcat, isservice, display, printto) +VALUES ('xxx999_999xxx_x9x9x9', 'xxx999', 'xxx999', 'Free Line entry', '000', '001', 1, '<html><center>Free Line entry', '1'); +INSERT INTO products(id, reference, code, name, category, taxcat, isservice, display, printto) +VALUES ('xxx998_998xxx_x8x8x8', 'xxx998', 'xxx998', 'Service Charge', '000', '001', 1, '<html><center>Service Charge', '1'); + +-- ADD PRODUCTS_CAT +INSERT INTO products_cat(product) VALUES ('xxx999_999xxx_x9x9x9'); +INSERT INTO products_cat(product) VALUES ('xxx998_998xxx_x8x8x8'); + +-- ADD LOCATION +INSERT INTO locations(id, name, address) VALUES ('0','Location 1','Local'); + +-- ADD SUPPLIERS +INSERT INTO suppliers(id, searchkey, name) VALUES ('0','uniCenta','uniCenta'); + +-- ADD UOM +INSERT INTO uom(id, name) VALUES ('0','Each'); + +-- ADD FLOORS +INSERT INTO floors(id, name, image) VALUES ('0', 'Restaurant floor', $FILE{/com/unicenta/images/paperboard960_600.png}); + +-- ADD PLACES +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('1', 'Table 1', 100, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('2', 'Table 2', 250, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('3', 'Table 3', 400, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('4', 'Table 4', 550, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('5', 'Table 5', 700, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('6', 'Table 6', 850, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('7', 'Table 7', 100, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('8', 'Table 8', 250, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('9', 'Table 9', 400, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('10', 'Table 10', 550, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('11', 'Table 11', 700, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('12', 'Table 12', 850, 150, '0', '1', 90, 45); + +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('13', 'Table 13', 100, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('14', 'Table 14', 250, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('15', 'Table 15', 400, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('16', 'Table 16', 550, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('17', 'Table 17', 700, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('18', 'Table 18', 850, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('19', 'Table 19', 100, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('20', 'Table 20', 250, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('21', 'Table 21', 400, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('22', 'Table 22', 550, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('23', 'Table 23', 700, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('24', 'Table 24', 850, 350, '0', '1', 90, 45); + +-- ADD SHIFTS +INSERT INTO shifts(id, startshift, endshift, pplid) VALUES ('0', '2018-01-01 00:00:00.001', '2018-01-01 00:00:00.002','0'); + +-- ADD BREAKS +INSERT INTO breaks(id, name, visible, notes) VALUES ('0', 'Lunch Break', TRUE, NULL); +INSERT INTO breaks(id, name, visible, notes) VALUES ('1', 'Tea Break', TRUE, NULL); +INSERT INTO breaks(id, name, visible, notes) VALUES ('2', 'Mid Break', TRUE, NULL); + +-- ADD SHIFT_BREAKS +INSERT INTO shift_breaks(id, shiftid, breakid, starttime, endtime) VALUES ('0', '0', '0', '2018-01-01 00:00:00.003', '2018-01-01 00:00:00.004'); + +-- ADD SEQUENCES +INSERT INTO pickup_number VALUES(1); +INSERT INTO ticketsnum VALUES(1); +INSERT INTO ticketsnum_refund VALUES(1); +INSERT INTO ticketsnum_payment VALUES(1); + +-- ADD APPLICATION VERSION +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-create_original.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-create_original.sql new file mode 100644 index 0000000..6166642 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-create_original.sql @@ -0,0 +1,721 @@ +-- uniCenta oPOS - Touch Friendly Point Of Sale +-- Copyright (c) 2009-2017 uniCenta +-- http://sourceforge.net/projects/unicentaopos +-- +-- This file is part of uniCenta oPOS. +-- +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +-- Database create script for MySQL +-- Copyright (c) 2009-2017 uniCenta +-- v4.00 + +CREATE TABLE `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `roles` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `permissions` mediumblob, + PRIMARY KEY (`id`), + UNIQUE KEY `roles_name_inx` (`name`) +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO ROLES(ID, NAME, PERMISSIONS) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); +INSERT INTO ROLES(ID, NAME, PERMISSIONS) VALUES('1', 'Manager role', $FILE{/com/unicenta/pos/templates/Role.Manager.xml} ); +INSERT INTO ROLES(ID, NAME, PERMISSIONS) VALUES('2', 'Employee role', $FILE{/com/unicenta/pos/templates/Role.Employee.xml} ); +INSERT INTO ROLES(ID, NAME, PERMISSIONS) VALUES('3', 'Guest role', $FILE{/com/unicenta/pos/templates/Role.Guest.xml} ); + +CREATE TABLE `people` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `apppassword` varchar(255) DEFAULT NULL, + `card` varchar(255) DEFAULT NULL, + `role` varchar(255) NOT NULL, + `visible` bit(1) NOT NULL, + `image` mediumblob, + PRIMARY KEY (`id`), + UNIQUE KEY `people_name_inx` (`name`), + KEY `people_fk_1` (`role`), + KEY `people_card_inx` (`card`), + CONSTRAINT `people_fk_1` FOREIGN KEY (`role`) REFERENCES `roles` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO PEOPLE(ID, NAME, APPPASSWORD, ROLE, VISIBLE, IMAGE) VALUES ('0', 'Administrator', NULL, '0', TRUE, NULL); +INSERT INTO PEOPLE(ID, NAME, APPPASSWORD, ROLE, VISIBLE, IMAGE) VALUES ('1', 'Manager', NULL, '1', TRUE, NULL); +INSERT INTO PEOPLE(ID, NAME, APPPASSWORD, ROLE, VISIBLE, IMAGE) VALUES ('2', 'Employee', NULL, '2', TRUE, NULL); +INSERT INTO PEOPLE(ID, NAME, APPPASSWORD, ROLE, VISIBLE, IMAGE) VALUES ('3', 'Guest', NULL, '3', TRUE, NULL); + + +CREATE TABLE `resources` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `restype` int(11) NOT NULL, + `content` mediumblob, + PRIMARY KEY (`id`), + UNIQUE KEY `resources_name_inx` (`name`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('0', 'Menu.Root', 0, $FILE{/com/unicenta/pos/templates/Menu.Root.txt}); + +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('1', 'coin.2', 1, $FILE{/com/unicenta/pos/templates/coin.2.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('2', 'coin.1', 1, $FILE{/com/unicenta/pos/templates/coin.1.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('3', 'coin.50', 1, $FILE{/com/unicenta/pos/templates/coin.50.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('4', 'coin.20', 1, $FILE{/com/unicenta/pos/templates/coin.20.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('5', 'coin.10', 1, $FILE{/com/unicenta/pos/templates/coin.10.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('6', 'coin.05', 1, $FILE{/com/unicenta/pos/templates/coin.05.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('7', 'coin.02', 1, $FILE{/com/unicenta/pos/templates/coin.02.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('8', 'coin.01', 1, $FILE{/com/unicenta/pos/templates/coin.01.png}); + +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('9', 'img.cash', 1, $FILE{/com/unicenta/pos/templates/img.cash.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('10', 'img.cashdrawer', 1, $FILE{/com/unicenta/pos/templates/img.cashdrawer.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('11', 'img.discount', 1, $FILE{/com/unicenta/pos/templates/img.discount.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('12', 'img.empty', 1, $FILE{/com/unicenta/pos/templates/img.empty.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('13', 'img.heart', 1, $FILE{/com/unicenta/pos/templates/img.heart.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('14', 'img.no_photo', 1, $FILE{/com/unicenta/pos/templates/img.no_photo.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('15', 'img.kit_print', 1, $FILE{/com/unicenta/pos/templates/img.kit_print.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('16', 'img.refundit', 1, $FILE{/com/unicenta/pos/templates/img.refundit.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('17', 'img.run_script', 1, $FILE{/com/unicenta/pos/templates/img.run_script.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('18', 'img.ticket_print', 1, $FILE{/com/unicenta/pos/templates/img.ticket_print.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('19', 'img.user', 1, $FILE{/com/unicenta/pos/templates/img.user.png}); + +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('20', 'note.50', 1, $FILE{/com/unicenta/pos/templates/note.50.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('21', 'note.20', 1, $FILE{/com/unicenta/pos/templates/note.20.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('22', 'note.10', 1, $FILE{/com/unicenta/pos/templates/note.10.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('23', 'note.5', 1, $FILE{/com/unicenta/pos/templates/note.5.png}); + +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('24', 'payment.cash', 0, $FILE{/com/unicenta/pos/templates/payment.cash.txt}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('25', 'Printer.CloseCash', 0, $FILE{/com/unicenta/pos/templates/Printer.CloseCash.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('26', 'Printer.CustomerPaid', 0, $FILE{/com/unicenta/pos/templates/Printer.CustomerPaid.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('27', 'Printer.CustomerPaid2', 0, $FILE{/com/unicenta/pos/templates/Printer.CustomerPaid2.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('28', 'Printer.FiscalTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.FiscalTicket.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('29', 'Printer.Inventory', 0, $FILE{/com/unicenta/pos/templates/Printer.Inventory.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('30', 'Printer.OpenDrawer', 0, $FILE{/com/unicenta/pos/templates/Printer.OpenDrawer.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('31', 'Printer.PartialCash', 0, $FILE{/com/unicenta/pos/templates/Printer.PartialCash.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('32', 'Printer.Product', 0, $FILE{/com/unicenta/pos/templates/Printer.Product.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('33', 'Printer.Start', 0, $FILE{/com/unicenta/pos/templates/Printer.Start.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('34', 'Printer.Ticket', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('35', 'Printer.Ticket2', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket2.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('36', 'Printer.TicketClose', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketClose.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('37', 'Printer.TicketRemote', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketRemote.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('38', 'Printer.TicketLine', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketLine.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('39', 'Printer.TicketNew', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketLine.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('40', 'Printer.TicketPreview', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketPreview.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('41', 'Printer.TicketTotal', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketTotal.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('42', 'Printer.Ticket.Logo', 1, $FILE{/com/unicenta/pos/templates/printer.ticket.logo.png}); + +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('43', 'script.AddLineNote', 0, $FILE{/com/unicenta/pos/templates/script.AddLineNote.txt}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('44', 'script.Event.Total', 0, $FILE{/com/unicenta/pos/templates/script.Event.Total.txt}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('45', 'script.linediscount', 0, $FILE{/com/unicenta/pos/templates/script.linediscount.txt}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('46', 'script.ReceiptConsolidate', 0, $FILE{/com/unicenta/pos/templates/script.ReceiptConsolidate.txt}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('47', 'script.Refundit', 0, $FILE{/com/unicenta/pos/templates/script.Refundit.txt}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('48', 'script.SendOrder', 0, $FILE{/com/unicenta/pos/templates/script.SendOrder.txt}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('49', 'script.ServiceCharge', 0, $FILE{/com/unicenta/pos/templates/script.script.ServiceCharge.txt}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('50', 'script.SetPerson', 0, $FILE{/com/unicenta/pos/templates/script.SetPerson.txt}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('51', 'script.StockCurrentAdd', 0, $FILE{/com/unicenta/pos/templates/script.StockCurrentAdd.txt}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('52', 'script.StockCurrentSet', 0, $FILE{/com/unicenta/pos/templates/script.StockCurrentSet.txt}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('53', 'script.totaldiscount', 0, $FILE{/com/unicenta/pos/templates/script.totaldiscount.txt}); + +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('54', 'Ticket.Buttons', 0, $FILE{/com/unicenta/pos/templates/Ticket.Buttons.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('55', 'Ticket.Close', 0, $FILE{/com/unicenta/pos/templates/Ticket.Close.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('56', 'Ticket.Discount', 0, $FILE{/com/unicenta/pos/templates/Ticket.Discount.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('57', 'Ticket.Line', 0, $FILE{/com/unicenta/pos/templates/Ticket.Line.xml}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('58', 'Ticket.TicketLineTaxesIncluded', 0, $FILE{/com/unicenta/pos/templates/Ticket.TicketLineTaxesIncluded.xml}); + +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('59', 'Window.Logo', 1, $FILE{/com/unicenta/pos/templates/window.logo.png}); +INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('60', 'Window.Title', 0, $FILE{/com/unicenta/pos/templates/Window.Title.txt}); + +CREATE TABLE `taxcustcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `taxcustcat_name_inx` (`name`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `customers` ( + `id` varchar(255) NOT NULL, + `searchkey` varchar(255) NOT NULL, + `taxid` varchar(255) DEFAULT NULL, + `name` varchar(255) NOT NULL, + `taxcategory` varchar(255) DEFAULT NULL, + `card` varchar(255) DEFAULT NULL, + `maxdebt` double NOT NULL DEFAULT '0', + `address` varchar(255) DEFAULT NULL, + `address2` varchar(255) DEFAULT NULL, + `postal` varchar(255) DEFAULT NULL, + `city` varchar(255) DEFAULT NULL, + `region` varchar(255) DEFAULT NULL, + `country` varchar(255) DEFAULT NULL, + `firstname` varchar(255) DEFAULT NULL, + `lastname` varchar(255) DEFAULT NULL, + `email` varchar(255) DEFAULT NULL, + `phone` varchar(255) DEFAULT NULL, + `phone2` varchar(255) DEFAULT NULL, + `fax` varchar(255) DEFAULT NULL, + `notes` varchar(255) DEFAULT NULL, + `visible` bit(1) NOT NULL DEFAULT b'1', + `curdate` datetime DEFAULT NULL, + `curdebt` double DEFAULT '0', + `image` mediumblob, + PRIMARY KEY (`id`), + UNIQUE KEY `customers_skey_inx` (`searchkey`), + KEY `customers_taxcat` (`taxcategory`), + KEY `customers_taxid_inx` (`taxid`), + KEY `customers_name_inx` (`name`), + KEY `customers_card_inx` (`card`), + CONSTRAINT `customers_taxcat` FOREIGN KEY (`taxcategory`) REFERENCES `taxcustcategories` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `taxsuppcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `taxsuppcat_name_inx` (`name`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `suppliers` ( + `id` varchar(255) NOT NULL, + `searchkey` varchar(255) NOT NULL, + `taxid` varchar(255) DEFAULT NULL, + `name` varchar(255) NOT NULL, + `taxcategory` varchar(255) DEFAULT NULL, + `card` varchar(255) DEFAULT NULL, + `maxdebt` double NOT NULL DEFAULT '0', + `address` varchar(255) DEFAULT NULL, + `address2` varchar(255) DEFAULT NULL, + `postal` varchar(255) DEFAULT NULL, + `city` varchar(255) DEFAULT NULL, + `region` varchar(255) DEFAULT NULL, + `country` varchar(255) DEFAULT NULL, + `firstname` varchar(255) DEFAULT NULL, + `lastname` varchar(255) DEFAULT NULL, + `email` varchar(255) DEFAULT NULL, + `phone` varchar(255) DEFAULT NULL, + `phone2` varchar(255) DEFAULT NULL, + `fax` varchar(255) DEFAULT NULL, + `notes` varchar(255) DEFAULT NULL, + `visible` bit(1) NOT NULL DEFAULT b'1', + `curdate` datetime DEFAULT NULL, + `curdebt` double DEFAULT '0', + + PRIMARY KEY (`id`), + UNIQUE KEY `suppliers_skey_inx` (`searchkey`), + KEY `suppliers_taxcat` (`taxcategory`), + KEY `suppliers_taxid_inx` (`taxid`), + KEY `suppliers_name_inx` (`name`), + CONSTRAINT `suppliers_taxcat` FOREIGN KEY (`taxcategory`) REFERENCES `taxsuppcategories` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `categories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `parentid` varchar(255) DEFAULT NULL, + `image` mediumblob, + `texttip` varchar(255) DEFAULT NULL, + `catshowname` smallint(6) NOT NULL DEFAULT '1', + `catorder` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `categories_name_inx` (`name`), + KEY `categories_fk_1` (`parentid`), + CONSTRAINT `categories_fk_1` FOREIGN KEY (`parentid`) REFERENCES `categories` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO CATEGORIES(ID, NAME) VALUES ('000', 'Category Standard'); + +CREATE TABLE `taxcategories` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `taxcat_name_inx` (`name`) +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO TAXCATEGORIES(ID, NAME) VALUES ('000', 'Tax Exempt'); +INSERT INTO TAXCATEGORIES(ID, NAME) VALUES ('001', 'Tax Standard'); + +CREATE TABLE `taxes` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `category` varchar(255) NOT NULL, + `custcategory` varchar(255) DEFAULT NULL, + `parentid` varchar(255) DEFAULT NULL, + `rate` double NOT NULL DEFAULT '0', + `ratecascade` bit(1) NOT NULL DEFAULT b'0', + `rateorder` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `taxes_name_inx` (`name`), + KEY `taxes_cat_fk` (`category`), + KEY `taxes_custcat_fk` (`custcategory`), + KEY `taxes_taxes_fk` (`parentid`), + CONSTRAINT `taxes_cat_fk` FOREIGN KEY (`category`) REFERENCES `taxcategories` (`id`), + CONSTRAINT `taxes_custcat_fk` FOREIGN KEY (`custcategory`) REFERENCES `taxcustcategories` (`id`), + CONSTRAINT `taxes_taxes_fk` FOREIGN KEY (`parentid`) REFERENCES `taxes` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO TAXES(ID, NAME, CATEGORY, CUSTCATEGORY, PARENTID, RATE, RATECASCADE, RATEORDER) VALUES ('000', 'Tax Exempt', '000', NULL, NULL, 0, FALSE, NULL); +INSERT INTO TAXES(ID, NAME, CATEGORY, CUSTCATEGORY, PARENTID, RATE, RATECASCADE, RATEORDER) VALUES ('001', 'Tax Standard', '001', NULL, NULL, 0.20, FALSE, NULL); + +CREATE TABLE `attribute` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `attributevalue` ( + `id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `value` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `attval_att` (`attribute_id`), + CONSTRAINT `attval_att` FOREIGN KEY (`attribute_id`) REFERENCES `attribute` (`id`) ON DELETE CASCADE +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `attributeset` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `attributeuse` ( + `id` varchar(255) NOT NULL, + `attributeset_id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `lineno` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `attuse_line` (`attributeset_id`,`lineno`), + KEY `attuse_att` (`attribute_id`), + CONSTRAINT `attuse_att` FOREIGN KEY (`attribute_id`) REFERENCES `attribute` (`id`), + CONSTRAINT `attuse_set` FOREIGN KEY (`attributeset_id`) REFERENCES `attributeset` (`id`) ON DELETE CASCADE +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `attributesetinstance` ( + `id` varchar(255) NOT NULL, + `attributeset_id` varchar(255) NOT NULL, + `description` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `attsetinst_set` (`attributeset_id`), + CONSTRAINT `attsetinst_set` FOREIGN KEY (`attributeset_id`) REFERENCES `attributeset` (`id`) ON DELETE CASCADE +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `attributeinstance` ( + `id` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) NOT NULL, + `attribute_id` varchar(255) NOT NULL, + `value` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `attinst_set` (`attributesetinstance_id`), + KEY `attinst_att` (`attribute_id`), + CONSTRAINT `attinst_att` FOREIGN KEY (`attribute_id`) REFERENCES `attribute` (`id`), + CONSTRAINT `attinst_set` FOREIGN KEY (`attributesetinstance_id`) REFERENCES `attributesetinstance` (`id`) ON DELETE CASCADE +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `products` ( + `id` varchar(255) NOT NULL, + `reference` varchar(255) NOT NULL, + `code` varchar(255) NOT NULL, + `codetype` varchar(255) DEFAULT NULL, + `name` varchar(255) NOT NULL, + `pricebuy` double NOT NULL DEFAULT '0', + `pricesell` double NOT NULL DEFAULT '0', + `category` varchar(255) NOT NULL, + `taxcat` varchar(255) NOT NULL, + `attributeset_id` varchar(255) DEFAULT NULL, + `stockcost` double DEFAULT NULL, + `stockvolume` double DEFAULT NULL, + `image` mediumblob, + `iscom` bit(1) NOT NULL DEFAULT b'0', + `isscale` bit(1) NOT NULL DEFAULT b'0', + `isconstant` bit(1) NOT NULL DEFAULT b'0', + `printkb` bit(1) NOT NULL DEFAULT b'0', + `sendstatus` bit(1) NOT NULL DEFAULT b'0', + `isservice` bit(1) NOT NULL DEFAULT b'0', + `attributes` mediumblob, + `display` varchar(255) DEFAULT NULL, + `isvprice` smallint(6) NOT NULL DEFAULT '0', + `isverpatrib` smallint(6) NOT NULL DEFAULT '0', + `texttip` varchar(255) DEFAULT NULL, + `warranty` smallint(6) NOT NULL DEFAULT '0', + `stockunits` double NOT NULL DEFAULT '0', + `printto` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `products_inx_0` (`reference`), + UNIQUE KEY `products_inx_1` (`code`), + UNIQUE KEY `products_name_inx` (`name`), + KEY `products_fk_1` (`category`), + KEY `products_taxcat_fk` (`taxcat`), + KEY `products_attrset_fk` (`attributeset_id`), + CONSTRAINT `products_attrset_fk` FOREIGN KEY (`attributeset_id`) REFERENCES `attributeset` (`id`), + CONSTRAINT `products_fk_1` FOREIGN KEY (`category`) REFERENCES `categories` (`id`), + CONSTRAINT `products_taxcat_fk` FOREIGN KEY (`taxcat`) REFERENCES `taxcategories` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO PRODUCTS(ID, REFERENCE, CODE, NAME, CATEGORY, TAXCAT, ISSERVICE) +VALUES ('xxx999_999xxx_x9x9x9', 'xxx999', 'xxx999', '***', '000', '001', 1); +INSERT INTO PRODUCTS(ID, REFERENCE, CODE, NAME, CATEGORY, TAXCAT, ISSERVICE) +VALUES ('xxx998_998xxx_x8x8x8', 'xxx998', 'xxx998', '***', '000', '001', 1); + +CREATE TABLE `products_cat` ( + `product` varchar(255) NOT NULL, + `catorder` int(11) DEFAULT NULL, + PRIMARY KEY (`product`), + KEY `products_cat_inx_1` (`catorder`), + CONSTRAINT `products_cat_fk_1` FOREIGN KEY (`product`) REFERENCES `products` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO PRODUCTS_CAT(PRODUCT) VALUES ('xxx999_999xxx_x9x9x9'); +INSERT INTO PRODUCTS_CAT(PRODUCT) VALUES ('xxx998_998xxx_x8x8x8'); + +CREATE TABLE `products_com` ( + `id` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `product2` varchar(255) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `pcom_inx_prod` (`product`,`product2`), + KEY `products_com_fk_2` (`product2`), + CONSTRAINT `products_com_fk_1` FOREIGN KEY (`product`) REFERENCES `products` (`id`), + CONSTRAINT `products_com_fk_2` FOREIGN KEY (`product2`) REFERENCES `products` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `locations` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `address` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `locations_name_inx` (`name`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `stockdiary` ( + `id` varchar(255) NOT NULL, + `datenew` datetime NOT NULL, + `reason` int(11) NOT NULL, + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) DEFAULT NULL, + `units` double NOT NULL, + `price` double NOT NULL, + `appuser` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `stockdiary_fk_1` (`product`), + KEY `stockdiary_attsetinst` (`attributesetinstance_id`), + KEY `stockdiary_fk_2` (`location`), + KEY `stockdiary_inx_1` (`datenew`), + CONSTRAINT `stockdiary_attsetinst` FOREIGN KEY (`attributesetinstance_id`) REFERENCES `attributesetinstance` (`id`), + CONSTRAINT `stockdiary_fk_1` FOREIGN KEY (`product`) REFERENCES `products` (`id`), + CONSTRAINT `stockdiary_fk_2` FOREIGN KEY (`location`) REFERENCES `locations` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `stocklevel` ( + `id` varchar(255) NOT NULL, + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `stocksecurity` double DEFAULT NULL, + `stockmaximum` double DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `stocklevel_product` (`product`), + KEY `stocklevel_location` (`location`), + CONSTRAINT `stocklevel_location` FOREIGN KEY (`location`) REFERENCES `locations` (`id`), + CONSTRAINT `stocklevel_product` FOREIGN KEY (`product`) REFERENCES `products` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `stockcurrent` ( + `location` varchar(255) NOT NULL, + `product` varchar(255) NOT NULL, + `attributesetinstance_id` varchar(255) DEFAULT NULL, + `units` double NOT NULL, + UNIQUE KEY `stockcurrent_inx` (`location`,`product`,`attributesetinstance_id`), + KEY `stockcurrent_fk_1` (`product`), + KEY `stockcurrent_attsetinst` (`attributesetinstance_id`), + CONSTRAINT `stockcurrent_attsetinst` FOREIGN KEY (`attributesetinstance_id`) REFERENCES `attributesetinstance` (`id`), + CONSTRAINT `stockcurrent_fk_1` FOREIGN KEY (`product`) REFERENCES `products` (`id`), + CONSTRAINT `stockcurrent_fk_2` FOREIGN KEY (`location`) REFERENCES `locations` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `closedcash` ( + `money` varchar(255) NOT NULL, + `host` varchar(255) NOT NULL, + `hostsequence` int(11) NOT NULL, + `datestart` datetime NOT NULL, + `dateend` datetime DEFAULT NULL, + `nosales` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`money`), + UNIQUE KEY `closedcash_inx_seq` (`host`,`hostsequence`), + KEY `closedcash_inx_1` (`datestart`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `receipts` ( + `id` varchar(255) NOT NULL, + `money` varchar(255) NOT NULL, + `datenew` datetime NOT NULL, + `attributes` mediumblob, + `person` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `receipts_fk_money` (`money`), + KEY `receipts_inx_1` (`datenew`), + CONSTRAINT `receipts_fk_money` FOREIGN KEY (`money`) REFERENCES `closedcash` (`money`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `tickets` ( + `id` varchar(255) NOT NULL, + `tickettype` int(11) NOT NULL DEFAULT '0', + `ticketid` int(11) NOT NULL, + `person` varchar(255) NOT NULL, + `customer` varchar(255) DEFAULT NULL, + `status` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `tickets_fk_2` (`person`), + KEY `tickets_customers_fk` (`customer`), + KEY `tickets_ticketid` (`tickettype`,`ticketid`), + CONSTRAINT `tickets_customers_fk` FOREIGN KEY (`customer`) REFERENCES `customers` (`id`), + CONSTRAINT `tickets_fk_2` FOREIGN KEY (`person`) REFERENCES `people` (`id`), + CONSTRAINT `tickets_fk_id` FOREIGN KEY (`id`) REFERENCES `receipts` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `ticketsnum` ( + `id` int(11) NOT NULL +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO TICKETSNUM VALUES(1); + + +CREATE TABLE `ticketsnum_refund` ( + `id` int(11) NOT NULL +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO TICKETSNUM_REFUND VALUES(1); + +CREATE TABLE `ticketsnum_payment` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`) +) ENGINE=innodb AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +INSERT INTO TICKETSNUM_PAYMENT VALUES (DEFAULT); + +CREATE TABLE `ticketlines` ( + `ticket` varchar(255) NOT NULL, + `line` int(11) NOT NULL, + `product` varchar(255) DEFAULT NULL, + `attributesetinstance_id` varchar(255) DEFAULT NULL, + `units` double NOT NULL, + `price` double NOT NULL, + `taxid` varchar(255) NOT NULL, + `attributes` mediumblob, + PRIMARY KEY (`ticket`,`line`), + KEY `ticketlines_fk_2` (`product`), + KEY `ticketlines_attsetinst` (`attributesetinstance_id`), + KEY `ticketlines_fk_3` (`taxid`), + CONSTRAINT `ticketlines_attsetinst` FOREIGN KEY (`attributesetinstance_id`) REFERENCES `attributesetinstance` (`id`), + CONSTRAINT `ticketlines_fk_2` FOREIGN KEY (`product`) REFERENCES `products` (`id`), + CONSTRAINT `ticketlines_fk_3` FOREIGN KEY (`taxid`) REFERENCES `taxes` (`id`), + CONSTRAINT `ticketlines_fk_ticket` FOREIGN KEY (`ticket`) REFERENCES `tickets` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `lineremoved` ( + `removeddate` timestamp NOT NULL DEFAULT current_timestamp, + `name` varchar(255) DEFAULT NULL, + `ticketid` varchar(255) DEFAULT NULL, + `productid` varchar(255) DEFAULT NULL, + `productname` varchar(255) DEFAULT NULL, + `units` double NOT NULL +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `payments` ( + `id` varchar(255) NOT NULL, + `receipt` varchar(255) NOT NULL, + `payment` varchar(255) NOT NULL, + `total` double NOT NULL DEFAULT '0', + `tip` double DEFAULT '0', + `transid` varchar(255) DEFAULT NULL, + `isprocessed` bit(1) DEFAULT b'0', + `returnmsg` mediumblob, + `notes` varchar(255) DEFAULT NULL, + `tendered` double DEFAULT NULL, + `cardname` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `payments_fk_receipt` (`receipt`), + KEY `payments_inx_1` (`payment`), + CONSTRAINT `payments_fk_receipt` FOREIGN KEY (`receipt`) REFERENCES `receipts` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `taxlines` ( + `id` varchar(255) NOT NULL, + `receipt` varchar(255) NOT NULL, + `taxid` varchar(255) NOT NULL, + `base` double NOT NULL DEFAULT '0', + `amount` double NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `taxlines_tax` (`taxid`), + KEY `taxlines_receipt` (`receipt`), + CONSTRAINT `taxlines_receipt` FOREIGN KEY (`receipt`) REFERENCES `receipts` (`id`), + CONSTRAINT `taxlines_tax` FOREIGN KEY (`taxid`) REFERENCES `taxes` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `floors` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `image` mediumblob, + PRIMARY KEY (`id`), + UNIQUE KEY `floors_name_inx` (`name`) +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO FLOORS(ID, NAME, IMAGE) VALUES ('0', 'Restaurant floor', $FILE{/com/unicenta/pos/templates/restaurant_floor.png}); + +CREATE TABLE `places` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `x` int(11) NOT NULL, + `y` int(11) NOT NULL, + `floor` varchar(255) NOT NULL, + `customer` varchar(255) DEFAULT NULL, + `waiter` varchar(255) DEFAULT NULL, + `ticketid` varchar(255) DEFAULT NULL, + `tablemoved` smallint(6) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `places_name_inx` (`name`) +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO PLACES(ID, NAME, X, Y, FLOOR) VALUES ('1', 'Table 1', 100, 50, '0'); +INSERT INTO PLACES(ID, NAME, X, Y, FLOOR) VALUES ('2', 'Table 2', 250, 50, '0'); +INSERT INTO PLACES(ID, NAME, X, Y, FLOOR) VALUES ('3', 'Table 3', 400, 50, '0'); +INSERT INTO PLACES(ID, NAME, X, Y, FLOOR) VALUES ('4', 'Table 4', 550, 50, '0'); +INSERT INTO PLACES(ID, NAME, X, Y, FLOOR) VALUES ('5', 'Table 5', 700, 50, '0'); +INSERT INTO PLACES(ID, NAME, X, Y, FLOOR) VALUES ('6', 'Table 6', 850, 50, '0'); +INSERT INTO PLACES(ID, NAME, X, Y, FLOOR) VALUES ('7', 'Table 7', 100, 150, '0'); +INSERT INTO PLACES(ID, NAME, X, Y, FLOOR) VALUES ('8', 'Table 8', 250, 150, '0'); +INSERT INTO PLACES(ID, NAME, X, Y, FLOOR) VALUES ('9', 'Table 9', 400, 150, '0'); +INSERT INTO PLACES(ID, NAME, X, Y, FLOOR) VALUES ('10', 'Table 10', 550, 150, '0'); +INSERT INTO PLACES(ID, NAME, X, Y, FLOOR) VALUES ('11', 'Table 11', 700, 150, '0'); +INSERT INTO PLACES(ID, NAME, X, Y, FLOOR) VALUES ('12', 'Table 12', 850, 150, '0'); + +CREATE TABLE `reservations` ( + `id` varchar(255) NOT NULL, + `created` datetime NOT NULL, + `datenew` datetime NOT NULL DEFAULT '2013-01-01 00:00:00', + `title` varchar(255) NOT NULL, + `chairs` int(11) NOT NULL, + `isdone` bit(1) NOT NULL, + `description` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `reservations_inx_1` (`datenew`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `reservation_customers` ( + `id` varchar(255) NOT NULL, + `customer` varchar(255) NOT NULL, + PRIMARY KEY (`id`), + KEY `res_cust_fk_2` (`customer`), + CONSTRAINT `res_cust_fk_1` FOREIGN KEY (`id`) REFERENCES `reservations` (`id`), + CONSTRAINT `res_cust_fk_2` FOREIGN KEY (`customer`) REFERENCES `customers` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `thirdparties` ( + `id` varchar(255) NOT NULL, + `cif` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `address` varchar(255) DEFAULT NULL, + `contactcomm` varchar(255) DEFAULT NULL, + `contactfact` varchar(255) DEFAULT NULL, + `payrule` varchar(255) DEFAULT NULL, + `faxnumber` varchar(255) DEFAULT NULL, + `phonenumber` varchar(255) DEFAULT NULL, + `mobilenumber` varchar(255) DEFAULT NULL, + `email` varchar(255) DEFAULT NULL, + `webpage` varchar(255) DEFAULT NULL, + `notes` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `thirdparties_cif_inx` (`cif`), + UNIQUE KEY `thirdparties_name_inx` (`name`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `sharedtickets` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `content` mediumblob, + `appuser` varchar(255) DEFAULT NULL, + `pickupid` int(11) NOT NULL DEFAULT '0', + `locked` varchar(20) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +-- Added for Employee Presence Management +CREATE TABLE `shifts` ( + `id` varchar(255) NOT NULL, + `startshift` datetime NOT NULL, + `endshift` datetime DEFAULT NULL, + `pplid` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO SHIFTS(ID, STARTSHIFT, ENDSHIFT, PPLID) VALUES ('0', '2017-01-01 00:00:00.001', '2017-01-01 00:00:00.002','0'); + +CREATE TABLE `leaves` ( + `id` varchar(255) NOT NULL, + `pplid` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `startdate` datetime NOT NULL, + `enddate` datetime NOT NULL, + `notes` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `leaves_pplid` (`pplid`), + CONSTRAINT `leaves_pplid` FOREIGN KEY (`pplid`) REFERENCES `people` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `breaks` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `visible` tinyint(1) NOT NULL DEFAULT '1', + `notes` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO BREAKS(ID, NAME, VISIBLE, NOTES) VALUES ('0', 'Lunch Break', TRUE, NULL); +INSERT INTO BREAKS(ID, NAME, VISIBLE, NOTES) VALUES ('1', 'Tea Break', TRUE, NULL); +INSERT INTO BREAKS(ID, NAME, VISIBLE, NOTES) VALUES ('2', 'Mid Break', TRUE, NULL); + +CREATE TABLE `shift_breaks` ( + `id` varchar(255) NOT NULL, + `shiftid` varchar(255) NOT NULL, + `breakid` varchar(255) NOT NULL, + `starttime` timestamp NOT NULL DEFAULT current_timestamp ON UPDATE current_timestamp, + `endtime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (`id`), + KEY `shift_breaks_breakid` (`breakid`), + KEY `shift_breaks_shiftid` (`shiftid`), + CONSTRAINT `shift_breaks_breakid` FOREIGN KEY (`breakid`) REFERENCES `breaks` (`id`), + CONSTRAINT `shift_breaks_shiftid` FOREIGN KEY (`shiftid`) REFERENCES `shifts` (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO SHIFT_BREAKS(ID, SHIFTID, BREAKID, STARTTIME, ENDTIME) VALUES ('0', '0', '0', '2017-01-01 00:00:00.003', '2017-01-01 00:00:00.004'); + +CREATE TABLE `moorers` ( + `vesselname` varchar(255) DEFAULT NULL, + `size` int(11) DEFAULT NULL, + `days` int(11) DEFAULT NULL, + `power` bit(1) NOT NULL DEFAULT b'0' +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `csvimport` ( + `id` varchar(255) NOT NULL, + `rownumber` varchar(255) DEFAULT NULL, + `csverror` varchar(255) DEFAULT NULL, + `reference` varchar(1024) DEFAULT NULL, + `code` varchar(1024) DEFAULT NULL, + `name` varchar(1024) DEFAULT NULL, + `pricebuy` double DEFAULT NULL, + `pricesell` double DEFAULT NULL, + `previousbuy` double DEFAULT NULL, + `previoussell` double DEFAULT NULL, + `category` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=innodb DEFAULT CHARSET=utf8; + +CREATE TABLE `pickup_number` ( + `id` int(11) NOT NULL DEFAULT '0' +) ENGINE=innodb DEFAULT CHARSET=utf8; +INSERT INTO PICKUP_NUMBER VALUES(1); + +CREATE TABLE `draweropened` ( + `opendate` timestamp NOT NULL DEFAULT current_timestamp, + `name` varchar(255) DEFAULT NULL, + `ticketid` varchar(255) DEFAULT NULL +) ENGINE=innodb DEFAULT CHARSET=utf8; + +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-dropFKeys.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-dropFKeys.sql new file mode 100644 index 0000000..f13ba13 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-dropFKeys.sql @@ -0,0 +1,93 @@ +-- uniCenta oPOS - Touch Friendly Point Of Sale +-- Copyright (c) 2009-2017 uniCenta +-- https://unicenta.com +-- +-- This file is part of uniCenta oPOS. +-- +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +/* + * Script created by Jack, uniCenta 07/08/2016 08:00:00 + * Modified 10 Sept 2017 + * Called by Transfer for v4.4 after MySQL-create-transfer.sql +*/ + +set foreign_key_checks = 0; + +alter table people drop foreign key people_fk_1; + +alter table attributeinstance drop foreign key attinst_set; +alter table attributeinstance drop foreign key attinst_att; +alter table attributesetinstance drop foreign key attsetinst_set; +alter table attributeuse drop foreign key attuse_set; +alter table attributeuse drop foreign key attuse_att; +alter table attributevalue drop foreign key attval_att; + +alter table categories drop foreign key categories_fk_1; + +alter table customers drop foreign key customers_taxcat; + +alter table leaves drop foreign key leaves_pplid; + +alter table payments drop foreign key payments_fk_receipt; + +alter table products drop foreign key products_attrset_fk; +alter table products drop foreign key products_taxcat_fk; +alter table products drop foreign key products_fk_1; +alter table products drop index products_inx_0; +alter table products drop index products_inx_1; +alter table products drop index products_name_inx; + +alter table products_bundle drop foreign key products_bundle_fk_1; +alter table products_bundle drop foreign key products_bundle_fk_2; + +alter table products_cat drop foreign key products_cat_fk_1; + +alter table products_com drop foreign key products_com_fk_1; +alter table products_com drop foreign key products_com_fk_2; + +alter table receipts drop foreign key receipts_fk_money; + +alter table reservation_customers drop foreign key res_cust_fk_1; +alter table reservation_customers drop foreign key res_cust_fk_2; + +alter table shift_breaks drop foreign key shift_breaks_breakid; +alter table shift_breaks drop foreign key shift_breaks_shiftid; + +alter table stockcurrent drop foreign key stockcurrent_attsetinst; +alter table stockcurrent drop foreign key stockcurrent_fk_1; +alter table stockcurrent drop foreign key stockcurrent_fk_2; + +alter table stockdiary drop foreign key stockdiary_attsetinst; +alter table stockdiary drop foreign key stockdiary_fk_1; +alter table stockdiary drop foreign key stockdiary_fk_2; + +alter table stocklevel drop foreign key stocklevel_product; +alter table stocklevel drop foreign key stocklevel_location; + +alter table taxes drop foreign key taxes_cat_fk; +alter table taxes drop foreign key taxes_custcat_fk; +alter table taxes drop foreign key taxes_taxes_fk; + +alter table taxlines drop foreign key taxlines_tax; +alter table taxlines drop foreign key taxlines_receipt; + +alter table ticketlines drop foreign key ticketlines_attsetinst; +alter table ticketlines drop foreign key ticketlines_fk_ticket; +alter table ticketlines drop foreign key ticketlines_fk_2; +alter table ticketlines drop foreign key ticketlines_fk_3; + +alter table tickets drop foreign key tickets_customers_fk; +alter table tickets drop foreign key tickets_fk_2; +alter table tickets drop foreign key tickets_fk_id; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-normalise-tables.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-normalise-tables.sql new file mode 100644 index 0000000..f550f81 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-normalise-tables.sql @@ -0,0 +1,434 @@ +-- uniCenta oPOS - Touch Friendly Point Of Sale +-- Copyright (c) 2009-2017 uniCenta +-- https://unicenta.com +-- +-- This file is part of uniCenta oPOS. +-- +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +/* + * Script created by Jack, uniCenta 28/07/2016 08:00:00 + * + * Database upgrade script for MySQL + * Normalise TABLENAME to tablename + * lowercase is common to all platforms + * Linux default is lowercase whereas windows and Mac accepts UPPER OR lowercase +*/ + +-- +-- CLEAR THE DECKS +-- Need to clear any unsettled sales as properties is serialized and so may not +-- match the formats + +DELETE FROM sharedtickets; + +/* Alter table in target */ +-- ALTER TABLE APPLICATIONS RENAME `applications` , +-- DROP KEY PRIMARY, ADD PRIMARY KEY(`id`) ; +ALTER TABLE APPLICATIONS RENAME `applications_tmp` , + DROP KEY PRIMARY +ALTER TABLE `applications_tmp` RENAME `applications`, + ADD PRIMARY KEY(`id`); + +/* Alter table in target */ +ALTER TABLE ATTRIBUTE RENAME `attribute_tmp` , + DROP KEY `PRIMARY`; +ALTER TABLE `attribute_tmp` RENAME `attribute`, + ADD PRIMARY KEY (`id`); + +/* Alter table in target */ +ALTER TABLE ATTRIBUTEINSTANCE RENAME `attributeinstance_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `ATTINST_ATT` , + DROP KEY `ATTINST_SET` ; +ALTER TABLE `attributeinstance_tmp` RENAME `attributeinstance`, + ADD PRIMARY KEY (`id`), + ADD KEY `attinst_att`(`attribute_id`), + ADD KEY `attinst_set`(`attributesetinstance_id`); + +/* Alter table in target */ +ALTER TABLE ATTRIBUTESET RENAME `attributeset_tmp` , + DROP KEY `PRIMARY`; +ALTER TABLE `attributeset_tmp` RENAME `attributeset` , + ADD PRIMARY KEY(`id`) ; + +/* Alter table in target */ +ALTER TABLE ATTRIBUTESETINSTANCE RENAME `attributesetinstance_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `ATTSETINST_SET` ; +ALTER TABLE `attributesetinstance_tmp` RENAME `attributesetinstance` , + ADD PRIMARY KEY(`id`), + ADD KEY `attsetinst_set`(`attributeset_id`) ; + +/* Alter table in target */ +ALTER TABLE ATTRIBUTEUSE RENAME `attributeuse_tmp` , + DROP KEY `PRIMARY` , + DROP KEY `ATTUSE_ATT` , + DROP KEY `ATTUSE_LINE` ; +ALTER TABLE `attributeuse_tmp` RENAME `attributeuse` , + ADD PRIMARY KEY(`id`), + ADD KEY `attuse_att`(`attribute_id`) , + ADD UNIQUE KEY `attuse_line`(`attributeset_id`,`lineno`) ; + +/* Alter table in target */ +ALTER TABLE ATTRIBUTEVALUE RENAME `attributevalue_tmp` , + DROP KEY `PRIMARY` , + DROP KEY `ATTVAL_ATT` ; +ALTER TABLE `attributevalue_tmp` RENAME `attributevalue` , + ADD PRIMARY KEY(`id`) , + ADD KEY `attval_att`(`attribute_id`) ; + +/* Alter table in target */ +ALTER TABLE BREAKS RENAME `breaks_tmp` , + DROP KEY `PRIMARY` ; +ALTER TABLE `breaks_tmp` RENAME `breaks` , + ADD PRIMARY KEY(`id`) ; + +/* Alter table in target */ +ALTER TABLE CATEGORIES RENAME `categories_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `categories_fk_1` , + DROP KEY `CATEGORIES_NAME_INX` ; +ALTER TABLE `categories_tmp` RENAME `categories` , + ADD PRIMARY KEY(`id`) , + ADD KEY `categories_fk_1`(`parentid`) , + ADD UNIQUE KEY `categories_name_inx`(`name`) ; + +/* Alter table in target */ +ALTER TABLE CLOSEDCASH RENAME `closedcash_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `CLOSEDCASH_INX_1` , + DROP KEY `CLOSEDCASH_INX_SEQ` ; +ALTER TABLE `closedcash_tmp` RENAME `closedcash` , + ADD PRIMARY KEY(`money`) , + ADD KEY `closedcash_inx_1`(`datestart`) , + ADD UNIQUE KEY `closedcash_inx_seq`(`host`,`hostsequence`) ; + +/* Alter table in target */ +ALTER TABLE CSVIMPORT RENAME `csvimport_tmp` , + DROP KEY `PRIMARY` ; +ALTER TABLE `csvimport_tmp` RENAME `csvimport` , + ADD PRIMARY KEY(`id`) ; + +/* Alter table in target */ +ALTER TABLE CUSTOMERS RENAME `customers_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `CUSTOMERS_CARD_INX` , + DROP KEY `CUSTOMERS_NAME_INX` , + DROP KEY `CUSTOMERS_SKEY_INX` , + DROP KEY `CUSTOMERS_TAXCAT` , + DROP KEY `CUSTOMERS_TAXID_INX` ; +ALTER TABLE `customers_tmp` RENAME `customers` , + ADD PRIMARY KEY(`id`) , + ADD KEY `customers_card_inx`(`card`) , + ADD KEY `customers_name_inx`(`name`) , + ADD UNIQUE KEY `customers_skey_inx`(`searchkey`) , + ADD KEY `customers_taxcat`(`taxcategory`) , + ADD KEY `customers_taxid_inx`(`taxid`) ; + +/* Alter table in target */ +ALTER TABLE DRAWEROPENED RENAME `draweropened_tmp` ; +ALTER TABLE `draweropened_tmp` RENAME `draweropened` ; + +/* Alter table in target */ +ALTER TABLE FLOORS RENAME `floors_tmp` , + DROP KEY `PRIMARY` , + DROP KEY `FLOORS_NAME_INX` ; +ALTER TABLE `floors_tmp` RENAME `floors` , + ADD PRIMARY KEY(`id`) , + ADD UNIQUE KEY `floors_name_inx`(`name`) ; + +/* Alter table in target */ +ALTER TABLE LEAVES RENAME `leaves_tmp` , + DROP KEY `PRIMARY` , + DROP KEY `lEAVES_PPLID` ; +ALTER TABLE `leaves_tmp` RENAME `leaves` , + ADD PRIMARY KEY(`id`) , + ADD KEY `leaves_pplid`(`pplid`) ; + + +/* Alter table in target */ +ALTER TABLE LINEREMOVED RENAME `lineremoved_tmp` ; +ALTER TABLE `lineremoved_tmp` RENAME `lineremoved` ; + +/* Alter table in target */ +ALTER TABLE LOCATIONS RENAME `locations_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `LOCATIONS_NAME_INX` ; +ALTER TABLE `locations_tmp` RENAME `locations` , + ADD PRIMARY KEY(`id`) , + ADD UNIQUE KEY `locations_name_inx`(`name`) ; + +/* Alter table in target */ +ALTER TABLE MOORERS RENAME `moorers_tmp` ; +ALTER TABLE `moorers_tmp` RENAME `moorers` ; + +/* Alter table in target */ +ALTER TABLE PAYMENTS RENAME `payments_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `PAYMENTS_FK_RECEIPT` , + DROP KEY `PAYMENTS_INX_1` ; +ALTER TABLE `payments_tmp` RENAME `payments` , + ADD PRIMARY KEY(`id`) , + ADD KEY `payments_fk_receipt`(`receipt`) , + ADD KEY `payments_inx_1`(`payment`) ; + +/* Alter table in target */ +ALTER TABLE PEOPLE RENAME `people_tmp` , + DROP KEY `PRIMARY` , + DROP KEY `PEOPLE_CARD_INX` , + DROP KEY `PEOPLE_FK_1` , + DROP KEY `PEOPLE_NAME_INX` ; +ALTER TABLE `people_tmp` RENAME `people` , + ADD PRIMARY KEY(`id`) , + ADD KEY `people_card_inx`(`card`) , + ADD KEY `people_fk_1`(`role`) , + ADD UNIQUE KEY `people_name_inx`(`name`) ; + +/* Alter table in target */ +ALTER TABLE PLACES RENAME `places_tmp` , + DROP KEY `PRIMARY` , + DROP KEY `PLACES_NAME_INX` ; +ALTER TABLE `places_tmp` RENAME `places` , + ADD PRIMARY KEY(`id`) , + ADD UNIQUE KEY `places_name_inx`(`name`) ; + + +/* Alter table in target */ +ALTER TABLE PRODUCTS RENAME `products_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `PRODUCTS_ATTRSET_FK` , + DROP KEY `PRODUCTS_FK_1` , + DROP KEY `PRODUCTS_INX_0` , + DROP KEY `PRODUCTS_INX_1` , + DROP KEY `PRODUCTS_NAME_INX` , + DROP KEY `PRODUCTS_TAXCAT_FK` ; +ALTER TABLE `products_tmp` RENAME `products` , + ADD PRIMARY KEY(`id`) , + ADD KEY `products_attrset_fx`(`attributeset_id`) , + ADD KEY `products_fk_1`(`category`) , + ADD UNIQUE KEY `products_inx_0`(`reference`) , + ADD UNIQUE KEY `products_inx_1`(`code`) , + ADD KEY `products_name_inx`(`name`) , + ADD KEY `products_taxcat_fk`(`taxcat`) ; + +/* Alter table in target */ +ALTER TABLE PRODUCTS_CAT RENAME `products_cat_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `PRODUCTS_CAT_INX_1` ; +ALTER TABLE `products_cat_tmp` RENAME `products_cat` , + ADD PRIMARY KEY(`product`) , + ADD KEY `products_cat_inx_1`(`catorder`) ; + +/* Alter table in target */ +ALTER TABLE PRODUCTS_COM RENAME `products_com_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `PCOM_INX_PROD` , + DROP KEY `PRODUCTS_COM_FK_2` ; +ALTER TABLE `products_com_tmp` RENAME `products_com` , + ADD PRIMARY KEY(`id`) , + ADD UNIQUE KEY `pcom_inx_prod`(`product`,`product2`) , + ADD KEY `products_com_fk_2`(`product2`) ; + +/* Alter table in target */ +ALTER TABLE RECEIPTS RENAME `receipts_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `RECEIPTS_FK_MONEY` , + DROP KEY `RECEIPTS_INX_1` ; +ALTER TABLE `receipts_tmp` RENAME `receipts` , + ADD PRIMARY KEY(`id`) , + ADD KEY `receipts_fk_money`(`money`) , + ADD KEY `receipts_inx_1`(`datenew`) ; + + +/* Alter table in target */ +ALTER TABLE RESERVATION_CUSTOMERS RENAME `reservation_customers_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `RES_CUST_FK_2` ; +ALTER TABLE `reservation_customers_tmp` RENAME `reservation_customers` , + ADD PRIMARY KEY(`id`) , + ADD KEY `res_cust_fk_2`(`customer`) ; + + +/* Alter table in target */ +ALTER TABLE RESERVATIONS RENAME `reservations_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `RESERVATIONS_INX_1` ; +ALTER TABLE `reservations_tmp` RENAME `reservations` , + ADD PRIMARY KEY(`id`) , + ADD KEY `reservations_inx_1`(`datenew`) ; + +/* Alter table in target */ +ALTER TABLE RESOURCES RENAME `resources_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `RESOURCES_NAME_INX` ; +ALTER TABLE `resources_tmp` RENAME `resources` , + ADD PRIMARY KEY(`id`) , + ADD UNIQUE KEY `resources_name_inx`(`name`) ; + + +/* Alter table in target */ +ALTER TABLE ROLES RENAME `roles_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `ROLES_NAME_INX` ; +ALTER TABLE `roles_tmp` RENAME `roles` , + ADD PRIMARY KEY(`id`) , + ADD UNIQUE KEY `roles_name_inx`(`name`) ; + +/* Alter table in target */ +ALTER TABLE SHAREDTICKETS RENAME `sharedtickets_tmp` , + DROP KEY `PRIMARY` ; +ALTER TABLE `sharedtickets_tmp` RENAME `sharedtickets` , + ADD PRIMARY KEY(`id`) ; + +/* Alter table in target */ +ALTER TABLE SHIFT_BREAKS RENAME `shift_breaks_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `SHIFT_BREAKS_BREAKID` , + DROP KEY `SHIFT_BREAKS_SHIFTID` ; +ALTER TABLE `shift_breaks_tmp` RENAME `shift_breaks` , + ADD PRIMARY KEY(`id`) , + ADD KEY `shift_breaks_breakid`(`breakid`) , + ADD KEY `shift_breaks_shiftid`(`shiftid`) ; + +/* Alter table in target */ +ALTER TABLE SHIFTS RENAME `shifts_tmp` , + DROP KEY `PRIMARY` ; +ALTER TABLE `shifts_tmp` RENAME `shifts` , + ADD PRIMARY KEY(`id`) ; + +/* Alter table in target */ +ALTER TABLE STOCKCURRENT RENAME `stockcurrent_tmp` , +DROP KEY `STOCKCURRENT_ATTSETINST` , +DROP KEY `STOCKCURRENT_FK_1` , +DROP KEY `STOCKCURRENT_INX` ; +ALTER TABLE `stockcurrent_tmp` RENAME `stockcurrent` , +ADD KEY `stockcurrent_attsetinst`(`attributesetinstance_id`) , +ADD KEY `stockcurrent_fk_1`(`product`) , +ADD UNIQUE KEY `stockcurrent_inx`(`location`,`product`,`attributesetinstance_id`) ; + +/* Alter table in target */ +ALTER TABLE STOCKDIARY RENAME `stockdiary_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `STOCKDIARY_ATTSETINST` , + DROP KEY `STOCKDIARY_FK_1` , + DROP KEY `STOCKDIARY_FK_2` , + DROP KEY `STOCKDIARY_INX_1` ; +ALTER TABLE `stockdiary_tmp` RENAME `stockdiary` , + ADD PRIMARY KEY(`id`) , + ADD KEY `stockdiary_fk_1`(`product`) , + ADD KEY `stockdiary_fk_2`(`location`) , + ADD KEY `stockdiary_attsetinst`(`attributesetinstance_id`) , + ADD KEY `stockdiary_inx_1`(`datenew`) ; + + +/* Alter table in target */ +ALTER TABLE STOCKLEVEL RENAME `stocklevel_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `STOCKLEVEL_LOCATION` , + DROP KEY `STOCKLEVEL_PRODUCT` ; +ALTER TABLE `stocklevel_tmp` RENAME `stocklevel` , + ADD PRIMARY KEY(`id`) , + ADD KEY `stocklevel_location`(`location`) , + ADD KEY `stocklevel_product`(`product`) ; + +/* Alter table in target */ +ALTER TABLE TAXCATEGORIES RENAME `taxcategories_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `TAXCAT_NAME_INX` ; +ALTER TABLE `taxcategories_tmp` RENAME `taxcategories` , + ADD PRIMARY KEY(`id`) , + ADD UNIQUE KEY `taxcat_name_inx`(`name`) ; + +/* Alter table in target */ +ALTER TABLE TAXCUSTCATEGORIES RENAME `taxcustcategories_tmp` , + DROP KEY `PRIMARY`, +DROP KEY `TAXCUSTCAT_NAME_INX` ; +ALTER TABLE `taxcustcategories_tmp` RENAME `taxcustcategories` , + ADD PRIMARY KEY(`id`) , + ADD UNIQUE KEY `taxcustcat_name_inx`(`name`) ; + +/* Alter table in target */ +ALTER TABLE TAXES RENAME `taxes_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `TAXES_CAT_FK` , + DROP KEY `TAXES_CUSTCAT_FK` , + DROP KEY `TAXES_NAME_INX` , + DROP KEY `TAXES_TAXES_FK` ; +ALTER TABLE `taxes_tmp` RENAME `taxes` , + ADD PRIMARY KEY(`id`) , + ADD KEY `taxes_cat_fk`(`category`) , + ADD KEY `taxes_custcat_fk`(`custcategory`) , + ADD UNIQUE KEY `taxes_name_inx`(`name`) , + ADD KEY `taxes_taxes_fk`(`parentid`) ; + + +/* Alter table in target */ +ALTER TABLE TAXLINES RENAME `taxlines_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `TAXLINES_RECEIPT` , + DROP KEY `TAXLINES_TAX` ; +ALTER TABLE `taxlines_tmp` RENAME `taxlines` , + ADD PRIMARY KEY(`id`) , + ADD KEY `taxlines_receipt`(`receipt`) , + ADD KEY `taxlines_tax`(`taxid`) ; + + +/* Alter table in target */ +ALTER TABLE THIRDPARTIES RENAME `thirdparties_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `THIRDPARTIES_CIF_INX` , + DROP KEY `THIRDPARTIES_NAME_INX` ; +ALTER TABLE `thirdparties_tmp` RENAME `thirdparties` , + ADD PRIMARY KEY(`id`) , + ADD UNIQUE KEY `thirdparties_cif_inx`(`cif`) , + ADD UNIQUE KEY `thirdparties_name_inx`(`name`) ; + + +/* Alter table in target */ +ALTER TABLE TICKETLINES RENAME `ticketlines_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `TICKETLINES_ATTSETINST` , + DROP KEY `TICKETLINES_FK_2` , + DROP KEY `TICKETLINES_FK_3` ; +ALTER TABLE `ticketlines_tmp` RENAME `ticketlines` , + ADD PRIMARY KEY(`ticket`,`line`) , + ADD KEY `ticketlines_attsetinst`(`attributesetinstance_id`) , + ADD KEY `ticketlines_fk_2`(`product`) , + ADD KEY `ticketlines_fk_3`(`taxid`) ; + +/* Alter table in target */ +ALTER TABLE TICKETS RENAME `tickets_tmp` , + DROP KEY `PRIMARY`, + DROP KEY `tickets_CUSTOMERS_FK` , + DROP KEY `tickets_FK_2` , + DROP KEY `tickets_TICKETID` ; +ALTER TABLE `tickets_tmp` RENAME `tickets` , + ADD PRIMARY KEY(`id`) , + ADD KEY `tickets_customers_fk`(`customer`) , + ADD KEY `tickets_fk_2`(`person`) , + ADD KEY `tickets_ticketid`(`tickettype`,`ticketid`) ; + + +/* Alter table in target */ +ALTER TABLE TICKETSNUM RENAME `ticketsnum_tmp` ; +ALTER TABLE `ticketsnum_tmp` RENAME `ticketsnum` ; + +ALTER TABLE TICKETSNUM_PAYMENT RENAME `ticketsnum_payment_tmp` , + DROP KEY `PRIMARY` ; +ALTER TABLE `ticketsnum_payment_tmp` RENAME `ticketsnum_payment` , + ADD PRIMARY KEY(`id`) ; + +ALTER TABLE TICKETSNUM_REFUND RENAME `ticketsnum_refund_tmp` ; +ALTER TABLE `ticketsnum_refund_tmp` RENAME `ticketsnum_refund` ; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-orders-table.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-orders-table.sql new file mode 100644 index 0000000..15e67d6 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-orders-table.sql @@ -0,0 +1,35 @@ +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +/* + * Script created by Jack, uniCenta 20/11/2016 08:00:00 + * + * Create ORDERS table for Remote Display +*/ + +/* Header line. Object: orders. Script date: 01/01/2017 00:00:01. */ +CREATE TABLE IF NOT EXISTS `orders` ( + `id` int(11) NOT NULL, + `orderid` varchar(50) DEFAULT NULL, + `qty` int(11) DEFAULT '1', + `details` varchar(255) DEFAULT NULL, + `attributes` varchar(255) DEFAULT NULL, + `notes` varchar(255) DEFAULT NULL, + `ticketid` varchar(50) DEFAULT NULL, + `ordertime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `displayid` int(11) DEFAULT '1', + `auxiliary` int(11) DEFAULT NULL, + `completetime` timestamp, + PRIMARY KEY (`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.1.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.1.sql new file mode 100644 index 0000000..d55c033 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.1.sql @@ -0,0 +1,45 @@ +-- uniCenta oPOS - Touch Friendly Point Of Sale +-- Copyright (c) 2009-2018 uniCenta +-- https://unicenta.com +-- +-- This file is part of uniCenta oPOS. +-- +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +-- Database upgrade script for MySQL +-- v4.5.1 - v4.5.2 17FEB2018 + +-- +-- CLEAR THE DECKS +-- +DELETE FROM sharedtickets; + +-- RECREATE applications -- +DROP TABLE `applications`; +CREATE TABLE IF NOT EXISTS `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `instdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +set foreign_key_checks = 0; + +DELETE FROM roles WHERE id = '0'; +INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); + +set foreign_key_checks = 1; + +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.2.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.2.sql new file mode 100644 index 0000000..df8581d --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.2.sql @@ -0,0 +1,38 @@ +-- uniCenta oPOS - Touch Friendly Point Of Sale +-- Copyright (c) 2009-2018 uniCenta +-- https://unicenta.com +-- +-- This file is part of uniCenta oPOS. +-- +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +-- Database upgrade script for MySQL +-- v4.5.2 - v4.5.3 3MAR2018 + +-- +-- CLEAR THE DECKS +-- +DELETE FROM sharedtickets; + +-- RECREATE applications -- +DROP TABLE `applications`; +CREATE TABLE IF NOT EXISTS `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `instdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.3.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.3.sql new file mode 100644 index 0000000..3ca4f64 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.3.sql @@ -0,0 +1,38 @@ +-- uniCenta oPOS - Touch Friendly Point Of Sale +-- Copyright (c) 2009-2018 uniCenta +-- https://unicenta.com +-- +-- This file is part of uniCenta oPOS. +-- +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +-- Database upgrade script for MySQL +-- v4.5.3 - v4.5.4 9MAY2018 + +-- +-- CLEAR THE DECKS +-- +DELETE FROM sharedtickets; + +-- RECREATE applications -- +DROP TABLE `applications`; +CREATE TABLE IF NOT EXISTS `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `instdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.4.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.4.sql new file mode 100644 index 0000000..594c851 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.4.sql @@ -0,0 +1,54 @@ +-- uniCenta oPOS - Touch Friendly Point Of Sale +-- Copyright (c) 2009-2018 uniCenta +-- https://unicenta.com +-- +-- This file is part of uniCenta oPOS. +-- +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +-- Database upgrade script for MySQL +-- v4.5 - v4.5.5 3JUNE2018 + +-- +-- CLEAR THE DECKS +-- +DELETE FROM sharedtickets; + +set foreign_key_checks = 0; + +-- RECREATE applications -- +DROP TABLE `applications`; +CREATE TABLE IF NOT EXISTS `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `instdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +-- SYSTEM +DELETE FROM resources WHERE id = '00'; +INSERT INTO resources(id, name, restype, content) VALUES('00', 'Menu.Root', 0, $FILE{/com/unicenta/pos/templates/Menu.Root.txt}); + +-- COMMONS +DELETE FROM roles WHERE id = '0'; +INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); +DELETE FROM roles WHERE id = '1'; +INSERT INTO roles(id, name, permissions) VALUES('1', 'Manager role', $FILE{/com/unicenta/pos/templates/Role.Manager.xml} ); +DELETE FROM roles WHERE id = '2'; +INSERT INTO roles(id, name, permissions) VALUES('2', 'Employee role', $FILE{/com/unicenta/pos/templates/Role.Employee.xml} ); + +set foreign_key_checks = 1; + +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.sql new file mode 100644 index 0000000..5e970f8 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade-4.5.sql @@ -0,0 +1,48 @@ +-- uniCenta oPOS - Touch Friendly Point Of Sale +-- Copyright (c) 2009-2018 uniCenta +-- https://unicenta.com +-- +-- This file is part of uniCenta oPOS. +-- +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +-- Database upgrade script for MySQL +-- v4.5 - v4.5.1 27JAN2018 + +-- +-- CLEAR THE DECKS +-- +DELETE FROM sharedtickets; + +set foreign_key_checks = 0; + +-- RECREATE applications -- +DROP TABLE `applications`; +CREATE TABLE IF NOT EXISTS `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `instdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + +-- VERSIONS + +-- COMMONS +DELETE FROM roles WHERE id = '0'; +INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); + +set foreign_key_checks = 1; + +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade_master.sql b/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade_master.sql new file mode 100644 index 0000000..b9be8c6 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/MySQL-upgrade_master.sql @@ -0,0 +1,62 @@ +-- CLEAR THE DECKS +DELETE FROM sharedtickets; + +-- Switch OFF table foreign key relationships +set foreign_key_checks = 0; + +-- RECREATE applications table +DROP TABLE `applications`; +CREATE TABLE IF NOT EXISTS `applications` ( + `id` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `version` varchar(255) NOT NULL, + `instdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY ( `id` ) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT = Compact; + + +-- SYSTEM +DELETE FROM resources WHERE name = 'script.posapps'; + + +DELETE FROM resources WHERE id = '0'; +DELETE FROM resources WHERE id = '00'; +INSERT INTO resources(id, name, restype, content) VALUES('00', 'Menu.Root', 0, $FILE{/com/unicenta/pos/templates/Menu.Root.txt}); + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Ticket.Buttons.xml} WHERE name = 'Ticket.Buttons'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Printer.Ticket.xml} WHERE name = 'Printer.Ticket'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Ticket.Close.xml} WHERE name = 'Ticket.Close'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/Cash.Close.xml} WHERE name = 'Cash.Close'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.created.xml} WHERE name = 'Customer.Created'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.deleted.xml} WHERE name = 'Customer.Deleted'; +COMMIT; + +UPDATE resources SET content = $FILE{/com/unicenta/pos/templates/customer.updated.xml} WHERE name = 'Customer.Updated'; +COMMIT; + + +-- ROLES +DELETE FROM roles WHERE id = '0'; +INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); +DELETE FROM roles WHERE id = '1'; +INSERT INTO roles(id, name, permissions) VALUES('1', 'Manager role', $FILE{/com/unicenta/pos/templates/Role.Manager.xml} ); +DELETE FROM roles WHERE id = '2'; +INSERT INTO roles(id, name, permissions) VALUES('2', 'Employee role', $FILE{/com/unicenta/pos/templates/Role.Employee.xml} ); + + +-- Switch ON table foreign key relationships +set foreign_key_checks = 1; + +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); + +COMMIT; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/PostgreSQL-create.sql b/src/main/resources/com/unicenta/pos/scripts/PostgreSQL-create.sql new file mode 100644 index 0000000..625c440 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/PostgreSQL-create.sql @@ -0,0 +1,746 @@ +-- uniCenta oPOS - Touch Friendly Point Of Sale +-- Copyright (C) 2009-2017 uniCenta +-- http://sourceforge.net/projects/unicentaopos +-- +-- This file is part of uniCenta oPOS. +-- +-- uniCenta oPOS 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. +-- +-- uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +-- Database create script for PostgreSQL +-- v4.1.4 + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE applications ( + id VARCHAR NOT NULL, + name VARCHAR NOT NULL, + version VARCHAR NOT NULL, + PRIMARY KEY (id) +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE roles ( + id VARCHAR NOT NULL, + name VARCHAR NOT NULL, + permissions BYTEA, + PRIMARY KEY (id) +); +CREATE UNIQUE INDEX ROLES_NAME_INX ON roles(name); +INSERT INTO ROLES(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); +INSERT INTO ROLES(id, name, permissions) VALUES('1', 'Manager role', $FILE{/com/unicenta/pos/templates/Role.Manager.xml} ); +INSERT INTO ROLES(id, name, permissions) VALUES('2', 'Employee role', $FILE{/com/unicenta/pos/templates/Role.Employee.xml} ); +INSERT INTO ROLES(id, name, permissions) VALUES('3', 'Guest role', $FILE{/com/unicenta/pos/templates/Role.Guest.xml} ); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE people ( + id VARCHAR NOT NULL, + name VARCHAR NOT NULL, + apppassword VARCHAR, + card VARCHAR, + role VARCHAR NOT NULL, + visible BOOLEAN NOT NULL, + image BYTEA, + PRIMARY KEY (id), + CONSTRAINT PEOPLE_FK_1 FOREIGN KEY (ROLE) REFERENCES roles(id) +); +CREATE UNIQUE INDEX PEOPLE_NAME_INX ON people(name); +CREATE INDEX PEOPLE_CARD_INX ON people(card); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('0', 'Administrator', NULL, '0', TRUE, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('1', 'Manager', NULL, '1', TRUE, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('2', 'Employee', NULL, '2', TRUE, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('3', 'Guest', NULL, '3', TRUE, NULL); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE resources ( + id VARCHAR NOT NULL, + name VARCHAR NOT NULL, + restype INTEGER NOT NULL, + content BYTEA, + PRIMARY KEY (id) +); +CREATE UNIQUE INDEX RESOURCES_NAME_INX ON resources(name); + +-- ADD resources -- +-- MENU +INSERT INTO resources(id, name, restype, content) VALUES('0', 'Menu.Root', 0, $FILE{/com/unicenta/pos/templates/Menu.Root.txt}); + +-- IMAGES +INSERT INTO resources(id, name, restype, content) VALUES('1', 'coin.01', 1, $FILE{/com/unicenta/pos/templates/coin.01.png}); +INSERT INTO resources(id, name, restype, content) VALUES('2', 'coin.02', 1, $FILE{/com/unicenta/pos/templates/coin.02.png}); +INSERT INTO resources(id, name, restype, content) VALUES('3', 'coin.05', 1, $FILE{/com/unicenta/pos/templates/coin.05.png}); +INSERT INTO resources(id, name, restype, content) VALUES('4', 'coin.1', 1, $FILE{/com/unicenta/pos/templates/coin.1.png}); +INSERT INTO resources(id, name, restype, content) VALUES('5', 'coin.10', 1, $FILE{/com/unicenta/pos/templates/coin.10.png}); +INSERT INTO resources(id, name, restype, content) VALUES('6', 'coin.2', 1, $FILE{/com/unicenta/pos/templates/coin.2.png}); +INSERT INTO resources(id, name, restype, content) VALUES('7', 'coin.20', 1, $FILE{/com/unicenta/pos/templates/coin.20.png}); +INSERT INTO resources(id, name, restype, content) VALUES('8', 'coin.50', 1, $FILE{/com/unicenta/pos/templates/coin.50.png}); +INSERT INTO resources(id, name, restype, content) VALUES('9', 'img.cash', 1, $FILE{/com/unicenta/pos/templates/img.cash.png}); +INSERT INTO resources(id, name, restype, content) VALUES('10', 'img.cashdrawer', 1, $FILE{/com/unicenta/pos/templates/img.cashdrawer.png}); +INSERT INTO resources(id, name, restype, content) VALUES('11', 'img.discount', 1, $FILE{/com/unicenta/pos/templates/img.discount.png}); +INSERT INTO resources(id, name, restype, content) VALUES('12', 'img.discount_b', 1, $FILE{/com/unicenta/pos/templates/img.discount_b.png}); +INSERT INTO resources(id, name, restype, content) VALUES('13', 'img.empty', 1, $FILE{/com/unicenta/pos/templates/img.empty.png}); +INSERT INTO resources(id, name, restype, content) VALUES('14', 'img.heart', 1, $FILE{/com/unicenta/pos/templates/img.heart.png}); +INSERT INTO resources(id, name, restype, content) VALUES('15', 'img.keyboard_32', 1, $FILE{/com/unicenta/pos/templates/img.keyboard_32.png}); +INSERT INTO resources(id, name, restype, content) VALUES('16', 'img.kit_print', 1, $FILE{/com/unicenta/pos/templates/img.kit_print.png}); +INSERT INTO resources(id, name, restype, content) VALUES('17', 'img.no_photo', 1, $FILE{/com/unicenta/pos/templates/img.no_photo.png}); +INSERT INTO resources(id, name, restype, content) VALUES('18', 'img.refundit', 1, $FILE{/com/unicenta/pos/templates/img.refundit.png}); +INSERT INTO resources(id, name, restype, content) VALUES('19', 'img.run_script', 1, $FILE{/com/unicenta/pos/templates/img.run_script.png}); +INSERT INTO resources(id, name, restype, content) VALUES('20', 'img.ticket_print', 1, $FILE{/com/unicenta/pos/templates/img.ticket_print.png}); +INSERT INTO resources(id, name, restype, content) VALUES('21', 'img.user', 1, $FILE{/com/unicenta/pos/templates/img.user.png}); +INSERT INTO resources(id, name, restype, content) VALUES('22', 'note.50', 1, $FILE{/com/unicenta/pos/templates/note.50.png}); +INSERT INTO resources(id, name, restype, content) VALUES('23', 'note.20', 1, $FILE{/com/unicenta/pos/templates/note.20.png}); +INSERT INTO resources(id, name, restype, content) VALUES('24', 'note.10', 1, $FILE{/com/unicenta/pos/templates/note.10.png}); +INSERT INTO resources(id, name, restype, content) VALUES('25', 'note.5', 1, $FILE{/com/unicenta/pos/templates/note.5.png}); + +-- PRINTER +INSERT INTO resources(id, name, restype, content) VALUES('26', 'Printer.CloseCash.Preview', 0, $FILE{/com/unicenta/pos/templates/Printer.CloseCash.Preview.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('27', 'Printer.CloseCash', 0, $FILE{/com/unicenta/pos/templates/Printer.CloseCash.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('28', 'Printer.CustomerPaid', 0, $FILE{/com/unicenta/pos/templates/Printer.CustomerPaid.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('29', 'Printer.CustomerPaid2', 0, $FILE{/com/unicenta/pos/templates/Printer.CustomerPaid2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('30', 'Printer.FiscalTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.FiscalTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('31', 'Printer.Inventory', 0, $FILE{/com/unicenta/pos/templates/Printer.Inventory.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('32', 'Printer.OpenDrawer', 0, $FILE{/com/unicenta/pos/templates/Printer.OpenDrawer.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('33', 'Printer.PartialCash', 0, $FILE{/com/unicenta/pos/templates/Printer.PartialCash.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('34', 'Printer.PrintLastTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.PrintLastTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('35', 'Printer.Product', 0, $FILE{/com/unicenta/pos/templates/Printer.Product.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('36', 'Printer.ReprintTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.ReprintTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('37', 'Printer.Start', 0, $FILE{/com/unicenta/pos/templates/Printer.Start.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('38', 'Printer.Ticket.P1', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P1.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('39', 'Printer.Ticket.P2', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('40', 'Printer.Ticket.P3', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P3.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('41', 'Printer.Ticket.P4', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P4.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('42', 'Printer.Ticket.P5', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P5.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('43', 'Printer.Ticket.P6', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P6.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('44', 'Printer.Ticket', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('45', 'Printer.Ticket2', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('46', 'Printer.TicketClose', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketClose.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('47', 'Printer.TicketRemote', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketRemote.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('48', 'Printer.TicketLine', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketLine.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('49', 'Printer.TicketNew', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketLine.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('50', 'Printer.TicketPreview', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketPreview.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('51', 'Printer.TicketTotal', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketTotal.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('52', 'Printer.Ticket.Logo', 1, $FILE{/com/unicenta/pos/templates/printer.ticket.logo.png}); + +-- SCRIPTS +INSERT INTO resources(id, name, restype, content) VALUES('53', 'script.AddLineNote', 0, $FILE{/com/unicenta/pos/templates/script.AddLineNote.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('54', 'script.Event.Total', 0, $FILE{/com/unicenta/pos/templates/script.Event.Total.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('55', 'script.Keyboard', 0, $FILE{/com/unicenta/pos/templates/script.Keyboard.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('56', 'script.linediscount', 0, $FILE{/com/unicenta/pos/templates/script.linediscount.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('57', 'script.ReceiptConsolidate', 0, $FILE{/com/unicenta/pos/templates/script.ReceiptConsolidate.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('58', 'script.Refundit', 0, $FILE{/com/unicenta/pos/templates/script.Refundit.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('59', 'script.SendOrder', 0, $FILE{/com/unicenta/pos/templates/script.SendOrder.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('60', 'script.ServiceCharge', 0, $FILE{/com/unicenta/pos/templates/script.script.ServiceCharge.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('61', 'script.SetPerson', 0, $FILE{/com/unicenta/pos/templates/script.SetPerson.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('62', 'script.StockCurrentAdd', 0, $FILE{/com/unicenta/pos/templates/script.StockCurrentAdd.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('63', 'script.StockCurrentSet', 0, $FILE{/com/unicenta/pos/templates/script.StockCurrentSet.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('64', 'script.totaldiscount', 0, $FILE{/com/unicenta/pos/templates/script.totaldiscount.txt}); + +-- SYSTEM +INSERT INTO resources(id, name, restype, content) VALUES('65', 'payment.cash', 0, $FILE{/com/unicenta/pos/templates/payment.cash.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('66', 'ticket.addline', 0, $FILE{/com/unicenta/pos/templates/ticket.addline.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('67', 'ticket.change', 0, $FILE{/com/unicenta/pos/templates/ticket.change.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('68', 'Ticket.Buttons', 0, $FILE{/com/unicenta/pos/templates/Ticket.Buttons.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('69', 'Ticket.Close', 0, $FILE{/com/unicenta/pos/templates/Ticket.Close.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('70', 'Ticket.Discount', 0, $FILE{/com/unicenta/pos/templates/Ticket.Discount.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('71', 'Ticket.Line', 0, $FILE{/com/unicenta/pos/templates/Ticket.Line.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('72', 'ticket.removeline', 0, $FILE{/com/unicenta/pos/templates/ticket.removeline.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('73', 'ticket.setline', 0, $FILE{/com/unicenta/pos/templates/ticket.setline.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('74', 'Ticket.TicketLineTaxesIncluded', 0, $FILE{/com/unicenta/pos/templates/Ticket.TicketLineTaxesIncluded.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('75', 'Window.Logo', 1, $FILE{/com/unicenta/pos/templates/window.logo.png}); +INSERT INTO resources(id, name, restype, content) VALUES('76', 'Window.Title', 0, $FILE{/com/unicenta/pos/templates/Window.Title.txt}); + + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE taxcustcategories ( + id VARCHAR NOT NULL, + name VARCHAR NOT NULL, + PRIMARY KEY (id) +); +CREATE UNIQUE INDEX TAXCUSTCAT_NAME_INX ON taxcustcategories(name); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE CUSTOMERS ( + id varchar NOT NULL, + searchkey varchar NOT NULL, + taxid varchar default NULL, + name varchar NOT NULL, + taxcategory varchar default NULL, + card varchar default NULL, + maxdebt double precision default 0 NOT NULL, + address varchar default NULL, + address2 varchar default NULL, + postal varchar default NULL, + city varchar default NULL, + region varchar default NULL, + country varchar default NULL, + firstname varchar default NULL, + lastname varchar default NULL, + email varchar default NULL, + phone varchar default NULL, + phone2 varchar default NULL, + fax varchar default NULL, + notes varchar default NULL, + visible BOOLEAN NOT NULL DEFAULT TRUE, + curdate timestamp default NULL, + curdebt double precision default 0, + image bytea, + isvip BOOLEAN NOT NULL DEFAULT TRUE, + discount double precision default 0 NOT NULL, + PRIMARY KEY (id), + CONSTRAINT CUSTOMERS_TAXCAT FOREIGN KEY (taxcategory) REFERENCES taxcustcategories(id) +); +CREATE UNIQUE INDEX CUSTOMERS_SKEY_INX ON customers(searchkey); +CREATE INDEX CUSTOMERS_TAXID_INX ON customers(taxid); +CREATE INDEX CUSTOMERS_NAME_INX ON customers(name); +CREATE INDEX CUSTOMERS_CARD_INX ON customers(card); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE categories ( + id VARCHAR NOT NULL, + name VARCHAR NOT NULL, + parentid VARCHAR, + image BYTEA, + texttip VARCHAR DEFAULT NULL, + catshowname BOOLEAN NOT NULL DEFAULT TRUE, + catorder varchar default NULL, + PRIMARY KEY (id), + CONSTRAINT categories_fk_1 FOREIGN KEY (parentid) REFERENCES categories(id) +); +CREATE UNIQUE INDEX CATEGORIES_NAME_INX ON categories(name); +INSERT INTO categories(id, name) VALUES ('000', 'Category Standard'); +INSERT INTO categories(id, name) VALUES ('xxx999', '***'); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE taxcategories ( + id varchar NOT NULL, + name varchar NOT NULL, + PRIMARY KEY ( id ) +); +CREATE UNIQUE INDEX TAXCAT_NAME_INX ON taxcategories(name); +INSERT INTO taxcategories(id, name) VALUES ('000', 'Tax Exempt'); +INSERT INTO taxcategories(id, name) VALUES ('001', 'Tax Standard'); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE taxes ( + id varchar NOT NULL, + name varchar NOT NULL, + category varchar NOT NULL, + custcategory varchar default NULL, + parentid varchar default NULL, + rate double precision default 0 NOT NULL, + ratecascade BOOLEAN NOT NULL DEFAULT FALSE, + rateorder integer default NULL, + PRIMARY KEY (id), + CONSTRAINT TAXES_CAT_FK FOREIGN KEY (category) REFERENCES taxcategories(id), + CONSTRAINT TAXES_CUSTCAT_FK FOREIGN KEY (custcategory) REFERENCES taxcustcategories(id), + CONSTRAINT TAXES_TAXES_FK FOREIGN KEY (parentid) REFERENCES taxes(id) +); +CREATE UNIQUE INDEX TAXES_NAME_INX ON taxes(name); +INSERT INTO TAXES(id, name, category, custcategory, parentid, rate, ratecascade, rateorder) VALUES ('000', 'Tax Exempt', '000', NULL, NULL, 0, false, NULL); +INSERT INTO TAXES(id, name, category, custcategory, parentid, rate, ratecascade, rateorder) VALUES ('001', 'Tax Standard', '001', NULL, NULL, 0.10, false, NULL); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE attribute ( + id VARCHAR NOT NULL, + name VARCHAR NOT NULL, + PRIMARY KEY (id) +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE attributevalue ( + id VARCHAR NOT NULL, + attribute_id VARCHAR NOT NULL, + value VARCHAR, + PRIMARY KEY (id), + CONSTRAINT attval_att FOREIGN KEY (attribute_id) REFERENCES attribute(id) ON DELETE CASCADE +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE attributeset ( + id VARCHAR NOT NULL, + name VARCHAR NOT NULL, + PRIMARY KEY (id) +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE attributeuse ( + id VARCHAR NOT NULL, + attributeset_id VARCHAR NOT NULL, + attribute_id VARCHAR NOT NULL, + lineno INTEGER, + PRIMARY KEY (id), + CONSTRAINT attuse_set FOREIGN KEY (attributeset_id) REFERENCES attributeset(id) ON DELETE CASCADE, + CONSTRAINT attuse_att FOREIGN KEY (attribute_id) REFERENCES attribute(id) +); +CREATE UNIQUE INDEX attuse_line ON attributeuse(attributeset_id, lineno); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE attributesetinstance ( + id VARCHAR NOT NULL, + attributeset_ID VARCHAR NOT NULL, + description VARCHAR, + PRIMARY KEY (id), + CONSTRAINT attsetinst_set FOREIGN KEY (attributeset_id) REFERENCES attributeset(id) ON DELETE CASCADE +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE attributeinstance ( + id VARCHAR NOT NULL, + attributesetinstance_id VARCHAR NOT NULL, + attribute_id VARCHAR NOT NULL, + value VARCHAR, + PRIMARY KEY (id), + constraint attinst_set foreign key (attributesetinstance_id) references attributesetinstance(id) on delete cascade, + constraint attinst_att foreign key (attribute_id) references attribute(id) +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE products ( + id varchar NOT NULL, + reference varchar NOT NULL, + code varchar NOT NULL, + codetype varchar default NULL, + name varchar NOT NULL, + pricebuy double precision default 0 NOT NULL, + pricesell double precision default 0 NOT NULL, + category varchar NOT NULL, + taxcat varchar NOT NULL, + attributeset_id varchar default NULL, + stockcost double precision default 0 NOT NULL, + stockvolume double precision default 0 NOT NULL, + image bytea default NULL, + iscom BOOLEAN NOT NULL DEFAULT FALSE, + isscale BOOLEAN NOT NULL DEFAULT FALSE, + isconstant BOOLEAN NOT NULL DEFAULT FALSE, + printkb BOOLEAN NOT NULL DEFAULT FALSE, + sendstatus BOOLEAN NOT NULL DEFAULT FALSE, + isservice BOOLEAN NOT NULL DEFAULT FALSE, + attributes bytea default NULL, + display varchar default NULL, + isvprice BOOLEAN NOT NULL DEFAULT FALSE, + isverpatrib BOOLEAN NOT NULL DEFAULT FALSE, + texttip varchar default NULL, + warranty BOOLEAN NOT NULL DEFAULT FALSE, + stockunits double precision default 0 NOT NULL, + printto varchar default '1', + supplier varchar default NULL, + uom varchar default '0', + PRIMARY KEY (ID), + CONSTRAINT PRODUCTS_FK_1 FOREIGN KEY (category) REFERENCES categories(id), + CONSTRAINT PRODUCTS_TAXCAT_FK FOREIGN KEY (taxcat) REFERENCES taxcategories(id), + CONSTRAINT PRODUCTS_ATTRSET_FK FOREIGN KEY (attributeset_id) REFERENCES attributeset(id) +); +CREATE UNIQUE INDEX PRODUCTS_INX_0 ON products(reference); +CREATE UNIQUE INDEX PRODUCTS_INX_1 ON products(code); +CREATE INDEX PRODUCTS_NAME_INX ON products(name); + +-- ADD PRODUCTS +INSERT INTO products(id, reference, code, name, category, taxcat, isservice, display, printto) +VALUES ('xxx999_999xxx_x9x9x9', 'xxx999', 'xxx999', '***', '000', '001', false, '<html><center>***', '1'); +INSERT INTO products(id, reference, code, name, category, taxcat, isservice, display, printto) +VALUES ('xxx998_998xxx_x8x8x8', 'xxx998', 'xxx998', '****', '000', '001', true, '<html><center>****', '1'); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE products_cat ( + product VARCHAR NOT NULL, + catorder INTEGER, + PRIMARY KEY (product), + CONSTRAINT PRODUCTS_CAT_FK_1 FOREIGN KEY (product) REFERENCES products(id) +); +CREATE INDEX PRODUCTS_CAT_INX_1 ON products_cat(catorder); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE products_com ( + id VARCHAR NOT NULL, + product VARCHAR NOT NULL, + product2 VARCHAR NOT NULL, + PRIMARY KEY (id), + CONSTRAINT PRODUCTS_COM_FK_1 FOREIGN KEY (product) REFERENCES products(id), + CONSTRAINT PRODUCTS_COM_FK_2 FOREIGN KEY (product2) REFERENCES products(id) +); +CREATE UNIQUE INDEX PCOM_INX_PROD ON products_com(product, product2); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE locations ( + id VARCHAR NOT NULL, + name VARCHAR NOT NULL, + address VARCHAR, + PRIMARY KEY (id) +); +CREATE UNIQUE INDEX LOCATIONS_NAME_INX ON locations(name); +INSERT INTO locations(id, name, address) VALUES('0', 'General', NULL); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE stockdiary ( + id varchar NOT NULL, + datenew timestamp NOT NULL, + reason integer NOT NULL, + location varchar NOT NULL, + product varchar NOT NULL, + attributesetinstance_id varchar, + units double precision default 0 NOT NULL, + price double precision default 0 NOT NULL, + appuser varchar, + supplier varchar default NULL, + supplierdoc varchar default NULL, + PRIMARY KEY (id), + CONSTRAINT STOCKDIARY_FK_1 FOREIGN KEY (product) REFERENCES products(id), + CONSTRAINT STOCKDIARY_ATTSETINST FOREIGN KEY (attributesetinstance_id) REFERENCES attributesetinstance(id), + CONSTRAINT STOCKDIARY_FK_2 FOREIGN KEY (location) REFERENCES locations(id) +); +CREATE INDEX STOCKDIARY_INX_1 ON stockdiary(datenew); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE stocklevel ( + id varchar NOT NULL, + location varchar NOT NULL, + product varchar NOT NULL, + stocksecurity double precision default 0 NOT NULL, + stockmaximum double precision default 0 NOT NULL, + PRIMARY KEY (id), + CONSTRAINT STOCKLEVEL_PRODUCT FOREIGN KEY (product) REFERENCES products(id), + CONSTRAINT STOCKLEVEL_LOCATION FOREIGN KEY (location) REFERENCES locations(id) +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE stockcurrent ( + location varchar NOT NULL, + product varchar NOT NULL, + attributesetinstance_id varchar default NULL, + units double precision default 0 NOT NULL, + CONSTRAINT STOCKCURRENT_FK_1 FOREIGN KEY (product) REFERENCES products(id), + CONSTRAINT STOCKCURRENT_ATTSETINST FOREIGN KEY (attributesetinstance_id) REFERENCES attributesetinstance(id), + CONSTRAINT STOCKCURRENT_FK_2 FOREIGN KEY (location) REFERENCES locations(id) +); +CREATE UNIQUE INDEX STOCKCURRENT_INX ON stockcurrent(location, product, attributesetinstance_id); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE closedcash ( + money varchar NOT NULL, + host varchar NOT NULL, + hostsequence INTEGER NOT NULL, + datestart TIMESTAMP NOT NULL, + dateend TIMESTAMP, + nosales INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY(money) +); +CREATE INDEX CLOSEDCASH_INX_1 ON closedcash(datestart); +CREATE UNIQUE INDEX CLOSEDCASH_INX_SEQ ON closedcash(host, hostsequence); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE RECEIPTS ( + id VARCHAR NOT NULL, + MONEY VARCHAR NOT NULL, + datenew TIMESTAMP NOT NULL, + attributes BYTEA, + person VARCHAR, + PRIMARY KEY (id), +CONSTRAINT RECEIPTS_FK_MONEY FOREIGN KEY (money) REFERENCES closedcash(money) +); +CREATE INDEX RECEIPTS_INX_1 ON receipts(datenew); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE tickets ( + id VARCHAR NOT NULL, + tickettype INTEGER DEFAULT 0 NOT NULL, + ticketid INTEGER NOT NULL, + person VARCHAR NOT NULL, + customer VARCHAR DEFAULT NULL, + status INTEGER DEFAULT 0 NOT NULL, + PRIMARY KEY (id), + CONSTRAINT TICKETS_FK_ID FOREIGN KEY (id) REFERENCES receipts(id), + CONSTRAINT TICKETS_FK_2 FOREIGN KEY (PERSON) REFERENCES people(id), + CONSTRAINT TICKETS_CUSTOMERS_FK FOREIGN KEY (customer) REFERENCES customers(id) +); +CREATE INDEX TICKETS_TICKETID ON tickets(tickettype, ticketid); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE ticketlines ( + ticket VARCHAR NOT NULL, + line INTEGER NOT NULL, + product VARCHAR, + attributesetinstance_id VARCHAR, + units double precision default 0 NOT NULL, + price double precision default 0 NOT NULL, + taxid VARCHAR NOT NULL, + attributes BYTEA, + PRIMARY KEY (ticket, line), + CONSTRAINT TICKETLINES_FK_TICKET FOREIGN KEY (ticket) REFERENCES tickets(id), + CONSTRAINT TICKETLINES_FK_2 FOREIGN KEY (product) REFERENCES products(id), + CONSTRAINT TICKETLINES_ATTSETINST FOREIGN KEY (attributesetinstance_id) REFERENCES attributesetinstance(id), + CONSTRAINT TICKETLINES_FK_3 FOREIGN KEY (taxid) REFERENCES taxes(id) +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ + CREATE TABLE lineremoved ( + removeddate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + name VARCHAR DEFAULT NULL, + ticketid VARCHAR DEFAULT NULL, + productid VARCHAR DEFAULT NULL, + productname VARCHAR DEFAULT NULL, + units double precision default 0 NOT NULL +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE payments ( + id varchar NOT NULL, + receipt varchar NOT NULL, + payment varchar NOT NULL, + total double precision default 0 NOT NULL, + tip double precision default 0 NOT NULL, + transid varchar default NULL, + isprocessed BOOLEAN NOT NULL DEFAULT FALSE, + returnmsg bytea default NULL, + notes varchar default NULL, + tendered double precision default 0 NOT NULL, + cardname varchar default NULL, + voucher varchar default NULL, + PRIMARY KEY (id), + CONSTRAINT PAYMENTS_FK_RECEIPT FOREIGN KEY (receipt) REFERENCES receipts(id) +); +CREATE INDEX PAYMENTS_INX_1 ON payments(payment); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE taxlines ( + id VARCHAR NOT NULL, + receipt VARCHAR NOT NULL, + taxid VARCHAR NOT NULL, + base double precision default 0 NOT NULL, + amount double precision default 0 NOT NULL, + PRIMARY KEY (id), + CONSTRAINT TAXLINES_TAX FOREIGN KEY (taxid) REFERENCES taxes(id), + CONSTRAINT TAXLINES_RECEIPT FOREIGN KEY (receipt) REFERENCES receipts(id) +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE floors ( + id VARCHAR NOT NULL, + name VARCHAR NOT NULL, + image BYTEA, + PRIMARY KEY (id) +); +CREATE UNIQUE INDEX FLOORS_NAME_INX ON floors(name); +INSERT INTO floors(id, name, image) VALUES ('0', 'Restaurant floor', $FILE{/com/unicenta/pos/templates/restaurant_floor.png}); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE places ( + id VARCHAR NOT NULL, + name VARCHAR NOT NULL, + x INTEGER NOT NULL, + y INTEGER NOT NULL, + floor VARCHAR NOT NULL, + customer VARCHAR, + waiter VARCHAR, + ticketid VARCHAR, + tablemoved BOOLEAN NOT NULL DEFAULT FALSE, + PRIMARY KEY (id), + CONSTRAINT PLACES_FK_1 FOREIGN KEY (floor) REFERENCES floors(id) +); +CREATE UNIQUE INDEX PLACES_NAME_INX ON places(name); +INSERT INTO places(id, name, x, y, floor) VALUES ('1', 'Table 1', 80, 70, '0'); +INSERT INTO places(id, name, x, y, floor) VALUES ('2', 'Table 2', 250, 75, '0'); +INSERT INTO places(id, name, x, y, floor) VALUES ('3', 'Table 3', 400, 75, '0'); +INSERT INTO places(id, name, x, y, floor) VALUES ('4', 'Table 4', 80, 200, '0'); +INSERT INTO places(id, name, x, y, floor) VALUES ('5', 'Table 5', 260, 210, '0'); +INSERT INTO places(id, name, x, y, floor) VALUES ('6', 'Table 6', 430, 210, '0'); +INSERT INTO places(id, name, x, y, floor) VALUES ('7', 'Table 7', 80, 330, '0'); +INSERT INTO places(id, name, x, y, floor) VALUES ('8', 'Table 8', 190, 350, '0'); +INSERT INTO places(id, name, x, y, floor) VALUES ('9', 'Table 9', 295, 350, '0'); +INSERT INTO places(id, name, x, y, floor) VALUES ('10', 'Table 10', 430, 345, '0'); +INSERT INTO places(id, name, x, y, floor) VALUES ('11', 'Table 11', 550, 135, '0'); +INSERT INTO places(id, name, x, y, floor) VALUES ('12', 'Table 12', 550, 290, '0'); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE reservations ( + id VARCHAR NOT NULL, + created TIMESTAMP NOT NULL, + datenew TIMESTAMP DEFAULT '2016-01-01 00:00:00' NOT NULL, + title VARCHAR NOT NULL, + chairs INTEGER NOT NULL, + isdone BOOLEAN NOT NULL, + description VARCHAR, + PRIMARY KEY (id) +); +CREATE INDEX RESERVATIONS_INX_1 ON reservations(datenew); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE reservation_customers ( + id VARCHAR NOT NULL, + customer VARCHAR NOT NULL, + PRIMARY KEY (id), + CONSTRAINT RES_CUST_FK_1 FOREIGN KEY (id) REFERENCES reservations(id), + CONSTRAINT RES_CUST_FK_2 FOREIGN KEY (customer) REFERENCES customers(id) +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE thirdparties ( + id VARCHAR NOT NULL, + cif VARCHAR NOT NULL, + name VARCHAR NOT NULL, + address VARCHAR, + concatcomm VARCHAR, + contactfact VARCHAR, + payrule VARCHAR, + faxnumber VARCHAR, + phonenumber VARCHAR, + mobilenumber VARCHAR, + email VARCHAR, + webpage VARCHAR, + notes VARCHAR, + PRIMARY KEY (id) +); +CREATE UNIQUE INDEX THIRDPARTIES_CIF_INX ON thirdparties(cif); +CREATE UNIQUE INDEX THIRDPARTIES_NAME_INX ON thirdparties(name); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE sharedtickets ( + id varchar NOT NULL, + name varchar NOT NULL, + content bytea default NULL, + appuser varchar default NULL, + pickupid integer NOT NULL default '0', + locked varchar default NULL, + PRIMARY KEY (id) +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE shifts ( + id VARCHAR NOT NULL, + startshift TIMESTAMP NOT NULL, + endshift TIMESTAMP, + pplid VARCHAR NOT NULL, + PRIMARY KEY (id) +); +INSERT INTO shifts(id, startshift, endshift, pplid) VALUES ('0', '2016-01-01 00:00:00.001', '2016-01-01 00:00:00.002','0'); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE leaves ( + id VARCHAR NOT NULL, + pplid VARCHAR NOT NULL, + name VARCHAR NOT NULL, + startdate TIMESTAMP NOT NULL, + enddate TIMESTAMP NOT NULL, + notes VARCHAR, + PRIMARY KEY (ID), + CONSTRAINT lEAVES_PPLID FOREIGN KEY (pplid) REFERENCES people(id) +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE breaks ( + id VARCHAR NOT NULL, + name VARCHAR NOT NULL, + notes VARCHAR, + visible BOOLEAN NOT NULL, + PRIMARY KEY (id) +); +INSERT INTO breaks(id, name, visible, notes) VALUES ('0', 'Lunch Break', TRUE, NULL); +INSERT INTO breaks(id, name, visible, notes) VALUES ('1', 'Tea Break', TRUE, NULL); +INSERT INTO breaks(id, name, visible, notes) VALUES ('2', 'Mid Break', TRUE, NULL); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE shift_breaks ( + id VARCHAR NOT NULL, + shiftid VARCHAR NOT NULL, + breakid VARCHAR NOT NULL, + starttime TIMESTAMP NOT NULL, + endtime TIMESTAMP, + PRIMARY KEY (id), + CONSTRAINT SHIFT_BREAKS_BREAKID FOREIGN KEY (breakid) REFERENCES breaks(id), + CONSTRAINT SHIFT_BREAKS_SHIFTID FOREIGN KEY (shiftid) REFERENCES shifts(id) +); +INSERT INTO shift_breaks(id, shiftid, breakid, starttime, endtime) VALUES ('0', '0', '0', '2016-01-01 00:00:00.003', '2016-01-01 00:00:00.004'); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE moorers ( + vesselname VARCHAR, + size INTEGER, + days INTEGER, + power BOOLEAN NOT NULL DEFAULT FALSE +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE csvimport ( + id VARCHAR NOT NULL, + rownumber VARCHAR, + csverror VARCHAR, + reference VARCHAR, + code VARCHAR, + name VARCHAR, + pricebuy double precision, + pricesell double precision, + previousbuy double precision, + previoussell double precision, + category VARCHAR, + tax VARCHAR, + searchkey VARCHAR, + PRIMARY KEY (ID) +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE suppliers ( + id varchar NOT NULL, + searchkey varchar NOT NULL, + taxid varchar default NULL, + name varchar NOT NULL, + maxdebt double precision default 0 NOT NULL, + address varchar default NULL, + address2 varchar default NULL, + postal varchar default NULL, + city varchar default NULL, + region varchar default NULL, + country varchar default NULL, + firstname varchar default NULL, + lastname varchar default NULL, + email varchar default NULL, + phone varchar default NULL, + phone2 varchar default NULL, + fax varchar default NULL, + notes varchar default NULL, + visible BOOLEAN NOT NULL DEFAULT TRUE, + curdate timestamp default NULL, + curdebt double precision default 0, + vatid varchar default NULL, + PRIMARY KEY ( id ) +); +CREATE UNIQUE INDEX SUPPLIERS_SKEY_INX ON suppliers(searchkey); +CREATE INDEX SUPPLIERS_NAME_INX ON suppliers(name); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE uom ( + id VARCHAR NOT NULL, + name VARCHAR NOT NULL, + PRIMARY KEY ( id ) +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE TABLE vouchers ( + id VARCHAR NOT NULL, + voucher_number VARCHAR DEFAULT NULL, + customer VARCHAR DEFAULT NULL, + amount double precision default 0 NOT NULL, + status CHAR(1) DEFAULT 'A', + PRIMARY KEY ( id ) +); + +/* Header line. Object: vouchers. Script date: 08/05/2016 18:00:00. */ +CREATE SEQUENCE ticketsnum START WITH 1; +CREATE SEQUENCE ticketsnum_refund START WITH 1; +CREATE SEQUENCE ticketsnum_payment START WITH 1; +CREATE SEQUENCE pickup_number START WITH 1; + +CREATE TABLE draweropened ( + opendate TIMESTAMP DEFAULT NOW(), + name VARCHAR, + ticketid VARCHAR +); + +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/scripts/SQLite-create.sql b/src/main/resources/com/unicenta/pos/scripts/SQLite-create.sql new file mode 100644 index 0000000..b27f019 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/scripts/SQLite-create.sql @@ -0,0 +1,699 @@ + +CREATE TABLE applications ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + version varchar(255) NOT NULL, + instdate timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP , + PRIMARY KEY (id) +); + +CREATE TABLE attribute ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE attributeinstance ( + id varchar(255) NOT NULL, + attributesetinstance_id varchar(255) NOT NULL, + attribute_id varchar(255) NOT NULL, + value varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE attributeset ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE attributesetinstance ( + id varchar(255) NOT NULL, + attributeset_id varchar(255) NOT NULL, + description varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE attributeuse ( + id varchar(255) NOT NULL, + attributeset_id varchar(255) NOT NULL, + attribute_id varchar(255) NOT NULL, + lineno int(11) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE attributevalue ( + id varchar(255) NOT NULL, + attribute_id varchar(255) NOT NULL, + value varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE breaks ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + visible tinyint(1) NOT NULL default 1 , + notes varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE categories ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + parentid varchar(255) default NULL, + image mediumblob default NULL, + texttip varchar(255) default NULL, + catshowname smallint(6) NOT NULL default 1 , + catorder varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE closedcash ( + money varchar(255) NOT NULL, + host varchar(255) NOT NULL, + hostsequence int(11) NOT NULL, + datestart datetime NOT NULL, + dateend datetime default NULL, + nosales int(11) NOT NULL default 0 , + PRIMARY KEY (money) +); + +CREATE TABLE csvimport ( + id varchar(255) NOT NULL, + rownumber varchar(255) default NULL, + csverror varchar(255) default NULL, + reference varchar(255) default NULL, + code varchar(255) default NULL, + name varchar(255) default NULL, + pricebuy double default NULL, + pricesell double default NULL, + previousbuy double default NULL, + previoussell double default NULL, + category varchar(255) default NULL, + tax varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE customers ( + id varchar(255) NOT NULL, + searchkey varchar(255) NOT NULL, + taxid varchar(255) default NULL, + name varchar(255) NOT NULL, + taxcategory varchar(255) default NULL, + card varchar(255) default NULL, + maxdebt double NOT NULL default 0 , + address varchar(255) default NULL, + address2 varchar(255) default NULL, + postal varchar(255) default NULL, + city varchar(255) default NULL, + region varchar(255) default NULL, + country varchar(255) default NULL, + firstname varchar(255) default NULL, + lastname varchar(255) default NULL, + email varchar(255) default NULL, + phone varchar(255) default NULL, + phone2 varchar(255) default NULL, + fax varchar(255) default NULL, + notes varchar(255) default NULL, + visible int(1) NOT NULL default 1 , + curdate datetime default NULL, + curdebt double default 0 , + image mediumblob default NULL, + isvip int(1) NOT NULL default 0 , + discount double default 0 , + memodate datetime default CURRENT_TIMESTAMP , + PRIMARY KEY (id) +); + +CREATE TABLE draweropened ( + opendate timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP , + name varchar(255) default NULL, + ticketid varchar(255) default NULL +); + +CREATE TABLE floors ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + image mediumblob default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE leaves ( + id varchar(255) NOT NULL, + pplid varchar(255) NOT NULL, + name varchar(255) NOT NULL, + startdate datetime NOT NULL, + enddate datetime NOT NULL, + notes varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE lineremoved ( + removeddate timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP , + name varchar(255) default NULL, + ticketid varchar(255) default NULL, + productid varchar(255) default NULL, + productname varchar(255) default NULL, + units double NOT NULL +); + +CREATE TABLE locations ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + address varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE moorers ( + vesselname varchar(255) default NULL, + size int(11) default NULL, + days int(11) default NULL, + power int(1) NOT NULL default 0 +); + +CREATE TABLE IF NOT EXISTS orders ( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + orderid varchar(50) DEFAULT NULL, + qty int(11) DEFAULT 1 , + details varchar(255) DEFAULT NULL, + attributes varchar(255) DEFAULT NULL, + notes varchar(255) DEFAULT NULL, + ticketid varchar(50) DEFAULT NULL, + ordertime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP , + displayid int(11) DEFAULT 1 , + auxiliary int(11) DEFAULT NULL, + completetime timestamp NULL +); + +CREATE TABLE payments ( + id varchar(255) NOT NULL, + receipt varchar(255) NOT NULL, + payment varchar(255) NOT NULL, + total double NOT NULL default 0 , + tip double default 0 , + transid varchar(255) default NULL, + isprocessed int(1) default 0 , + returnmsg mediumblob default NULL, + notes varchar(255) default NULL, + tendered double default NULL, + cardname varchar(255) default NULL, + voucher varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE people ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + apppassword varchar(255) default NULL, + card varchar(255) default NULL, + role varchar(255) NOT NULL, + visible int(1) NOT NULL, + image mediumblob default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE pickup_number ( + id int(11) NOT NULL default 0 +); + +CREATE TABLE places ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + seats varchar(6) NOT NULL DEFAULT 1 , + x int(11) NOT NULL, + y int(11) NOT NULL, + floor varchar(255) NOT NULL, + customer varchar(255) default NULL, + waiter varchar(255) default NULL, + ticketid varchar(255) default NULL, + tablemoved smallint(6) NOT NULL default 0 , + width int(11) NOT NULL, + height int(11) NOT NULL, + guests int(11) DEFAULT 0, + occupied datetime DEFAULT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE products ( + id varchar(255) NOT NULL, + reference varchar(255) NOT NULL, + code varchar(255) NOT NULL, + codetype varchar(255) default NULL, + name varchar(255) NOT NULL, + pricebuy double NOT NULL default 0 , + pricesell double NOT NULL default 0 , + category varchar(255) NOT NULL, + taxcat varchar(255) NOT NULL, + attributeset_id varchar(255) default NULL, + stockcost double NOT NULL default 0 , + stockvolume double NOT NULL default 0 , + image mediumblob default NULL, + iscom int(1) NOT NULL default 0 , + isscale int(1) NOT NULL default 0 , + isconstant smallint(1) NOT NULL default 0 , + printkb int(1) NOT NULL default 0 , + sendstatus int(1) NOT NULL default 0 , + isservice int(1) NOT NULL default 0 , + attributes mediumblob default NULL, + display varchar(255) default NULL, + isvprice smallint(6) NOT NULL default 0 , + isverpatrib smallint(6) NOT NULL default 0 , + texttip varchar(255) default NULL, + warranty smallint(6) NOT NULL default 0 , + stockunits double NOT NULL default 0 , + printto varchar(255) default 1 , + supplier varchar(255) default NULL, + uom varchar(255) default 0 , + memodate datetime default '2018-01-01 00:00:01' , + PRIMARY KEY (id) +); + +CREATE TABLE products_bundle ( + id varchar(255) NOT NULL, + product VARCHAR(255) NOT NULL, + product_bundle VARCHAR(255) NOT NULL, + quantity DOUBLE NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE products_cat ( + product varchar(255) NOT NULL, + catorder int(11) default NULL, + PRIMARY KEY (product) +); + +CREATE TABLE products_com ( + id varchar(255) NOT NULL, + product varchar(255) NOT NULL, + product2 varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE receipts ( + id varchar(255) NOT NULL, + money varchar(255) NOT NULL, + datenew datetime NOT NULL, + attributes mediumblob default NULL, + person varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE reservation_customers ( + id varchar(255) NOT NULL, + customer varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE reservations ( + id varchar(255) NOT NULL, + created datetime NOT NULL, + datenew datetime NOT NULL default '2018-01-01 00:00:00' , + title varchar(255) NOT NULL, + chairs int(11) NOT NULL, + isdone int(1) NOT NULL, + description varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE resources ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + restype int(11) NOT NULL, + content mediumblob default NULL, + version varchar(10) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE roles ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + permissions mediumblob default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE sharedtickets ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + content mediumblob default NULL, + appuser varchar(255) default NULL, + pickupid int(11) NOT NULL default 0 , + locked varchar(20) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE shift_breaks ( + id varchar(255) NOT NULL, + shiftid varchar(255) NOT NULL, + breakid varchar(255) NOT NULL, + starttime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP , + endtime timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP , + PRIMARY KEY (id) +); + +CREATE TABLE shifts ( + id varchar(255) NOT NULL, + startshift datetime NOT NULL, + endshift datetime default NULL, + pplid varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE stockcurrent ( + location varchar(255) NOT NULL, + product varchar(255) NOT NULL, + attributesetinstance_id varchar(255) default NULL, + units double NOT NULL +); + +CREATE TABLE stockdiary ( + id varchar(255) NOT NULL, + datenew datetime NOT NULL, + reason int(11) NOT NULL, + location varchar(255) NOT NULL, + product varchar(255) NOT NULL, + attributesetinstance_id varchar(255) default NULL, + units double NOT NULL, + price double NOT NULL, + appuser varchar(255) default NULL, + supplier varchar(255) default NULL, + supplierdoc varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE stocklevel ( + id varchar(255) NOT NULL, + location varchar(255) NOT NULL, + product varchar(255) NOT NULL, + stocksecurity double default NULL, + stockmaximum double default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE suppliers ( + id varchar(255) NOT NULL, + searchkey varchar(255) NOT NULL, + taxid varchar(255) default NULL, + name varchar(255) NOT NULL, + maxdebt double NOT NULL default 0 , + address varchar(255) default NULL, + address2 varchar(255) default NULL, + postal varchar(255) default NULL, + city varchar(255) default NULL, + region varchar(255) default NULL, + country varchar(255) default NULL, + firstname varchar(255) default NULL, + lastname varchar(255) default NULL, + email varchar(255) default NULL, + phone varchar(255) default NULL, + phone2 varchar(255) default NULL, + fax varchar(255) default NULL, + notes varchar(255) default NULL, + visible int(1) NOT NULL default 1 , + curdate datetime default NULL, + curdebt double default 0 , + vatid varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE taxcategories ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE taxcustcategories ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE taxes ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + category varchar(255) NOT NULL, + custcategory varchar(255) default NULL, + parentid varchar(255) default NULL, + rate double NOT NULL default 0 , + ratecascade int(1) NOT NULL default 0 , + rateorder int(11) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE taxlines ( + id varchar(255) NOT NULL, + receipt varchar(255) NOT NULL, + taxid varchar(255) NOT NULL, + base double NOT NULL default 0 , + amount double NOT NULL default 0 , + PRIMARY KEY (id) +); + +CREATE TABLE taxsuppcategories ( + id varchar(255) NOT NULL, + name varchar(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE thirdparties ( + id varchar(255) NOT NULL, + cif varchar(255) NOT NULL, + name varchar(255) NOT NULL, + address varchar(255) default NULL, + contactcomm varchar(255) default NULL, + contactfact varchar(255) default NULL, + payrule varchar(255) default NULL, + faxnumber varchar(255) default NULL, + phonenumber varchar(255) default NULL, + mobilenumber varchar(255) default NULL, + email varchar(255) default NULL, + webpage varchar(255) default NULL, + notes varchar(255) default NULL, + PRIMARY KEY (id) +); + +CREATE TABLE ticketlines ( + ticket varchar(255) NOT NULL, + line int(11) NOT NULL, + product varchar(255) default NULL, + attributesetinstance_id varchar(255) default NULL, + units double NOT NULL, + price double NOT NULL, + taxid varchar(255) NOT NULL, + attributes mediumblob default NULL, + PRIMARY KEY (ticket , line) +); + +CREATE TABLE tickets ( + id varchar(255) NOT NULL, + tickettype int(11) NOT NULL default 0 , + ticketid int(11) NOT NULL, + person varchar(255) NOT NULL, + customer varchar(255) default NULL, + status int(11) NOT NULL default 0 , + PRIMARY KEY (id) +); + +CREATE TABLE ticketsnum ( + id int(11) NOT NULL +); + +CREATE TABLE ticketsnum_payment ( + id int(11) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE ticketsnum_refund ( + id int(11) NOT NULL +); + +CREATE TABLE uom ( + id VARCHAR(255) NOT NULL, + name VARCHAR(255) NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE vouchers ( + id VARCHAR(100) NOT NULL, + voucher_number VARCHAR(100) DEFAULT NULL, + customer VARCHAR(100) DEFAULT NULL, + amount DOUBLE DEFAULT NULL, + status CHAR(1) DEFAULT A , + PRIMARY KEY (id) +); + +-- ADD roles +INSERT INTO roles(id, name, permissions) VALUES('0', 'Administrator role', $FILE{/com/unicenta/pos/templates/Role.Administrator.xml} ); +INSERT INTO roles(id, name, permissions) VALUES('1', 'Manager role', $FILE{/com/unicenta/pos/templates/Role.Manager.xml} ); +INSERT INTO roles(id, name, permissions) VALUES('2', 'Employee role', $FILE{/com/unicenta/pos/templates/Role.Employee.xml} ); +INSERT INTO roles(id, name, permissions) VALUES('3', 'Guest role', $FILE{/com/unicenta/pos/templates/Role.Guest.xml} ); + +-- ADD people +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('0', 'Administrator', NULL, '0', 1, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('1', 'Manager', NULL, '1', 1, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('2', 'Employee', NULL, '2', 1, NULL); +INSERT INTO people(id, name, apppassword, role, visible, image) VALUES ('3', 'Guest', NULL, '3', 1, NULL); + +-- ADD resources -- +-- SYSTEM +INSERT INTO resources(id, name, restype, content) VALUES('00', 'Menu.Root', 0, $FILE{/com/unicenta/pos/templates/Menu.Root.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('02', 'Cash.Close', 0, $FILE{/com/unicenta/pos/templates/Cash.Close.xml}); +INSERT INTO resources(ID, name, restype, content) VALUES('03', 'Customer.Created', 0, $FILE{/com/unicenta/pos/templates/customer.created.xml}); +INSERT INTO resources(ID, name, restype, content) VALUES('04', 'Customer.Deleted', 0, $FILE{/com/unicenta/pos/templates/customer.deleted.xml}); +INSERT INTO resources(ID, name, restype, content) VALUES('05', 'Customer.Updated', 0, $FILE{/com/unicenta/pos/templates/customer.updated.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('06', 'payment.cash', 0, $FILE{/com/unicenta/pos/templates/payment.cash.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('07', 'Ticket.Buttons', 0, $FILE{/com/unicenta/pos/templates/Ticket.Buttons.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('08', 'Ticket.Close', 0, $FILE{/com/unicenta/pos/templates/Ticket.Close.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('09', 'Ticket.Line', 0, $FILE{/com/unicenta/pos/templates/Ticket.Line.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('10', 'Window.Title', 0, $FILE{/com/unicenta/pos/templates/Window.Title.txt}); + +-- IMAGES +INSERT INTO resources(id, name, restype, content) VALUES('11', 'img.001', 1, $FILE{/com/unicenta/images/.01.png}); +INSERT INTO resources(id, name, restype, content) VALUES('12', 'img.002', 1, $FILE{/com/unicenta/images/.02.png}); +INSERT INTO resources(id, name, restype, content) VALUES('13', 'img.005', 1, $FILE{/com/unicenta/images/.05.png}); +INSERT INTO resources(id, name, restype, content) VALUES('14', 'img.010', 1, $FILE{/com/unicenta/images/.10.png}); +INSERT INTO resources(id, name, restype, content) VALUES('15', 'img.020', 1, $FILE{/com/unicenta/images/.20.png}); +INSERT INTO resources(id, name, restype, content) VALUES('16', 'img.025', 1, $FILE{/com/unicenta/images/.25.png}); +INSERT INTO resources(id, name, restype, content) VALUES('17', 'img.050', 1, $FILE{/com/unicenta/images/.50.png}); +INSERT INTO resources(id, name, restype, content) VALUES('18', 'img.1', 1, $FILE{/com/unicenta/images/1.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('19', 'img.2', 1, $FILE{/com/unicenta/images/2.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('20', 'img.5', 1, $FILE{/com/unicenta/images/5.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('21', 'img.10', 1, $FILE{/com/unicenta/images/10.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('22', 'img.20', 1, $FILE{/com/unicenta/images/20.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('23', 'img.50', 1, $FILE{/com/unicenta/images/50.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('24', 'img.100', 1, $FILE{/com/unicenta/images/100.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('25', 'img.200', 1, $FILE{/com/unicenta/images/200.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('26', 'img.500', 1, $FILE{/com/unicenta/images/500.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('27', 'img.1000', 1, $FILE{/com/unicenta/images/1000.00.png}); +INSERT INTO resources(id, name, restype, content) VALUES('28', 'img.cash', 1, $FILE{/com/unicenta/images/cash.png}); +INSERT INTO resources(id, name, restype, content) VALUES('29', 'img.cashdrawer', 1, $FILE{/com/unicenta/images/cashdrawer.png}); +INSERT INTO resources(id, name, restype, content) VALUES('30', 'img.discount', 1, $FILE{/com/unicenta/images/discount.png}); +INSERT INTO resources(id, name, restype, content) VALUES('31', 'img.discount_b', 1, $FILE{/com/unicenta/images/discount_b.png}); +INSERT INTO resources(id, name, restype, content) VALUES('32', 'img.heart', 1, $FILE{/com/unicenta/images/heart.png}); +INSERT INTO resources(id, name, restype, content) VALUES('33', 'img.keyboard_48', 1, $FILE{/com/unicenta/images/keyboard_48.png}); +INSERT INTO resources(id, name, restype, content) VALUES('34', 'img.kit_print', 1, $FILE{/com/unicenta/images/kit_print.png}); +INSERT INTO resources(id, name, restype, content) VALUES('35', 'img.no_photo', 1, $FILE{/com/unicenta/images/no_photo.png}); +INSERT INTO resources(id, name, restype, content) VALUES('36', 'img.refundit', 1, $FILE{/com/unicenta/images/refundit.png}); +INSERT INTO resources(id, name, restype, content) VALUES('37', 'img.run_script', 1, $FILE{/com/unicenta/images/run_script.png}); +INSERT INTO resources(id, name, restype, content) VALUES('38', 'img.ticket_print', 1, $FILE{/com/unicenta/images/ticket_print.png}); +INSERT INTO resources(id, name, restype, content) VALUES('40', 'Printer.Ticket.Logo', 1, $FILE{/com/unicenta/images/printer.ticket.logo.jpg}); + +-- PRINTER +INSERT INTO resources(id, name, restype, content) VALUES('41', 'Printer.CloseCash.Preview', 0, $FILE{/com/unicenta/pos/templates/Printer.CloseCash.Preview.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('42', 'Printer.CloseCash', 0, $FILE{/com/unicenta/pos/templates/Printer.CloseCash.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('43', 'Printer.CustomerPaid', 0, $FILE{/com/unicenta/pos/templates/Printer.CustomerPaid.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('44', 'Printer.CustomerPaid2', 0, $FILE{/com/unicenta/pos/templates/Printer.CustomerPaid2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('45', 'Printer.FiscalTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.FiscalTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('46', 'Printer.Inventory', 0, $FILE{/com/unicenta/pos/templates/Printer.Inventory.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('47', 'Printer.OpenDrawer', 0, $FILE{/com/unicenta/pos/templates/Printer.OpenDrawer.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('48', 'Printer.PartialCash', 0, $FILE{/com/unicenta/pos/templates/Printer.PartialCash.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('49', 'Printer.PrintLastTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.PrintLastTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('50', 'Printer.Product', 0, $FILE{/com/unicenta/pos/templates/Printer.Product.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('52', 'Printer.ReprintTicket', 0, $FILE{/com/unicenta/pos/templates/Printer.ReprintTicket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('53', 'Printer.Start', 0, $FILE{/com/unicenta/pos/templates/Printer.Start.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('54', 'Printer.Ticket.P1', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P1.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('55', 'Printer.Ticket.P2', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('56', 'Printer.Ticket.P3', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P3.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('57', 'Printer.Ticket.P4', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P4.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('58', 'Printer.Ticket.P5', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P5.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('59', 'Printer.Ticket.P6', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.P6.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('60', 'Printer.Ticket', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('61', 'Printer.Ticket2', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket2.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('62', 'Printer.TicketClose', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketClose.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('63', 'Printer.TicketLine', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketLine.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('64', 'Printer.TicketNew', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketLine.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('65', 'Printer.TicketPreview', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketPreview.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('66', 'Printer.Ticket_A4', 0, $FILE{/com/unicenta/pos/templates/Printer.Ticket_A4.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('67', 'Printer.TicketPreview_A4', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketPreview_A4.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('68', 'Printer.TicketRemote', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketRemote.xml}); +INSERT INTO resources(id, name, restype, content) VALUES('69', 'Printer.TicketTotal', 0, $FILE{/com/unicenta/pos/templates/Printer.TicketTotal.xml}); + +-- SCRIPTS +INSERT INTO resources(id, name, restype, content) VALUES('70', 'script.Keyboard', 0, $FILE{/com/unicenta/pos/templates/script.Keyboard.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('71', 'script.Linediscount', 0, $FILE{/com/unicenta/pos/templates/script.Linediscount.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('73', 'script.SendOrder', 0, $FILE{/com/unicenta/pos/templates/script.SendOrder.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('74', 'script.Totaldiscount', 0, $FILE{/com/unicenta/pos/templates/script.Totaldiscount.txt}); +INSERT INTO resources(id, name, restype, content) VALUES('75', 'script.multibuy', 0, $FILE{/com/unicenta/pos/templates/script.multibuy.txt}); + +-- ADD CATEGORIES +INSERT INTO categories(id, name) VALUES ('000', 'Category Standard'); + +-- ADD TAXCATEGORIES +/* 002 added 31/01/2017 00:00:00. */ +INSERT INTO taxcategories(id, name) VALUES ('000', 'Tax Exempt'); +INSERT INTO taxcategories(id, name) VALUES ('001', 'Tax Standard'); +INSERT INTO taxcategories(id, name) VALUES ('002', 'Tax Other'); + +-- ADD TAXES +/* 002 added 31/01/2017 00:00:00. */ +INSERT INTO taxes(id, name, category, custcategory, parentid, rate, ratecascade, rateorder) VALUES ('000', 'Tax Exempt', '000', NULL, NULL, 0, 0, NULL); +INSERT INTO taxes(id, name, category, custcategory, parentid, rate, ratecascade, rateorder) VALUES ('001', 'Tax Standard', '001', NULL, NULL, 0.20, 0, NULL); +INSERT INTO taxes(id, name, category, custcategory, parentid, rate, ratecascade, rateorder) VALUES ('002', 'Tax Other', '002', NULL, NULL, 0, 0, NULL); + +-- ADD PRODUCTS +INSERT INTO products(id, reference, code, name, category, taxcat, isservice, display, printto) +VALUES ('xxx999_999xxx_x9x9x9', 'xxx999', 'xxx999', 'Free Line entry', '000', '001', 1, '<html><center>Free Line entry', '1'); +INSERT INTO products(id, reference, code, name, category, taxcat, isservice, display, printto) +VALUES ('xxx998_998xxx_x8x8x8', 'xxx998', 'xxx998', 'Service Charge', '000', '001', 1, '<html><center>Service Charge', '1'); + +-- ADD PRODUCTS_CAT +INSERT INTO products_cat(product) VALUES ('xxx999_999xxx_x9x9x9'); +INSERT INTO products_cat(product) VALUES ('xxx998_998xxx_x8x8x8'); + +-- ADD LOCATION +INSERT INTO locations(id, name, address) VALUES ('0','Location 1','Local'); + +-- ADD SUPPLIERS +INSERT INTO suppliers(id, searchkey, name) VALUES ('0','unicenta','unicenta'); + +-- ADD UOM +INSERT INTO uom(id, name) VALUES ('0','Each'); + +-- ADD FLOORS +INSERT INTO floors(id, name, image) VALUES ('0', 'Restaurant floor', $FILE{/com/unicenta/images/paperboard960_600.png}); + +-- ADD PLACES +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('1', 'Table 1', 100, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('2', 'Table 2', 250, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('3', 'Table 3', 400, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('4', 'Table 4', 550, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('5', 'Table 5', 700, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('6', 'Table 6', 850, 50, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('7', 'Table 7', 100, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('8', 'Table 8', 250, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('9', 'Table 9', 400, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('10', 'Table 10', 550, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('11', 'Table 11', 700, 150, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('12', 'Table 12', 850, 150, '0', '1', 90, 45); + +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('13', 'Table 13', 100, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('14', 'Table 14', 250, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('15', 'Table 15', 400, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('16', 'Table 16', 550, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('17', 'Table 17', 700, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('18', 'Table 18', 850, 250, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('19', 'Table 19', 100, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('20', 'Table 20', 250, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('21', 'Table 21', 400, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('22', 'Table 22', 550, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('23', 'Table 23', 700, 350, '0', '1', 90, 45); +INSERT INTO places(id, name, x, y, floor, seats, width, height) VALUES ('24', 'Table 24', 850, 350, '0', '1', 90, 45); + +-- ADD SHIFTS +INSERT INTO shifts(id, startshift, endshift, pplid) VALUES ('0', '2018-01-01 00:00:00.001', '2018-01-01 00:00:00.002','0'); + +-- ADD BREAKS +INSERT INTO breaks(id, name, visible, notes) VALUES ('0', 'Lunch Break', 1, NULL); +INSERT INTO breaks(id, name, visible, notes) VALUES ('1', 'Tea Break', 1, NULL); +INSERT INTO breaks(id, name, visible, notes) VALUES ('2', 'Mid Break', 1, NULL); + +-- ADD SHIFT_BREAKS +INSERT INTO shift_breaks(id, shiftid, breakid, starttime, endtime) VALUES ('0', '0', '0', '2018-01-01 00:00:00.003', '2018-01-01 00:00:00.004'); + +-- ADD SEQUENCES +INSERT INTO pickup_number VALUES(1); +INSERT INTO ticketsnum VALUES(1); +INSERT INTO ticketsnum_refund VALUES(1); +INSERT INTO ticketsnum_payment VALUES(1); + +-- ADD APPLICATION VERSION +INSERT INTO applications(id, name, version) VALUES($APP_ID{}, $APP_NAME{}, $APP_VERSION{}); diff --git a/src/main/resources/com/unicenta/pos/templates/APrinter.FiscalTicket.xml b/src/main/resources/com/unicenta/pos/templates/APrinter.FiscalTicket.xml new file mode 100644 index 0000000..9e9a559 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/APrinter.FiscalTicket.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> +<output> + <fiscalreceipt> + #foreach ($ticketline in $ticket.getLines()) + <!-- setting $vatinfo to the values contained in the fiscal printer vat table--> + #if (${ticketline.getTaxInfo().getRate()}==0.04) + #set ($vatinfo ="1") + #elseif (${ticketline.getTaxInfo().getRate()}==0.1) + #set ($vatinfo ="2") + #elseif (${ticketline.getTaxInfo().getRate()}==0.2) + #set ($vatinfo ="3") + #else + #set ($vatinfo ="1") + #end + #if ($ticketline.isProductCom()) + <line price="${ticketline.getValue()}" units="${ticketline.getMultiply()}" tax="${vatinfo}">*${ticketline.printName()}</line> + #else + <line price="${ticketline.getValue()}" units="${ticketline.getMultiply()}" tax="${vatinfo}">${ticketline.printName()}</line> + #end + #end + <message>Items count: ${ticket.printArticlesCount()}</message> + #foreach ($paymentline in $ticket.payment) + #if ($paymentline.name == "cash") + <total paid="${paymentline.getPaid()}">Cash</total> + #end + #if ($paymentline.name == "cashrefund") + <total paid="${paymentline.getTotal()}">Refund</total> + #end + #if ($paymentline.name == "ccard") + <total paid="${paymentline.getTotal()}">Mag card</total> + #end + #if ($paymentline.name == "ccardrefund") + <total paid="${paymentline.getTotal()}">Mag card refund</total> + #end + #if ($paymentline.name == "cheque") + <total paid="${paymentline.getTotal()}">Cheque</total> + #end + #if ($paymentline.name == "chequerefund") + <total paid="${paymentline.getTotal()}">Cheque refund</total> + #end + #end + </fiscalreceipt> +<!-- Other commands --> +<!-- + <fiscalzreport/> + <fiscalxreport/> +--> +</output> diff --git a/src/main/resources/com/unicenta/pos/templates/Cash.Close.xml b/src/main/resources/com/unicenta/pos/templates/Cash.Close.xml new file mode 100644 index 0000000..a9a30ca --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Cash.Close.xml @@ -0,0 +1,25 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// http://sourceforge.net/projects/unicentaopos +// +// This file is part of uniCenta oPOS. +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// ************************************************************************** +// Cash.Close +// This script runs in the cash.close event + + + + diff --git a/src/main/resources/com/unicenta/pos/templates/Menu.Root.txt b/src/main/resources/com/unicenta/pos/templates/Menu.Root.txt new file mode 100644 index 0000000..e2bc8a2 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Menu.Root.txt @@ -0,0 +1,151 @@ +group = menu.addGroup("Menu.Main"); + group.addPanel("/com/unicenta/images/sale.png", "Menu.Ticket", "com.unicenta.pos.sales.JPanelTicketSales"); + group.addPanel("/com/unicenta/images/saleedit.png", "Menu.TicketEdit", "com.unicenta.pos.sales.JPanelTicketEdits"); + group.addPanel("/com/unicenta/images/customerpay.png", "Menu.CustomersPayment", "com.unicenta.pos.customers.CustomersPayment"); + group.addPanel("/com/unicenta/images/payments.png", "Menu.Payments", "com.unicenta.pos.panels.JPanelPayments"); + group.addPanel("/com/unicenta/images/calculator.png", "Menu.CloseTPV", "com.unicenta.pos.panels.JPanelCloseMoney"); + +group = menu.addGroup("Menu.Backoffice"); + submenu = group.addSubmenu("/com/unicenta/images/plugin.png", "Menu.Plugins", "plugins.configure"); + + submenu = group.addSubmenu("/com/unicenta/images/customer.png", "Menu.Customers", "com.unicenta.pos.forms.MenuCustomers"); + submenu.addTitle("Menu.Panel.Customers.Forms"); + submenu.addPanel("/com/unicenta/images/customer.png", "Menu.CustomersManagement", "com.unicenta.pos.customers.CustomersPanel"); + + submenu.addTitle("Menu.Panel.Customers.Reports"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Customers.Reports.Report", "/com/unicenta/reports/customers.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Customers.Reports.Sales", "/com/unicenta/reports/customers_sales.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Customers.Reports.Debtors", "/com/unicenta/reports/customers_debtors.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Customers.Reports.Diary", "/com/unicenta/reports/customers_diary.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Customers.Reports.Cards", "/com/unicenta/reports/customers_cards.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Customers.Reports.List", "/com/unicenta/reports/customers_list.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Customers.Reports.Export", "/com/unicenta/reports/customers_export.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Customers.Reports.Vouchers", "/com/unicenta/reports/customers_vouchers.bs"); + + submenu = group.addSubmenu("/com/unicenta/images/stockmaint.png", "Menu.Suppliers", "com.unicenta.pos.forms.MenuSuppliers"); + submenu.addTitle("Menu.Panel.Suppliers.Forms"); + submenu.addPanel("/com/unicenta/images/customer.png", "Menu.SuppliersManagement", "com.unicenta.pos.suppliers.SuppliersPanel"); + submenu.addTitle("Menu.Panel.Suppliers.Reports"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Suppliers.Reports.Report", "/com/unicenta/reports/suppliers.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Suppliers.Reports.Products", "/com/unicenta/reports/suppliers_products.bs"); +// submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Suppliers.Reports.Creditors", "/com/unicenta/reports/suppliers_creditors.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Suppliers.Reports.Diary", "/com/unicenta/reports/suppliers_diary.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Suppliers.Reports.Sales", "/com/unicenta/reports/suppliers_sales.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Suppliers.Reports.List", "/com/unicenta/reports/suppliers_list.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Suppliers.Reports.Export", "/com/unicenta/reports/suppliers_export.bs"); + + submenu = group.addSubmenu("/com/unicenta/images/products.png", "Menu.StockManagement", "com.unicenta.pos.forms.MenuStockManagement"); + submenu.addTitle("Menu.Panel.Stock.Forms"); + + submenu.addPanel("/com/unicenta/images/category.png", "Menu.Categories", "com.unicenta.pos.inventory.CategoriesPanel"); + submenu.addPanel("/com/unicenta/images/products.png", "Menu.Products", "com.unicenta.pos.inventory.ProductsPanel"); + submenu.addPanel("/com/unicenta/images/location.png", "Menu.ProductsWarehouse", "com.unicenta.pos.inventory.ProductsWarehousePanel"); + submenu.addPanel("/com/unicenta/images/stockmaint.png", "Menu.StockMovement", "com.unicenta.pos.inventory.StockManagement"); + submenu.addPanel("/com/unicenta/images/auxiliary.png", "Menu.Auxiliar", "com.unicenta.pos.inventory.AuxiliarPanel"); + submenu.addPanel("/com/unicenta/images/bundle.png", "Menu.Bundle", "com.unicenta.pos.inventory.BundlePanel"); + submenu.addPanel("/com/unicenta/images/attributes.png", "Menu.Attributes", "com.unicenta.pos.inventory.AttributesPanel"); + submenu.addPanel("/com/unicenta/images/attributes.png", "Menu.AttributeValues", "com.unicenta.pos.inventory.AttributeValuesPanel"); + submenu.addPanel("/com/unicenta/images/attributes.png", "Menu.AttributeSets", "com.unicenta.pos.inventory.AttributeSetsPanel"); + submenu.addPanel("/com/unicenta/images/attributes.png", "Menu.AttributeUse", "com.unicenta.pos.inventory.AttributeUsePanel"); + submenu.addPanel("/com/unicenta/images/products.png", "Menu.Uom", "com.unicenta.pos.inventory.UomPanel"); + + submenu.addTitle("Menu.Panel.Stock.Reports"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Inventory", "/com/unicenta/reports/inventory.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Inventory2", "/com/unicenta/reports/inventory_b.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Inventory.Reports.Diary", "/com/unicenta/reports/inventory_diary.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.InventoryBroken", "/com/unicenta/reports/inventory_broken.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.InventoryDiff", "/com/unicenta/reports/inventory_diff.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.InventoryDiffDetail", "/com/unicenta/reports/inventory_diffdetail.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.InventoryListDetail", "/com/unicenta/reports/inventory_listdetail.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Products", "/com/unicenta/reports/products.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.SaleCatalog", "/com/unicenta/reports/salecatalog.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.ProductLabels", "/com/unicenta/reports/labels_product.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.BarcodeSheet", "/com/unicenta/reports/labels_barcode_sheet.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.ShelfEdgeLabels", "/com/unicenta/reports/labels_barcode_shelfedge.bs"); + + + submenu = group.addSubmenu("/com/unicenta/images/sales.png", "Menu.SalesManagement", "com.unicenta.pos.forms.MenuSalesManagement"); + submenu.addTitle("Menu.Panel.Sales.Reports"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Closing", "/com/unicenta/reports/sales_closedpos.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Closing1", "/com/unicenta/reports/sales_closedpos_1.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.CashRegisterLog", "/com/unicenta/reports/sales_cashregisterlog.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.ExtendedCashRegisterLog", "/com/unicenta/reports/sales_extendedcashregisterlog.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.CashFlow", "/com/unicenta/reports/sales_cashflow.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.PaymentReport", "/com/unicenta/reports/sales_payments.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.CategorySales", "/com/unicenta/reports/sales_categorysales.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.CategorySales1", "/com/unicenta/reports/sales_categorysales_1.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.ClosedProducts", "/com/unicenta/reports/sales_closedproducts.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.ClosedProducts1", "/com/unicenta/reports/sales_closedproducts_1.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.ExtendedByProducts", "/com/unicenta/reports/sales_extproducts.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.SalesProfit", "/com/unicenta/reports/sales_productsalesprofit.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.SaleTaxes", "/com/unicenta/reports/sales_saletaxes.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.TaxCatSales", "/com/unicenta/reports/sales_taxcatsales.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.ReportTaxes", "/com/unicenta/reports/sales_taxes.bs"); + submenu.addTitle("Menu.Panel.Sales.Charts"); + submenu.addPanel("/com/unicenta/images/chart.png", "Menu.ProductSales", "/com/unicenta/reports/sales_chart_productsales.bs"); + submenu.addPanel("/com/unicenta/images/chart.png", "Menu.ProductCategorySalesPieChart", "/com/unicenta/reports/sales_chart_piesalescat.bs"); + submenu.addPanel("/com/unicenta/images/chart.png", "Menu.SalesChart", "/com/unicenta/reports/sales_chart_sales.bs"); + submenu.addPanel("/com/unicenta/images/chart.png", "Menu.TimeSeriesProduct", "/com/unicenta/reports/sales_chart_timeseriesproduct.bs"); + submenu.addPanel("/com/unicenta/images/chart.png", "Menu.Top10Sales", "/com/unicenta/reports/sales_chart_top10.bs"); + + + submenu = group.addSubmenu("/com/unicenta/images/maintain.png", "Menu.Maintenance", "com.unicenta.pos.forms.MenuMaintenance"); + submenu.addTitle("Menu.Panel.Maintenance.Forms"); + submenu.addPanel("/com/unicenta/images/resources.png", "Menu.Resources", "com.unicenta.pos.admin.ResourcesPanel"); + submenu.addPanel("/com/unicenta/images/roles.png", "Menu.Roles", "com.unicenta.pos.admin.RolesPanel"); + submenu.addPanel("/com/unicenta/images/user.png", "Menu.Users", "com.unicenta.pos.admin.PeoplePanel"); + submenu.addPanel("/com/unicenta/images/bookmark.png", "Menu.TaxCategories", "com.unicenta.pos.inventory.TaxCategoriesPanel"); + submenu.addPanel("/com/unicenta/images/bookmark.png", "Menu.TaxCustCategories", "com.unicenta.pos.inventory.TaxCustCategoriesPanel"); + submenu.addPanel("/com/unicenta/images/bookmark.png", "Menu.Taxes", "com.unicenta.pos.inventory.TaxPanel"); + submenu.addPanel("/com/unicenta/images/location.png", "Menu.Locations", "com.unicenta.pos.inventory.LocationsPanel"); + submenu.addPanel("/com/unicenta/images/floors.png", "Menu.Floors", "com.unicenta.pos.mant.JPanelFloors"); + submenu.addPanel("/com/unicenta/images/tables.png", "Menu.Tables", "com.unicenta.pos.mant.JPanelPlaces"); + submenu.addPanel("/com/unicenta/images/products.png", "Menu.Vouchers", "com.unicenta.pos.voucher.VoucherPanel"); + + submenu.addTitle("Menu.Panel.Maintenance.Reports"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.UsersReport", "/com/unicenta/reports/users.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.UserSells", "/com/unicenta/reports/users_sales.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.UserNoSales", "/com/unicenta/reports/users_nosales.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.UserVoids", "/com/unicenta/reports/users_voids.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Customers.Reports.Vouchers", "/com/unicenta/reports/customers_vouchers.bs"); + +// EPM + submenu = group.addSubmenu("/com/unicenta/images/users.png", "Menu.PresenceManagement", "com.unicenta.pos.forms.MenuEmployees"); + submenu.addTitle("Menu.PresenceManagement"); + submenu.addPanel("/com/unicenta/images/coffee.png", "Menu.Breaks", "com.unicenta.pos.epm.BreaksPanel"); + submenu.addPanel("/com/unicenta/images/leaves.png", "Menu.Leaves", "com.unicenta.pos.epm.LeavesPanel"); + submenu.addTitle("Menu.Employees.Reports"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.EPM.DailyPresenceReport", "/com/unicenta/reports/epm_dailypresence.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.EPM.DailyScheduleReport", "/com/unicenta/reports/epm_dailyschedule.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.EPM.PerformanceReport", "/com/unicenta/reports/epm_performance.bs"); + + + group = menu.addGroup("Menu.Utilities"); + submenu = group.addSubmenu("/com/unicenta/images/utilities.png", "Menu.Tools", "com.unicenta.pos.imports.JPanelCSV"); + submenu.addTitle("Menu.Import"); + submenu.addPanel("/com/unicenta/images/import.png", "Menu.CSVImport", "com.unicenta.pos.imports.JPanelCSVImport"); + submenu.addPanel("/com/unicenta/images/import.png", "Menu.CSVStockQty", "com.unicenta.pos.imports.StockQtyImport"); + submenu.addPanel("/com/unicenta/images/import.png", "Menu.CustomerCSVImport", "com.unicenta.pos.imports.CustomerCSVImport"); + submenu.addPanel("/com/unicenta/images/database.png", "Menu.CSVReset", "com.unicenta.pos.imports.JPanelCSVCleardb"); + submenu.addPanel("/com/unicenta/images/database.png", "Menu.Transfer", "com.unicenta.pos.transfer.Transfer"); + submenu.addTitle("Menu.Import.Reports"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Tools.NewProducts", "/com/unicenta/reports/tools_newproducts.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Tools.UpdatedPrices", "/com/unicenta/reports/tools_updatedprices.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Tools.StockQtyUpdate", "/com/unicenta/reports/tools_inventoryqtyupdate.bs"); +// submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Tools.BadPrices", "/com/unicenta/reports/tools_badprice.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Tools.InvalidCategory", "/com/unicenta/reports/tools_invalidcategory.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Tools.MissingData", "/com/unicenta/reports/tools_missingdata.bs"); + submenu.addPanel("/com/unicenta/images/reports.png", "Menu.Tools.InvalidData", "/com/unicenta/reports/tools_invaliddata.bs"); + + group = menu.addGroup("Menu.System"); + group.addChangePasswordAction(); + group.addPanel("/com/unicenta/images/configuration.png", "Menu.Configuration", "com.unicenta.pos.config.JPanelConfiguration"); + group.addPanel("/com/unicenta/images/printer.png", "Menu.Printer", "com.unicenta.pos.panels.JPanelPrinter"); + group.addPanel("/com/unicenta/images/timer.png", "Menu.CheckInCheckOut", "com.unicenta.pos.epm.JPanelEmployeePresence"); + +// Deprecated options. Only required with Openbravo ERP software +// submenu.addTitle("Menu.Maintenance.ERP"); +// submenu.addExecution("/com/unicenta/images/openbravo.png", "Menu.ERPProducts", "com.unicenta.possync.ProductsSyncCreate"); +// submenu.addExecution("/com/unicenta/images/openbravo.png", "Menu.ERPOrders", "com.unicenta.possync.OrdersSyncCreate"); + + group.addExitAction(); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.CloseCash.Preview.xml b/src/main/resources/com/unicenta/pos/templates/Printer.CloseCash.Preview.xml new file mode 100644 index 0000000..7cbf66e --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.CloseCash.Preview.xml @@ -0,0 +1,126 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + This file is part of uniCenta oPOS. + uniCenta oPOS 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. + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +--> + +<output> + <ticket> + <image>Printer.Ticket.Logo</image> + <line></line> + <line></line> + <line size="1"> + <text align ="center" bold="true" length="42">Close Cash Preview</text> + </line> + <line></line> + <line><text length="18" bold="true">Printed:</text><text>${payments.printDate()}</text></line> + <line><text length="18" bold="true">Printed by:</text><text>${payments.printUser()}</text></line> + <line><text length="18" bold="true">Terminal:</text><text>${payments.printHost()}</text></line> + <line><text length="18" bold="true">Sequence:</text><text>${payments.printSequence()}</text></line> + <line><text length="18" bold="true">Last Close Date:</text><text>${payments.printDateStart()}</text></line> + <line><text>------------------------------------------</text></line> + <line></line> + <line> + <text align ="left" bold="true" length="32">Payments Report</text> + <text align ="right" bold="true" length="10">Amount</text> + </line> + <line><text>------------------------------------------</text></line> + #foreach ($line in $payments.getPaymentLines()) + <line> + <text align ="left" length="32">${line.printType()} ${line.printReason()}</text> + <text align ="right" length="10">${line.printValue()}</text> + </line> + #end + <line><text>------------------------------------------</text></line> + <line> + <text align ="left" length="32" bold="true">Total Sales</text> + <text align ="right" length="10" bold="true">${payments.printPaymentsTotal()}</text> + </line> + <line> + <text align ="left" length="22">Number of Payments:</text> + <text align ="right" length="10">${payments.printPayments()}</text> + </line> + <line></line> + <line> + <text align ="left" bold="true" length="32">Tax Analysis</text> + <text align ="right" bold="true" length="10">Amount</text> + </line> + <line><text>------------------------------------------</text></line> + #foreach ($line in $payments.getSaleLines()) + <line> + <text align ="left" length="32">${line.printTaxName()}</text> + <text align ="right" length="10">${line.printTaxes()}</text> + </line> + #end + <line><text>------------------------------------------</text></line> +<!-- START OF VOIDS --> + <line size="1"><text align="center" length="42" bold="true">Line Voids</text></line> + <line> + <text align ="left" length="6" bold="true">Tkt</text> + <text align ="left" length="12" bold="true">User</text> + <text align ="left" length="19" bold="true">Product</text> + <text align ="right" length="5" bold="true">Total</text> + </line> + <line><text>------------------------------------------</text></line> + #foreach ($line in $payments.getRemovedProductLines()) + <line> + <text align ="left" length="6">${line.printTicketId()}</text> + <text align ="left" length="11">${line.printWorkerName()}</text> + <text align ="left" length="1"></text> + <text align ="left" length="19">${line.printProductName()}</text> + <text align ="right" length="5">${line.printTotalUnits()}</text> + </line> + #end + <line><text>------------------------------------------</text></line> + <line></line> +<!-- END OF VOIDS --> + +<!-- START OF NO SALES --> + <line size="1"><text align="center" length="42" bold="true">No Sales</text></line> + <line> + <text align ="left" length="34" bold="true">User</text> + <text align ="right" length="8" bold="true">Ticket</text> + </line> + <line><text>------------------------------------------</text></line> + #foreach ($line in $payments.getDrawerOpenedLines()) + <line> + <text align ="left" length="34">${line.printUserName()}</text> + <text align ="right" length="8">${line.printTicketId()}</text> + </line> + #end + <line><text>------------------------------------------</text></line> + <line></line> +<!-- END OF NO SALES --> + + <line> + <text align ="left" length="32">Receipts:</text> + <text align ="right" length="10">${payments.printSales()}</text> + </line> + <line></line> + <line size="1"> + <text align ="left" length="32" bold="true">SubTotal</text> + <text align ="right" length="10" bold="true">${payments.printSalesBase()}</text> + </line> + <line size="1"> + <text align ="left" length="32" bold="true">Taxes</text> + <text align ="right" length="10" bold="true">${payments.printSalesTaxes()}</text> + </line> + <line size="1"> + <text align ="left" length="32" bold="true">Totals</text> + <text align ="right" length="10" bold="true">${payments.printSalesTotal()}</text> + </line> + </ticket> +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.CloseCash.xml b/src/main/resources/com/unicenta/pos/templates/Printer.CloseCash.xml new file mode 100644 index 0000000..6ef7d60 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.CloseCash.xml @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + This file is part of uniCenta oPOS. + uniCenta oPOS 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. + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +--> + +<output> + <ticket> + <image>Printer.Ticket.Logo</image> + <line></line> + <line></line> + <line size="1"> + <text align ="center" bold="true" length="42">Close Cash Report</text> + </line> + <line></line> + <line> + <text align ="left" bold="true" length="30">Payments Report</text> + <text align ="right" bold="true" length="12">Amount</text> + </line> + <line><text>------------------------------------------</text></line> + #foreach ($line in $payments.getPaymentLines()) + <line> + <text align ="left" length="30">${line.printType()} ${line.printReason()}</text> + <text align ="right" length="12">${line.printValue()}</text> + </line> + #end + <line><text>------------------------------------------</text></line> + <line> + <text align ="left" length="30" bold="true">Total Sales</text> + <text align ="right" length="12" bold="true">${payments.printPaymentsTotal()}</text> + </line> + <line> + <text align ="left" length="30">Number of Payments:</text> + <text align ="right" length="12">${payments.printPayments()}</text> + </line> + <line></line> + <line> + <text align ="left" bold="true" length="30">Tax Analysis</text> + <text align ="right" bold="true" length="12">Amount</text> + </line> + <line><text>------------------------------------------</text></line> + #foreach ($line in $payments.getSaleLines()) + <line> + <text align ="left" length="30">${line.printTaxName()}</text> + <text align ="right" length="12">${line.printTaxes()}</text> + </line> + #end + <line><text>------------------------------------------</text></line> +<!-- START OF VOIDS --> + <line size="1"><text align="center" length="42" bold="true">Line Voids</text></line> + <line> + <text align ="left" length="6" bold="true">Tkt</text> + <text align ="left" length="12" bold="true">User</text> + <text align ="left" length="19" bold="true">Product</text> + <text align ="right" length="5" bold="true">Total</text> + </line> + <line><text>------------------------------------------</text></line> + #foreach ($line in $payments.getRemovedProductLines()) + <line> + <text align ="left" length="6">${line.printTicketId()}</text> + <text align ="left" length="11">${line.printWorkerName()}</text> + <text align ="left" length="1"></text> + <text align ="left" length="19">${line.printProductName()}</text> + <text align ="right" length="5">${line.printTotalUnits()}</text> + </line> + #end + <line><text>------------------------------------------</text></line> + <line></line> +<!-- END OF VOIDS --> + +<!-- START OF NO SALES --> + <line size="1"><text align="center" length="42" bold="true">No Sales</text></line> + <line> + <text align ="left" length="34" bold="true">User</text> + <text align ="right" length="8" bold="true">Ticket</text> + </line> + <line><text>------------------------------------------</text></line> + #foreach ($line in $payments.getDrawerOpenedLines()) + <line> + <text align ="left" length="34">${line.printUserName()}</text> + <text align ="right" length="8">${line.printTicketId()}</text> + </line> + #end + <line><text>------------------------------------------</text></line> + <line></line> +<!-- END OF NO SALES --> + + <line> + <text align ="left" length="3">Receipts:</text> + <text align ="right" length="12">${payments.printSales()}</text> + </line> + <line></line> + <line size="1"> + <text align ="left" length="30" bold="true">SubTotal</text> + <text align ="right" length="12" bold="true">${payments.printSalesBase()}</text> + </line> + <line size="1"> + <text align ="left" length="30" bold="true">Taxes</text> + <text align ="right" length="12" bold="true">${payments.printSalesTaxes()}</text> + </line> + <line size="1"> + <text align ="left" length="30" bold="true">Totals</text> + <text align ="right" length="12" bold="true">${payments.printSalesTotal()}</text> + </line> + <line><text>------------------------------------------</text></line> + <line><text length="18" bold="true">Closed by:</text><text>${payments.printUser()}</text></line> + <line><text length="18" bold="true">Terminal:</text><text>${payments.printHost()}</text></line> + <line><text length="18" bold="true">Sequence:</text><text>${payments.printSequence()}</text></line> + <line><text length="18" bold="true">Start Date:</text><text>${payments.printDateStart()}</text></line> + <line><text length="18" bold="true">End Date:</text><text>${payments.printDateEnd()}</text></line> + + </ticket> +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.CustomerPaid.xml b/src/main/resources/com/unicenta/pos/templates/Printer.CustomerPaid.xml new file mode 100644 index 0000000..4da2783 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.CustomerPaid.xml @@ -0,0 +1,160 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + uniCenta oPOS is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty or + 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 uniCenta oPOS. + If not, see <http://www.gnu.org/licenses/>. + +--> +<output> + <display> + <line> + <text align="left" length="10">Total paid</text> + <text align="right" length="10">${ticket.printTotalPaid()}</text> + </line> + <line> + <text align="center" length="20">Thank You for your custom</text> + </line> + </display> + <ticket> + <image>Printer.Ticket.Logo</image> + <line></line> + <line> + <text align="center" length="42">Printer.CustomerPaid</text> + </line> + <line> + <text align="center" length="42">You can change this template</text> + </line> + <line> + <text align="center" length="42">in the Resources panel</text> + </line> + <line></line> + <line> + <text align="left" length="15">Receipt:</text> + <text>${ticket.printId()}</text> + </line> + <line> + <text align="left" length="15">Date:</text> + <text>${ticket.printDate()}</text> + </line> + + #if ($ticket.getCustomer()) + <line> + <text align="left" length="15">Account:</text> + <text>${ticket.getCustomer().printTaxid()}</text> + </line> + <line> + <text align="left" length="15">Customer:</text> + <text>${ticket.getCustomer().printName()}</text> + </line> + + #end + + <line></line> + <line size="1"> + <text align ="left" length="32" bold="true">Total Paid</text> + <text align ="right" length="10" bold="true">${ticket.printTotalPaid()}</text> + </line> + <line></line> + <line> + <text align ="left" length="32" bold="true">Account Balance</text> + <text align ="right" length="10" bold="true">${customer.printCurDebt()}</text> + </line> + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <line></line> + <line> + <text bold="true">Cash</text> + </line> + <line> + <text align="left" length="22">Tendered:</text> + <text align ="right" length="20">${paymentline.printPaid()}</text> + </line> + <line> + <text align="left" length="22">Change:</text> + <text align ="right" length="20">${paymentline.printChange()}</text> + </line> + #end + + #if ($paymentline.name == "ccard") + <line></line> + <line> + <text bold="true">Mag card</text> + </line> + <line> + <text align ="right" length="42">${paymentline.printTotal()}</text> + </line> + <line> + <text align ="left" length="22">Number:</text> + <text>${paymentline.printCardNumber()}</text> + </line> + <line> + <text align ="left" length="22">Expiry Date:</text> + <text>${paymentline.printExpirationDate()}</text> + </line> + <line> + <text align ="left" length="22">Operation:</text> + <text>${paymentline.printTransactionID()}</text> + </line> + <line> + <text align ="left" length="22">Authorization:</text> + <text>${paymentline.printAuthorization()}</text> + </line> + #end + + #if ($paymentline.name == "cheque") + <line></line> + <line> + <text bold="true">Cheque</text> + </line> + <line> + <text align ="right" length="42">${paymentline.printTotal()}</text> + </line> + #end + + #if ($paymentline.name == "voucherin") + <line></line> + <line> + <text bold="true">Voucher</text> + </line> + <line> + <text align ="right" length="42">${paymentline.printTotal()}</text> + </line> + #end + #end + <line></line> + <line> + <text align="left" length="15">Cashier:</text> + <text>${ticket.printUser()}</text> + </line> + <line></line> + <line> + <text align="center" length="42">Thank You for your custom</text> + </line> + </ticket> + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <opendrawer/> + #end + + #if ($paymentline.name == "cashrefund") + <opendrawer/> + #end + #end +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.CustomerPaid2.xml b/src/main/resources/com/unicenta/pos/templates/Printer.CustomerPaid2.xml new file mode 100644 index 0000000..4a21907 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.CustomerPaid2.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> +<output> + <display> + <line> + <text align="left" length="10">Total Paid</text> + <text align="right" length="10">${ticket.printTotalPaid()}</text> + </line> + <line> + <text align="center" length="20">Thank You for your custom</text> + </line> + </display> +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.FiscalTicket.xml b/src/main/resources/com/unicenta/pos/templates/Printer.FiscalTicket.xml new file mode 100644 index 0000000..e735b08 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.FiscalTicket.xml @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> +<output> + <fiscalreceipt> + #foreach ($ticketline in $ticket.getLines()) + <!-- setting $vatinfo to the values contained in the fiscal printer vat table--> + #if (${ticketline.getTaxInfo().getRate()}==0.04) + #set ($vatinfo ="1") + #elseif (${ticketline.getTaxInfo().getRate()}==0.1) + #set ($vatinfo ="2") + #elseif (${ticketline.getTaxInfo().getRate()}==0.2) + #set ($vatinfo ="3") + #else #set ($vatinfo ="1") + #end + #if ($ticketline.isProductCom()) + <line price="${ticketline.getValue()}" units="${ticketline.getMultiply()}" tax="${vatinfo}">*${ticketline.printName()}</line> + #else + <line price="${ticketline.getValue()}" units="${ticketline.getMultiply()}" tax="${vatinfo}">${ticketline.printName()}</line> + #end + #end + <message>Items count: ${ticket.printArticlesCount()}</message> + #foreach ($paymentline in $ticket.payment) + #if ($paymentline.name == "cash") + <total paid="${paymentline.getPaid()}">Cash</total> + #end + #if ($paymentline.name == "cashrefund") + <total paid="${paymentline.getTotal()}">Refund</total> + #end + #if ($paymentline.name == "ccard") + <total paid="${paymentline.getTotal()}">Mag card</total> + #end + #if ($paymentline.name == "ccardrefund") + <total paid="${paymentline.getTotal()}">Mag card refund</total> + #end + #if ($paymentline.name == "cheque") + <total paid="${paymentline.getTotal()}">Cheque</total> + #end + #if ($paymentline.name == "chequerefund") + <total paid="${paymentline.getTotal()}">Cheque refund</total> + #end + #end + </fiscalreceipt> +<!-- Other commands --> +<!-- + <fiscalzreport/> + <fiscalxreport/> +--> +</output> diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.Inventory.xml b/src/main/resources/com/unicenta/pos/templates/Printer.Inventory.xml new file mode 100644 index 0000000..d8f5735 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.Inventory.xml @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + https://unicenta.com + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> + +<output> + <ticket> + <image>Printer.Ticket.Logo</image> + <line></line> + <line><text align="center" length="42">You can change Printer.Inventory template</text></line> + <line><text align="center" length="42">in the Resources panel</text></line> + <line></line> + <line><text align="center" bold="true" length="42">Inventory Record</text></line> + <line> + <text align ="left" bold="true" length="12">Date : </text> + <text align ="left" length="30">${inventoryrecord.printDate()}</text></line> + <line><text align ="left" bold="true" length="12">Reason : </text> + <text align ="left" length="30">${inventoryrecord.printReason()}</text></line> + <line><text align ="left" bold="true" length="12">User : </text> + <text align ="left" length="30">${inventoryrecord.printUser()}</text></line> + <line><text align ="left" bold="true" length="12">Location : </text> + <text align ="left" length="30">${inventoryrecord.printLocation()}</text></line> + <line><text align ="left" bold="true" length="12">Supplier : </text> + <text align ="left" length="30">${inventoryrecord.printSupplier()}</text></line> + <line><text align ="left" bold="true" length="12">Document : </text> + <text align ="left" length="30">${inventoryrecord.printSupplierDoc()}</text></line> + + <line size="1"> + #if ($inventoryrecord.isInput()) + <text align ="center" bold="true" length="42">In</text> + #else + <text align ="center" bold="true" length="42">Out</text> + #end + </line> + <line></line> + <line> + <text align ="left" bold="true" length="17">Item</text> + <text align ="right" bold="true" length="10">Price</text> + <text align ="right" bold="true" length="5">Qty</text> + <text align ="right" bold="true" length="10">Value</text> + </line> + <line> + <text>------------------------------------------</text> + </line> + #foreach ($inventoryline in $inventoryrecord.getLines()) + <line> + <text align ="left" length="17">${inventoryline.printName()}</text> + <text align ="right" length="10">${inventoryline.printPrice()}</text> + <text align ="right" length="5">x${inventoryline.printMultiply()}</text> + <text align ="right" length="10">${inventoryline.printSubValue()}</text> + </line> + #if ($inventoryline.productAttSetInstId) + <line><text align ="left" length="42">${inventoryline.productAttSetInstDesc}</text></line> + #end + #end + <line><text>------------------------------------------</text></line> + <line></line> + <line> + <text align ="left" bold="true" length="27">Totals :</text> + <text align ="right" bold="true" length="5">${inventoryrecord.printTotalArticles()}</text> + <text align ="right" bold="true" length="10">${inventoryrecord.printSubTotal()}</text> + </line> + <line></line> + <line><text align="center" length="42">Please keep this ticket</text></line> + </ticket> +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.OpenDrawer.xml b/src/main/resources/com/unicenta/pos/templates/Printer.OpenDrawer.xml new file mode 100644 index 0000000..be13014 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.OpenDrawer.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. + If not, see <http://www.gnu.org/licenses/>. + + --> +<output> + + <opendrawer/> + +</output> diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.PartialCash.xml b/src/main/resources/com/unicenta/pos/templates/Printer.PartialCash.xml new file mode 100644 index 0000000..e63f0da --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.PartialCash.xml @@ -0,0 +1,201 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> +<output> + <ticket> + <image>Printer.Ticket.Logo</image> + <line></line> + <line></line> + <line size="1"><text align="center" length="42" bold="true">Partial Cash Report</text></line> + <line></line> + +<!-- START OF SEQUENCE DETAIL --> + <line><text length="18" bold="true">Run by:</text><text>${payments.printUser()}</text></line> + <line><text length="18" bold="true">Terminal:</text><text>${payments.printHost()}</text></line> + <line><text length="18" bold="true">Sequence:</text><text>${payments.printSequence()}</text></line> + <line><text length="18" bold="true">Start Date:</text><text>${payments.printDateStart()}</text></line> + <line><text length="18" bold="true">End Date:</text><text>${payments.printDateEnd()}</text></line> + <line></line> +<!-- END OF SEQUENCE DETAIL --> + +<!-- START OF SALES --> + <line size="1"><text align="center" length="42" bold="true">Sales</text></line> + <line> + <text align ="left" length="16" bold="true">Name</text> + <text align ="right" length="6" bold="true">Sold</text> + <text align ="right" length="10" bold="true">Net</text> + <text align ="right" length="10" bold="true">Total</text> + </line> + <line><text>------------------------------------------</text></line> + #foreach ($line in $payments.getProductSalesLines()) + <line> + <text align ="left" length="16">${line.printProductName()}</text> + <text align ="right" length="6">${line.printProductUnits()}</text> + <text align ="right" length="10">${line.printProductPriceNet()}</text> + <text align ="right" length="10">${line.printProductSubValue()}</text> + </line> + #end + <line><text>------------------------------------------</text></line> + <line> + <text align ="left" length="16" bold="true">Total</text> + <text align ="right" length="6" bold="true">${payments.printProductSalesTotalUnits()}</text> + <text align ="right" length="10" bold="true">${payments.printSalesBase()}</text> + <text align ="right" length="10" bold="true">${payments.printProductSalesTotal()}</text> + </line> + <line></line> +<!-- END OF SALES SUMMARY --> + +<!-- START OF CATEGORIES SUMMARY --> + <line size="1"><text align="center" length="42" bold="true">Product Categories</text></line> + <line> + <text align ="left" length="16" bold="true">Name</text> + <text align ="right" length="6" bold="true">Sold</text> + <text align ="right" length="10" bold="true"></text> + <text align ="right" length="10" bold="true">Total</text> + </line> + <line><text>------------------------------------------</text></line> + #foreach ($line in $payments.getCategorySalesLines()) + <line> + <text align ="left" length="16">${line.printCategoryName()}</text> + <text align ="right" length="6">${line.printCategoryUnits()}</text> + <text align ="right" length="10"></text> + <text align ="right" length="10">${line.printCategorySum()}</text> + </line> + #end + <line><text>------------------------------------------</text></line> + <line><text align ="left" length="16" bold="true">Total</text> + <text align ="right" length="6" bold="true">${payments.printCategorySalesTotalUnits()}</text> + <text align ="right" length="10" bold="true"></text> + <text align ="right" length="10" bold="true">${payments.printCategorySalesTotal()}</text> + </line> + <line></line> +<!-- END OF CATEGORIES SUMMARY --> + +<!-- START OF VOIDS --> + <line size="1"><text align="center" length="42" bold="true">Line Voids</text></line> + <line> + <text align ="left" length="6" bold="true">Tkt</text> + <text align ="left" length="12" bold="true">User</text> + <text align ="left" length="19" bold="true">Product</text> + <text align ="right" length="5" bold="true">Total</text> + </line> + <line><text>------------------------------------------</text></line> + #foreach ($line in $payments.getRemovedProductLines()) + <line> + <text align ="left" length="6">${line.printTicketId()}</text> + <text align ="left" length="11">${line.printWorkerName()}</text> + <text align ="left" length="1"></text> + <text align ="left" length="19">${line.printProductName()}</text> + <text align ="right" length="5">${line.printTotalUnits()}</text> + </line> + #end + <line><text>------------------------------------------</text></line> + <line></line> +<!-- END OF VOIDS --> + +<!-- START OF NO SALES --> + <line size="1"><text align="center" length="42" bold="true">No Sales</text></line> + <line> + <text align ="left" length="34" bold="true">User</text> + <text align ="right" length="8" bold="true">Ticket</text> + </line> + <line><text>------------------------------------------</text></line> + #foreach ($line in $payments.getDrawerOpenedLines()) + <line> + <text align ="left" length="34">${line.printUserName()}</text> + <text align ="right" length="8">${line.printTicketId()}</text> + </line> + #end + <line><text>------------------------------------------</text></line> + <line></line> +<!-- END OF NO SALES --> + +<!-- START OF TAXES ANALYSIS --> + <line size="1"><text align="center" length="42" bold="true">Taxes</text></line> + <line> + <text align ="left" length="12" bold="true">Name</text> + <text align ="right" length="10" bold="true">Net</text> + <text align ="right" length="10" bold="true">Gross</text> + <text align ="right" length="10" bold="true">Total</text> + </line> + <line><text>------------------------------------------</text></line> + #foreach ($line in $payments.getSaleLines()) + <line> + <text align ="left" length="12">${line.printTaxName()}</text> + <text align ="right" length="10">${line.printTaxNet()}</text> + <text align ="right" length="10">${line.printTaxGross()}</text> + <text align ="right" length="10">${line.printTaxes()}</text> + + </line> + #end + <line><text>------------------------------------------</text></line> + <line></line> +<!-- END OF TAXES ANALYSIS --> + +<!-- START OF PAYMENTS --> + <line size="1"><text align="center" length="42" bold="true">Payments</text></line> + <line> + <text align ="left" length="32" bold="true">Type</text> + <text align ="right" length="10" bold="true">Total</text> + </line> + <line><text>------------------------------------------</text></line> + #foreach ($line in $payments.getPaymentLines()) + <line> + <text align ="left" length="22">${line.printType()}</text> + <text align ="right" length="10">${line.printReason()}</text> + <text align ="right" length="10">${line.printValue()}</text> + </line> + #end + <line><text>------------------------------------------</text></line> + <line> + <text align ="left" length="30" bold="true">Total</text> + <text align ="right" length="12" bold="true">${payments.printPaymentsTotal()}</text> + </line> + <line></line> +<!-- END OF PAYMENTS RECEIVED --> + +<!-- START OF TOTALS SUMMARY --> + <line><text>******************************************</text></line> + <line size="1"><text align="center" length="42" bold="true">SUMMARY</text></line> + <line><text>******************************************</text></line> + <line><text align ="left" length="30" bold="true">Tickets</text> + <text align ="right" length="12" bold="true">${payments.printSales()}</text> + </line> + <line><text align ="left" length="30" bold="true">Ticket Lines</text> + <text align ="right" length="12" bold="true">${payments.printProductSalesRows()}</text> + </line> + <line><text align ="left" length="30" bold="true">Payments</text> + <text align ="right" length="12" bold="true">${payments.printPayments()}</text> + </line> + <line><text align ="left" length="30" bold="true">Net Sales</text> + <text align ="right" length="12" bold="true">${payments.printSalesBase()}</text> + </line> + <line><text align ="left" length="30" bold="true">Tax</text> + <text align ="right" length="12" bold="true">${payments.printSalesTaxes()}</text> + </line> + <line><text align ="left" length="30" bold="true">Gross Sales</text> + <text align ="right" length="12" bold="true">${payments.printSalesTotal()}</text> + </line> +<!-- END OF TOTALS SUMMARY --> + + </ticket> + +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.PrintLastTicket.xml b/src/main/resources/com/unicenta/pos/templates/Printer.PrintLastTicket.xml new file mode 100644 index 0000000..06129e5 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.PrintLastTicket.xml @@ -0,0 +1,405 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> + +<output> + + <display> + <line><text align="left" length="8">Total</text><text align="right" length="12">${ticket.printTotal()}</text></line> + <line><text align="center" length="20">Thank you</text></line> + </display> + + <ticket> + <image>Printer.Ticket.Logo</image> + <line> + </line> + #if (${ticket.printTicketHeaderLine1()} != "") + <line> + <text align="center" length="42">${ticket.printTicketHeaderLine1()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine2()} != "") + <line> + <text align="center" length="42">${ticket.printTicketHeaderLine2()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine3()} != "") + <line> + <text align="center" length="42">${ticket.printTicketHeaderLine3()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine4()} != "") + <line> + <text align="center" length="42">${ticket.printTicketHeaderLine4()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine5()} != "") + <line> + <text align="center" length="42">${ticket.printTicketHeaderLine5()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine6()} != "") + <line> + <text align="center" length="42">${ticket.printTicketHeaderLine6()}</text> + </line> + #end + + <line> + <text align="center" length="42">Printer.PrintLastTicket</text> + </line> + <line></line> + #if (${ticket.ticketType} == 0) + <line> + <text align="left" length="15">Receipt:</text> + <text>${ticket.printId()}</text> + </line> + #end + #if (${ticket.ticketType} == 1) + <line> + <text align="left" length="15">Refund:</text> + <text>${ticket.printId()}</text> + </line> + #end + + <line> + <text align="left" length="15">Date:</text> + <text>${ticket.printDate()}</text> + </line> + <line> + <text align="left" length="15">Terminal: </text> + <text>${ticket.getHost()}</text> + </line> + <line> + <text align="left" length="15">Served by:</text> + <text>${ticket.printUser()}</text> + </line> + + #if ($ticket.getCustomer()) + <line> + <text align="left" length="15">Account #:</text> + <text>${ticket.getCustomer().printTaxCustomerID()}</text> + </line> + <line> + <text align="left" length="15">Customer:</text> + <text>${ticket.getCustomer().printName()}</text> + </line> + <line> + <text align="left" length="15">Address:</text> + <text>${ticket.getCustomer().printAddress()}</text> + </line> + <line> + <text align="left" length="15">Postal:</text> + <text>${ticket.getCustomer().printPostal()}</text> + </line> + <line> + <text align="left" length="15">Phone:</text> + <text>${ticket.getCustomer().printPhone()}</text> + </line> + <line> + <text align="left" length="15">Current Debt:</text> + <text>${ticket.getCustomer().printCurDebt()}</text> + </line> + #end + + #if (${tickettext.place} != ${place}) + <line> + <text align="left" length="15">Table:</text> + <text>${place}</text> + </line> + #end + <line></line> + + <line> + <text align ="left" length="17">Item</text> + <text align ="right" length="8">Price</text> + <text align ="right" length="7">Qty</text> + <text align ="right" length="10">Value</text> + </line> + <line> + <text align="left" length="42">------------------------------------------</text> + </line> + + #foreach ($ticketline in $ticket.getLines()) + <line> + #if ($ticketline.isProductCom()) + <text align ="left" length="17">*${ticketline.printName()}</text> + #else + <text align ="left" length="17">${ticketline.printName()}</text> + #end +<!-- Print line to show Prices pre-Tax + <text align ="right" length="8">${ticketline.printPrice()}</text> + <text align ="right" length="7">x${ticketline.printMultiply()}</text> + <text align ="right" length="8">${ticketline.printSubValue()}</text> + </line> +--> + +<!-- Print line to show Prices inc. Tax --> + <text align ="right" length="8">${ticketline.printPriceTax()}</text> + <text align ="right" length="7">x${ticketline.printMultiply()}</text> + <text align ="right" length="10">${ticketline.printValue()}</text> + </line> + +<!-- un-comment line below if you want to add a product's properties --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("ingredients", "")}</text> </line> --> + +<!-- un-comment line below if you want to add a user input sales line's Note --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("notes", "")}</text> </line> --> + +<!-- un-comment line below if you want to add a product's barcode --> + <!-- <line><text align ="left" length="12">Barcode : </text>${ticketline.printCode()}</text></line> --> + +<!-- un-comment line below if you want to add a product's Reference --> + <!-- <line><text align ="left" length="12">Reference : </text>${ticketline.printReference()}</text></line> --> + + #if ($ticketline.productAttSetInstId) + <line> + <text align ="left" length="42">${ticketline.productAttSetInstDesc}</text> + </line> + #end + #end + + <line><text align="left" length="42">------------------------------------------</text></line> + <line><text>Items count: </text><text align ="left" length="14">${ticket.printArticlesCount()}</text></line> + <line></line> + <line><text align ="left" bold="true" length="16">Subtotal</text><text align ="right" length="26">${ticket.printSubTotal()}</text></line> + <line><text align ="left" length="16">Tax</text><text align ="right" length="26">${ticket.printTax()}</text></line> + <line></line> + <line size="1"><text align ="left" length="16" bold="true">Balance Due</text><text align ="right" length="26" bold="true">${ticket.printTotal()}</text></line> + <line></line> + + #foreach ($taxinfo in $taxes) +<!-- #set( $taxline = $ticket.getTaxLine($taxinfo)) --> + <line> + <text align ="left" length="18">${taxline.getTaxInfo()}</text> + <text align ="right" length="12">${taxline.printSubTotal()}</text> + <text align ="right" length="12">${taxline.printTax()}</text> + </line> + #end + <line></line> + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <line><text bold="true">Cash</text></line> + <line> + <text align="left" length="22">Tendered:</text> + <text align ="right" length="20">${paymentline.printPaid()}</text> + </line> + <line> + <text align="left" length="22">Change:</text> + <text align ="right" length="20">${paymentline.printChange()}</text> + </line> + #end + + #if ($paymentline.name == "cashrefund") + <line> + <text align="left" length="22" bold="true">Refund</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "cheque") + <line> + <text align="left" length="22" bold="true">Cheque</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "chequerefund") + <line> + <text align="left" length="22" bold="true">Cheque Refund</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "voucherin") + <line> + <text align="left" length="22" bold="true">Voucher</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "voucherout") + <line> + <text align="left" length="22" bold="true">Note Refund</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "slip") + <line> + <text align="left" length="22" bold="true">Slip</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "free") + <line> + <text align="left" length="22" bold="true">Free</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "debt") + <line> + <text align="left" length="22" bold="true">On Account</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #end + + #if (${ticket.printTicketFooterLine1()} != "") + <line></line> + <line> + <text align="center" length="42">${ticket.printTicketFooterLine1()}</text> + </line> + <line><text>==========================================</text></line> + #end + #if (${ticket.printTicketFooterLine2()} != "") + <line><text>${ticket.printTicketFooterLine2()}</text></line> + #end + #if (${ticket.printTicketFooterLine3()} != "") + <line><text>${ticket.printTicketFooterLine3()}</text></line> + #end + #if (${ticket.printTicketFooterLine4()} != "") + <line><text>${ticket.printTicketFooterLine4()}</text></line> + #end + #if (${ticket.printTicketFooterLine5()} != "") + <line><text>${ticket.printTicketFooterLine5()}</text></line> + #end + #if (${ticket.printTicketFooterLine6()} != "") + <line><text>${ticket.printTicketFooterLine6()}</text></line> + #end + <line></line> + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "ccard") + #if ($paymentline.chipAndPin) + <line size="1"> + <text align="center" length="42" bold="true">CARD SALE</text> + </line> + <line size="1"> + <text>${paymentline.getCardName()}</text> + </line> + <line> + <text>${paymentline.printCardNumber()}</text> + </line> + <line></line> + <line size="1"> + <text align="left" length="10">AMOUNT</text> + <text align ="right" length="32">${paymentline.printTotal()}</text></line> + <line> + <text>Tranx ID : </text> + <text>${paymentline.printTransactionID()}</text> + </line> + <line> + <text>Auth Code : </text> + <text>${paymentline.printAuthorization()}</text> + </line> + <line> + <text>Verified By : </text> + <text>${paymentline.printVerification()}</text> + </line> + #end + #if (!$paymentline.chipAndPin) + <line size="1"> + <text align="center" length="42" bold="true">CARD SALE</text> + </line> + <line size="1"> + <text>${paymentline.getCardName()}</text> + </line> + <line> + <text>${paymentline.printCardNumber()}</text> + </line> + <line></line> + <line size="1"> + <text align="left" length="10">AMOUNT</text> + <text align ="right" length="32">${paymentline.printTotal()}</text></line> + <text align ="left" length="22">Expiration Date:</text> + <text>${paymentline.printExpirationDate()}</text> + </line> + <line> + <text>Operation : </text> + <text>${paymentline.printTransactionID()}</text> + </line> + <line> + <text>Auth Code : </text> + <text>${paymentline.printAuthorization()}</text> + </line> + <line></line> + #end + #if ($ticket.hasTip()) + <line> + <text align ="left" length="16">Tip:</text> + <text align ="right" length="26">_______________</text></line> + <line></line> + + <line size="1"> + <text align ="left" length="16" bold="false">Total</text> + <text align ="right" length="26" bold="false">_______________</text></line> + <line></line> + <line></line> + <line size="1"> + <text align ="left" length="42" bold="false">__________________________________________</text> + </line> + <line size="1"> + <text align ="center" length="42" bold="false">Signature</text> + </line> + #else + <line size="1"> + <text align ="left" length="16" bold="true">Total</text> + <text align ="right" length="26" bold="true">${ticket.printTotal()}</text> + </line> + #end + #end + #if ($paymentline.name == "ccardrefund") + <line size="1"> + <text align="center" length="42" bold="true">CARD REFUND</text> + </line> + <line size="1"> + <text>${paymentline.getCardName()}</text> + </line> + <line> + <text>${paymentline.printCardNumber()}</text> + </line> + <line></line> + <line size="1"> + <text align="left" length="10">AMOUNT</text> + <text align ="right" length="32">${paymentline.printTotal()}</text></line> + <line> + <text align ="left" length="22">Expiration Date:</text> + <text>${paymentline.printExpirationDate()}</text></line> + <line> + <text>Tranx ID : </text> + <text>${paymentline.printTransactionID()}</text> + </line> + <line> + <text>Auth Code : </text> + <text>${paymentline.printAuthorization()}</text> + </line> + <line></line> + #end + #end + +</ticket> + +#foreach ($paymentline in $ticket.payments) +#if ($paymentline.name == "cash") + <opendrawer/> +#end + #if ($paymentline.name == "cashrefund") + <opendrawer/> + #end +#end + +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.Product.xml b/src/main/resources/com/unicenta/pos/templates/Printer.Product.xml new file mode 100644 index 0000000..0ca57f5 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.Product.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> +<output> + <ticket> + <image>Printer.Ticket.Logo</image> + <line> + <text align="center" length="42">N.I.F. 00.000.000 X</text> + </line> + <line size="1"> + <text align ="center" length="42" bold="true">${product.printName()}</text> + </line> + <line></line> + <line size="3"> + <text>Eur.</text> + <text align ="right" length="6">${product.printPriceEur()}</text> + </line> + <line size="2"> + <text>Pts.</text> + <text align ="right" length="6">${product.printPricePts()}</text> + </line> + <barcode type="EAN13">${product.printCode()}</barcode> + </ticket> +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.ReprintTicket.xml b/src/main/resources/com/unicenta/pos/templates/Printer.ReprintTicket.xml new file mode 100644 index 0000000..9d14a1a --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.ReprintTicket.xml @@ -0,0 +1,303 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> + +<output> + + <display> + <line><text align="left" length="8">Total</text><text align="right" length="12">${ticket.printTotal()}</text></line> + <line><text align="center" length="20">Thank you</text></line> + </display> + + <ticket> + <image>Printer.Ticket.Logo</image> + <line></line> + #if (${ticket.printTicketHeaderLine1()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine1()}</text></line> + #end + #if (${ticket.printTicketHeaderLine2()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine2()}</text></line> + #end + #if (${ticket.printTicketHeaderLine3()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine3()}</text></line> + #end + #if (${ticket.printTicketHeaderLine4()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine4()}</text></line> + #end + #if (${ticket.printTicketHeaderLine5()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine5()}</text></line> + #end + #if (${ticket.printTicketHeaderLine6()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine6()}</text></line> + #end + + <line><text align="center" length="42">Printer.ReprintTicket</text></line> + <line></line> + #if (${ticket.ticketType} == 0) + <line><text align="left" length="15">Receipt:</text><text>${ticket.printId()}</text></line> + #end + #if (${ticket.ticketType} == 1) + <line><text align="left" length="15">Refund:</text><text>${ticket.printId()}</text></line> + #end + + <line><text align="left" length="15">Date:</text><text>${ticket.printDate()}</text></line> + <line><text align="left" length="15">Terminal: </text><text>${ticket.getHost()}</text></line> + <line><text align="left" length="15">Served by:</text><text>${ticket.printUser()}</text></line> + + #if ($ticket.getCustomer()) + <line><text align="left" length="15">Account #:</text><text>${ticket.getCustomer().printTaxCustomerID()}</text></line> + <line><text align="left" length="15">Customer:</text><text>${ticket.getCustomer().printName()}</text></line> + <line><text align="left" length="15">Address:</text><text>${ticket.getCustomer().printAddress()}</text></line> + <line><text align="left" length="15">Postal:</text><text>${ticket.getCustomer().printPostal()}</text></line> + <line><text align="left" length="15">Phone:</text><text>${ticket.getCustomer().printPhone1()}</text></line> + <line><text align="left" length="15">Current Debt:</text><text>${ticket.getCustomer().printCurDebt()}</text></line> + #end + + #if (${tickettext.place} != ${place}) + <line><text align="left" length="15">Table:</text><text>${place}</text></line> + #end + <line></line> + + <line> + <text align ="left" length="17">Item</text> + <text align ="right" length="8">Price</text> + <text align ="right" length="7">Qty</text> + <text align ="right" length="10">Value</text> + </line> + <line><text align="left" length="42">------------------------------------------</text></line> + + #foreach ($ticketline in $ticket.getLines()) + <line> + #if ($ticketline.isProductCom()) + <text align ="left" length="17">*${ticketline.printName()}</text> + #else + <text align ="left" length="17">${ticketline.printName()}</text> + #end + <!-- Print line to show Prices pre-Tax + <text align ="right" length="8">${ticketline.printPrice()}</text> + <text align ="right" length="7">x${ticketline.printMultiply()}</text> + <text align ="right" length="8">${ticketline.printSubValue()}</text> + </line> + --> + + <!-- Print line to show Prices inc. Tax --> + <text align ="right" length="8">${ticketline.printPriceTax()}</text> + <text align ="right" length="7">x${ticketline.printMultiply()}</text> + <text align ="right" length="10">${ticketline.printValue()}</text> + </line> + +<!-- un-comment line below if you want to add a product's properties --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("ingredients", "")}</text> </line> --> + +<!-- un-comment line below if you want to add a user input sales line's Note --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("notes", "")}</text> </line> --> + +<!-- un-comment line below if you want to add a product's barcode --> + <!-- <line><text align ="left" length="12">Barcode : </text>${ticketline.printCode()}</text></line> --> + +<!-- un-comment line below if you want to add a product's Reference --> + <!-- <line><text align ="left" length="12">Reference : </text>${ticketline.printReference()}</text></line> --> + + #if ($ticketline.productAttSetInstId) + <line><text align ="left" length="42">${ticketline.productAttSetInstDesc}</text></line> + #end + #end + + <line><text align="left" length="42">------------------------------------------</text></line> + <line><text>Items count: </text><text align ="left" length="14">${ticket.printArticlesCount()}</text></line> + <line></line> + <line><text align ="left" bold="true" length="16">Subtotal</text><text align ="right" length="26">${ticket.printSubTotal()}</text></line> + <line><text align ="left" length="16">Tax</text><text align ="right" length="26">${ticket.printTax()}</text></line> + <line></line> + <line size="1"><text align ="left" length="16" bold="true">Balance Due</text> + <text align ="right" length="26" bold="true">${ticket.printTotal()}</text> + </line> + <line></line> + + #foreach ($taxinfo in $taxes) +<!-- #set( $taxline = $ticket.getTaxLine($taxinfo)) --> + <line> + <text align ="left" length="18">${taxline.getTaxInfo()}</text> + <text align ="right" length="12">${taxline.printSubTotal()}</text> + <text align ="right" length="12">${taxline.printTax()}</text> + </line> + #end + <line></line> + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <line><text bold="true">Cash</text></line> + <line><text align="left" length="22">Tendered:</text><text align ="right" length="20">${paymentline.printPaid()}</text></line> + <line><text align="left" length="22">Change:</text><text align ="right" length="20">${paymentline.printChange()}</text></line> + #end + + #if ($paymentline.name == "cashrefund") + <line> + <text align="left" length="22" bold="true">Refund</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "cheque") + <line> + <text align="left" length="22" bold="true">Cheque</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "chequerefund") + <line> + <text align="left" length="22" bold="true">Cheque Refund</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "voucherin") + <line> + <text align="left" length="22" bold="true">Voucher</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "voucherout") + <line> + <text align="left" length="22" bold="true">Note Refund</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "slip") + <line> + <text align="left" length="22" bold="true">Slip</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "free") + <line> + <text align="left" length="22" bold="true">Free</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "debt") + <line> + <text align="left" length="22" bold="true">On Account</text> + <text align ="right" length="20">${paymentline.printTotal()}</text> + </line> + #end + #end + + #if (${ticket.printTicketFooterLine1()} != "") + <line></line> + <line> + <text align="center" length="42">${ticket.printTicketFooterLine1()}</text> + </line> + <line><text>==========================================</text></line> + #end + #if (${ticket.printTicketFooterLine2()} != "") + <line><text>${ticket.printTicketFooterLine2()}</text></line> + #end + #if (${ticket.printTicketFooterLine3()} != "") + <line><text>${ticket.printTicketFooterLine3()}</text></line> + #end + #if (${ticket.printTicketFooterLine4()} != "") + <line><text>${ticket.printTicketFooterLine4()}</text></line> + #end + #if (${ticket.printTicketFooterLine5()} != "") + <line><text>${ticket.printTicketFooterLine5()}</text></line> + #end + #if (${ticket.printTicketFooterLine6()} != "") + <line><text>${ticket.printTicketFooterLine6()}</text></line> + #end + <line></line> + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "ccard") + #if ($paymentline.chipAndPin) + <line size="1"><text align="center" length="42" bold="true">CARD SALE</text></line> + <line size="1"><text>${paymentline.getCardName()}</text></line> + <line><text>${paymentline.printCardNumber()}</text></line> + <line></line> + <line size="1"> + <text align="left" length="10">AMOUNT</text> + <text align ="right" length="32">${paymentline.printTotal()}</text></line> + <line><text>Tranx ID : </text><text>${paymentline.printTransactionID()}</text></line> + <line><text>Auth Code : </text><text>${paymentline.printAuthorization()}</text></line> + <line><text>Verified By : </text><text>${paymentline.printVerification()}</text></line> + #end + #if (!$paymentline.chipAndPin) + <line size="1"><text align="center" length="42" bold="true">CARD SALE</text></line> + <line size="1"><text>${paymentline.getCardName()}</text></line> + <line><text>${paymentline.printCardNumber()}</text></line> + <line></line> + <line size="1"> + <text align="left" length="10">AMOUNT</text> + <text align ="right" length="32">${paymentline.printTotal()}</text> + </line> + <line> + <text align ="left" length="22">Expiration Date:</text> + <text>${paymentline.printExpirationDate()}</text> + </line> + <line><text>Operation : </text><text>${paymentline.printTransactionID()}</text></line> + <line><text>Auth Code : </text><text>${paymentline.printAuthorization()}</text></line> + <line></line> + #end + #if ($ticket.hasTip()) + <line><text align ="left" length="16">Tip:</text><text align ="right" length="26">_______________</text></line> + <line></line> + <line size="1"> + <text align ="left" length="16" bold="false">Total</text> + <text align ="right" length="26" bold="false">_______________</text></line> + <line></line> + <line></line> + <line size="1"> + <text align ="left" length="42" bold="false">__________________________________________</text> + </line> + <line size="1"> + <text align ="center" length="42" bold="false">Signature</text> + </line> + #else + <line size="1"> + <text align ="left" length="16" bold="true">Total</text> + <text align ="right" length="26" bold="true">${ticket.printTotal()}</text> + </line> + #end + #end + #if ($paymentline.name == "ccardrefund") + <line size="1"><text align="center" length="42" bold="true">CARD REFUND</text></line> + <line size="1"><text>${paymentline.getCardName()}</text></line> + <line><text>${paymentline.printCardNumber()}</text></line> + <line></line> + <line size="1"><text align="left" length="10">AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line> + <line><text align ="left" length="22">Expiration Date:</text><text>${paymentline.printExpirationDate()}</text></line> + <line><text>Tranx ID : </text><text>${paymentline.printTransactionID()}</text></line> + <line><text>Auth Code : </text><text>${paymentline.printAuthorization()}</text></line> + <line></line> + #end + #end + +</ticket> + +<!-- unComment this block if you want to open Cashdrawer in Print Preview +#foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <opendrawer/> + #end + #if ($paymentline.name == "cashrefund") + <opendrawer/> + #end +#end --> + +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.Start.xml b/src/main/resources/com/unicenta/pos/templates/Printer.Start.xml new file mode 100644 index 0000000..c6f7214 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.Start.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> + +<output> +<!-- DISPLAY ANIMATION OPTIONS --> +<!-- <display animation="flyer"> --> +<!-- <display animation="scroll"> --> +<!-- <display animation="blink"> --> +<!-- <display animation="curtain"> --> + + <display animation="none"> + <line><text align="center" length="20">uniCenta oPOS</text></line> + <line><text align="center" length="20">Touch Friendly POS</text></line> + </display> +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P1.xml b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P1.xml new file mode 100644 index 0000000..648780a --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P1.xml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +--> + +<output> + <display> + <line> + <text align="left" length="10">Order sent to P1</text> + <text align="right" length="10">${ticket.printTotal()}</text> + </line> + <line> + <text align="center" length="20">Thank you.</text> + </line> + </display> + + <ticket printer="1"> + <line></line> + <line></line> + <line size = "1"><text bold = "true" align="center" length="42">Printer 1</text></line> + <line></line> + <line size = "1"><text>Order : </text><text bold = "true">${ticket.getPickupId()}</text></line> + + #if (${tickettext.place} != ${place}) + <line size = "1"><text align="left" length="15">Table:</text><text>${place}</text></line> + #end + + <line><text align="left" length="15">Date:</text><text>${ticket.printDate()}</text></line> + <line><text align="left" length="15">Sent from: </text><text>${ticket.getHost()}</text></line> + <line><text align="left" length="15">Server:</text><text>${ticket.printUser()}</text></line> + + #if ($ticket.getCustomer()) + <line><text align="left" length="15">Customer:</text><text>${ticket.getCustomer().getName()}</text></line> + <line><text align="left" length="15">Account #:</text><text>${ticket.getCustomer().getTaxid()}</text></line> + #end + + <line></line> + <line><text align ="left" length="17">Item</text><text align ="right" length="5"></text></line> + <line><text>------------------------------------------</text></line> + + #foreach ($ticketline in $ticket.getLines()) + #if($ticketline.printPrinter().equals("1")) + #if($ticketline.getProperty("ticket.updated").equals("true")) + #if ($ticketline.isProductCom()) + <line size="1"><text align ="left" length="37">--${ticketline.printName()}</text></line> + #else + <line size="1"> + <text align ="left" length="5"> ${ticketline.printMultiply()}x</text> + <text align ="left" length="37"> ${ticketline.printName()}</text> + </line> + #end + + <!-- un-comment line below if you want to add a product's properties --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("ingredients", "")}</text> </line> --> + + <!-- un-comment line below if you want to add a user input sales line's Note --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("notes", "")}</text> </line> --> + + <!-- Add the following lines only for 2.30 Attributes --> + #if ($ticketline.productAttSetInstId) + <line><text align ="left" length="42">${ticketline.productAttSetInstDesc}</text></line> + <line></line> + #end + ${ticketline.setProperty("ticket.updated", "false")} + #end + #end + #end + </ticket> +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P2.xml b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P2.xml new file mode 100644 index 0000000..533d8c5 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P2.xml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +--> + +<output> + <display> + <line> + <text align="left" length="10">Order sent to P2</text> + <text align="right" length="10">${ticket.printTotal()}</text> + </line> + <line> + <text align="center" length="20">Thank you.</text> + </line> + </display> + + <ticket printer="2"> + <line></line> + <line></line> + <line size = "1"><text bold = "true" align="center" length="42">Printer 2</text></line> + <line></line> + <line size = "1"><text>Order : </text><text bold = "true">${ticket.getPickupId()}</text></line> + + <line><text align="left" length="15">Date:</text><text>${ticket.printDate()}</text></line> + <line><text align="left" length="15">Sent from: </text><text>${ticket.getHost()}</text></line> + <line><text align="left" length="15">Server:</text><text>${ticket.printUser()}</text></line> + + #if ($ticket.getCustomer()) + <line><text align="left" length="15">Customer:</text><text>${ticket.getCustomer().getName()}</text></line> + <line><text align="left" length="15">Account #:</text><text>${ticket.getCustomer().getTaxid()}</text></line> + #end + + #if (${tickettext.place} != ${place}) + <line><text align="left" length="15">Table:</text><text>${place}</text></line> + #end + + <line></line> + <line><text align ="left" length="17">Item</text><text align ="right" length="5"></text></line> + <line><text>------------------------------------------</text></line> + + #foreach ($ticketline in $ticket.getLines()) + #if($ticketline.printPrinter().equals("2")) + #if($ticketline.getProperty("ticket.updated").equals("true")) + #if ($ticketline.isProductCom()) + <line size="1"><text align ="left" length="37">--${ticketline.printName()}</text></line> + #else + <line size="1"> + <text align ="left" length="5"> ${ticketline.printMultiply()}x</text> + <text align ="left" length="37"> ${ticketline.printName()}</text> + </line> + #end + + <!-- un-comment line below if you want to add a product's properties --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("ingredients", "")}</text> </line> --> + + <!-- un-comment line below if you want to add a user input sales line's Note --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("notes", "")}</text> </line> --> + + <!-- Add the following lines only for 2.30 Attributes --> + #if ($ticketline.productAttSetInstId) + <line><text align ="left" length="42">${ticketline.productAttSetInstDesc}</text></line> + <line></line> + #end + ${ticketline.setProperty("ticket.updated", "false")} + #end + #end + #end + </ticket> +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P3.xml b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P3.xml new file mode 100644 index 0000000..2792a1f --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P3.xml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +--> + +<output> + <display> + <line> + <text align="left" length="10">Order sent to P3</text> + <text align="right" length="10">${ticket.printTotal()}</text> + </line> + <line> + <text align="center" length="20">Thank you.</text> + </line> + </display> + + <ticket printer="3"> + <line></line> + <line></line> + <line size = "1"><text bold = "true" align="center" length="42">Printer 3</text></line> + <line></line> + <line size = "1"><text>Order : </text><text bold = "true">${ticket.getPickupId()}</text></line> + + <line><text align="left" length="15">Date:</text><text>${ticket.printDate()}</text></line> + <line><text align="left" length="15">Sent from: </text><text>${ticket.getHost()}</text></line> + <line><text align="left" length="15">Server:</text><text>${ticket.printUser()}</text></line> + + #if ($ticket.getCustomer()) + <line><text align="left" length="15">Customer:</text><text>${ticket.getCustomer().getName()}</text></line> + <line><text align="left" length="15">Account #:</text><text>${ticket.getCustomer().getTaxid()}</text></line> + #end + + #if (${tickettext.place} != ${place}) + <line><text align="left" length="15">Table:</text><text>${place}</text></line> + #end + + <line></line> + <line><text align ="left" length="17">Item</text><text align ="right" length="5"></text></line> + <line><text>------------------------------------------</text></line> + + #foreach ($ticketline in $ticket.getLines()) + #if($ticketline.printPrinter().equals("3")) + #if($ticketline.getProperty("ticket.updated").equals("true")) + #if ($ticketline.isProductCom()) + <line size="1"><text align ="left" length="37">--${ticketline.printName()}</text></line> + #else + <line size="1"> + <text align ="left" length="5"> ${ticketline.printMultiply()}x</text> + <text align ="left" length="37"> ${ticketline.printName()}</text> + </line> + #end + + <!-- un-comment line below if you want to add a product's properties --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("ingredients", "")}</text> </line> --> + + <!-- un-comment line below if you want to add a user input sales line's Note --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("notes", "")}</text> </line> --> + + <!-- Add the following lines only for 2.30 Attributes --> + #if ($ticketline.productAttSetInstId) + <line><text align ="left" length="42">${ticketline.productAttSetInstDesc}</text></line> + <line></line> + #end + ${ticketline.setProperty("ticket.updated", "false")} + #end + #end + #end + </ticket> +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P4.xml b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P4.xml new file mode 100644 index 0000000..947a212 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P4.xml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +--> + +<output> + <display> + <line> + <text align="left" length="10">Order sent to P4</text> + <text align="right" length="10">${ticket.printTotal()}</text> + </line> + <line> + <text align="center" length="20">Thank you.</text> + </line> + </display> + + <ticket printer="4"> + <line></line> + <line></line> + <line size = "1"><text bold = "true" align="center" length="42">Printer 4</text></line> + <line></line> + <line size = "1"><text>Order : </text><text bold = "true">${ticket.getPickupId()}</text></line> + + <line><text align="left" length="15">Date:</text><text>${ticket.printDate()}</text></line> + <line><text align="left" length="15">Sent from: </text><text>${ticket.getHost()}</text></line> + <line><text align="left" length="15">Server:</text><text>${ticket.printUser()}</text></line> + + #if ($ticket.getCustomer()) + <line><text align="left" length="15">Customer:</text><text>${ticket.getCustomer().getName()}</text></line> + <line><text align="left" length="15">Account #:</text><text>${ticket.getCustomer().getTaxid()}</text></line> + #end + + #if (${tickettext.place} != ${place}) + <line><text align="left" length="15">Table:</text><text>${place}</text></line> + #end + + <line></line> + <line><text align ="left" length="17">Item</text><text align ="right" length="5"></text></line> + <line><text>------------------------------------------</text></line> + + #foreach ($ticketline in $ticket.getLines()) + #if($ticketline.printPrinter().equals("4")) + #if($ticketline.getProperty("ticket.updated").equals("true")) + #if ($ticketline.isProductCom()) + <line size="1"><text align ="left" length="37">--${ticketline.printName()}</text></line> + #else + <line size="1"> + <text align ="left" length="5"> ${ticketline.printMultiply()}x</text> + <text align ="left" length="37"> ${ticketline.printName()}</text> + </line> + #end + + <!-- un-comment line below if you want to add a product's properties --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("ingredients", "")}</text> </line> --> + + <!-- un-comment line below if you want to add a user input sales line's Note --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("notes", "")}</text> </line> --> + + <!-- Add the following lines only for 2.30 Attributes --> + #if ($ticketline.productAttSetInstId) + <line><text align ="left" length="42">${ticketline.productAttSetInstDesc}</text></line> + <line></line> + #end + ${ticketline.setProperty("ticket.updated", "false")} + #end + #end + #end + </ticket> +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P5.xml b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P5.xml new file mode 100644 index 0000000..0e9f623 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P5.xml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +--> + +<output> + <display> + <line> + <text align="left" length="10">Order sent to P5</text> + <text align="right" length="10">${ticket.printTotal()}</text> + </line> + <line> + <text align="center" length="20">Thank you.</text> + </line> + </display> + + <ticket printer="5"> + <line></line> + <line></line> + <line size = "1"><text bold = "true" align="center" length="42">Printer 5</text></line> + <line></line> + <line size = "1"><text>Order : </text><text bold = "true">${ticket.getPickupId()}</text></line> + + <line><text align="left" length="15">Date:</text><text>${ticket.printDate()}</text></line> + <line><text align="left" length="15">Sent from: </text><text>${ticket.getHost()}</text></line> + <line><text align="left" length="15">Server:</text><text>${ticket.printUser()}</text></line> + + #if ($ticket.getCustomer()) + <line><text align="left" length="15">Customer:</text><text>${ticket.getCustomer().getName()}</text></line> + <line><text align="left" length="15">Account #:</text><text>${ticket.getCustomer().getTaxid()}</text></line> + #end + + #if (${tickettext.place} != ${place}) + <line><text align="left" length="15">Table:</text><text>${place}</text></line> + #end + + <line></line> + <line><text align ="left" length="17">Item</text><text align ="right" length="5"></text></line> + <line><text>------------------------------------------</text></line> + + #foreach ($ticketline in $ticket.getLines()) + #if($ticketline.printPrinter().equals("5")) + #if($ticketline.getProperty("ticket.updated").equals("true")) + #if ($ticketline.isProductCom()) + <line size="1"><text align ="left" length="37">--${ticketline.printName()}</text></line> + #else + <line size="1"> + <text align ="left" length="5"> ${ticketline.printMultiply()}x</text> + <text align ="left" length="37"> ${ticketline.printName()}</text> + </line> + #end + + <!-- un-comment line below if you want to add a product's properties --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("ingredients", "")}</text> </line> --> + + <!-- un-comment line below if you want to add a user input sales line's Note --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("notes", "")}</text> </line> --> + + <!-- Add the following lines only for 2.30 Attributes --> + #if ($ticketline.productAttSetInstId) + <line><text align ="left" length="42">${ticketline.productAttSetInstDesc}</text></line> + <line></line> + #end + ${ticketline.setProperty("ticket.updated", "false")} + #end + #end + #end + </ticket> +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P6.xml b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P6.xml new file mode 100644 index 0000000..ac00dff --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.P6.xml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +--> + +<output> + <display> + <line> + <text align="left" length="10">Order sent to P6</text> + <text align="right" length="10">${ticket.printTotal()}</text> + </line> + <line> + <text align="center" length="20">Thank you.</text> + </line> + </display> + + <ticket printer="6"> + <line></line> + <line></line> + <line size = "1"><text bold = "true" align="center" length="42">Printer 6</text></line> + <line></line> + <line size = "1"><text>Order : </text><text bold = "true">${ticket.getPickupId()}</text></line> + + <line><text align="left" length="15">Date:</text><text>${ticket.printDate()}</text></line> + <line><text align="left" length="15">Sent from: </text><text>${ticket.getHost()}</text></line> + <line><text align="left" length="15">Server:</text><text>${ticket.printUser()}</text></line> + + #if ($ticket.getCustomer()) + <line><text align="left" length="15">Customer:</text><text>${ticket.getCustomer().getName()}</text></line> + <line><text align="left" length="15">Account #:</text><text>${ticket.getCustomer().getTaxid()}</text></line> + #end + + #if (${tickettext.place} != ${place}) + <line><text align="left" length="15">Table:</text><text>${place}</text></line> + #end + + <line></line> + <line><text align ="left" length="17">Item</text><text align ="right" length="5"></text></line> + <line><text>------------------------------------------</text></line> + + #foreach ($ticketline in $ticket.getLines()) + #if($ticketline.printPrinter().equals("6")) + #if($ticketline.getProperty("ticket.updated").equals("true")) + #if ($ticketline.isProductCom()) + <line size="1"><text align ="left" length="37">--${ticketline.printName()}</text></line> + #else + <line size="1"> + <text align ="left" length="5"> ${ticketline.printMultiply()}x</text> + <text align ="left" length="37"> ${ticketline.printName()}</text> + </line> + #end + + <!-- un-comment line below if you want to add a product's properties --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("ingredients", "")}</text> </line> --> + + <!-- un-comment line below if you want to add a user input sales line's Note --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("notes", "")}</text> </line> --> + + <!-- Add the following lines only for 2.30 Attributes --> + #if ($ticketline.productAttSetInstId) + <line><text align ="left" length="42">${ticketline.productAttSetInstDesc}</text></line> + <line></line> + #end + ${ticketline.setProperty("ticket.updated", "false")} + #end + #end + #end + </ticket> +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.xml b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.xml new file mode 100644 index 0000000..6e82338 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket.xml @@ -0,0 +1,270 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2019 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> + +<output> + + <display> + <line><text align="left" length="8">Total</text><text align="right" length="12">${ticket.printTotal()}</text></line> + <line><text align="center" length="20">Thank you</text></line> + </display> + + <ticket> + <image>Printer.Ticket.Logo</image> + <line> + </line> + #if (${ticket.printTicketHeaderLine1()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine1()}</text></line> + #end + #if (${ticket.printTicketHeaderLine2()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine2()}</text></line> + #end + #if (${ticket.printTicketHeaderLine3()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine3()}</text></line> + #end + #if (${ticket.printTicketHeaderLine4()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine4()}</text></line> + #end + #if (${ticket.printTicketHeaderLine5()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine5()}</text></line> + #end + #if (${ticket.printTicketHeaderLine6()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine6()}</text></line> + #end + + <line><text align="center" length="42">Printer.Ticket</text></line> + <line></line> + #if (${ticket.ticketType} == 0) + <line><text align="left" length="15">Receipt:</text><text>${ticket.printId()}</text></line> + #end + #if (${ticket.ticketType} == 1) + <line><text align="left" length="15">Refund:</text><text>${ticket.printId()}</text></line> + #end + + <line><text align="left" length="15">Date:</text><text>${ticket.printDate()}</text></line> + <line><text align="left" length="15">Terminal: </text><text>${ticket.getHost()}</text></line> + <line><text align="left" length="15">Served by:</text><text>${ticket.printUser()}</text></line> + + #if ($ticket.getCustomer()) + <line><text align="left" length="15">Account #:</text><text>${ticket.getCustomer().printTaxCustomerID()}</text></line> + <line><text align="left" length="15">Customer:</text><text>${ticket.getCustomer().printName()}</text></line> + <line><text align="left" length="15">Address:</text><text>${ticket.getCustomer().printAddress()}</text></line> + <line><text align="left" length="15">Postal:</text><text>${ticket.getCustomer().printPostal()}</text></line> + <line><text align="left" length="15">Phone:</text><text>${ticket.getCustomer().printPhone1()}</text></line> + <line><text align="left" length="15">Current Debt:</text><text>${ticket.getCustomer().printCurDebt()}</text></line> + <line><text align="left" length="15">Balance:</text><text>${ticket.getCustomer().printCurBal()}</text></line> + <line><text align="left" length="15">TaxId:</text><text>${ticket.getCustomer().getTaxid()}</text></line> + #end + + #if (${tickettext.place} != ${place}) + <line><text align="left" length="15">Table:</text><text>${place}</text></line> + #end + <line></line> + <line> + <text align ="left" length="17">Item</text> + <text align ="right" length="8">Price</text> + <text align ="right" length="7">Qty</text> + <text align ="right" length="10">Value</text> + </line> + <line><text align="left" length="42">------------------------------------------</text></line> + + #foreach ($ticketline in $ticket.getLines()) + <line> + #if ($ticketline.isProductCom()) + <text align ="left" length="17">*${ticketline.printName()}</text> + #else + <text align ="left" length="17">${ticketline.printName()}</text> + #end + <!-- Print line to show Prices pre-Tax + <text align ="right" length="8">${ticketline.printPrice()}</text> + <text align ="right" length="7">x${ticketline.printMultiply()}</text> + <text align ="right" length="8">${ticketline.printSubValue()}</text> + </line> + --> + + <!-- Print line to show Prices inc. Tax --> + <text align ="right" length="8">${ticketline.printPriceTax()}</text> + <text align ="right" length="7">x${ticketline.printMultiply()}</text> + <text align ="right" length="10">${ticketline.printValue()}</text> + </line> + + <!-- un-comment line below if you want to add a product's properties --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("ingredients", "")}</text> </line> --> + + <!-- un-comment line below if you want to add a user input sales line's Note --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("notes", "")}</text> </line> --> + + <!-- un-comment line below if you want to add a product's barcode --> + <!-- <line><text align ="left" length="12">Barcode : </text>${ticketline.printCode()}</text></line> --> + + <!-- un-comment line below if you want to add a product's Reference --> + <!-- <line><text align ="left" length="12">Reference : </text>${ticketline.printReference()}</text></line> --> + + #if ($ticketline.productAttSetInstId) + <line><text align ="left" length="42">${ticketline.productAttSetInstDesc}</text></line> + #end + #end + + <line><text align="left" length="42">------------------------------------------</text></line> + <line><text>Items count: </text><text align ="left" length="14">${ticket.printArticlesCount()}</text></line> + <line></line> + <line> + <text align ="left" bold="true" length="16">Subtotal</text> + <text align ="right" length="26">${ticket.printSubTotal()}</text> + </line> + <line> + <text align ="left" length="16">Tax</text> + <text align ="right" length="26">${ticket.printTax()}</text> + </line> + <line></line> + <line size="1"> + <text align ="left" length="16" bold="true">Balance Due</text> + <text align ="right" length="26" bold="true">${ticket.printTotal()}</text> + </line> + <line></line> + + #foreach ($taxinfo in $taxes) + #set( $taxline = $ticket.getTaxLine($taxinfo)) + <line> + <text align ="left" length="18">${taxline.getTaxInfo()}</text> + <text align ="right" length="12">${taxline.printSubTotal()}</text> + <text align ="right" length="12">${taxline.printTax()}</text> + </line> + #end + <line></line> + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <line><text bold="true">Cash</text></line> + <line><text align="left" length="22">Tendered:</text><text align ="right" length="20">${paymentline.printPaid()}</text></line> + <line><text align="left" length="22">Change:</text><text align ="right" length="20">${paymentline.printChange()}</text></line> + #end + + #if ($paymentline.name == "cashrefund") + <line><text align="left" length="22" bold="true">Refund</text><text align ="right" length="20">${paymentline.printPaid()}</text></line> + #end + #if ($paymentline.name == "cheque") + <line><text align="left" length="22" bold="true">Cheque</text><text align ="right" length="20">${paymentline.printPaid()}</text></line> + #end + #if ($paymentline.name == "chequerefund") + <line><text align="left" length="22" bold="true">Cheque Refund</text><text align ="right" length="20">${paymentline.printPaid()}</text></line> + #end + #if ($paymentline.name == "voucherin") + <line><text align="left" length="22" bold="true">Voucher : ${paymentline.printVoucherNumber()}</text><text align ="right" length="20">${paymentline.printPaid()}</text></line> + #end + #if ($paymentline.name == "voucherout") + <line><text align="left" length="22" bold="true">Voucher Refund : ${paymentline.printVoucherNumber()}</text><text align ="right" length="20">${paymentline.printPaid()}</text></line> + #end + #if ($paymentline.name == "slip") + <line><text align="left" length="22" bold="true">Slip</text><text align ="right" length="20">${paymentline.printPaid()}</text></line> + #end + #if ($paymentline.name == "free") + <line><text align="left" length="22" bold="true">Free</text><text align ="right" length="20">${paymentline.printPaid()}</text></line> + #end + #if ($paymentline.name == "debt") + <line><text align="left" length="22" bold="true">On Account</text><text align ="right" length="20">${paymentline.printPaid()}</text></line> + #end + #end + + #if (${ticket.printTicketFooterLine1()} != "") + <line></line> + <line><text align="center" length="42">${ticket.printTicketFooterLine1()}</text></line> + <line><text>==========================================</text></line> + #end + #if (${ticket.printTicketFooterLine2()} != "") + <line><text>${ticket.printTicketFooterLine2()}</text></line> + #end + #if (${ticket.printTicketFooterLine3()} != "") + <line><text>${ticket.printTicketFooterLine3()}</text></line> + #end + #if (${ticket.printTicketFooterLine4()} != "") + <line><text>${ticket.printTicketFooterLine4()}</text></line> + #end + #if (${ticket.printTicketFooterLine5()} != "") + <line><text>${ticket.printTicketFooterLine5()}</text></line> + #end + #if (${ticket.printTicketFooterLine6()} != "") + <line><text>${ticket.printTicketFooterLine6()}</text></line> + #end + <line></line> + + #foreach ($paymentline in $ticket.payments) + + #if ($paymentline.name == "ccard") + #if ($paymentline.chipAndPin) + <line size="1"><text align="center" length="42" bold="true">CARD SALE</text></line> + <line size="1"><text>${paymentline.getCardName()}</text></line> + <line><text>${paymentline.printCardNumber()}</text></line> + <line></line> + <line size="1"><text align="left" length="10">AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line> + <line><text>Tranx ID : </text><text>${paymentline.printTransactionID()}</text></line> + <line><text>Auth Code : </text><text>${paymentline.printAuthorization()}</text></line> + <line><text>Verified By : </text><text>${paymentline.printVerification()}</text></line> + <line><text>Card # (last 4) : </text><text>${paymentline.printLastFourDigits()}</text></line> + #end + #if (!$paymentline.chipAndPin) + <line size="1"><text align="center" length="42" bold="true">CARD SALE</text></line> + <line size="1"><text>${paymentline.getCardName()}</text></line> + <line><text>${paymentline.printCardNumber()}</text></line> + <line></line> + <line size="1"><text align="left" length="10">AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line> + <line><text align ="left" length="22">Expiration Date:</text><text>${paymentline.printExpirationDate()}</text></line> + <line><text>Operation : </text><text>${paymentline.printTransactionID()}</text></line> + <line><text>Auth Code : </text><text>${paymentline.printAuthorization()}</text></line> + <line></line> + #end + #if ($ticket.hasTip()) + <line><text align ="left" length="16">Tip:</text><text align ="right" length="26">_______________</text></line> + <line></line> + <line size="1"><text align ="left" length="16" bold="false">Total</text><text align ="right" length="26" bold="false">_______________</text></line> + <line></line> + <line></line> + <line size="1"><text align ="left" length="42" bold="false">__________________________________________</text></line> + <line size="1"><text align ="center" length="42" bold="false">Signature</text></line> + #else + <line size="1"><text align ="left" length="16" bold="true">Total</text><text align ="right" length="26" bold="true">${paymentline.printTotal()}</text></line> + #end + #end + #if ($paymentline.name == "ccardrefund") + <line size="1"><text align="center" length="42" bold="true">CARD REFUND</text></line> + <line size="1"><text>${paymentline.getCardName()}</text></line> + <line><text>${paymentline.printCardNumber()}</text></line> + <line></line> + <line size="1"><text align="left" length="10">AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line> + <line><text align ="left" length="22">Expiration Date:</text><text>${paymentline.printExpirationDate()}</text></line> + <line><text>Tranx ID : </text><text>${paymentline.printTransactionID()}</text></line> + <line><text>Auth Code : </text><text>${paymentline.printAuthorization()}</text></line> + <line></line> + #end + #end + + </ticket> + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <opendrawer/> + #end + #if ($paymentline.name == "cashrefund") + <opendrawer/> + #end + #end + +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.Ticket2.xml b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket2.xml new file mode 100644 index 0000000..99a0c2d --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket2.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> +<output> + <display> + <line> + <text align="left" length="8">Total:</text> + <text align="right" length="12">${ticket.printTotal()}</text> + </line> + <line> + <text align="center" length="20">Thank You for your custom</text> + </line> + </display> + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <opendrawer/> + #end + #if ($paymentline.name == "cashrefund") + <opendrawer/> + #end + #end +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.TicketClose.xml b/src/main/resources/com/unicenta/pos/templates/Printer.TicketClose.xml new file mode 100644 index 0000000..4208fbf --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.TicketClose.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + + This displays amount tendered and change on customer display + + --> +<output> + <display> + #foreach ($paymentline in $ticket.payments) + <line> + <text align="left" length="8">Given:</text> + <text align ="right" length="12">${paymentline.printPaid()}</text> + </line> + <line> + <text align="left" length="8">Change:</text> + <text align ="right" length="12">${paymentline.printChange()}</text> + </line> + #end + </display> +</output> diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.TicketLine.xml b/src/main/resources/com/unicenta/pos/templates/Printer.TicketLine.xml new file mode 100644 index 0000000..3524579 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.TicketLine.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> +<output> + <display> + <line> + #if ($ticketline.isProductCom()) + <text align="left" length="15">*${ticketline.printName()}</text> + #else + <text align="left" length="15">${ticketline.printName()}</text> + #end + <text align="right" length="5">x${ticketline.printMultiply()}</text> + </line> + <line> +<!-- These lines for values without tax + <text align="right" length="10">${ticketline.printPrice()}</text> + <text align="right" length="10">${ticketline.printSubValue()}</text> +--> +<!-- These lines for values with tax --> + <text align ="right" length="10">${ticketline.printPriceTax()}</text> + <text align ="right" length="10">${ticketline.printValue()}</text> + + </line> + </display> +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.TicketNew.xml b/src/main/resources/com/unicenta/pos/templates/Printer.TicketNew.xml new file mode 100644 index 0000000..b0848d1 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.TicketNew.xml @@ -0,0 +1,319 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +--> +<output> + <display> + <line> + <text align="left" length="10">Total</text> + <text align="right" length="10">${ticket.printTotal()}</text> + </line> + <line> + <text align="center" length="20">Thank you for your custom</text> + </line> + </display> + <ticket> + <image>Printer.Ticket.Logo</image> + <line></line> + #if (${ticket.printTicketHeaderLine1()} != "") + <line> + <text align="center" length="42">${ticket.printTicketHeaderLine1()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine2()} != "") + <line> + <text align="center" length="42">${ticket.printTicketHeaderLine2()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine3()} != "") + <line> + <text align="center" length="42">${ticket.printTicketHeaderLine3()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine4()} != "") + <line> + <text align="center" length="42">${ticket.printTicketHeaderLine4()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine5()} != "") + <line> + <text align="center" length="42">${ticket.printTicketHeaderLine5()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine6()} != "") + <line> + <text align="center" length="42">${ticket.printTicketHeaderLine6()}</text> + </line> + #end + <line> + <text align="center" length="42">Printer.TicketNew</text> + </line> + <line></line> + #if (${ticket.ticketType} == 0) + <line> + <text align="left" length="15">Receipt:</text> + <text>${ticket.printId()}</text> + </line> + #end + #if (${ticket.ticketType} == 1) + <line> + <text align="left" length="15">Refund:</text> + <text>${ticket.printId()}</text> + </line> + #end + <line> + <text align="left" length="15">Date:</text> + <text>${ticket.printDate()}</text> + </line> + #if ($ticket.getCustomer()) + <line> + <text align="left" length="15">Customer:</text> + <text>${ticket.getCustomer().printName()}</text> + </line> + <line> + <text align="left" length="15">Account #:</text> + <text>${ticket.getCustomer().printTaxid()}</text> + </line> + <line> + <text align="left" length="15">Current Debt:</text> + <text>${ticket.getCustomer().printCurDebt()}</text> + </line> + #end + + #if (${tickettext.place} != ${place}) + <line> + <text align="left" length="15">Table:</text> + <text>${place}</text> + </line> + #end + + <line> + <text align="left" length="15">Served by:</text> + <text>${ticket.printUser()}</text> + </line> + <line></line> + <line> + <text align ="left" length="17">Item</text> + <text align ="right" length="8">Price</text> + <text align ="right" length="7">Qty</text> + <text align ="right" length="10">Value</text> + </line> + <line> + <text>------------------------------------------</text> + </line> + + #foreach ($ticketline in $ticket.getLines()) + <line> + #if ($ticketline.isProductCom()) + <text align ="left" length="17">*${ticketline.printName()}</text> + #else + <text align ="left" length="17">${ticketline.printName()}</text> + #end + <text align ="right" length="8">${ticketline.printPriceTax()}</text> + <text align ="right" length="7">x${ticketline.printMultiply()}</text> + <text align ="right" length="10">${ticketline.printValue()}</text> + </line> + #if ($ticketline.productAttSetInstId) + <line> + <text align ="left" length="42">${ticketline.productAttSetInstDesc}</text> + </line> + #end + #end + <line> + <text>------------------------------------------</text> + </line> + <line> + <text>Items count: </text> + <text align ="left" length="14">${ticket.printArticlesCount()}</text> + </line> + <line></line> + <line size="1"> + <text align ="left" length="16" bold="true">Total</text> + <text align ="right" length="26" bold="true">${ticket.printTotal()}</text> + </line> + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <line> + <text bold="true">Cash</text> + </line> + <line> + <text align="left" length="22">Tendered:</text> + <text align ="right" length="20">${paymentline.printPaid()}</text> + </line> + <line> + <text align="left" length="22">Change:</text> + <text align ="right" length="20">${paymentline.printChange()}</text> + </line> + #end + #if ($paymentline.name == "cashrefund") + <line> + <text bold="true">Refund</text> + </line> + <line> + <text align ="right" length="42">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "ccard") + <line> + <text bold="true">Card</text> + </line> + <line> + <text align ="right" length="42">${paymentline.printTotal()}</text> + </line> + <line> + <text align ="left" length="22">Card Number:</text> + <text>${paymentline.printCardNumber()}</text> + </line> + <line> + <text align ="left" length="22">Expiration Date:</text> + <text>${paymentline.printExpirationDate()}</text> + </line> + <line> + <text align ="left" length="22">Operation:</text> + <text>${paymentline.printTransactionID()}</text> + </line> + <line> + <text align ="left" length="22">Authorisation:</text> + <text>${paymentline.printAuthorization()}</text> + </line> + #end + #if ($paymentline.name == "ccardrefund") + <line> + <text bold="true">Card Refund</text> + </line> + <line> + <text align ="right" length="42">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "cheque") + <line></line> + <line> + <text bold="true">Cheque</text> + </line> + <line> + <text align ="right" length="42">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "chequerefund") + <line></line> + <line> + <text bold="true">Cheque Refund</text> + </line> + <line> + <text align ="right" length="42">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "voucherin") + <line></line> + <line> + <text bold="true">Voucher</text> + </line> + <line> + <text align ="right" length="42">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "voucherout") + <line></line> + <line> + <text bold="true">Note Refund</text> + </line> + <line> + <text align ="right" length="42">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "free") + <line></line> + <line> + <text bold="true">Free</text> + </line> + <line> + <text align ="right" length="42">${paymentline.printTotal()}</text> + </line> + #end + #if ($paymentline.name == "debt") + <line></line> + <line> + <text bold="true">On Account</text> + </line> + <line> + <text align ="right" length="42">${paymentline.printTotal()}</text> + </line> + #end + #end + <line></line> + <line> + <text align ="left" bold="true" length="16">Nett of Tax:</text> + <text align ="right" length="26">${ticket.printSubTotal()}</text> + </line> + <line> + <text align ="left" length="16">Taxes:</text> + <text align ="right" length="26">${ticket.printTax()}</text> + </line> + #foreach ($taxinfo in $taxes) + <line> + <text align ="left" length="18">${taxinfo.getTaxInfo()}</text> + <text align ="right" length="12">${taxinfo.printSubTotal()}</text> + <text align ="right" length="12">${taxinfo.printTax()}</text> + </line> + #end + <line></line> + <line> + <text align="center" length="42">${ticket.printTicketFooterLine1()}</text> + </line> + <line> + <text>==========================================</text> + </line> + #end + #if (${ticket.printTicketFooterLine2()} != "") + <line> + <text>${ticket.printTicketFooterLine2()}</text> + </line> + #end + #if (${ticket.printTicketFooterLine3()} != "") + <line> + <text>${ticket.printTicketFooterLine3()}</text> + </line> + #end + #if (${ticket.printTicketFooterLine4()} != "") + <line> + <text>${ticket.printTicketFooterLine4()}</text> + </line> + #end + #if (${ticket.printTicketFooterLine5()} != "") + <line> + <text>${ticket.printTicketFooterLine5()}</text> + </line> + #end + #if (${ticket.printTicketFooterLine6()} != "") + <line> + <text>${ticket.printTicketFooterLine6()}</text> + </line> + #end + </ticket> + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <opendrawer/> + #end + #if ($paymentline.name == "cashrefund") + <opendrawer/> + #end + #end +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.TicketPreview.xml b/src/main/resources/com/unicenta/pos/templates/Printer.TicketPreview.xml new file mode 100644 index 0000000..29000b4 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.TicketPreview.xml @@ -0,0 +1,245 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> + +<output> + + <display> + <line><text align="left" length="8">Total</text><text align="right" length="12">${ticket.printTotal()}</text></line> + <line><text align="center" length="20">Thank you</text></line> + </display> + + <ticket> + <image>Printer.Ticket.Logo</image> + <line></line> + #if (${ticket.printTicketHeaderLine1()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine1()}</text></line> + #end + #if (${ticket.printTicketHeaderLine2()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine2()}</text></line> + #end + #if (${ticket.printTicketHeaderLine3()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine3()}</text></line> + #end + #if (${ticket.printTicketHeaderLine4()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine4()}</text></line> + #end + #if (${ticket.printTicketHeaderLine5()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine5()}</text></line> + #end + #if (${ticket.printTicketHeaderLine6()} != "") + <line><text align="center" length="42">${ticket.printTicketHeaderLine6()}</text></line> + #end + + <line><text align="center" length="42">Printer.TicketPreview</text></line> + <line></line> + #if (${ticket.ticketType} == 0) + <line><text align="left" length="15">Receipt:</text><text>${ticket.printId()}</text></line> + #end + #if (${ticket.ticketType} == 1) + <line><text align="left" length="15">Refund:</text><text>${ticket.printId()}</text></line> + #end + + <line><text align="left" length="15">Date:</text><text>${ticket.printDate()}</text></line> + <line><text align="left" length="15">Terminal: </text><text>${ticket.getHost()}</text></line> + <line><text align="left" length="15">Served by:</text><text>${ticket.printUser()}</text></line> + + #if ($ticket.getCustomer()) + <line><text align="left" length="15">Account #:</text><text>${ticket.getCustomer().printTaxCustomerID()}</text></line> + <line><text align="left" length="15">Customer:</text><text>${ticket.getCustomer().printName()}</text></line> + <line><text align="left" length="15">Address:</text><text>${ticket.getCustomer().printAddress()}</text></line> + <line><text align="left" length="15">Postal:</text><text>${ticket.getCustomer().printPostal()}</text></line> + <line><text align="left" length="15">Phone:</text><text>${ticket.getCustomer().printPhone1()}</text></line> + <line><text align="left" length="15">Current Debt:</text><text>${ticket.getCustomer().printCurDebt()}</text></line> + <line><text align="left" length="15">Balance:</text><text>${ticket.getCustomer().printCurBal()}</text></line> + #end + + #if (${tickettext.place} != ${place}) + <line><text align="left" length="15">Table:</text><text>${place}</text></line> + #end + <line></line> + <line> + <text align ="left" length="17">Item</text> + <text align ="right" length="8">Price</text> + <text align ="right" length="7">Qty</text> + <text align ="right" length="10">Value</text> + </line> + <line><text align="left" length="42">------------------------------------------</text></line> + + #foreach ($ticketline in $ticket.getLines()) + <line> + #if ($ticketline.isProductCom()) + <text align ="left" length="17">*${ticketline.printName()}</text> + #else + <text align ="left" length="17">${ticketline.printName()}</text> + #end +<!-- Print line to show Prices pre-Tax + <text align ="right" length="8">${ticketline.printPrice()}</text> + <text align ="right" length="7">x${ticketline.printMultiply()}</text> + <text align ="right" length="8">${ticketline.printSubValue()}</text> + </line> +--> + +<!-- Print line to show Prices inc. Tax --> + <text align ="right" length="8">${ticketline.printPriceTax()}</text> + <text align ="right" length="7">x${ticketline.printMultiply()}</text> + <text align ="right" length="10">${ticketline.printValue()}</text> + </line> + +<!-- un-comment line below if you want to add a product's properties --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("ingredients", "")}</text> </line> --> + +<!-- un-comment line below if you want to add a user input sales line's Note --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("notes", "")}</text> </line> --> + +<!-- un-comment line below if you want to add a product's barcode --> + <!-- <line><text align ="left" length="12">Barcode : </text>${ticketline.printCode()}</text></line> --> + +<!-- un-comment line below if you want to add a product's Reference --> + <!-- <line><text align ="left" length="12">Reference : </text>${ticketline.printReference()}</text></line> --> + + #if ($ticketline.productAttSetInstId) + <line><text align ="left" length="42">${ticketline.productAttSetInstDesc}</text></line> + #end + #end + + <line><text align="left" length="42">------------------------------------------</text></line> + <line><text>Items count: </text><text align ="left" length="14">${ticket.printArticlesCount()}</text></line> + <line></line> + <line> + <text align ="left" bold="true" length="16">Subtotal</text> + <text align ="right" length="26">${ticket.printSubTotal()}</text> + </line> + <line> + <text align ="left" length="16">Tax</text> + <text align ="right" length="26">${ticket.printTax()}</text> + </line> + <line></line> + <line size="1"> + <text align ="left" length="16" bold="true">Balance Due</text> + <text align ="right" length="26" bold="true">${ticket.printTotal()}</text> + </line> + <line></line> + + + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <line><text bold="true">Cash</text></line> + <line><text align="left" length="22">Tendered:</text><text align ="right" length="20">${paymentline.printPaid()}</text></line> + <line><text align="left" length="22">Change:</text><text align ="right" length="20">${paymentline.printChange()}</text></line> + #end + + #if ($paymentline.name == "cashrefund") + <line><text align="left" length="22" bold="true">Refund</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "cheque") + <line><text align="left" length="22" bold="true">Cheque</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "chequerefund") + <line><text align="left" length="22" bold="true">Cheque Refund</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "voucherin") + <line><text align="left" length="22" bold="true">Voucher</text><text align ="right" length="20">${paymentline.printPaid()}</text></line> + #end + #if ($paymentline.name == "voucherout") + <line><text align="left" length="22" bold="true">Voucher Refund<text align ="right" length="20">${paymentline.printPaid()}</text></line> + #end + #if ($paymentline.name == "slip") + <line><text align="left" length="22" bold="true">Slip</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "free") + <line><text align="left" length="22" bold="true">Free</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "debt") + <line><text align="left" length="22" bold="true">On Account</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #end + + #if (${ticket.printTicketFooterLine1()} != "") + <line></line> + <line><text align="center" length="42">${ticket.printTicketFooterLine1()}</text></line> + <line><text>==========================================</text></line> + #end + #if (${ticket.printTicketFooterLine2()} != "") + <line><text>${ticket.printTicketFooterLine2()}</text></line> + #end + #if (${ticket.printTicketFooterLine3()} != "") + <line><text>${ticket.printTicketFooterLine3()}</text></line> + #end + #if (${ticket.printTicketFooterLine4()} != "") + <line><text>${ticket.printTicketFooterLine4()}</text></line> + #end + #if (${ticket.printTicketFooterLine5()} != "") + <line><text>${ticket.printTicketFooterLine5()}</text></line> + #end + #if (${ticket.printTicketFooterLine6()} != "") + <line><text>${ticket.printTicketFooterLine6()}</text></line> + #end + <line></line> + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "ccard") + #if ($paymentline.chipAndPin) + <line size="1"><text align="center" length="42" bold="true">CARD SALE</text></line> + <line><text align = "center" length="42" bold="true">A card payment was received</text></line> + <line></line> + <line size="1"><text align="left" length="10">AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line> + #end + #if (!$paymentline.chipAndPin) + <line size="1"><text align="center" length="42" bold="true">CARD SALE</text></line> + <line><text align = "center" length="42" bold="true">A card payment was received</text></line> + <line></line> + <line size="1"><text align="left" length="10">AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line> + #end + #if ($ticket.hasTip()) + <line><text align ="left" length="16">Tip:</text><text align ="right" length="26">_______________</text></line> + <line></line> + <line size="1"><text align ="left" length="16" bold="false">Total</text><text align ="right" length="26" bold="false">_______________</text></line> + <line></line> + <line></line> + <line size="1"><text align ="left" length="42" bold="false">__________________________________________</text></line> + <line size="1"><text align ="center" length="42" bold="false">Signature</text></line> + #else + <line size="1"><text align ="left" length="16" bold="true">Total</text><text align ="right" length="26" bold="true">${paymentline.printTotal()}</text></line> + #end + #end + #if ($paymentline.name == "ccardrefund") + <line size="1"><text align="center" length="42" bold="true">CARD SALE</text></line> + <line></line> + <line><text align = "center" length="42" bold="true">A card payment was received</text></line> + <line></line> + <line size="1"><text align="left" length="10">AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line> + #end + #end + + </ticket> + +#foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <opendrawer/> + #end + #if ($paymentline.name == "cashrefund") + <opendrawer/> + #end +#end + +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.TicketPreview_A4.xml b/src/main/resources/com/unicenta/pos/templates/Printer.TicketPreview_A4.xml new file mode 100644 index 0000000..94d6426 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.TicketPreview_A4.xml @@ -0,0 +1,243 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Contributed by: Julian Roberts, Brockley Estate, Tasmania + Additional changes: uniCenta 2015 + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> + +<output> + + <display> + <line><text align="left" length="8">Total</text><text align="right" length="12">${ticket.printTotal()}</text></line> + <line><text align="center" length="20">Thank you</text></line> + </display> + + <ticket> + <image>Printer.Ticket.Logo</image> + <line></line> + #if (${ticket.printTicketHeaderLine1()} != "") + <line><text align="center" length="126">${ticket.printTicketHeaderLine1()}</text></line> + #end + #if (${ticket.printTicketHeaderLine2()} != "") + <line><text align="center" length="126">${ticket.printTicketHeaderLine2()}</text></line> + #end + #if (${ticket.printTicketHeaderLine3()} != "") + <line><text align="center" length="126">${ticket.printTicketHeaderLine3()}</text></line> + #end + #if (${ticket.printTicketHeaderLine4()} != "") + <line><text align="center" length="126">${ticket.printTicketHeaderLine4()}</text></line> + #end + #if (${ticket.printTicketHeaderLine5()} != "") + <line><text align="center" length="126">${ticket.printTicketHeaderLine5()}</text></line> + #end + #if (${ticket.printTicketHeaderLine6()} != "") + <line><text align="center" length="126">${ticket.printTicketHeaderLine6()}</text></line> + #end + + <line><text align="center" length="126">Printer.TicketPreview</text></line> + <line></line> + #if (${ticket.ticketType} == 0) + <line><text align="left" length="15">Receipt:</text><text>${ticket.printId()}</text></line> + #end + #if (${ticket.ticketType} == 1) + <line><text align="left" length="15">Refund:</text><text>${ticket.printId()}</text></line> + #end + + <line><text align="left" length="15">Date:</text><text>${ticket.printDate()}</text></line> + <line><text align="left" length="15">Terminal: </text><text>${ticket.getHost()}</text></line> + <line><text align="left" length="15">Served by:</text><text>${ticket.printUser()}</text></line> + + #if ($ticket.getCustomer()) + <line><text align="left" length="15">Account #:</text><text>${ticket.getCustomer().printTaxCustomerID()}</text></line> + <line><text align="left" length="15">Customer:</text><text>${ticket.getCustomer().printName()}</text></line> + <line><text align="left" length="15">Address:</text><text>${ticket.getCustomer().printAddress()}</text></line> + <line><text align="left" length="15">Postal:</text><text>${ticket.getCustomer().printPostal()}</text></line> + <line><text align="left" length="15">Phone:</text><text>${ticket.getCustomer().printPhone1()}</text></line> + <line><text align="left" length="15">Current Debt:</text><text>${ticket.getCustomer().printCurDebt()}</text></line> + <line><text align="left" length="15">Balance:</text><text>${ticket.getCustomer().printCurBal()}</text></line> + #end + + #if (${tickettext.place} != ${place}) + <line><text align="left" length="15">Table:</text><text>${place}</text></line> + #end + <line></line> + <line> + <text align ="left" length="83">Item</text> + <text align ="right" length="10">Price</text> + <text align ="right" length="5">Qty</text> + <text align ="right" length="10">Value</text> + </line> + <line><text align="left" length="108">------------------------------------------</text></line> + + #foreach ($ticketline in $ticket.getLines()) + <line> + #if ($ticketline.isProductCom()) + <text align ="left" length="83">*${ticketline.printName()}</text> + #else + <text align ="left" length="83">${ticketline.printName()}</text> + #end +<!-- Print line to show Prices pre-Tax --> + <text align ="right" length="10">${ticketline.printPrice()}</text> + <text align ="right" length="5">x${ticketline.printMultiply()}</text> + <text align ="right" length="10">${ticketline.printSubValue()}</text> + </line> + +<!-- Print line to show Prices inc. Tax + <text align ="right" length="10">${ticketline.printPriceTax()}</text> + <text align ="right" length="5">x${ticketline.printMultiply()}</text> + <text align ="right" length="10">${ticketline.printValue()}</text> + </line> +--> + +<!-- un-comment line below if you want to add a product's properties --> + <!-- <line><text align ="left" length="108">${ticketline.getProperty("ingredients", "")}</text> </line> --> + +<!-- un-comment line below if you want to add a user input sales line's Note --> + <!-- <line><text align ="left" length="108">${ticketline.getProperty("notes", "")}</text> </line> --> + +<!-- un-comment line below if you want to add a product's barcode --> + <!-- <line><text align ="left" length="30">Barcode : </text>${ticketline.printCode()}</text></line> --> + +<!-- un-comment line below if you want to add a product's Reference --> + <!-- <line><text align ="left" length="30">Reference : </text>${ticketline.printReference()}</text></line> --> + + #if ($ticketline.productAttSetInstId) + <line><text align ="left" length="42">${ticketline.productAttSetInstDesc}</text></line> + #end + #end + + <line><text align="left" length="108">------------------------------------------</text></line> + <line><text>Items count: </text><text align ="left" length="14">${ticket.printArticlesCount()}</text></line> + <line></line> + <line> + <text align ="left" bold="true" length="16">Subtotal</text> + <text align ="right" length="26">${ticket.printSubTotal()}</text> + </line> + <line> + <text align ="left" length="16">Tax</text> + <text align ="right" length="26">${ticket.printTax()}</text> + </line> + <line></line> + <line size="1"> + <text align ="left" length="16" bold="true">Balance Due</text> + <text align ="right" length="26" bold="true">${ticket.printTotal()}</text> + </line> + <line></line> + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <line><text bold="true">Cash</text></line> + <line><text align="left" length="22">Tendered:</text><text align ="right" length="20">${paymentline.printPaid()}</text></line> + <line><text align="left" length="22">Change:</text><text align ="right" length="20">${paymentline.printChange()}</text></line> + #end + + #if ($paymentline.name == "cashrefund") + <line><text align="left" length="22" bold="true">Refund</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "cheque") + <line><text align="left" length="22" bold="true">Cheque</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "chequerefund") + <line><text align="left" length="22" bold="true">Cheque Refund</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "voucherin") + <line><text align="left" length="22" bold="true">Voucher</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "voucherout") + <line><text align="left" length="22" bold="true">Note Refund</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "slip") + <line><text align="left" length="22" bold="true">Slip</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "free") + <line><text align="left" length="22" bold="true">Free</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "debt") + <line><text align="left" length="22" bold="true">On Account</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #end + + #if (${ticket.printTicketFooterLine1()} != "") + <line></line> + <line><text align="center" length="108">${ticket.printTicketFooterLine1()}</text></line> + <line><text>==========================================</text></line> + #end + #if (${ticket.printTicketFooterLine2()} != "") + <line><text>${ticket.printTicketFooterLine2()}</text></line> + #end + #if (${ticket.printTicketFooterLine3()} != "") + <line><text>${ticket.printTicketFooterLine3()}</text></line> + #end + #if (${ticket.printTicketFooterLine4()} != "") + <line><text>${ticket.printTicketFooterLine4()}</text></line> + #end + #if (${ticket.printTicketFooterLine5()} != "") + <line><text>${ticket.printTicketFooterLine5()}</text></line> + #end + #if (${ticket.printTicketFooterLine6()} != "") + <line><text>${ticket.printTicketFooterLine6()}</text></line> + #end + <line></line> + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "ccard") + #if ($paymentline.chipAndPin) + <line size="1"><text align="center" length="126" bold="true">CARD SALE</text></line> + <line><text align = "center" length="126" bold="true">A card payment was received</text></line> + <line></line> + <line size="1"><text align="left" length="10">AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line> + #end + #if (!$paymentline.chipAndPin) + <line size="1"><text align="center" length="126" bold="true">CARD SALE</text></line> + <line><text align = "center" length="126" bold="true">A card payment was received</text></line> + <line></line> + <line size="1"><text align="left" length="10">AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line> + #end + #if ($ticket.hasTip()) + <line><text align ="left" length="16">Tip:</text><text align ="right" length="26">_______________</text></line> + <line></line> + <line size="1"><text align ="left" length="16" bold="false">Total</text><text align ="right" length="26" bold="false">_______________</text></line> + <line></line> + <line></line> + <line size="1"><text align ="left" length="126" bold="false">__________________________________________</text></line> + <line size="1"><text align ="center" length="126" bold="false">Signature</text></line> + #else + <line size="1"><text align ="left" length="16" bold="true">Total</text><text align ="right" length="26" bold="true">${paymentline.printTotal()}</text></line> + #end + #end + #if ($paymentline.name == "ccardrefund") + <line size="1"><text align="center" length="126" bold="true">CARD SALE</text></line> + <line></line> + <line><text align = "center" length="126" bold="true">A card payment was received</text></line> + <line></line> + <line size="1"><text align="left" length="10">AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line> + #end + #end + + </ticket> + +#foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <opendrawer/> + #end + #if ($paymentline.name == "cashrefund") + <opendrawer/> + #end +#end + +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.TicketRemote.xml b/src/main/resources/com/unicenta/pos/templates/Printer.TicketRemote.xml new file mode 100644 index 0000000..31a6c1f --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.TicketRemote.xml @@ -0,0 +1,116 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +--> + +<output> + + <display> + <line> + <text align="left" length="8">Sent!</text> + <text align="right" length="12">${ticket.printTotal()}</text> + </line> + <line> + <text align="center" length="20">Thank you</text> + </line> + </display> + + <ticket printer = "2"> + <line></line> + <line></line> + <line size = "1"> + <text bold = "true" align="center" length="42">ORDER</text> + </line> + <line></line> + + #if (${tickettext.place} != ${place}) + <line size ="1"> + <text bold="true" align="left" length="15">Table:</text> + <text bold="true">${place}</text> + </line> + #end + + <line> + <text align="left" length="15">Server:</text> + <text>${ticket.printUser()}</text> + </line> + + <line> + <text align="left" length="15">Date:</text> + <text>${ticket.printDate()}</text> + </line> + <line> + <text align="left" length="15">Receipt:</text> + <text>${ticket.printId()}</text> + </line> + + #if ($ticket.getCustomer()) + <line> + <text align="left" length="15">Customer:</text> + <text>${ticket.getCustomer().getName()}</text> + </line> + <line> + <text align="left" length="15">Account #:</text> + <text>${ticket.getCustomer().getTaxid()}</text> + </line> + #end + + <line></line> + <line> + <text align ="left" length="17">Item</text> + <text align ="right" length="5"></text> + </line> + <line> + <text>------------------------------------------</text> + </line> + + #foreach ($ticketline in $ticket.getLines()) +<!-- Show Product's assigned Printer +<line><text align="left" length="15">Printer :</text><text>${ticketline.printPrinter()}</text></line>--> + + #if(($ticketline.printPrinter()) && ($ticketline.getProperty("sendstatus").equals("No"))) + <line size = "1"> + <text align ="left" length="5">${ticketline.printMultiply()}x</text> + #if ($ticketline.isProductCom()) + <text align ="left" length="37">--${ticketline.printName()}</text> + #else + <text align ="left" length="37">${ticketline.printName()}</text> + #end + </line> + + <!-- un-comment line below if you want to add a product's properties --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("ingredients", "")}</text> </line> --> + + <!-- un-comment line below if you want to add a user input sales line's Note --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("notes", "")}</text> </line> --> + + #if ($ticketline.productAttSetInstId) + <line> + <text align ="left" length="42"> ${ticketline.productAttSetInstDesc}</text> + </line> + <line></line> + #end + #end + #end + <line> + <text>------------------------------------------</text> + </line> + </ticket> +</output> diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.TicketTotal.xml b/src/main/resources/com/unicenta/pos/templates/Printer.TicketTotal.xml new file mode 100644 index 0000000..a4a4426 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.TicketTotal.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> +<output> + <display> + <line> + <text align="left" length="8">Total:</text> + <text align="right" length="12">${ticket.printTotal()}</text> + </line> + <line> + <text align="center" length="20">Thank You for your custom</text> + </line> + </display> +</output> diff --git a/src/main/resources/com/unicenta/pos/templates/Printer.Ticket_A4.xml b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket_A4.xml new file mode 100644 index 0000000..a9cc185 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Printer.Ticket_A4.xml @@ -0,0 +1,259 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Contributed by: Julian Roberts, Brockley Estate, Tasmania + Additional changes: uniCenta 2015 + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> + +<output> + +<display> + <line><text align="left" length="10">Total</text><text align="right" length="10">${ticket.printTotal()}</text></line> + <line><text align="center" length="20">Thank you for your custom</text></line> +</display> + +<ticket> + <line></line> + <image>Printer.Ticket.Logo</image> + <line></line> + <line><text align="center" length="126">Tax Invoice</text></line> + <line></line> + + #if (${ticket.printTicketHeaderLine1()} != "") + <line> + <text align="center" length="126">${ticket.printTicketHeaderLine1()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine2()} != "") + <line> + <text align="center" length="126">${ticket.printTicketHeaderLine2()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine3()} != "") + <line> + <text align="center" length="126">${ticket.printTicketHeaderLine3()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine4()} != "") + <line> + <text align="center" length="126">${ticket.printTicketHeaderLine4()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine5()} != "") + <line> + <text align="center" length="126">${ticket.printTicketHeaderLine5()}</text> + </line> + #end + #if (${ticket.printTicketHeaderLine6()} != "") + <line> + <text align="center" length="126">${ticket.printTicketHeaderLine6()}</text> + </line> + #end + + <line></line> + + + #if (${ticket.ticketType} == 0) + <line><text align="left" length="15">Receipt:</text><text>${ticket.printId()}</text></line> + #end + + #if (${ticket.ticketType} == 1) + <line><text align="left" length="15">Refund:</text><text>${ticket.printId()}</text></line> + #end + <line><text align="left" length="15">Date:</text><text>${ticket.printDate()}</text></line> + + #if ($ticket.getCustomer()) + <line><text align="left" length="15">Account #:</text><text>${ticket.getCustomer().printTaxCustomerID()}</text></line> + <line><text align="left" length="15">Customer:</text><text>${ticket.getCustomer().printName()}</text></line> + <line><text align="left" length="15">Address:</text><text>${ticket.getCustomer().printAddress()}</text></line> + <line><text align="left" length="15">Postal:</text><text>${ticket.getCustomer().printPostal()}</text></line> + <line><text align="left" length="15">Phone:</text><text>${ticket.getCustomer().printPhone1()}</text></line> + <line><text align="left" length="15">Current Debt:</text><text>${ticket.getCustomer().printCurDebt()}</text></line> + <line><text align="left" length="15">Balance:</text><text>${ticket.getCustomer().printCurBal()}</text></line> + #end + + #if (${tickettext.place} != ${place}) + <line><text align="left" length="15">Table/Room:</text><text>${place}</text></line> + #end + + <line><text align="left" length="15">Served by:</text><text>${ticket.printUser()}</text></line> + <line></line> + <line><text align ="left" length="83">Item</text><text align ="right" length="10">Price</text><text align ="right" length="5">Qty</text><text align ="right" length="10">Value</text></line> + <line><text align="left" length="108">------------------------------------------------------------------------------------------------------------</text></line> + +#foreach ($ticketline in $ticket.getLines()) + <line> + + #if ($ticketline.isProductCom()) + <text align ="left" length="83">*${ticketline.printName()}</text> + #else + <text align ="left" length="83">${ticketline.printName()}</text> + #end + <text align ="right" length="10">${ticketline.printPriceTax()}</text> + <text align ="right" length="5">x${ticketline.printMultiply()}</text> + <text align ="right" length="10">${ticketline.printValue()}</text> + </line> + + <!-- un-comment line below if you want to add a product's properties --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("ingredients", "")}</text> </line> --> + + <!-- un-comment line below if you want to add a user input sales line's Note --> + <!-- <line><text align ="left" length="42">${ticketline.getProperty("notes", "")}</text> </line> --> + + #if ($ticketline.productAttSetInstId) + <line><text align ="left" length="42">${ticketline.productAttSetInstDesc}</text></line> + #end +#end + <line><text align="left" length="108">------------------------------------------------------------------------------------------------------------</text></line> + <line><text>Items count: </text><text align ="left" length="14">${ticket.printArticlesCount()}</text></line> + +#foreach ($paymentline in $ticket.payments) + + #if ($paymentline.name == "cash") + <line><text bold="true">Cash</text></line> +<!-- <line><text align="left" length="22">Tendered:</text><text align ="right" length="20">${paymentline.printTendered()}</text></line> --> + <line><text align="left" length="22">Change:</text><text align ="right" length="20">${paymentline.printChange()}</text></line> + #end + + #if ($paymentline.name == "cashrefund") + <line><text bold="true">Refund</text></line> + <line><text align ="right" length="108">${paymentline.printTotal()}</text></line> + #end + + #if ($paymentline.name == "ccard") + <line><text bold="true">Card</text></line> + <line> <text>Card Type</text></line> + <line> + <text>${paymentline.getCardName()}</text> + </line> + <line><text align ="right" length="108">${paymentline.printTotal()}</text></line> + #end + + #if ($paymentline.name == "ccardrefund") + <line><text bold="true">Card Refund</text></line> + <line> <text>Card Type</text></line> + <line> + <text>${paymentline.getCardName()}</text> + </line> + <line><text align ="right" length="108">${paymentline.printTotal()}</text></line> + #end + + #if ($paymentline.name == "cheque") + <line></line> + <line><text bold="true">Cheque</text></line> + <line><text align ="right" length="108">${paymentline.printTotal()}</text></line> + #end + + #if ($paymentline.name == "chequerefund") + <line></line> + <line><text bold="true">Cheque Refund</text></line> + <line><text align ="right" length="108">${paymentline.printTotal()}</text></line> + #end + + #if ($paymentline.name == "voucherin") + <line></line> + <line><text bold="true">Voucher</text></line> + <line><text align ="right" length="108">${paymentline.printTotal()}</text></line> + #end + + #if ($paymentline.name == "voucherout") + <line></line> + <line><text bold="true">Note Refund</text></line> + <line><text align ="right" length="108">${paymentline.printTotal()}</text></line> + #end + + #if ($paymentline.name == "free") + <line></line> + <line><text bold="true">Free</text></line> + <line><text align ="right" length="108">${paymentline.printTotal()}</text></line> + #end + + #if ($paymentline.name == "debt") + <line></line> + <line><text bold="true">On Account</text></line> + <line><text align ="right" length="108">${paymentline.printTotal()}</text></line> + #end +#end + + + <line></line> + <line><text align ="left" length="16">Taxable Items:</text><text align ="right" length="92">${ticket.printSubTotal()}</text></line> + <line><text align ="left" length="22">Tax Included in total:</text><text align ="right" length="86">${ticket.printTax()}</text></line> + <line></line> + + <line></line> + <line size="1"><text align ="left" length="16" bold="true">Total</text><text align ="right" length="92" bold="true">${ticket.printTotal()}</text></line> + +<!-- #foreach ($taxinfo in $taxes) --> +<!-- #set( $taxline = $ticket.getTaxLine($taxinfo)) --> +<!-- <line> --> +<!-- <text align ="left" length="18">${taxline.getTaxInfo()}</text> --> +<!-- <text align ="right" length="12">${taxline.printSubTotal()}</text> --> +<!-- <text align ="right" length="12">${taxline.printTax()}</text> --> +<!-- </line> --> +<!--#end --> + + <line></line> + #if (${ticket.printTicketFooterLine1()} != "") + <line> + <text align="center" length="105">${ticket.printTicketFooterLine1()}</text> + </line> + <line> + <text>==========================================</text> + </line> + #end + #if (${ticket.printTicketFooterLine2()} != "") + <line> + <text>${ticket.printTicketFooterLine2()}</text> + </line> + #end + #if (${ticket.printTicketFooterLine3()} != "") + <line> + <text>${ticket.printTicketFooterLine3()}</text> + </line> + #end + #if (${ticket.printTicketFooterLine4()} != "") + <line> + <text>${ticket.printTicketFooterLine4()}</text> + </line> + #end + #if (${ticket.printTicketFooterLine5()} != "") + <line> + <text>${ticket.printTicketFooterLine5()}</text> + </line> + #end + #if (${ticket.printTicketFooterLine6()} != "") + <line> + <text>${ticket.printTicketFooterLine6()}</text> + </line> + #end + <line></line> +<!-- <line><barcode type="CODE128">${ticket.printId()}</barcode></line> --> + +</ticket> + +#foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <opendrawer/> + #end + #if ($paymentline.name == "cashrefund") + <opendrawer/> + #end +#end + +</output> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Role.Administrator.xml b/src/main/resources/com/unicenta/pos/templates/Role.Administrator.xml new file mode 100644 index 0000000..7c0c214 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Role.Administrator.xml @@ -0,0 +1,198 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. + If not, see <http://www.gnu.org/licenses/>. +--> + +<!-- + The Administrator Role Permissions has full access to all uniCenta oPOS + functionality. + The Administrator Role should only be used to make system changes. + + *** Do not change unless you know what you are doing *** +--> + + +<permissions> + <class name="plugins.configure"/> + <class name="com.unicenta.pos.panels.JPanelCloseMoney"/> + <class name="com.unicenta.pos.panels.JPanelCloseMoneyReprint"/> + <class name="com.unicenta.pos.panels.JPanelPayments"/> + <class name="com.unicenta.pos.sales.JPanelTicketEdits"/> + <class name="com.unicenta.pos.sales.JPanelTicketSales"/> + + <class name="payment.bank"/> + <class name="payment.cash"/> + <class name="payment.cheque"/> + <class name="payment.debt"/> + <class name="payment.free"/> + <class name="payment.magcard"/> + <class name="payment.slip"/> + <class name="payment.voucher"/> + <class name="refund.cash"/> + <class name="refund.cheque"/> + <class name="refund.magcard"/> + <class name="refund.voucher"/> + <class name="sales.ChangeTaxOptions"/> + <class name="sales.DeleteLines"/> + <class name="sales.DeleteTicket"/> + <class name="sales.EditLines"/> + <class name="sales.EditTicket"/> + <class name="sales.Layout"/> + <class name="sales.Override"/> + <class name="sales.PrintRemote"/> + <class name="sales.PrintTicket"/> + <class name="sales.RefundTicket"/> + <class name="sales.ShowList"/> + <class name="sales.Total"/> + <class name="sales.ViewSharedTicket"/> + +<!-- Standard button scripts --> + <class name="button.opendrawer"/> + <class name="button.print"/> + <class name="button.Totaldiscount"/> + +<!-- Additional button scripts --> + <class name="button.keyboard"/> + <class name="button.Linediscount"/> + <class name="button.refundit"/> + <class name="button.scharge"/> + <class name="button.sendorder"/> + +<class name="com.unicenta.pos.forms.MenuCustomers"/> + <class name="com.unicenta.pos.customers.CustomersPanel"/> + <class name="/com/unicenta/reports/customers.bs"/> + <class name="/com/unicenta/reports/customers_cards.bs"/> + <class name="/com/unicenta/reports/customers_debtors.bs"/> + <class name="/com/unicenta/reports/customers_diary.bs"/> + <class name="/com/unicenta/reports/customers_export.bs"/> + <class name="/com/unicenta/reports/customers_list.bs"/> + <class name="/com/unicenta/reports/customers_sales.bs"/> + + +<class name="com.unicenta.pos.forms.MenuSuppliers"/> + <class name="com.unicenta.pos.suppliers.SuppliersPanel"/> + <class name="/com/unicenta/reports/suppliers.bs"/> + <class name="/com/unicenta/reports/suppliers_b.bs"/> + <class name="/com/unicenta/reports/suppliers_creditors.bs"/> + <class name="/com/unicenta/reports/suppliers_diary.bs"/> + <class name="/com/unicenta/reports/suppliers_export.bs"/> + <class name="/com/unicenta/reports/suppliers_list.bs"/> + <class name="/com/unicenta/reports/suppliers_products.bs"/> + <class name="/com/unicenta/reports/suppliers_sales.bs"/> + +<class name="com.unicenta.pos.forms.MenuStockManagement"/> + <class name="com.unicenta.pos.inventory.AttributeSetsPanel"/> + <class name="com.unicenta.pos.inventory.AttributesPanel"/> + <class name="com.unicenta.pos.inventory.AttributeUsePanel"/> + <class name="com.unicenta.pos.inventory.AttributeValuesPanel"/> + <class name="com.unicenta.pos.inventory.AuxiliarPanel"/> + <class name="com.unicenta.pos.inventory.BundlePanel"/> + <class name="com.unicenta.pos.inventory.CategoriesPanel"/> + + <class name="com.unicenta.pos.inventory.ProductsPanel"/> + <class name="com.unicenta.pos.inventory.ProductsWarehousePanel"/> + <class name="com.unicenta.pos.inventory.StockDiaryPanel"/> + <class name="com.unicenta.pos.inventory.StockManagement"/> + <class name="com.unicenta.pos.inventory.TaxCategoriesPanel"/> + <class name="com.unicenta.pos.inventory.TaxCustCategoriesPanel"/> + <class name="com.unicenta.pos.inventory.TaxPanel"/> + <class name="com.unicenta.pos.inventory.UomPanel"/> + + <class name="/com/unicenta/reports/inventory.bs"/> + <class name="/com/unicenta/reports/inventory_b.bs"/> + <class name="/com/unicenta/reports/inventory_broken.bs"/> + <class name="/com/unicenta/reports/inventory_diary.bs"/> + <class name="/com/unicenta/reports/inventory_diff.bs"/> + <class name="/com/unicenta/reports/inventory_diffdetail.bs"/> + <class name="/com/unicenta/reports/inventory_listdetail.bs"/> + <class name="/com/unicenta/reports/labels_barcode_sheet.bs"/> + <class name="/com/unicenta/reports/labels_barcode_shelfedge.bs"/> <class name="/com/unicenta/reports/productscatalog.bs"/> + <class name="/com/unicenta/reports/labels_product.bs"/> + <class name="/com/unicenta/reports/products.bs"/> + <class name="/com/unicenta/reports/salecatalog.bs"/> + +<class name="com.unicenta.pos.forms.MenuSalesManagement"/> + <class name="/com/unicenta/reports/sales_cashflow.bs"/> + <class name="/com/unicenta/reports/sales_cashregisterlog.bs"/> + <class name="/com/unicenta/reports/sales_categorysales.bs"/> + <class name="/com/unicenta/reports/sales_categorysales_1.bs"/> + <class name="/com/unicenta/reports/sales_closedpos.bs"/> + <class name="/com/unicenta/reports/sales_closedpos_1.bs"/> + <class name="/com/unicenta/reports/sales_closedproducts.bs"/> + <class name="/com/unicenta/reports/sales_closedproducts_1.bs"/> + <class name="/com/unicenta/reports/sales_extendedcashregisterlog.bs"/> + <class name="/com/unicenta/reports/sales_extproducts.bs"/> + <class name="/com/unicenta/reports/sales_payments.bs"/> + <class name="/com/unicenta/reports/sales_productsalesprofit.bs"/> + <class name="/com/unicenta/reports/sales_saletaxes.bs"/> + <class name="/com/unicenta/reports/sales_taxcatsales.bs"/> + <class name="/com/unicenta/reports/sales_taxes.bs"/> + + <class name="/com/unicenta/reports/sales_chart_piesalescat.bs"/> + <class name="/com/unicenta/reports/sales_chart_productsales.bs"/> + <class name="/com/unicenta/reports/sales_chart_sales.bs"/> + <class name="/com/unicenta/reports/sales_chart_timeseriesproduct.bs"/> + <class name="/com/unicenta/reports/sales_chart_top10.bs"/> + +<class name="com.unicenta.pos.forms.MenuMaintenance"/> + <class name="com.unicenta.pos.admin.PeoplePanel"/> + <class name="com.unicenta.pos.admin.ResourcesPanel"/> + <class name="com.unicenta.pos.admin.RolesPanel"/> + <class name="com.unicenta.pos.inventory.LocationsPanel"/> + <class name="com.unicenta.pos.mant.JPanelFloors"/> + <class name="com.unicenta.pos.mant.JPanelPlaces"/> + <class name="com.unicenta.pos.voucher.VoucherPanel"/> + <class name="/com/unicenta/reports/customers_vouchers.bs"/> + <class name="/com/unicenta/reports/users.bs"/> + <class name="/com/unicenta/reports/users_nosales.bs"/> + <class name="/com/unicenta/reports/users_sales.bs"/> + <class name="/com/unicenta/reports/users_tips.bs"/> + <class name="/com/unicenta/reports/users_voids.bs"/> + +<class name="com.unicenta.pos.imports.JPanelCSV"/> + <class name="com.unicenta.pos.imports.CustomerCSVImport"/> + <class name="com.unicenta.pos.imports.JPanelCSVCleardb"/> + <class name="com.unicenta.pos.imports.JPanelCSVImport"/> + <class name="com.unicenta.pos.imports.StockQtyImport"/> + <class name="com.unicenta.pos.transfer.Transfer"/> + <class name="/com/unicenta/reports/tools_invalidcategory.bs"/> + <class name="/com/unicenta/reports/tools_invaliddata.bs"/> + <class name="/com/unicenta/reports/tools_inventoryqtyupdate.bs"/> + <class name="/com/unicenta/reports/tools_missingdata.bs"/> + <class name="/com/unicenta/reports/tools_newproducts.bs"/> + <class name="/com/unicenta/reports/tools_updatedprices.bs"/> +// <class name="/com/unicenta/reports/tools_badprice.bs"/> + +<!-- EPM --> +<class name="com.unicenta.pos.forms.MenuEmployees" /> + <class name="com.unicenta.pos.epm.BreaksPanel" /> + <class name="com.unicenta.pos.epm.JPanelEmployeePresence" /> + <class name="com.unicenta.pos.epm.LeavesPanel" /> + <class name="/com/unicenta/reports/epm_dailypresence.bs" /> + <class name="/com/unicenta/reports/epm_dailyschedule.bs" /> + <class name="/com/unicenta/reports/epm_performance.bs" /> + +<!-- <class name="com.unicenta.possync.ProductsSyncCreate"/> --> +<!-- <class name="com.unicenta.possync.OrdersSyncCreate"/> --> + <class name="Menu.ChangePassword"/> + <class name="com.unicenta.pos.panels.JPanelPrinter"/> + <class name="com.unicenta.pos.config.JPanelConfiguration"/> + +</permissions> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Role.Employee.xml b/src/main/resources/com/unicenta/pos/templates/Role.Employee.xml new file mode 100644 index 0000000..57866ae --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Role.Employee.xml @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. + If not, see <http://www.gnu.org/licenses/>. +--> + +<!-- + The Administrator Role Permissions has full access to all uniCenta oPOS + functionality. + The Administrator Role should only be used to make system changes. + + *** Do not change unless you know what you are doing *** +--> + + +<permissions> + <class name="com.unicenta.pos.customers.CustomersPayment"/> + <class name="com.unicenta.pos.panels.JPanelPayments"/> + <class name="com.unicenta.pos.sales.JPanelTicketEdits"/> + <class name="com.unicenta.pos.sales.JPanelTicketSales"/> + + <class name="payment.cash"/> + <class name="payment.cheque"/> + <class name="payment.debt"/> + <class name="payment.free"/> + <class name="payment.magcard"/> + <class name="payment.slip"/> + <class name="payment.voucher"/> + <class name="sales.DeleteLines"/> + <class name="sales.EditLines"/> + <class name="sales.EditTicket"/> + <class name="sales.PrintRemote"/> + <class name="sales.PrintTicket"/> + <class name="sales.Total"/> + <class name="sales.ViewSharedTicket"/> + +<!-- Standard button scripts --> + <class name="button.opendrawer"/> + <class name="button.print"/> + <class name="button.Totaldiscount"/> + +<!-- Additional button scripts --> + <class name="button.keyboard"/> + <class name="button.Linediscount"/> + <class name="button.scharge"/> + <class name="button.sendorder"/> + +<class name="com.unicenta.pos.forms.MenuCustomers"/> + <class name="com.unicenta.pos.customers.CustomersPanel"/> + <class name="/com/unicenta/reports/customers.bs"/> + <class name="/com/unicenta/reports/customers_cards.bs"/> + +<class name="com.unicenta.pos.forms.MenuSuppliers"/> + <class name="com.unicenta.pos.suppliers.SuppliersPanel"/> + <class name="/com/unicenta/reports/suppliers.bs"/> + +<class name="com.unicenta.pos.forms.MenuMaintenance"/> + <class name="com.unicenta.pos.voucher.VoucherPanel"/> + +<!-- EPM --> +<class name="com.unicenta.pos.forms.MenuEmployees" /> + <class name="Menu.ChangePassword"/> + <class name="com.unicenta.pos.panels.JPanelPrinter"/> + <class name="com.unicenta.pos.config.JPanelConfiguration"/> + +</permissions> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Role.Guest.xml b/src/main/resources/com/unicenta/pos/templates/Role.Guest.xml new file mode 100644 index 0000000..e6d1a32 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Role.Guest.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> +<permissions> + <class name="com.unicenta.pos.sales.JPanelTicketSales"/> + <class name="button.keyboard"/> +</permissions> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Role.Manager.xml b/src/main/resources/com/unicenta/pos/templates/Role.Manager.xml new file mode 100644 index 0000000..7addf2c --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Role.Manager.xml @@ -0,0 +1,198 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. + If not, see <http://www.gnu.org/licenses/>. +--> + +<!-- + The Administrator Role Permissions has full access to all uniCenta oPOS + functionality. + The Administrator Role should only be used to make system changes. + + *** Do not change unless you know what you are doing *** +--> + + +<permissions> + <class name="com.unicenta.pos.customers.CustomersPayment"/> + <class name="com.unicenta.pos.panels.JPanelCloseMoney"/> + <class name="com.unicenta.pos.panels.JPanelCloseMoneyReprint"/> + <class name="com.unicenta.pos.panels.JPanelPayments"/> + <class name="com.unicenta.pos.sales.JPanelTicketEdits"/> + <class name="com.unicenta.pos.sales.JPanelTicketSales"/> + + <class name="payment.bank"/> + <class name="payment.cash"/> + <class name="payment.cheque"/> + <class name="payment.debt"/> + <class name="payment.free"/> + <class name="payment.magcard"/> + <class name="payment.slip"/> + <class name="payment.voucher"/> + <class name="refund.cash"/> + <class name="refund.cheque"/> + <class name="refund.magcard"/> + <class name="refund.voucher"/> + <class name="sales.ChangeTaxOptions"/> + <class name="sales.DeleteLines"/> + <class name="sales.DeleteTicket"/> + <class name="sales.EditLines"/> + <class name="sales.EditTicket"/> + <class name="sales.Layout"/> + <class name="sales.Override"/> + <class name="sales.PrintRemote"/> + <class name="sales.PrintTicket"/> + <class name="sales.RefundTicket"/> + <class name="sales.ShowList"/> + <class name="sales.Total"/> + <class name="sales.ViewSharedTicket"/> + +<!-- Standard button scripts --> + <class name="button.opendrawer"/> + <class name="button.print"/> + <class name="button.Totaldiscount"/> + +<!-- Additional button scripts --> + <class name="button.keyboard"/> + <class name="button.Linediscount"/> + <class name="button.refundit"/> + <class name="button.scharge"/> + <class name="button.sendorder"/> + +<class name="com.unicenta.pos.forms.MenuCustomers"/> + <class name="com.unicenta.pos.customers.CustomersPanel"/> + <class name="/com/unicenta/reports/customers.bs"/> + <class name="/com/unicenta/reports/customers_cards.bs"/> + <class name="/com/unicenta/reports/customers_debtors.bs"/> + <class name="/com/unicenta/reports/customers_diary.bs"/> + <class name="/com/unicenta/reports/customers_export.bs"/> + <class name="/com/unicenta/reports/customers_list.bs"/> + <class name="/com/unicenta/reports/customers_sales.bs"/> + + +<class name="com.unicenta.pos.forms.MenuSuppliers"/> + <class name="com.unicenta.pos.suppliers.SuppliersPanel"/> + <class name="/com/unicenta/reports/suppliers.bs"/> + <class name="/com/unicenta/reports/suppliers_b.bs"/> + <class name="/com/unicenta/reports/suppliers_creditors.bs"/> + <class name="/com/unicenta/reports/suppliers_diary.bs"/> + <class name="/com/unicenta/reports/suppliers_export.bs"/> + <class name="/com/unicenta/reports/suppliers_list.bs"/> + <class name="/com/unicenta/reports/suppliers_products.bs"/> + <class name="/com/unicenta/reports/suppliers_sales.bs"/> + +<class name="com.unicenta.pos.forms.MenuStockManagement"/> + <class name="com.unicenta.pos.inventory.AttributeSetsPanel"/> + <class name="com.unicenta.pos.inventory.AttributesPanel"/> + <class name="com.unicenta.pos.inventory.AttributeUsePanel"/> + <class name="com.unicenta.pos.inventory.AttributeValuesPanel"/> + <class name="com.unicenta.pos.inventory.AuxiliarPanel"/> + <class name="com.unicenta.pos.inventory.BundlePanel"/> + <class name="com.unicenta.pos.inventory.CategoriesPanel"/> + + <class name="com.unicenta.pos.inventory.ProductsPanel"/> + <class name="com.unicenta.pos.inventory.ProductsWarehousePanel"/> + <class name="com.unicenta.pos.inventory.StockDiaryPanel"/> + <class name="com.unicenta.pos.inventory.StockManagement"/> + <class name="com.unicenta.pos.inventory.TaxCategoriesPanel"/> + <class name="com.unicenta.pos.inventory.TaxCustCategoriesPanel"/> + <class name="com.unicenta.pos.inventory.TaxPanel"/> + <class name="com.unicenta.pos.inventory.UomPanel"/> + + <class name="/com/unicenta/reports/inventory.bs"/> + <class name="/com/unicenta/reports/inventory_b.bs"/> + <class name="/com/unicenta/reports/inventory_broken.bs"/> + <class name="/com/unicenta/reports/inventory_diary.bs"/> + <class name="/com/unicenta/reports/inventory_diff.bs"/> + <class name="/com/unicenta/reports/inventory_diffdetail.bs"/> + <class name="/com/unicenta/reports/inventory_listdetail.bs"/> + <class name="/com/unicenta/reports/labels_barcode_sheet.bs"/> + <class name="/com/unicenta/reports/labels_barcode_shelfedge.bs"/> <class name="/com/unicenta/reports/productscatalog.bs"/> + <class name="/com/unicenta/reports/labels_product.bs"/> + <class name="/com/unicenta/reports/products.bs"/> + <class name="/com/unicenta/reports/salecatalog.bs"/> + +<class name="com.unicenta.pos.forms.MenuSalesManagement"/> + <class name="/com/unicenta/reports/sales_cashflow.bs"/> + <class name="/com/unicenta/reports/sales_cashregisterlog.bs"/> + <class name="/com/unicenta/reports/sales_categorysales.bs"/> + <class name="/com/unicenta/reports/sales_categorysales_1.bs"/> + <class name="/com/unicenta/reports/sales_closedpos.bs"/> + <class name="/com/unicenta/reports/sales_closedpos_1.bs"/> + <class name="/com/unicenta/reports/sales_closedproducts.bs"/> + <class name="/com/unicenta/reports/sales_closedproducts_1.bs"/> + <class name="/com/unicenta/reports/sales_extendedcashregisterlog.bs"/> + <class name="/com/unicenta/reports/sales_extproducts.bs"/> + <class name="/com/unicenta/reports/sales_payments.bs"/> + <class name="/com/unicenta/reports/sales_productsalesprofit.bs"/> + <class name="/com/unicenta/reports/sales_saletaxes.bs"/> + <class name="/com/unicenta/reports/sales_taxcatsales.bs"/> + <class name="/com/unicenta/reports/sales_taxes.bs"/> + + <class name="/com/unicenta/reports/sales_chart_piesalescat.bs"/> + <class name="/com/unicenta/reports/sales_chart_productsales.bs"/> + <class name="/com/unicenta/reports/sales_chart_sales.bs"/> + <class name="/com/unicenta/reports/sales_chart_timeseriesproduct.bs"/> + <class name="/com/unicenta/reports/sales_chart_top10.bs"/> + +<class name="com.unicenta.pos.forms.MenuMaintenance"/> + <class name="com.unicenta.pos.admin.PeoplePanel"/> + <class name="com.unicenta.pos.admin.ResourcesPanel"/> + <class name="com.unicenta.pos.admin.RolesPanel"/> + <class name="com.unicenta.pos.inventory.LocationsPanel"/> + <class name="com.unicenta.pos.mant.JPanelFloors"/> + <class name="com.unicenta.pos.mant.JPanelPlaces"/> + <class name="com.unicenta.pos.voucher.VoucherPanel"/> + <class name="/com/unicenta/reports/customers_vouchers.bs"/> + <class name="/com/unicenta/reports/users.bs"/> + <class name="/com/unicenta/reports/users_nosales.bs"/> + <class name="/com/unicenta/reports/users_sales.bs"/> + <class name="/com/unicenta/reports/users_tips.bs"/> + <class name="/com/unicenta/reports/users_voids.bs"/> + +<class name="com.unicenta.pos.imports.JPanelCSV"/> + <class name="com.unicenta.pos.imports.CustomerCSVImport"/> + <class name="com.unicenta.pos.imports.JPanelCSVCleardb"/> + <class name="com.unicenta.pos.imports.JPanelCSVImport"/> + <class name="com.unicenta.pos.imports.StockQtyImport"/> + <class name="com.unicenta.pos.transfer.Transfer"/> + <class name="/com/unicenta/reports/tools_invalidcategory.bs"/> + <class name="/com/unicenta/reports/tools_invaliddata.bs"/> + <class name="/com/unicenta/reports/tools_inventoryqtyupdate.bs"/> + <class name="/com/unicenta/reports/tools_missingdata.bs"/> + <class name="/com/unicenta/reports/tools_newproducts.bs"/> + <class name="/com/unicenta/reports/tools_updatedprices.bs"/> +// <class name="/com/unicenta/reports/tools_badprice.bs"/> + +<!-- EPM --> +<class name="com.unicenta.pos.forms.MenuEmployees" /> + <class name="com.unicenta.pos.epm.BreaksPanel" /> + <class name="com.unicenta.pos.epm.JPanelEmployeePresence" /> + <class name="com.unicenta.pos.epm.LeavesPanel" /> + <class name="/com/unicenta/reports/epm_dailypresence.bs" /> + <class name="/com/unicenta/reports/epm_dailyschedule.bs" /> + <class name="/com/unicenta/reports/epm_performance.bs" /> + +<!-- <class name="com.unicenta.possync.ProductsSyncCreate"/> --> +<!-- <class name="com.unicenta.possync.OrdersSyncCreate"/> --> + <class name="Menu.ChangePassword"/> + <class name="com.unicenta.pos.panels.JPanelPrinter"/> + <class name="com.unicenta.pos.config.JPanelConfiguration"/> + +</permissions> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Ticket.Buttons.xml b/src/main/resources/com/unicenta/pos/templates/Ticket.Buttons.xml new file mode 100644 index 0000000..94d9bf8 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Ticket.Buttons.xml @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> + +<!-- To ENABLE a feature remove the beginning and end of line commentors --> +<!-- To DISABLE a feature you must add the beginning and of line commentors --> + +<configuration> +<!-- Sales Ticket Button Bar - Show icons **************************************** --> + + <!-- SET Sales Ticket Refund Item (Default=DISABLED) --> + <!-- <button key="button.refundit" image="img.refundit" code="script.Refundit"/> --> + + <!-- SET Sales Ticket ServiceCharge (Default=DISABLED) --> + <!-- <button key="button.scharge" image="img.heart" code="script.ServiceCharge"/> --> + + <!-- SET Sales line Note (Default=DISABLED) --> + <!-- <button key="button.note" image="img.refundit" code="script.addlinenote"/> --> + + <!-- SET Line or Total Discount (Default=TotalDiscount= ENABLED) --> + <button key="button.Totaldiscount" image="img.discount" code="script.Totaldiscount"/> + <button key="button.Linediscount" image="img.discount_b" code="script.Linediscount"/> + + <!-- SET Waiter's name (Default=DISABLED) --> + <!-- <button key="button.setperson" image="img.user" code="script.SetPerson"/> --> + + <!-- SET Remote Printer (Default=DISABLED) --> + <!-- <button key="button.sendorder" image="img.kit_print" code="script.SendOrder"/> --> + + <!-- SET Ticket Print Preview (Default=ENABLED) --> + <button key="button.print" image="img.ticket_print" template="Printer.TicketPreview"/> + + <!-- SET Open Cashdrawer (Default=ENABLED) --> + <button key="button.opendrawer" image="img.cashdrawer" template="Printer.OpenDrawer"/> + <!-- SET Virtual Keyboard (Default=ENABLED) --> + <button key="button.keyboard" image="img.keyboard_48" code="script.Keyboard"/> + +<!-- END Sales Ticket Button Bar - Show icons --> + +<!-- SET Ticket Button Bar - Text Only ****************************************************************** --> + <!-- <button key="button.refundit" name="button.refundit" code="script.Refundit"/> --> + <!-- <button key="button.Linediscount" name="button.Linediscount" code="script.Linediscount"/> --> + <!-- <button key="button.Totaldiscount" name="button.Totaldiscount" code="script.Totaldiscount"/> --> + <!-- <button key="button.setperson" name="button.setperson" code="script.SetPerson"/> --> + <!-- <button key="button.sendorder" name="button.sendorder" code="script.SendOrder"/> --> + <!-- <button key="button.print" titlekey="button.print" template="Printer.TicketPreview"/> --> + <!-- <button key="button.opendrawer" titlekey="button.opendrawer" template="Printer.OpenDrawer"/> --> + <!-- <button key="button.keyboard" titlekey="button.keyboard" template="script.Keyboard"/> --> +<!-- END Ticket Button Bar - Text Only --> + +<!-- SET Product Area Size ********************************************* --> + <!-- Maximum Category height for 800x480 for PDA in Full Screen mode --> + <!-- <cat-height value="100" /> --> + + <!-- Maximum Category height for 800x600 --> + <!-- <cat-height value="155" /> --> + + <!-- Maximum Category height for 1024x768 in Full Screen mode (Default=ENABLED) --> + <cat-height value="320" /> + + <!-- Maximum Category height for 1280x1024 in Full Screen mode --> + <!-- <cat-height value="640" /> --> +<!-- END Product Area Size --> + +<!-- SET Product Button Sizes ****************************************** --> + <!-- Small Product button size in Sales screen (Default=DISABLED) --> + <!-- <img-width value="64"/> --> + <!-- <img-height value="48"/> --> + + <!-- Medium Product button size in Sales screen (Default=ENABLED) --> + <img-width value="107"/> + <img-height value="60"/> + +<!-- Large Product button size in Sales screen (Default=DISABLED)--> + <!-- <img-width value="128"/> --> + <!-- <img-height value="96"/> --> +<!-- END Product Button Size --> + +<!-- Print Receipt (Default=ENABLED) --> + <printselected value="true"/> + + <!-- ADDITIONAL FEATURES ************************************************* --> + <!-- SET Show Change in Cash Sale (Default=ENABLED --> + <event key="ticket.close" code="Ticket.Close"/> + <event key="cash.close" code="Cash.Close"/> + +<!-- Execute your own scripts by EVENTS triggered by Sales Screen --> + <!-- <event key="ticket.change" code="script.multibuy"/> Discount 2 different products --> + <!-- <event key="ticket.change" code="script.YourChangeScript"/> after a ticketline is changed --> + <!-- <event key="ticket.addline" code="script.YourAddLineScript"/> before a ticketline is added --> + <!-- <event key="ticket.setline" code="script.YourSetLineScript"/> before an exisitng ticketline is changed --> + <!-- <event key="ticket.removeline" code="script.YourRemoveLineScript"/> before a ticketline is deleted --> + <!-- <event key="ticket.show" code="script.YourShowScript"/> before the receipt is shown --> + <!-- <event key="ticket.total" code="script.YourTotalScript"/> after the equals button --> + <!-- <event key="ticket.save" code="script.YourSaveScript"/> after payment OK button --> + <!-- <event key="ticket.close" code="script.YourCloseScript"/> after ticket is stored in database and ticket number assigned --> + + + <taxesincluded value="true"/> + <taxcategoryid value="001"/> + <pricevisible value="true" /> + +</configuration> diff --git a/src/main/resources/com/unicenta/pos/templates/Ticket.Close.xml b/src/main/resources/com/unicenta/pos/templates/Ticket.Close.xml new file mode 100644 index 0000000..6b34e93 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Ticket.Close.xml @@ -0,0 +1,59 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// http://sourceforge.net/projects/unicentaopos +// +// This file is part of uniCenta oPOS. +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. 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 com.unicenta.pos.payment.PaymentInfo; + import javax.swing.JOptionPane; + import javax.swing.JDialog; + + +boolean isCash = false; +String change = ""; +PaymentInfo p = ticket.payments.getFirst(); + +if ("cash".equals(p.getName())) { + isCash = true; + change = p.printChange(); +} + +// 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,20))); +message = "Change: " + change; + JLabel FontText = new JLabel(message); + FontText.setFont (new Font ( "Arial", Font.BOLD, 36) ); + +if(isCash) { + JOptionPane pane = new JOptionPane(); + pane.setMessage(FontText); + pane.setPreferredSize( new Dimension(450,150)); + JDialog dialog = pane.createDialog("Cash payment"); + 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()))); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Ticket.Line.xml b/src/main/resources/com/unicenta/pos/templates/Ticket.Line.xml new file mode 100644 index 0000000..036ea17 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Ticket.Line.xml @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> + +<!-- This sales transaction screen is great for Retailers! --> +<line> + <column name="label.item" width="185" align="left" value="<html> + #if ($ticketline.isProductCom()) <i>*&nbsp;&nbsp; + ${ticketline.printName()}</i> + #else + ${ticketline.printName()} + #end + <br>${ticketline.getProductAttSetInstDesc()}"/> + + <column name="label.price" width="50" align="right" value="${ticketline.printPrice()}"/> + <column name="label.units" width="50" align="right" value="x${ticketline.printMultiply()}"/> + <column name="label.tax" width="50" align="right" value="${ticketline.printTaxRate()}"/> + <column name="label.value" width="100" align="right" value="${ticketline.printValue()}"/> + <column name="label.printto" width="5" align="center" value="${ticketline.printPrinter()}"/> +<!--<column name="label.sendorder" width="5" align="left" value="${ticketline.getProperty('printkb','?')}"/> --> +<!--<column name="label.sendstatus" width="5" align="left" value="${ticketline.getProperty('sendstatus','?')}"/> --> +</line> + +<!-- This sales transaction screen is great for Hospitality! +<line> + <column name="label.item2" width="235" align="left" value="<html> + #if ($ticketline.isProductCom()) + <i>*&nbsp;&nbsp;${ticketline.printName()}</i> + #else + ${ticketline.printName()} + #end + <br>${ticketline.getProductAttSetInstDesc()}"/> + + <column name="label.units2" width="50" align="right" value="x${ticketline.printMultiply()}"/> + <column name="label.value2" width="100" align="right" value="${ticketline.printValue()}"/> + <column name="label.printto" width="5" align="center" value="${ticketline.printPrinter()}"/> +</line> + --> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Ticket.TicketLineTaxesIncluded.xml b/src/main/resources/com/unicenta/pos/templates/Ticket.TicketLineTaxesIncluded.xml new file mode 100644 index 0000000..e8c419b --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Ticket.TicketLineTaxesIncluded.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + uniCenta oPOS - Touch friendly Point Of Sale + Copyright (c) 2009-2018 uniCenta. + http://sourceforge.net/projects/unicentaopos + + This file is part of uniCenta oPOS. + + uniCenta oPOS 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. + + uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + --> + +<line> + <column name="label.item" width="125" align="left" value="<html> + #if ($ticketline.isProductCom()) + <i>*&nbsp;&nbsp;${ticketline.printName()}</i> + #else ${ticketline.printName()} + + #end"/> + <column name="label.price" width="80" align="right" value="${ticketline.printPriceTax()}"/> + <column name="label.units" width="50" align="right" value="x${ticketline.printMultiply()}"/> + <column name="label.tax" width="100" align="right" value="${ticketline.printTaxRate()}"/> + <column name="label.value" width="80" align="right" value="${ticketline.printValue()}"/> +</line> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/Window.Title.txt b/src/main/resources/com/unicenta/pos/templates/Window.Title.txt new file mode 100644 index 0000000..d818753 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/Window.Title.txt @@ -0,0 +1 @@ +uniCenta oPOS - Touch Friendly Point Of Sale \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/customer.created.xml b/src/main/resources/com/unicenta/pos/templates/customer.created.xml new file mode 100644 index 0000000..2f962f0 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/customer.created.xml @@ -0,0 +1,27 @@ +// Customer.Created +// This script initialises the uniCenta posApps CUSTOMER CREATED +// REST API web services +// +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// http://sourceforge.net/projects/unicentaopos +// +// This file is part of uniCenta oPOS. +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// ************************************************************************** + +import uk.co.pos_apps.PosApps; + +PosApps.createCustomer(device, customer); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/customer.deleted.xml b/src/main/resources/com/unicenta/pos/templates/customer.deleted.xml new file mode 100644 index 0000000..07118a0 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/customer.deleted.xml @@ -0,0 +1,27 @@ +// Customer.Deleted +// This script initialises the uniCenta posApps CUSTOMER DELETED +// REST API web services +// +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// http://sourceforge.net/projects/unicentaopos +// +// This file is part of uniCenta oPOS. +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// ************************************************************************** + +import uk.co.pos_apps.PosApps; + +PosApps.deleteCustomer(device, customer); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/customer.updated.xml b/src/main/resources/com/unicenta/pos/templates/customer.updated.xml new file mode 100644 index 0000000..0bd5e42 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/customer.updated.xml @@ -0,0 +1,27 @@ +// Customer.Updated +// This script initialises the uniCenta posApps CUSTOMER UPDATED +// REST API web services +// +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// http://sourceforge.net/projects/unicentaopos +// +// This file is part of uniCenta oPOS. +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// ************************************************************************** + +import uk.co.pos_apps.PosApps; + +PosApps.updateCustomer(device, customer); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/payment.cash.txt b/src/main/resources/com/unicenta/pos/templates/payment.cash.txt new file mode 100644 index 0000000..d7b093f --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/payment.cash.txt @@ -0,0 +1,41 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// http://sourceforge.net/projects/unicentaopos +// +// This file is part of uniCenta oPOS. +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// ************************************************************************* + +// ************************************************************************* +// All currency payment denominations to show in Payment forms +// You can find additional prepared currency styles in the Configs folder of +// uniCenta oPOS install folder. Use the Import button to load +// +// To INCLUDE a denomination remove "//" from the line +// To EXCLUDE a denomination add "//" to the line +// ************************************************************************* + +payment.addButton("img.50", 50.0); +payment.addButton("img.20", 20.0); +payment.addButton("img.10", 10.0); +payment.addButton("img.5", 5.0); +payment.addButton("img.2", 2.0); +payment.addButton("img.1", 1.00); +payment.addButton("img.050", 0.50); +payment.addButton("img.020", 0.20); +payment.addButton("img.010", 0.10); +payment.addButton("img.005", 0.05); +payment.addButton("img.002", 0.02); +payment.addButton("img.001", 0.01); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/script.Keyboard.txt b/src/main/resources/com/unicenta/pos/templates/script.Keyboard.txt new file mode 100644 index 0000000..8ac6769 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/script.Keyboard.txt @@ -0,0 +1,29 @@ +// script.Keyboard.txt +// This script launches uniCenta Virtual Keyboard +// +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// http://sourceforge.net/projects/unicentaopos +// +// This file is part of uniCenta oPOS. +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// ************************************************************************** + +Runtime runtime = Runtime.getRuntime(); +// Windows +Process proc = runtime.getRuntime() .exec("cmd /C start osk.exe"); + +// Ubuntu +// Process proc = runtime.getRuntime() .exec("onboard"); \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/script.Linediscount.txt b/src/main/resources/com/unicenta/pos/templates/script.Linediscount.txt new file mode 100644 index 0000000..e1db363 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/script.Linediscount.txt @@ -0,0 +1,51 @@ +// script.Linediscount +// +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// http://sourceforge.net/projects/unicentaopos +// +// This file is part of uniCenta oPOS. +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// ************************************************************************** +// This script applies UsersInput %Discount for the Item Line value +// To use in the sales screen: Highlight the line you want to discount +// Then Tap in the %Discount amount and touch the % button + +import com.unicenta.format.Formats; +import com.unicenta.pos.ticket.TicketLineInfo; +import com.unicenta.pos.ticket.TicketProductInfo; + +discountrate = sales.getInputValue() / 100.0; + +index = sales.getSelectedIndex(); +if (index >= 0) { + line = ticket.getLine(index); + if (line.getPrice() > 0.0 && discountrate > 0.0) { + sdiscount = Formats.PERCENT.formatValue(discountrate); + ticket.insertLine(index + 1, + new TicketLineInfo( + "Line Discount " + sdiscount, + line.getProductTaxCategoryID(), + line.getProductPrinter(), + line.getMultiply(), + -(double)Math.abs(line.getNewPrice() * discountrate * 100) / 100, + line.getTaxInfo())); + sales.setSelectedIndex(index + 1); + } else { + java.awt.Toolkit.getDefaultToolkit().beep(); + } +} else { + java.awt.Toolkit.getDefaultToolkit().beep(); +} \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/script.SendOrder.txt b/src/main/resources/com/unicenta/pos/templates/script.SendOrder.txt new file mode 100644 index 0000000..98f224e --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/script.SendOrder.txt @@ -0,0 +1,76 @@ +// script.SendOrder +// Sends an item in a Sale to a remote Printers +// +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// http://sourceforge.net/projects/unicentaopos +// +// This file is part of uniCenta oPOS. +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// ************************************************************************** + +private boolean printedP1 = false; +private boolean printedP2 = false; +private boolean printedP3 = false; +private boolean printedP4 = false; +private boolean printedP5 = false; +private boolean printedP6 = false; + +for(int i= 0; i < ticket.getLinesCount(); i++){ + line = ticket.getLine(i); + + if (line.getProperty("product.printer")!=null) { + + if (line.getProperty("product.printer").equals("1")) { + if((printedP1 == false) && line.getProperty("ticket.updated").equals("true")) { + sales.printTicket("Printer.Ticket.P1"); + printedP1 = true; + } + } + + if (line.getProperty("product.printer").equals("2")) { + if((printedP2 == false) && line.getProperty("ticket.updated").equals("true")){ + sales.printTicket("Printer.Ticket.P2"); + printedP2 = true; + } + } + if (line.getProperty("product.printer").equals("3")) { + if((printedP3 == false) && line.getProperty("ticket.updated").equals("true")){ + sales.printTicket("Printer.Ticket.P3"); + printedP3 = true; + } + } + + if (line.getProperty("product.printer").equals("4")) { + if((printedP4 == false) && line.getProperty("ticket.updated").equals("true")){ + sales.printTicket("Printer.Ticket.P4"); + printedP4 = true; + } + } + if (line.getProperty("product.printer").equals("5")) { + if((printedP5 == false) && line.getProperty("ticket.updated").equals("true")){ + sales.printTicket("Printer.Ticket.P5"); + printedP5 = true; + } + } + + if (line.getProperty("product.printer").equals("6")) { + if((printedP6 == false) && line.getProperty("ticket.updated").equals("true")){ + sales.printTicket("Printer.Ticket.P6"); + printedP6 = true; + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/script.Totaldiscount.txt b/src/main/resources/com/unicenta/pos/templates/script.Totaldiscount.txt new file mode 100644 index 0000000..3dbe8ed --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/script.Totaldiscount.txt @@ -0,0 +1,54 @@ +// script.Totaldiscount +// +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// http://sourceforge.net/projects/unicentaopos +// +// This file is part of uniCenta oPOS. +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// ************************************************************************** +// This script applies UsersInput %Discount for the Total Ticket +// each Line value is recalculated and annotated +// To use in the sales screen: Highlight the line you want to discount +// Then Tap in the %Discount amount and touch the % button + +import com.unicenta.format.Formats; +import com.unicenta.pos.ticket.TicketLineInfo; +import com.unicenta.pos.ticket.TicketProductInfo; + +discountrate = sales.getInputValue() / 100.0; + +index = sales.getSelectedIndex(); +if (index >= 0) { + if (ticket.getTotal() > 0.0 && discountrate > 0.0) { + sdiscount = Formats.PERCENT.formatValue((discountrate)); + for (int number= 0; number < ticket.getLinesCount(); number++) { + line = ticket.getLine(number); + ticket.setLine(number, + new TicketLineInfo( + line.getProductID(), + line.getProductName() + " - Item Discount @ " + sdiscount, + line.getProductTaxCategoryID(), + line.getProductPrinter(), + line.getMultiply(), + line.getNewPrice() - (double)Math.abs(line.getNewPrice() * discountrate * 100) /100, + line.getTaxInfo())); + } + } else { + java.awt.Toolkit.getDefaultToolkit().beep(); + } +} else { + java.awt.Toolkit.getDefaultToolkit().beep(); +} \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/script.multibuy.txt b/src/main/resources/com/unicenta/pos/templates/script.multibuy.txt new file mode 100644 index 0000000..d8fbd7f --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/script.multibuy.txt @@ -0,0 +1,82 @@ +// +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright © 2009-2020 uniCenta +// +// This file is part of uniCenta oPOS. +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. +// ************************************************************************** + +import com.unicenta.pos.ticket.TicketLineInfo; + +index = sales.getSelectedIndex(); +if (index != -1) + +{ + line = ticket.getLine(index); + int count = Integer.parseInt(line.getProperty("COUNT", "0")); + Double newPrice1 = new Double(line.getProperty("PRICE", "0")); + String groupName = line.getProperty("GROUP", "0"); + if (count > 0) { + int productCount = 0; + int discountsAlreadyApplied = 0; + String productID = line.getProductID(); + + for (TicketLineInfo ticketLine: ticket.getLines()) { + boolean grouped = groupName.equals(ticketLine.getProperty("GROUP", "0")); + boolean multi = count > 0; + if (multi && grouped) { + productCount++; + } + if (ticketLine.getProductName().contains("Buy")) { + discountsAlreadyApplied = discountsAlreadyApplied + count; + } + } + + if (count == (productCount - discountsAlreadyApplied)) { + + newPrice2 = -(line.getPriceTax() * count) + newPrice1; + + + ticket.insertLine(ticket.getLinesCount(), + new TicketLineInfo( + "Buy " + count + " for £" + (line.getProperty("PRICE")),ox + line.getProductTaxCategoryID(), + "", + 1, + 0, + line.getTaxInfo())); + + + sales.setSelectedIndex(ticket.getLinesCount() - 1); + index = sales.getSelectedIndex(); + line = ticket.getLine(index); + line.setPriceTax(newPrice2); + sales.setSelectedIndex(ticket.getLinesCount() - 2); + + + + /* Remove BOGO property to start fresh */ + for (i = 0; i < ticket.getLinesCount(); i++) { + if (productID.equals(ticket.getLine(i).getProductID())) { + ticket.getLine(i).setProperty("COUNT", "0"); + } + } + } + + + sales.setSelectedIndex(ticket.getLinesCount() - 1); + } +} +//END MULTI BUY \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/template.Ticket.A4_Beta.vm b/src/main/resources/com/unicenta/pos/templates/template.Ticket.A4_Beta.vm new file mode 100644 index 0000000..f2e1a82 --- /dev/null +++ b/src/main/resources/com/unicenta/pos/templates/template.Ticket.A4_Beta.vm @@ -0,0 +1,208 @@ +#set ( $leftm= " " ) ## Uses spaces to set the LEFT margin - 10 is default for A4 +#set ( $len= 'length="130"' ) ## Sets the line LENGTH - 130 is default for A4 + +<ticket> + <image>Printer.Ticket.Logo</image> + <line size="1"><text align="center" $len>$leftm Printer.TicketPreview_A4</text></line> + <line></line> + + <line> + #if (${ticket.ticketType} == 0) + <text align="left" length="40">$leftm Receipt: ${ticket.printId()}</text> + #if (${ticket.printTicketHeaderLine1()} != "") + <text align="right" length="90">$leftm ${ticket.printTicketHeaderLine1()}</text> + #end + #end + #if (${ticket.ticketType} == 1) + <text align="left" length="40">$leftm Refund: ${ticket.printId()}</text> + #if (${ticket.printTicketHeaderLine1()} != "") + <text align="right" length="90">$leftm ${ticket.printTicketHeaderLine1()}</text> + #end + #end + </line> + <line> + <text align="left" length="20">$leftm Date: </text><text length="20">${ticket.printDate()}</text> + #if (${ticket.printTicketHeaderLine2()} != "") + <text align="right" length="90">$leftm ${ticket.printTicketHeaderLine2()}</text> + #end + </line> + <line> + <text align="left" length="20">$leftm Terminal: </text><text length="20">${ticket.getHost()}</text> + #if (${ticket.printTicketHeaderLine3()} != "") + <text align="right" length="90">$leftm ${ticket.printTicketHeaderLine3()}</text> + #end + </line> + <line> + <text align="left" length="20">$leftm Server: </text><text length="20">${ticket.printUser()}</text> + #if (${ticket.printTicketHeaderLine4()} != "") + <text align="right" length="90">${ticket.printTicketHeaderLine4()}</text> + #end + </line> + <line> + #if (${tickettext.place} != ${place}) + <text align="left" length="20">$leftm Table:</text><text length="20">${place}</text> + #if (${ticket.printTicketHeaderLine5()} != "") + <text align="right" length="90">${ticket.printTicketHeaderLine5()}</text> + #end + #else + #if (${ticket.printTicketHeaderLine5()} != "") + <text align="right" $len>${ticket.printTicketHeaderLine5()}</text> + #end + #end + </line> + <line> + #if (${ticket.printTicketHeaderLine6()} != "") + <text align="right" $len>${ticket.printTicketHeaderLine6()}</text> + #end + </line> + + #if ($ticket.getCustomer()) + <line><text align="left">$leftm Account #: </text><text>${ticket.getCustomer().printTaxCustomerID()}</text></line> + <line><text align="left">$leftm Customer: </text><text>${ticket.getCustomer().printName()}</text></line> + <line><text align="left">$leftm Address: </text><text>${ticket.getCustomer().printAddress()}</text></line> + <line><text align="left">$leftm Postal: </text><text>${ticket.getCustomer().printPostal()}</text></line> + <line><text align="left">$leftm Phone: </text><text>${ticket.getCustomer().printPhone1()}</text></line> + <line><text align="left">$leftm Current Debt: </text><text>${ticket.getCustomer().printCurDebt()}</text></line> + #end + + <line></line> + <line><text align="left" $len>$leftm ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</text></line> + <line> + <text align ="left" length="20" bold="true">$leftm REFERENCE</text> + <text align ="left" length="74" bold="true">$leftm ITEM</text> + <text align ="right" length="10" bold="true">PRICE</text> + <text align ="right" length="10" bold="true">QTY</text> + <text align ="right" bold="true">$leftm VALUE</text> + </line> + <line><text align="left" $len>$leftm ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</text></line> + + #foreach ($ticketline in $ticket.getLines()) + <line> + #if ($ticketline.isProductCom()) + <text align ="left" length="20">$leftm ★${ticketline.printReference()}</text> + <text align ="left" length="74">$leftm ${ticketline.printName()}</text> + #else + <text align ="left" length="20">$leftm ${ticketline.printReference()}</text> + <text align ="left" length="74">$leftm ${ticketline.printName()}</text> + #end + + <text align ="right" length="11">${ticketline.printPriceTax()}</text> + <text align ="right" length="10">${ticketline.printMultiply()}</text> + <text align ="right" length="15">${ticketline.printValue()}</text> + </line> + + #if ($ticketline.productAttSetInstId) + <line><text align ="left" length="74">$leftm $leftm ★★ ${ticketline.productAttSetInstDesc}</text></line> + #end + #end + + <line><text align="left" $len>$leftm ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</text></line> + <line><text>$leftm Items count: </text><text align ="left" length="15">${ticket.printArticlesCount()}</text></line> + <line></line> + <line> + <text align="right" length="115">$leftm Subtotal</text> + <text align ="right" length="15">${ticket.printSubTotal()}</text> + </line> + <line> + <text align ="right" length="115">$leftm Tax</text> + <text align ="right" length="15">${ticket.printTax()}</text> + </line> + <line><text align="right" $len>$leftm ───────────────</text></line> + <line></line> + <line size="1"> + <text align ="right" length="115" bold="true">$leftm Balance Due</text> + <text align ="right" length="15" bold="true">${ticket.printTotal()}</text> + </line> + <line><text align="right" $len>$leftm ═══════════════</text></line> + <line></line> + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "cash") + <line><text bold="true">$leftm Cash</text></line> + <line><text align="left" length="22">$leftm Tendered:</text><text align ="right" length="20">${paymentline.printPaid()}</text></line> + <line><text align="left" length="22">$leftm Change:</text><text align ="right" length="20">${paymentline.printChange()}</text></line> + #end + + #if ($paymentline.name == "cashrefund") + <line><text align="left" length="22" bold="true">$leftm Refund</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "cheque") + <line><text align="left" length="22" bold="true">$leftm Cheque</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "chequerefund") + <line><text align="left" length="22" bold="true">$leftm Cheque Refund</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "voucherin") + <line><text align="left" length="22" bold="true">$leftm Voucher</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "voucherout") + <line><text align="left" length="22" bold="true">$leftm Note Refund</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "slip") + <line><text align="left" length="22" bold="true">$leftm Slip</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "free") + <line><text align="left" length="22" bold="true">$leftm Free</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #if ($paymentline.name == "debt") + <line><text align="left" length="22" bold="true">$leftm On Account</text><text align ="right" length="20">${paymentline.printTotal()}</text></line> + #end + #end + + #if (${ticket.printTicketFooterLine1()} != "") + <line></line> + <line><text align="center" $len>$leftm ${ticket.printTicketFooterLine1()}</text></line> + <line><text align="left" $len>$leftm ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────</text></line> + #end + #if (${ticket.printTicketFooterLine2()} != "") + <line><text>$leftm ${ticket.printTicketFooterLine2()}</text></line> + #end + #if (${ticket.printTicketFooterLine3()} != "") + <line><text>$leftm ${ticket.printTicketFooterLine3()}</text></line> + #end + #if (${ticket.printTicketFooterLine4()} != "") + <line><text>$leftm ${ticket.printTicketFooterLine4()}</text></line> + #end + #if (${ticket.printTicketFooterLine5()} != "") + <line><text>$leftm ${ticket.printTicketFooterLine5()}</text></line> + #end + #if (${ticket.printTicketFooterLine6()} != "") + <line><text>$leftm ${ticket.printTicketFooterLine6()}</text></line> + #end + <line></line> + + #foreach ($paymentline in $ticket.payments) + #if ($paymentline.name == "ccard") + #if ($paymentline.chipAndPin) + <line size="1"><text align="center" $len bold="true">$leftm CARD SALE</text></line> + <line><text align = "center" $len bold="true">$leftm A card payment was received</text></line> + <line></line> + <line size="1"><text align="left">$leftm AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line> + #end + #if (!$paymentline.chipAndPin) + <line size="1"><text align="center" $len bold="true">$leftm CARD SALE</text></line> + <line><text align = "center" $len bold="true">$leftm A card payment was received</text></line> + <line></line> + <line size="1"><text align="left">$leftm AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line> + #end + #if ($ticket.hasTip()) + <line><text align ="left">$leftm Tip: </text><text align ="right" length="26">_______________</text></line> + <line></line> + <line size="1"><text align ="left" bold="false">$leftm Total </text><text align ="right" length="26" bold="false">_______________</text></line> + <line></line> + <line></line> + <line size="1"><text align ="left" bold="false">$leftm __________________________________________</text></line> + <line size="1"><text align ="center" bold="false">$leftm Signature</text></line> + #else + <line size="1"><text align ="left" bold="true">$leftm Total</text><text align ="right" length="26" bold="true">${paymentline.printTotal()}</text></line> + #end + #end + #if ($paymentline.name == "ccardrefund") + <line size="1"><text align="center" $len bold="true">$leftm CARD SALE</text></line> + <line></line> + <line><text align = "center" $len bold="true">$leftm A card payment was received</text></line> + <line></line> + <line size="1"><text align="left">$leftm AMOUNT</text><text align ="right" length="32">${paymentline.printTotal()}</text></line> + #end + #end +</ticket> \ No newline at end of file diff --git a/src/main/resources/com/unicenta/pos/templates/template.Ticket.A4_Beta.zip b/src/main/resources/com/unicenta/pos/templates/template.Ticket.A4_Beta.zip new file mode 100644 index 0000000..fd6a318 Binary files /dev/null and b/src/main/resources/com/unicenta/pos/templates/template.Ticket.A4_Beta.zip differ diff --git a/src/main/resources/com/unicenta/reports/customers.bs b/src/main/resources/com/unicenta/reports/customers.bs new file mode 100644 index 0000000..f42e6a6 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers.bs @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>. + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.Customers.Reports.Report"); +report.setReport("/com/unicenta/reports/customers"); +report.setResourceBundle("com/unicenta/reports/customers_messages"); + +report.setSentence("SELECT ID, TAXID, " + + "NAME, ADDRESS, ADDRESS2, CITY, POSTAL, " + + "NOTES, CARD, MAXDEBT, CURDATE, CURDEBT, " + + "FIRSTNAME, LASTNAME "+ + "FROM customers " + + "WHERE VISIBLE = " + app.getSession().DB.TRUE() + " AND ?(QBF_FILTER)"); + +report.addParameter("ID"); +report.addParameter("NAME"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsCustomer()); + +report.addField("ID", com.unicenta.data.loader.Datas.STRING); +report.addField("TAXID", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("ADDRESS", com.unicenta.data.loader.Datas.STRING); +report.addField("ADDRESS2", com.unicenta.data.loader.Datas.STRING); +report.addField("CITY", com.unicenta.data.loader.Datas.STRING); +report.addField("POSTAL", com.unicenta.data.loader.Datas.STRING); +report.addField("NOTES", com.unicenta.data.loader.Datas.STRING); +report.addField("CARD", com.unicenta.data.loader.Datas.STRING); +report.addField("MAXDEBT", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("CURDATE", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("CURDEBT", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("FIRSTNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("LASTNAME", com.unicenta.data.loader.Datas.STRING); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers.jrxml b/src/main/resources/com/unicenta/reports/customers.jrxml new file mode 100644 index 0000000..230a951 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers.jrxml @@ -0,0 +1,358 @@ +<?xml version="1.0" encoding="UTF-8"?> +<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="customers" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20" uuid="483cf3a5-e533-4773-8e36-e0b65c997c7e"> + <property name="ireport.scriptlethandling" value="0"/> + <property name="ireport.encoding" value="UTF-8"/> + <property name="ireport.zoom" value="1.5"/> + <property name="ireport.x" value="0"/> + <property name="ireport.y" value="0"/> + <import value="net.sf.jasperreports.engine.*"/> + <import value="java.util.*"/> + <import value="net.sf.jasperreports.engine.data.*"/> + <queryString> + <![CDATA[SELECT ID, NAME, ADDRESS, NOTES, CARD, MAXDEBT, CURDATE, CURDEBT +FROM CUSTOMERS +WHERE VISIBLE = TRUE AND CARD IS NOT NULL AND CARD <> '']]> + </queryString> + <field name="ID" class="java.lang.String"/> + <field name="NAME" class="java.lang.String"/> + <field name="TAXID" class="java.lang.String"/> + <field name="ADDRESS" class="java.lang.String"/> + <field name="ADDRESS2" class="java.lang.String"/> + <field name="CITY" class="java.lang.String"/> + <field name="POSTAL" class="java.lang.String"/> + <field name="MAXDEBT" class="java.lang.Double"/> + <field name="CURDEBT" class="java.lang.Double"/> + <field name="CURDATE" class="java.util.Date"/> + <field name="NOTES" class="java.lang.String"/> + <field name="CARD" class="java.lang.String"/> + <background> + <band/> + </background> + <title> + <band/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/customers_b.bs b/src/main/resources/com/unicenta/reports/customers_b.bs new file mode 100644 index 0000000..b795992 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_b.bs @@ -0,0 +1,45 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.CustomersBReport"); +report.setReport("/com/unicenta/reports/customers"); +report.setResourceBundle("com/unicenta/reports/customers_messages"); + +// report.setSentence("SELECT ID, TAXID, NAME, ADDRESS, NOTES, CARD, MAXDEBT, CURDATE, CURDEBT " + +// "FROM customers " + +// "WHERE VISIBLE = " + app.getSession().DB.TRUE() + " AND CURDEBT IS NOT NULL AND CURDEBT > 0"); + +// JG:uniCenta 9 Jan 11 to allow <> 0 +report.setSentence("SELECT ID, TAXID, NAME, ADDRESS, NOTES, CARD, MAXDEBT, CURDATE, CURDEBT " + + "FROM customers " + + "WHERE VISIBLE = " + app.getSession().DB.TRUE() + " AND CURDEBT IS NOT NULL AND CURDEBT <> 0"); + +report.addField("ID", com.unicenta.data.loader.Datas.STRING); +report.addField("TAXID", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("ADDRESS", com.unicenta.data.loader.Datas.STRING); +report.addField("NOTES", com.unicenta.data.loader.Datas.STRING); +report.addField("CARD", com.unicenta.data.loader.Datas.STRING); +report.addField("MAXDEBT", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("CURDATE", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("CURDEBT", com.unicenta.data.loader.Datas.DOUBLE); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_cards.bs b/src/main/resources/com/unicenta/reports/customers_cards.bs new file mode 100644 index 0000000..2f43316 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_cards.bs @@ -0,0 +1,49 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.Customers.Reports.Cards"); +report.setReport("/com/unicenta/reports/customers_cards"); +report.setResourceBundle("com/unicenta/reports/customers_messages"); + +report.setSentence("SELECT ID, TAXID, NAME, CARD, " + + "FIRSTNAME, LASTNAME, " + + "ADDRESS, ADDRESS2, CITY, POSTAL, " + + "IMAGE " + + "FROM customers " + + "WHERE VISIBLE = " + app.getSession().DB.TRUE() + " AND ?(QBF_FILTER)"); + +report.addParameter("ID"); +report.addParameter("NAME"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsCustomer()); + +report.addField("ID", com.unicenta.data.loader.Datas.STRING); +report.addField("TAXID", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("CARD", com.unicenta.data.loader.Datas.STRING); +report.addField("FIRSTNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("LASTNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("ADDRESS", com.unicenta.data.loader.Datas.STRING); +report.addField("ADDRESS2", com.unicenta.data.loader.Datas.STRING); +report.addField("CITY", com.unicenta.data.loader.Datas.STRING); +report.addField("POSTAL", com.unicenta.data.loader.Datas.STRING); +report.addField("IMAGE", com.unicenta.data.loader.Datas.IMAGE); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_cards.jrxml b/src/main/resources/com/unicenta/reports/customers_cards.jrxml new file mode 100644 index 0000000..b47e52f --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_cards.jrxml @@ -0,0 +1,181 @@ + + + + + + + + + + + + '']]> + + + + + + + + + + + + + + + + + <band/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/customers_debtors.bs b/src/main/resources/com/unicenta/reports/customers_debtors.bs new file mode 100644 index 0000000..64bedc9 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_debtors.bs @@ -0,0 +1,51 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.Customers.Reports.Debtors"); +report.setReport("/com/unicenta/reports/customers_debtors"); +report.setResourceBundle("com/unicenta/reports/customers_messages"); + +report.setSentence("SELECT ID, TAXID, NAME, ADDRESS, CURDEBT, CURDATE " + + "FROM customers " + + "WHERE VISIBLE = " + app.getSession().DB.TRUE() + " AND ?(QBF_FILTER)" + + "ORDER BY NAME "); + +report.addParameter("ID"); +report.addParameter("NAME"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsCustomer()); + +report.addParameter("CURDATE"); +report.addParameter("CURDATE"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); +report.addQBFFilter(paramdates); + +report.addField("ID", com.unicenta.data.loader.Datas.STRING); +report.addField("TAXID", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("ADDRESS", com.unicenta.data.loader.Datas.STRING); +report.addField("CURDEBT", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("CURDATE", com.unicenta.data.loader.Datas.TIMESTAMP); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_debtors.jrxml b/src/main/resources/com/unicenta/reports/customers_debtors.jrxml new file mode 100644 index 0000000..afeec0d --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_debtors.jrxml @@ -0,0 +1,294 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + <band/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/customers_diary.bs b/src/main/resources/com/unicenta/reports/customers_diary.bs new file mode 100644 index 0000000..b488844 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_diary.bs @@ -0,0 +1,61 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.Customers.Reports.Diary"); +report.setReport("/com/unicenta/reports/customers_diary"); +report.setResourceBundle("com/unicenta/reports/customers_messages"); + +report.setSentence("SELECT " + + "receipts.DATENEW, " + + "tickets.TICKETID, " + + "payments.PAYMENT, " + + "payments.TOTAL, " + + "customers.TAXID, " + + "customers.NAME " + + "FROM receipts, tickets, customers, payments " + + "WHERE receipts.ID = tickets.ID AND receipts.ID = payments.RECEIPT " + + "AND tickets.CUSTOMER = customers.ID " + +// JG AUG 2014 +// "AND (payments.PAYMENT = 'debt' OR payments.PAYMENT = 'debtpaid') " + + "AND ?(QBF_FILTER) " + + "ORDER BY customers.NAME, receipts.DATENEW DESC"); + +report.addParameter("receipts.DATENEW"); +report.addParameter("receipts.DATENEW"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); +report.addQBFFilter(paramdates); + +report.addParameter("customers.ID"); +report.addParameter("customers.NAME"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsCustomer()); + +report.addField("DATENEW", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("TICKETID", com.unicenta.data.loader.Datas.STRING); +report.addField("PAYMENT", com.unicenta.data.loader.Datas.STRING); +report.addField("TOTAL", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TAXID", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_diary.jrxml b/src/main/resources/com/unicenta/reports/customers_diary.jrxml new file mode 100644 index 0000000..a424be4 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_diary.jrxml @@ -0,0 +1,360 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/customers_export.bs b/src/main/resources/com/unicenta/reports/customers_export.bs new file mode 100644 index 0000000..9db42f0 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_export.bs @@ -0,0 +1,47 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.Customers.Reports.Export"); +report.setReport("/com/unicenta/reports/customers_export"); +report.setResourceBundle("com/unicenta/reports/customers_messages"); + +report.setSentence("SELECT ID,TAXID, NAME,FIRSTNAME,LASTNAME,ADDRESS,ADDRESS2,CITY,POSTAL,PHONE,EMAIL " + + "FROM customers " + + "WHERE VISIBLE = " + app.getSession().DB.TRUE() + " AND ?(QBF_FILTER)" + + "ORDER BY NAME "); + +report.addParameter("ID"); +report.addParameter("NAME"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsCustomer()); + +report.addField("ID", com.unicenta.data.loader.Datas.STRING); +report.addField("TAXID", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("FIRSTNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("LASTNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("ADDRESS", com.unicenta.data.loader.Datas.STRING); +report.addField("ADDRESS2", com.unicenta.data.loader.Datas.STRING); +report.addField("CITY", com.unicenta.data.loader.Datas.STRING); +report.addField("POSTAL", com.unicenta.data.loader.Datas.STRING); +report.addField("PHONE", com.unicenta.data.loader.Datas.STRING); +report.addField("EMAIL", com.unicenta.data.loader.Datas.STRING); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_export.jrxml b/src/main/resources/com/unicenta/reports/customers_export.jrxml new file mode 100644 index 0000000..037b836 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_export.jrxml @@ -0,0 +1,270 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/customers_list.bs b/src/main/resources/com/unicenta/reports/customers_list.bs new file mode 100644 index 0000000..09acf46 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_list.bs @@ -0,0 +1,46 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.Customers.Reports.List"); +report.setReport("/com/unicenta/reports/customers_list"); +report.setResourceBundle("com/unicenta/reports/customers_messages"); + +report.setSentence("SELECT TAXID, NAME, FIRSTNAME, LASTNAME,ADDRESS,ADDRESS2,CITY,POSTAL,PHONE,EMAIL " + + "FROM customers " + + "WHERE VISIBLE = " + app.getSession().DB.TRUE() + " AND ?(QBF_FILTER)" + + "ORDER BY NAME "); + +report.addParameter("TAXID"); +report.addParameter("NAME"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsCustomer()); + +report.addField("TAXID", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("FIRSTNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("LASTNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("ADDRESS", com.unicenta.data.loader.Datas.STRING); +report.addField("ADDRESS2", com.unicenta.data.loader.Datas.STRING); +report.addField("CITY", com.unicenta.data.loader.Datas.STRING); +report.addField("POSTAL", com.unicenta.data.loader.Datas.STRING); +report.addField("PHONE", com.unicenta.data.loader.Datas.STRING); +report.addField("EMAIL", com.unicenta.data.loader.Datas.STRING); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_list.jrxml b/src/main/resources/com/unicenta/reports/customers_list.jrxml new file mode 100644 index 0000000..65d4086 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_list.jrxml @@ -0,0 +1,315 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/customers_messages.properties b/src/main/resources/com/unicenta/reports/customers_messages.properties new file mode 100644 index 0000000..701e302 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_messages.properties @@ -0,0 +1,44 @@ +label.account=Account : +label.accountname = Acc' Name : +label.address=Address +label.address2=Address2 +label.city=City +label.contact=Contact +label.curdate=Date +label.curdebt=Owing +label.customer=Customer +label.date=Date +label.email=eMail +label.firstname=First Name +label.fulladdress = Address : +label.fullname = Holder : +label.lastname=Last Name +label.maxdebt=Max Debt +label.name=Name +label.notes=Notes +label.payment=Payment +label.period=Period: +label.postal=PCode +label.printed=Printed +label.product=Product +label.sales=Sales +label.taxid=Account +label.telephone=Telephone +label.ticket=Ticket +label.title.Customers=Customers +label.title.Debtors=Customer Debtors +label.title.Diary=Customers Diary +label.title.List=Customer List +label.title.Sales=Customer Sales +label.title.Vouchers=Customer Vouchers +label.total=Total +label.totalG=Grand Total +label.totalP=Amount +label.ttype=Type +label.units=Qty +label.vamount=Value +label.vnum=Number +label.vouchers=Vouchers +label.vstatus=Status +reason.A=Valid +reason.D=Redeemed diff --git a/src/main/resources/com/unicenta/reports/customers_messages_al_SQ.properties b/src/main/resources/com/unicenta/reports/customers_messages_al_SQ.properties new file mode 100644 index 0000000..39edf53 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_messages_al_SQ.properties @@ -0,0 +1,9 @@ +label.address=Adresa +label.curdebt=Borxhi aktual +label.curdate=Data e borxhit +label.maxdebt=Borxhi maximal i lejuar +label.name=Emri +label.notes=Shenim +label.printed=Printuar +label.taxid=Numeri Fiskal +label.title=Klienti \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_messages_ar.properties b/src/main/resources/com/unicenta/reports/customers_messages_ar.properties new file mode 100644 index 0000000..8a1d926 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_messages_ar.properties @@ -0,0 +1,7 @@ +label.curdate=\u062a\u0627\u0631\u064a\u062e \u0627\u0644\u0627\u064a\u062f\u0627\u0639 +label.curdebt=\u0627\u064a\u062f\u0627\u0639 \u0627\u0644\u062d\u0627\u0644\u064a +label.maxdebt=\u0627\u0642\u0635\u0649 \u0627\u064a\u062f\u0627\u0639 +label.notes=\u0645\u0644\u0627\u062d\u0638\u0627\u062a +label.printed=\u0645\u0637\u0628\u0648\u0639 +label.taxid=\u0631\u0642\u0645 \u0627\u0644\u062d\u0633\u0627\u0628 +label.title=\u0627\u0644\u0639\u0645\u0644\u0627\u0621 diff --git a/src/main/resources/com/unicenta/reports/customers_messages_de.properties b/src/main/resources/com/unicenta/reports/customers_messages_de.properties new file mode 100644 index 0000000..7482471 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_messages_de.properties @@ -0,0 +1,18 @@ +label.address=Adresse +label.address2=Adresse2 +label.city=Stadt +label.contact=Kontakt +label.curdate=Forderung Datum +label.curdebt=Forderung jetzt +label.email=e-Mail +label.firstname=Vorname +label.lastname=Nachname +label.maxdebt=Forderung max +label.name=Name +label.notes=Gutscheine +label.phone=Telefon +label.postal=PLZ +label.printed=Gedruckt am: +label.taxid=Steuer ID +label.telephone=Telefon +label.title=Kunden \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_messages_el.properties b/src/main/resources/com/unicenta/reports/customers_messages_el.properties new file mode 100644 index 0000000..8c058df --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_messages_el.properties @@ -0,0 +1,7 @@ +label.curdate=\u0397\u03bc\u03b5\u03c1\u03bf\u03bc\u03b7\u03bd\u03af\u03b1 \u03a7\u03c1\u03ad\u03bf\u03c5\u03c2 +label.curdebt=\u03a4\u03c1\u03ad\u03c7\u03bf\u03bd \u03a7\u03c1\u03ad\u03bf\u03c2 +label.maxdebt=\u039c\u03ad\u03b3\u03b9\u03c3\u03c4\u03bf \u03a7\u03c1\u03ad\u03bf\u03c2 +label.notes=\u03a3\u03b7\u03bc\u03b5\u03b9\u03ce\u03c3\u03b5\u03b9\u03c2 +label.printed=Printed +label.taxid=ID \u039b\u03bf\u03b3\u03b1\u03c1\u03b9\u03b1\u03c3\u03bc\u03bf\u03cd +label.title=\u03a0\u03b5\u03bb\u03ac\u03c4\u03b5\u03c2 \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_messages_en_US.properties b/src/main/resources/com/unicenta/reports/customers_messages_en_US.properties new file mode 100644 index 0000000..60f49a2 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_messages_en_US.properties @@ -0,0 +1,37 @@ +label.account=Account : +label.accountname = Acc' Name : +label.address=Address +label.address2=Address2 +label.city=City +label.contact=Contact +label.curdate=Date +label.curdebt=Owing +label.customer=Customer +label.date=Date +label.email=eMail +label.firstname=First Name +label.fulladdress = Address : +label.fullname = Holder : +label.lastname=Last Name +label.maxdebt=Max Debt +label.name=Name +label.notes=Notes +label.payment=Payment +label.period=Period: +label.postal=PCode +label.printed=Printed +label.product=Product +label.sales=Sales +label.taxid=Account +label.telephone=Telephone +label.ticket=Ticket +label.title.Customers=Customers +label.title.Debtors=Customer Debtors +label.title.Diary=Customers Diary +label.title.List=Customer List +label.title.Sales=Customer Sales +label.total=Total +label.totalG=Grand Total +label.totalP=Amount +label.ttype=Type +label.units=Qty diff --git a/src/main/resources/com/unicenta/reports/customers_messages_es.properties b/src/main/resources/com/unicenta/reports/customers_messages_es.properties new file mode 100644 index 0000000..b3b6246 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_messages_es.properties @@ -0,0 +1,40 @@ +label.account=Cuente : +label.accountname=Nombre : +label.address=Domicilio +label.address2=Domicilio 2 +label.barcode=C\u00f3digo de barras +label.city=Ciudad +label.contact=Contacto +label.curdate=Fecha de d\u00e9bito +label.curdebt=A cuenta +label.customer=Cliente +label.date=Fecha +label.email=eMail +label.firstname=Nombre de pila +label.fulladdress=Domicilio : +label.fullname=Poseedor : +label.lastname=Apellido : +label.maxdebt=M\u00e1ximo a cuenta +label.name=Nombre +label.notes=Notas +label.payment=Pago +label.period=Per\u00edodo +label.phone=Tel\u00e9fono +label.postal=C\u00f3digo postal +label.printed=Imprimir +label.product=Producto +label.sales=Ventas +label.taxid=CIF / NIF +label.telephone=Tel\u00e9fono +label.ticket=Recibo +label.title.Customers=Clientes +label.title.Debtors=Deudores del cliente +label.title.Diary=Diario del cliente +label.title.List=Lista de clientes +label.title.Sales=Ventas al cliente +label.title=Clientes +label.total=Total +label.totalG=Gran total +label.totalP=Cantidad +label.ttype=Tipo +label.units=Qty \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_messages_es_AR.properties b/src/main/resources/com/unicenta/reports/customers_messages_es_AR.properties new file mode 100644 index 0000000..98bddf6 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_messages_es_AR.properties @@ -0,0 +1,6 @@ +label.curdate=Fecha de d\u00E9bito +label.curdebt=A cuenta +label.maxdebt=M\u00E1ximo a cuenta +label.notes=Notas +label.taxid=CUIT / CUIL +label.title=Clientes diff --git a/src/main/resources/com/unicenta/reports/customers_messages_es_MX.properties b/src/main/resources/com/unicenta/reports/customers_messages_es_MX.properties new file mode 100644 index 0000000..0e00f58 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_messages_es_MX.properties @@ -0,0 +1,6 @@ +label.curdate=Fecha del crdito +label.curdebt=Crdito actual +label.maxdebt=Crdito mximo +label.notes=Notas +label.taxid=ID de impuesto +label.title=Clientes diff --git a/src/main/resources/com/unicenta/reports/customers_messages_et.properties b/src/main/resources/com/unicenta/reports/customers_messages_et.properties new file mode 100644 index 0000000..fdd40ea --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_messages_et.properties @@ -0,0 +1,7 @@ +label.curdate=V\u00f5la kuup\u00e4ev +label.curdebt=Hetke v\u00f5lg +label.maxdebt=Krediidipiir +label.notes=M\u00e4rkmed +label.printed=Tr\u00fckitud +label.taxid=Konto ID +label.title=Kliendid \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_messages_fr.properties b/src/main/resources/com/unicenta/reports/customers_messages_fr.properties new file mode 100644 index 0000000..ef9c3e9 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_messages_fr.properties @@ -0,0 +1,40 @@ +label.account=Compte : +label.accountname = Nom Compte : +label.address=Adresse +label.address2=Adresse2 +label.barcode=Code-barres +label.city=Ville +label.contact=Contact +label.curdate=Date du cr\u00e9dit +label.curdebt=Cr\u00e9dit actuel +label.customer=Client +label.date=Date +label.email=eMail +label.firstname=Pr\u00e9nom +label.fulladdress = Addresse : +label.fullname = Membre : +label.lastname=Nom de famille +label.maxdebt=Cr\u00e9dit maximum +label.name=Nom +label.notes=Notes +label.payment=Paiement +label.period=P\u00e9riod: +label.phone=T\u00e9l\u00e9phone +label.postal=Code Postal +label.printed=Imprim\u00e9 +label.product=Produit +label.sales=Ventes +label.taxid=N\u00b0 client +label.telephone=T\u00e9l\u00e9phone +label.ticket=Ticket +label.title.Customers=Clients +label.title.Debtors=Client d\u00e9biteurs +label.title.Diary=Journal clients +label.title.List=Liste Clients +label.title.Sales=Ventes par Client +label.title=Clientes +label.total=Total +label.totalG=Grande Total +label.totalP=Valeur +label.ttype=Type +label.units=Qt\u00e9 \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_messages_hr.properties b/src/main/resources/com/unicenta/reports/customers_messages_hr.properties new file mode 100644 index 0000000..29819c0 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_messages_hr.properties @@ -0,0 +1,7 @@ +label.curdate=Datum duga +label.curdebt=Trenutni dug +label.maxdebt=Max dug +label.notes=Bilje\u009ake +label.printed=Ispisano +label.taxid=Klijent +label.title=Kupac diff --git a/src/main/resources/com/unicenta/reports/customers_messages_it.properties b/src/main/resources/com/unicenta/reports/customers_messages_it.properties new file mode 100644 index 0000000..5de79b9 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_messages_it.properties @@ -0,0 +1,18 @@ +label.address=Indirizzo +label.address2=Indirizzo2 +label.city=Citta +label.contact=Contatto +label.curdate=Data Debito +label.curdebt=Debito Corrente +label.email=eMail +label.firstname=Nome +label.lastname=Cognome +label.maxdebt=Debito Massimo +label.name=Nome +label.notes=Note +label.phone=Telefono +label.postal=C.A.P. +label.printed=Stampato +label.taxid=ID Account +label.telephone=Telefono +label.title=Clienti \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_messages_nl.properties b/src/main/resources/com/unicenta/reports/customers_messages_nl.properties new file mode 100644 index 0000000..49b995e --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_messages_nl.properties @@ -0,0 +1,8 @@ +label.curdate=Datum krediet +label.curdebt=Huidig krediet +label.maxdebt=Maximum krediet +label.name=Naam +label.notes=Biljetten +label.printed=Afgedrukt +label.taxid=BTW ID +label.title=Klanten diff --git a/src/main/resources/com/unicenta/reports/customers_sales.bs b/src/main/resources/com/unicenta/reports/customers_sales.bs new file mode 100644 index 0000000..175af67 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_sales.bs @@ -0,0 +1,61 @@ +// uniCenta oPOS - touch friendly EPoS +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.Customers.Reports.Sales"); +report.setReport("/com/unicenta/reports/customers_sales"); +report.setResourceBundle("com/unicenta/reports/customers_messages"); + +report.setSentence("SELECT " + + "customers.NAME AS CNAME, " + + "receipts.DATENEW, " + + "tickets.TICKETID, " + + "products.NAME AS PNAME, " + + "tickets.TICKETTYPE, " + + "SUM(ticketlines.UNITS) AS UNITS, " + + "SUM(ticketlines.UNITS * ticketlines.PRICE) AS TOTAL " + + "FROM receipts, customers, tickets, ticketlines LEFT OUTER JOIN products ON ticketlines.PRODUCT = products.ID " + + "WHERE customers.ID = tickets.CUSTOMER AND ticketlines.PRODUCT = products.ID AND receipts.ID = tickets.ID AND tickets.ID = ticketlines.TICKET AND ?(QBF_FILTER) " + + "GROUP BY customers.NAME, receipts.DATENEW, tickets.TICKETID, products.NAME, tickets.TICKETTYPE " + + "ORDER BY customers.NAME, products.NAME, receipts.DATENEW"); + +report.addParameter("receipts.DATENEW"); +report.addParameter("receipts.DATENEW"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); + +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); +report.addQBFFilter(paramdates); + +report.addParameter("customers.ID"); +report.addParameter("customers.NAME"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsCustomer()); + +report.addField("CNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("DATENEW", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("TICKETID", com.unicenta.data.loader.Datas.STRING); +report.addField("PNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("TICKETTYPE", com.unicenta.data.loader.Datas.INT); +report.addField("UNITS", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TOTAL", com.unicenta.data.loader.Datas.DOUBLE); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_sales.jrxml b/src/main/resources/com/unicenta/reports/customers_sales.jrxml new file mode 100644 index 0000000..7872a46 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_sales.jrxml @@ -0,0 +1,471 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="52" splitType="Stretch"> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-5" mode="Transparent" x="50" y="33" width="110" height="15" uuid="5f5ae0a5-05ea-4f83-9cea-56f8eb5405d9"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.TIMESTAMP.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[1])]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-6" mode="Transparent" x="170" y="33" width="110" height="15" uuid="22773f2d-3be7-4fb0-a178-ccb224688745"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.TIMESTAMP.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[3])]]></textFieldExpression> + </textField> + <staticText> + <reportElement key="staticText-1" mode="Transparent" x="160" y="33" width="10" height="15" uuid="cb10ac3c-8836-43cb-8e5f-84a4f031dd27"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[- +]]></text> + </staticText> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-1" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#000000" uuid="36787551-14c1-4de0-a4bb-1d69f617e95b"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title.Sales}]]></textFieldExpression> + </textField> + <rectangle radius="5"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="d5616e40-441d-4c33-bf12-6bb75dd29c19"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-2" mode="Opaque" x="435" y="1" width="100" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="f1ebdeba-707c-4452-aac2-453ffaa466df"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField-3" x="435" y="15" width="100" height="15" uuid="491b1df9-4e20-46d9-aa2c-97b445839e31"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-4" mode="Opaque" x="0" y="33" width="50" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="86677afa-9925-4fbb-8dd8-29a2823cea73"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.period}]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/customers_vouchers.bs b/src/main/resources/com/unicenta/reports/customers_vouchers.bs new file mode 100644 index 0000000..6a4e9f4 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_vouchers.bs @@ -0,0 +1,58 @@ +// uniCenta oPOS - touch friendly EPoS +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.Customers.Reports.Vouchers"); +report.setReport("/com/unicenta/reports/customers_vouchers"); +report.setResourceBundle("com/unicenta/reports/customers_messages"); + +report.setSentence("SELECT customers.name AS CNAME, " + + "vouchers.voucher_number AS VNUM, " + + "vouchers.amount AS VAMOUNT, " + + "vouchers.status AS VSTATUS, " + + "payments.total AS TOTAL, " + + "tickets.ticketid AS TICKETID, " + + "receipts.datenew AS TDATE " + +"FROM (((tickets tickets " + + "INNER JOIN receipts receipts " + + "ON (tickets.id = receipts.id)) " + + "INNER JOIN payments payments " + + "ON (payments.receipt = receipts.id) " + + "AND (tickets.id = payments.receipt)) " + + "INNER JOIN vouchers vouchers " + + "ON (payments.voucher = vouchers.voucher_number)) " + + "INNER JOIN customers customers " + + "ON (tickets.customer = customers.id) " + +"WHERE ?(QBF_FILTER) " + +"ORDER BY customers.name "); + +report.addParameter("ID"); +report.addParameter("NAME"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsCustomer()); + +report.addField("CNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("VNUM", com.unicenta.data.loader.Datas.STRING); +report.addField("VAMOUNT", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("VSTATUS", com.unicenta.data.loader.Datas.STRING); +report.addField("TOTAL", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TICKETID", com.unicenta.data.loader.Datas.STRING); +report.addField("TDATE", com.unicenta.data.loader.Datas.TIMESTAMP); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/customers_vouchers.jrxml b/src/main/resources/com/unicenta/reports/customers_vouchers.jrxml new file mode 100644 index 0000000..bb9bd09 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/customers_vouchers.jrxml @@ -0,0 +1,282 @@ + + + + + + + + + + + + + + + + + + + + + + + + + <band height="52" splitType="Stretch"> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-1" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#000000" uuid="36787551-14c1-4de0-a4bb-1d69f617e95b"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title.Vouchers}]]></textFieldExpression> + </textField> + <rectangle radius="5"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="d5616e40-441d-4c33-bf12-6bb75dd29c19"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-2" mode="Opaque" x="435" y="1" width="100" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="f1ebdeba-707c-4452-aac2-453ffaa466df"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField-3" x="435" y="15" width="100" height="15" uuid="491b1df9-4e20-46d9-aa2c-97b445839e31"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-8" mode="Opaque" x="0" y="35" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="f5375ab7-2803-4c79-8e90-4e131ede4a81"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.customer}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-8" mode="Opaque" x="135" y="34" width="100" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="501c9103-6848-46b8-8439-d04294ee692e"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.vnum}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-9" mode="Opaque" x="235" y="34" width="89" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="eca6fd58-3893-496b-89e7-c924d310b067"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.vamount}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="324" y="34" width="52" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="59ae8cbf-43c1-4691-894e-ce92fb2424f6"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.vstatus}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="383" y="34" width="52" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="55b7a888-c5a0-4eda-97cd-81673a2a4db9"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.ticket}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="435" y="34" width="52" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="bc35bc02-0baa-4d4c-880c-310fc4907c95"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.curdate}]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/epm_dailypresence.bs b/src/main/resources/com/unicenta/reports/epm_dailypresence.bs new file mode 100644 index 0000000..8db912a --- /dev/null +++ b/src/main/resources/com/unicenta/reports/epm_dailypresence.bs @@ -0,0 +1,53 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// Copyright (C) 2011 Gjergj Sheldija +// http://www.acme-tech.net// +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.EPM.DailyPresenceReport"); +report.setReport("/com/unicenta/reports/epm_dailypresence"); +report.setResourceBundle("com/unicenta/reports/epm_messages"); + +report.setSentence("SELECT " + + "people.NAME, " + + "shifts.STARTSHIFT, " + + "shifts.ENDSHIFT, " + + "CONCAT('',TIMEDIFF(shifts.ENDSHIFT, shifts.STARTSHIFT)) AS TOTAL " + + "FROM people LEFT JOIN shifts ON shifts.PPLID = people.ID " + + "WHERE ?(QBF_FILTER) " + + "ORDER BY people.NAME "); + +report.addParameter("shifts.STARTSHIFT"); +report.addParameter("shifts.ENDSHIFT"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); + +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); + +report.addQBFFilter(paramdates); + +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("STARTSHIFT", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("ENDSHIFT", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("TOTAL", com.unicenta.data.loader.Datas.STRING); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/epm_dailypresence.jrxml b/src/main/resources/com/unicenta/reports/epm_dailypresence.jrxml new file mode 100644 index 0000000..873726f --- /dev/null +++ b/src/main/resources/com/unicenta/reports/epm_dailypresence.jrxml @@ -0,0 +1,325 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="74"> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-21" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="58913b3a-3a74-4ff0-bb6c-152118f55e3a"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-2" mode="Opaque" x="400" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="491b731e-32bf-4577-b242-f6a3cd696569"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField-3" x="400" y="15" width="135" height="15" uuid="ebc727d5-39f8-4d0e-9fa0-b1c66e9e86e4"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="0" y="33" width="50" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="93d41967-fa99-4dc3-9bb9-42937bf1ac4a"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.period}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-2" mode="Transparent" x="50" y="33" width="110" height="15" uuid="08faefff-0b38-49d8-aa07-f17b78c0428f"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.DATE.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[1])]]></textFieldExpression> + </textField> + <staticText> + <reportElement key="staticText-1" mode="Transparent" x="160" y="33" width="10" height="15" uuid="d61227ca-520e-4248-8eac-5e68d52f9f2b"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[-]]></text> + </staticText> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-3" mode="Transparent" x="170" y="33" width="110" height="15" uuid="ec266a5c-b5fa-4311-aa52-511d5b7b4144"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.DATE.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[3])]]></textFieldExpression> + </textField> + <rectangle radius="5"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="722cd55b-fc92-47f9-8e80-0b29773690dc"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-23" mode="Opaque" x="0" y="55" width="115" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="4d0d585f-031a-4e69-8ee8-bf1e3be63ec2"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.name}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-23" mode="Opaque" x="138" y="55" width="122" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="ae7b535b-8c14-4f2f-83e8-444045d379a0"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.start}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-23" mode="Opaque" x="280" y="55" width="130" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="304fb745-4d53-4fc5-962e-ca7884405ad1"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.end}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-23" mode="Opaque" x="435" y="55" width="100" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="7c97deba-f19c-4a87-befd-9135b79ff3eb"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.total}]]></textFieldExpression> + </textField> + <line> + <reportElement key="line-4" mode="Opaque" x="0" y="70" width="535" height="1" forecolor="#000000" backcolor="#FFFFFF" uuid="5dd2c504-c533-4184-8dac-e6074c364892"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </line> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/epm_dailyschedule.bs b/src/main/resources/com/unicenta/reports/epm_dailyschedule.bs new file mode 100644 index 0000000..31ce19e --- /dev/null +++ b/src/main/resources/com/unicenta/reports/epm_dailyschedule.bs @@ -0,0 +1,53 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// Copyright (C) 2011 Gjergj Sheldija +// http://www.acme-tech.net// +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.EPM.DailyScheduleReport"); +report.setReport("/com/unicenta/reports/epm_dailyschedule"); +report.setResourceBundle("com/unicenta/reports/epm_messages"); + +report.setSentence("SELECT " + + "people.NAME, " + + "leaves.STARTDATE, " + + "leaves.ENDDATE, " + + "CONCAT('',DATEDIFF(leaves.ENDDATE, leaves.STARTDATE)) AS TOTAL " + + "FROM people LEFT JOIN leaves ON leaves.PPLID = people.ID " + + "WHERE ?(QBF_FILTER) " + + "ORDER BY leaves.STARTDATE DESC "); + +report.addParameter("leaves.STARTDATE"); +report.addParameter("leaves.ENDDATE"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); + +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); + +report.addQBFFilter(paramdates); + +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("STARTDATE", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("ENDDATE", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("TOTAL", com.unicenta.data.loader.Datas.STRING); + +report; diff --git a/src/main/resources/com/unicenta/reports/epm_dailyschedule.jrxml b/src/main/resources/com/unicenta/reports/epm_dailyschedule.jrxml new file mode 100644 index 0000000..c320591 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/epm_dailyschedule.jrxml @@ -0,0 +1,325 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="74"> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-21" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="e5fe9f87-96f1-49fe-a57b-0df532b21172"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-23" mode="Opaque" x="0" y="55" width="115" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="81c434ac-428c-46b6-9087-88017033572d"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.name}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-23" mode="Opaque" x="138" y="55" width="122" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="b8260953-bd0a-4e0e-9b0e-c2eff170eec5"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.start}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-23" mode="Opaque" x="280" y="55" width="130" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="22455dcb-bb99-4806-bc03-67c9e56c7524"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.end}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-23" mode="Opaque" x="435" y="55" width="100" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="c15c7c6b-d2cd-4bd2-8f80-a1220123374f"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.total}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-2" mode="Opaque" x="400" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="fef16531-7fbf-40e9-a93a-b1be737e360f"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField-3" x="400" y="15" width="135" height="15" uuid="daa7df66-2c71-465b-9254-57d272322778"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="0" y="33" width="50" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="a3d2d7f3-d14b-4429-8f95-cf63c6a485ff"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.period}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-2" mode="Transparent" x="50" y="33" width="110" height="15" uuid="d042401e-df76-45eb-abee-fd71d6f39dcb"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.DATE.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[1])]]></textFieldExpression> + </textField> + <staticText> + <reportElement key="staticText-1" mode="Transparent" x="160" y="33" width="10" height="15" uuid="8ea26690-46db-4d3b-9ded-b6f163ee5a41"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[-]]></text> + </staticText> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-3" mode="Transparent" x="170" y="33" width="110" height="15" uuid="24091254-ee66-446c-a887-376129d95058"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.DATE.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[3])]]></textFieldExpression> + </textField> + <rectangle radius="5"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="02335135-98a2-410c-b26a-82b3377d2308"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + <line> + <reportElement key="line-4" mode="Opaque" x="0" y="70" width="535" height="1" forecolor="#000000" backcolor="#FFFFFF" uuid="e05c23ce-acdf-430d-91be-0f13cff3ebd1"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </line> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/epm_messages.properties b/src/main/resources/com/unicenta/reports/epm_messages.properties new file mode 100644 index 0000000..6c2154f --- /dev/null +++ b/src/main/resources/com/unicenta/reports/epm_messages.properties @@ -0,0 +1,17 @@ +label.cash=Cash Value +label.end=End Leave +label.end=End Shift +label.enddate=End Date +label.name=Name +label.period=Period: +label.printed=Printed +label.start=Start Leave +label.start=Start Shift +label.startdate=Start Date +label.title=Daily Presence +label.title=Daily Schedule +label.title=Performance Report +label.total=Total Days +label.total=Total Hours +label.total=Total: +label.user=User diff --git a/src/main/resources/com/unicenta/reports/epm_messages_al_SQ.properties b/src/main/resources/com/unicenta/reports/epm_messages_al_SQ.properties new file mode 100644 index 0000000..b8e1ace --- /dev/null +++ b/src/main/resources/com/unicenta/reports/epm_messages_al_SQ.properties @@ -0,0 +1,46 @@ +# uniCenta oPOS - touch friendly EPoS +# Copyright (c) 2013 uniCenta oPOS +# https://unicenta.com/projects/unicentaopos +# Copyright (C) 2011 Gjergj Sheldija +# http:#www.acme-tech.net +# +# This file is part of uniCenta oPOS. +# +# uniCenta oPOS 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. +# +# uniCenta oPOS 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 uniCenta oPOS. If not, see . + + +label.end=Fundi i Orarit +label.name=Emri +label.period=Periudha: +label.printed=Printuar +label.start=Fillimi i Orarit +label.title=Paraqitja Ditore +label.total=Totali i oreve + +label.end=Perfundimi i pushimit +label.name=Emri +label.period=Periudha: +label.printed=Printuar +label.start=Fillimi i Pushimit +label.title=Orari Ditor +label.total=Totali i Diteve + +label.title=Raporti i Permbushjes +label.printed=Printuar +label.period=Periudha +label.user=Perdorues +label.startdate=Data e Fillimit +label.enddate=Data e Mbarimit +label.cash=Vlera ne te Gatshme +label.total=Total: diff --git a/src/main/resources/com/unicenta/reports/epm_messages_de.properties b/src/main/resources/com/unicenta/reports/epm_messages_de.properties new file mode 100644 index 0000000..8d9a177 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/epm_messages_de.properties @@ -0,0 +1,46 @@ +# uniCenta oPOS - touch friendly EPoS +# Copyright (c) 2013 uniCenta oPOS +# https://unicenta.com/projects/unicentaopos +# Copyright (C) 2011 Gjergj Sheldija +# http:#www.acme-tech.net +# +# This file is part of uniCenta oPOS. +# +# uniCenta oPOS 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. +# +# uniCenta oPOS 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 uniCenta oPOS. If not, see . + + +label.end=Arbeitsende +label.name=Name +label.period=Zeitraum: +label.printed=Ausgedruckt am: +label.start=Arbeitsbeginn +label.title=T\u00e4gliche Anwesenheit +label.total=Summe Stunden + +label.end=Ende Unterbrechung +label.name=Name +label.period=Zeitraum: +label.printed=Ausgedruckt am: +label.start=Beginn Unterbrechung +label.title=Daily Schedule +label.total=Summe Tage + +label.title=Performance Report +label.printed=Erstellt am: +label.period=Zeitraum +label.user=Benutzer +label.startdate=Beginn +label.enddate=Ende +label.cash=Cash Value +label.total=Summe: diff --git a/src/main/resources/com/unicenta/reports/epm_messages_en_US.properties b/src/main/resources/com/unicenta/reports/epm_messages_en_US.properties new file mode 100644 index 0000000..0af2e82 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/epm_messages_en_US.properties @@ -0,0 +1,46 @@ +# uniCenta oPOS - touch friendly EPoS +# Copyright (c) 2013 uniCenta oPOS +# https://unicenta.com/projects/unicentaopos +# Copyright (C) 2011 Gjergj Sheldija +# http:#www.acme-tech.net +# +# This file is part of uniCenta oPOS. +# +# uniCenta oPOS 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. +# +# uniCenta oPOS 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 uniCenta oPOS. If not, see . + + +label.end=End Shift +label.name=Name +label.period=Period: +label.printed=Printed +label.start=Start Shift +label.title=Daily Presence +label.total=Total Hours + +label.end=End Leave +label.name=Name +label.period=Period: +label.printed=Printed +label.start=Start Leave +label.title=Daily Schedule +label.total=Total Days + +label.title=Performance Report +label.printed=Printed +label.period=Period +label.user=User +label.startdate=Start Date +label.enddate=End Date +label.cash=Cash Value +label.total=Total: \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/epm_messages_es.properties b/src/main/resources/com/unicenta/reports/epm_messages_es.properties new file mode 100644 index 0000000..039a355 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/epm_messages_es.properties @@ -0,0 +1,46 @@ +# uniCenta oPOS - touch friendly EPoS +# Copyright (c) 2013 uniCenta oPOS +# https://unicenta.com/projects/unicentaopos +# Copyright (C) 2011 Gjergj Sheldija +# http:#www.acme-tech.net +# +# This file is part of uniCenta oPOS. +# +# uniCenta oPOS 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. +# +# uniCenta oPOS 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 uniCenta oPOS. If not, see . + + +label.end=Fin +label.name=Nombre +label.period=Per\u00edodo: +label.printed=Imprimir +label.start=Inicio +label.title=Presencia Diaria +label.total=Horas Totales + +label.end=Ausencia Final +label.name=Nombre +label.period=Per\u00edodo: +label.printed=Imprimir +label.start=Inicio de la Ausencia +label.title=Agenda Diaria +label.total=Total D\u00edas + +label.title=Informe de Prestaciones +label.printed=Imprimir +label.period=Per\u00edodo +label.user=Usuario +label.startdate=Fecha Inicio +label.enddate=Fecha Final +label.cash=Efectivo +label.total=Total: \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/epm_messages_fr.properties b/src/main/resources/com/unicenta/reports/epm_messages_fr.properties new file mode 100644 index 0000000..54ce7c9 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/epm_messages_fr.properties @@ -0,0 +1,46 @@ +# uniCenta oPOS - touch friendly EPoS +# Copyright (c) 2013 uniCenta oPOS +# https://unicenta.com/projects/unicentaopos +# Copyright (C) 2011 Gjergj Sheldija +# http:#www.acme-tech.net +# +# This file is part of uniCenta oPOS. +# +# uniCenta oPOS 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. +# +# uniCenta oPOS 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 uniCenta oPOS. If not, see . + + +label.end=Fin +label.name=Nom +label.period=P\u00e9riode: +label.printed=Imprim\u00e9 +label.start=D\u00e9but +label.title=Pr\u00e9sence quotidienne +label.total=Total des heures + +label.end=Fin +label.name=Nom +label.period=P\u00e9riode: +label.printed=Imprim\u00e9 +label.start=D\u00e9but +label.title=Programme de la journ\u00e9e +label.total=Total jours + +label.title=Performance +label.printed=Imprim\u00e9 +label.period=P\u00e9riode +label.user=Utilisateur +label.startdate=Date d\u00e9but +label.enddate=Date Fin +label.cash=Valeur rachat +label.total=Total: diff --git a/src/main/resources/com/unicenta/reports/epm_messages_it.properties b/src/main/resources/com/unicenta/reports/epm_messages_it.properties new file mode 100644 index 0000000..617b384 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/epm_messages_it.properties @@ -0,0 +1,46 @@ +# uniCenta oPOS - touch friendly EPoS +# Copyright (c) 2013 uniCenta oPOS +# https://unicenta.com/projects/unicentaopos +# Copyright (C) 2011 Gjergj Sheldija +# http:#www.acme-tech.net +# +# This file is part of uniCenta oPOS. +# +# uniCenta oPOS 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. +# +# uniCenta oPOS 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 uniCenta oPOS. If not, see . + + +label.end=Fine Turno +label.name=Nome +label.period=Periodo: +label.printed=Stampato +label.start=Inizio Turno +label.title=Presenza Giornaliera +label.total=Totale Ore + +label.title=Rapporto Prestazioni +label.printed=Stampato +label.period=Periodo +label.user=Utente +label.startdate=Data Inizio +label.enddate=Data Fine +label.cash=valore in cassa +label.total=Totale: + +label.end=Fine Permesso +label.name=Nome +label.period=Periodo: +label.printed=Stampato +label.start=Inizio Permesso +label.title=Programma Giornaliero +label.total=Totale Giorni diff --git a/src/main/resources/com/unicenta/reports/epm_messages_nl.properties b/src/main/resources/com/unicenta/reports/epm_messages_nl.properties new file mode 100644 index 0000000..ca2cb18 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/epm_messages_nl.properties @@ -0,0 +1,30 @@ +# uniCenta oPOS - TRanslation File +# Copyright (c) 2014 J.SNijder +# You should have received a copy of the GNU General Public License +# along with uniCenta oPOS. If not, see . + + +label.end=Einde Dienst +label.name=Naam +label.period=Periode: +label.printed=Afgedrukt +label.start=Start Dienst +label.title=Dagelijkse aanwezigheid +label.total=Totaal Uren + +label.title=Prestatie Rapport +label.printed=Afgedrukt +label.period=Periode +label.user=Gebruiker +label.startdate=Start Datum +label.enddate=End Datum +label.cash=Contant Waarde +label.total=Totaal: + +label.end=Eind Verlof +label.name=Naam +label.period=Periode: +label.printed=Afgedrukt +label.start=Start Verlof +label.title=Werk Rooster +label.total=Totaal aantal Dagen diff --git a/src/main/resources/com/unicenta/reports/epm_performance.bs b/src/main/resources/com/unicenta/reports/epm_performance.bs new file mode 100644 index 0000000..a4490b1 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/epm_performance.bs @@ -0,0 +1,44 @@ +// uniCenta oPOS - Touch Friendly POS +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.EPM.PerformanceReport"); +report.setReport("/com/unicenta/reports/epm_performance"); +report.setResourceBundle("com/unicenta/reports/epm_messages"); + +report.setSentence("SELECT people.NAME, MIN(receipts.DATENEW) AS STARTDATE, MAX(receipts.DATENEW) AS ENDDATE, SUM(ticketlines.UNITS * ticketlines.PRICE) AS TOTAL " + + "FROM people, receipts, tickets, ticketlines WHERE people.ID = tickets.PERSON AND receipts.ID = tickets.ID AND tickets.ID = ticketlines.TICKET AND ?(QBF_FILTER) " + + "GROUP BY people.NAME ORDER BY people.NAME"); + +report.addParameter("receipts.DATENEW"); +report.addParameter("receipts.DATENEW"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); + +report.addQBFFilter(paramdates); + +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("STARTDATE", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("ENDDATE", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("TOTAL", com.unicenta.data.loader.Datas.DOUBLE); + +report; diff --git a/src/main/resources/com/unicenta/reports/epm_performance.jrxml b/src/main/resources/com/unicenta/reports/epm_performance.jrxml new file mode 100644 index 0000000..c0c0f30 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/epm_performance.jrxml @@ -0,0 +1,361 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="52"> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-8" mode="Transparent" x="50" y="33" width="110" height="15" uuid="2c9296a7-ebdd-492e-8a76-eb4b3b2cd07e"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None"> + <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.DATE.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[1])]]></textFieldExpression> + </textField> + <staticText> + <reportElement key="staticText-6" mode="Transparent" x="160" y="33" width="10" height="15" uuid="b1ca7940-fceb-4a3b-8fb3-de237d55f7b4"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None"> + <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[- +]]></text> + </staticText> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-9" mode="Transparent" x="170" y="33" width="110" height="15" uuid="333a6770-21f8-4a9c-a8ac-3b0af581877c"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.DATE.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[3])]]></textFieldExpression> + </textField> + <rectangle radius="5"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="b8dec4ad-1d69-4477-94e1-8e79b418b516"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-18" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="c6a3b9a4-5ece-4c85-85ea-f62565581587"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="Arial" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title}]]></textFieldExpression> + </textField> + <textField pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField" x="400" y="15" width="135" height="15" uuid="395d9440-b276-4529-a69c-9163965ef98e"/> + <textElement textAlignment="Right"> + <font fontName="Arial" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="400" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="6dee7c66-1ef2-40db-bec4-f089a72d5ade"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="Arial" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-19" mode="Opaque" x="0" y="33" width="50" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="8db2f46b-1f2e-436c-a1df-1aa21272ac15"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="Arial" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.period}]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/inventory.bs b/src/main/resources/com/unicenta/reports/inventory.bs new file mode 100644 index 0000000..41d9c41 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory.bs @@ -0,0 +1,77 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.Inventory"); +report.setReport("/com/unicenta/reports/inventory"); +report.setResourceBundle("com/unicenta/reports/inventory_messages"); + +report.setSentence("SELECT " + + "stockcurrent.LOCATION AS LOCATIONID, " + + "locations.NAME AS LOCATIONNAME, " + + "products.REFERENCE, " + + "products.NAME AS PRODUCTNAME, " + + "products.CATEGORY, " + + "categories.NAME AS CATEGORYNAME, " + + "SUM(stockcurrent.UNITS) AS UNITS, " + + "products.PRICEBUY, " + + "products.PRICESELL, " + + "COALESCE(products.STOCKVOLUME, 0) AS STOCKVOLUME, " + + "COALESCE(products.STOCKCOST, 0) AS STOCKCOST, " + + "COALESCE(stocklevel.STOCKSECURITY, 0) AS STOCKSECURITY, " + + "COALESCE(stocklevel.STOCKMAXIMUM, 0) AS STOCKMAXIMUM " + + "FROM stockcurrent " + + "JOIN locations ON stockcurrent.LOCATION = locations.ID " + + "JOIN products ON stockcurrent.PRODUCT = products.ID " + + "JOIN categories ON products.CATEGORY = categories.ID " + + "LEFT OUTER JOIN stocklevel ON stockcurrent.LOCATION = " + + "stocklevel.LOCATION AND stockcurrent.PRODUCT = stocklevel.PRODUCT " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY stockcurrent.LOCATION, locations.NAME, products.REFERENCE, " + + "products.NAME, products.CATEGORY, categories.NAME, products.PRICEBUY, " + + "products.PRICESELL, products.STOCKVOLUME, products.STOCKCOST, " + + "stocklevel.STOCKSECURITY, stocklevel.STOCKMAXIMUM " + + "ORDER BY stockcurrent.LOCATION, categories.NAME, products.NAME"); + +report.addParameter("stockcurrent.LOCATION"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsLocationWithFirst()); + +report.addParameter("products.NAME"); +report.addParameter("products.PRICEBUY"); +report.addParameter("products.PRICESELL"); +report.addParameter("products.CATEGORY"); +report.addParameter("products.CODE"); +report.addQBFFilter(new com.unicenta.pos.ticket.ProductFilter()); + +report.addField("LOCATIONID", com.unicenta.data.loader.Datas.STRING); +report.addField("LOCATIONNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("REFERENCE", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORY", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORYNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("UNITS", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("PRICEBUY", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("PRICESELL", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("STOCKVOLUME", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("STOCKCOST", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("STOCKSECURITY", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("STOCKMAXIMUM", com.unicenta.data.loader.Datas.DOUBLE); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory.jrxml b/src/main/resources/com/unicenta/reports/inventory.jrxml new file mode 100644 index 0000000..a092048 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory.jrxml @@ -0,0 +1,789 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="54"> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-13" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="6e227e7f-ac25-420b-9b5e-116f8186a57d"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title.inventory}]]></textFieldExpression> + </textField> + <rectangle radius="5"> + <reportElement key="rectangle-4" mode="Opaque" x="0" y="53" width="782" height="1" forecolor="#33CCFF" backcolor="#33CCFF" uuid="a9c6cfd0-90b1-4e74-a1d4-b42b8c0db50c"> + <property name="com.jaspersoft.studio.unit.width" value="pixel"/> + </reportElement> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="647" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="dbde2926-d2c6-4853-8c5b-13fa47b3ca0d"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField" x="647" y="15" width="135" height="15" uuid="110c2083-6cb6-4e0e-a07c-e99e74cad044"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + = $F{STOCKSECURITY}.doubleValue())]]> + + + + + + + + + + + + + + + + $F{STOCKMAXIMUM}.doubleValue())]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $F{STOCKMAXIMUM}.doubleValue())]]> + + + + + + + + + + + + + + + + + = $F{STOCKSECURITY}.doubleValue() + && $F{UNITS}.doubleValue()<= $F{STOCKMAXIMUM}.doubleValue())]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/inventory_b.bs b/src/main/resources/com/unicenta/reports/inventory_b.bs new file mode 100644 index 0000000..dc79c1d --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_b.bs @@ -0,0 +1,82 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.Inventory"); +report.setReport("/com/unicenta/reports/inventory_b"); +report.setResourceBundle("com/unicenta/reports/inventory_messages"); + +report.setSentence("SELECT " + + "stockcurrent.LOCATION AS LOCATIONID, locations.NAME AS LOCATIONNAME, " + + "products.REFERENCE, products.NAME AS PRODUCTNAME, " + + "products.CATEGORY, categories.NAME AS CATEGORYNAME, " + + "MIN(products.SUPPLIER), " + + "SUM(stockcurrent.UNITS) AS UNITS, " + + "products.PRICEBUY, products.PRICESELL, " + + "COALESCE(products.STOCKVOLUME, 0) AS STOCKVOLUME, " + + "COALESCE(products.STOCKCOST, 0) AS STOCKCOST, " + + "COALESCE(stocklevel.STOCKSECURITY, 0) AS STOCKSECURITY, " + + "COALESCE(stocklevel.STOCKMAXIMUM, 0) AS STOCKMAXIMUM, " + + "MIN(suppliers.NAME) AS SUPPLIERNAME, MIN(uom.NAME) AS UOM " + + "FROM (((((stockcurrent stockcurrent INNER JOIN locations locations " + + "ON (stockcurrent.LOCATION = locations.id)) " + + "INNER JOIN products products ON (stockcurrent.PRODUCT = products.ID)) " + + "INNER JOIN categories categories ON (products.CATEGORY = categories.ID)) " + + "RIGHT OUTER JOIN suppliers suppliers ON (suppliers.id = products.SUPPLIER)) " + + "INNER JOIN uom uom ON (uom.id = products.UOM)) " + + "LEFT OUTER JOIN stocklevel stocklevel ON (stockcurrent.LOCATION = stocklevel.LOCATION) " + + "AND (stockcurrent.PRODUCT = stocklevel.PRODUCT) " + + "WHERE ?(QBF_FILTER)" + + "GROUP BY stockcurrent.LOCATION, locations.NAME, products.REFERENCE, products.NAME, " + + "products.CATEGORY, categories.NAME, products.PRICEBUY, products.PRICESELL, " + + "products.STOCKVOLUME, products.STOCKCOST, stocklevel.STOCKSECURITY, stocklevel.STOCKMAXIMUM " + + "ORDER BY LOCATIONID ASC, CATEGORYNAME ASC, PRODUCTNAME ASC"); + +report.addParameter("stockcurrent.LOCATION"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsLocationWithFirst()); + +report.addParameter("suppliers.ID"); +report.addParameter("suppliers.NAME"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsSuppliers()); + +report.addParameter("products.NAME"); +report.addParameter("products.CATEGORY"); +report.addParameter("products.CODE"); +report.addParameter("stockcurrent.UNITS"); +report.addQBFFilter(new com.unicenta.pos.ticket.ProductFilter1()); + +report.addField("LOCATIONID", com.unicenta.data.loader.Datas.STRING); +report.addField("LOCATIONNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("REFERENCE", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORY", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORYNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("SUPPLIER", com.unicenta.data.loader.Datas.STRING); +report.addField("UNITS", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("PRICEBUY", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("PRICESELL", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("STOCKVOLUME", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("STOCKCOST", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("STOCKSECURITY", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("STOCKMAXIMUM", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("SUPPLIERNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("UOM", com.unicenta.data.loader.Datas.STRING); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_b.jrxml b/src/main/resources/com/unicenta/reports/inventory_b.jrxml new file mode 100644 index 0000000..1068c9c --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_b.jrxml @@ -0,0 +1,477 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="52"> + <rectangle radius="5"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="5ec53e75-a3c3-460e-ad26-e3bf449a9f75"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-13" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="1eb923ea-a85a-4bb0-b5c7-1d6730afc788"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title.current}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="400" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="7a7b157a-c985-461a-81a5-31142de08fe2"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField" x="400" y="15" width="135" height="15" uuid="d7d2c13e-a98f-4c08-9728-cb8890b31eb6"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + = $F{STOCKSECURITY}.doubleValue() + && $F{UNITS}.doubleValue()<= $F{STOCKMAXIMUM}.doubleValue())]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $F{STOCKMAXIMUM}.doubleValue())]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/inventory_broken.bs b/src/main/resources/com/unicenta/reports/inventory_broken.bs new file mode 100644 index 0000000..93bfebd --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_broken.bs @@ -0,0 +1,83 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.InventoryBroken"); +report.setReport("/com/unicenta/reports/inventory_b"); +report.setResourceBundle("com/unicenta/reports/inventory_messages"); + +report.setSentence("SELECT " + + "stockcurrent.LOCATION AS LOCATIONID, locations.NAME AS LOCATIONNAME, " + + "products.REFERENCE, products.NAME AS PRODUCTNAME, " + + "products.CATEGORY, categories.NAME AS CATEGORYNAME, " + + "MIN(products.SUPPLIER), " + + "SUM(stockcurrent.UNITS) AS UNITS, " + + "products.PRICEBUY, products.PRICESELL, " + + "COALESCE(products.STOCKVOLUME, 0) AS STOCKVOLUME, " + + "COALESCE(products.STOCKCOST, 0) AS STOCKCOST, " + + "COALESCE(stocklevel.STOCKSECURITY, 0) AS STOCKSECURITY, " + + "COALESCE(stocklevel.STOCKMAXIMUM, 0) AS STOCKMAXIMUM, " + + "MIN(suppliers.NAME) AS SUPPLIERNAME, MIN(uom.NAME) AS UOM " + + "FROM (((((stockcurrent stockcurrent JOIN locations locations " + + "ON (stockcurrent.LOCATION = locations.id)) " + + "JOIN products products ON (stockcurrent.PRODUCT = products.ID)) " + + "JOIN categories categories ON (products.CATEGORY = categories.ID)) " + + "RIGHT OUTER JOIN suppliers suppliers ON (suppliers.id = products.SUPPLIER)) " + + "INNER JOIN uom uom ON (uom.id = products.UOM)) " + + "LEFT OUTER JOIN stocklevel stocklevel ON (stockcurrent.LOCATION = stocklevel.LOCATION) " + + "AND (stockcurrent.PRODUCT = stocklevel.PRODUCT) " + + "WHERE ?(QBF_FILTER)" + + "GROUP BY stockcurrent.LOCATION, locations.NAME, products.REFERENCE, products.NAME, " + + "products.CATEGORY, categories.NAME, products.PRICEBUY, products.PRICESELL, " + + "products.STOCKVOLUME, products.STOCKCOST, stocklevel.STOCKSECURITY, stocklevel.STOCKMAXIMUM " + + "HAVING stocklevel.STOCKSECURITY IS NOT NULL AND stocklevel.STOCKSECURITY >= SUM(stockcurrent.UNITS) " + + "ORDER BY CATEGORYNAME ASC, PRODUCTNAME ASC, LOCATIONID ASC"); + +report.addParameter("stockcurrent.LOCATION"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsLocationWithFirst()); + +report.addParameter("suppliers.ID"); +report.addParameter("suppliers.NAME"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsSuppliers()); + +report.addParameter("products.NAME"); +report.addParameter("products.CATEGORY"); +report.addParameter("products.CODE"); +report.addParameter("stockcurrent.UNITS"); +report.addQBFFilter(new com.unicenta.pos.ticket.ProductFilter1()); + +report.addField("LOCATIONID", com.unicenta.data.loader.Datas.STRING); +report.addField("LOCATIONNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("REFERENCE", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORY", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORYNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("SUPPLIER", com.unicenta.data.loader.Datas.STRING); +report.addField("UNITS", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("PRICEBUY", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("PRICESELL", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("STOCKVOLUME", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("STOCKCOST", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("STOCKSECURITY", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("STOCKMAXIMUM", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("SUPPLIERNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("UOM", com.unicenta.data.loader.Datas.STRING); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_diary.bs b/src/main/resources/com/unicenta/reports/inventory_diary.bs new file mode 100644 index 0000000..3b9fc2f --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_diary.bs @@ -0,0 +1,69 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2018 uniCenta +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.Inventory.Reports.Diary"); +report.setReport("/com/unicenta/reports/inventory_diary"); +report.setResourceBundle("com/unicenta/reports/inventory_messages"); + +report.setSentence("SELECT " + + "TIMESTAMP(stockdiary.datenew), stockdiary.reason, MIN(stockdiary.supplierdoc), " + + "sum(stockdiary.units), MIN(stockdiary.price), " + + "sum(stockdiary.UNITS * stockdiary.PRICE) AS TOTALP, " + + "MIN(suppliers.name) AS SUPPLIERNAME, " + + "products.name, MIN(products.reference), MIN(products.code), " + + "locations.name " + + "FROM ((stockdiary stockdiary " + + "INNER JOIN locations locations " + + "ON (stockdiary.location = locations.id)) " + + "INNER JOIN products products " + + "ON (stockdiary.product = products.id)) " + + "LEFT OUTER JOIN suppliers suppliers " + + "ON (products.supplier = suppliers.id) " + + "WHERE VISIBLE = " + app.getSession().DB.TRUE() + " AND ?(QBF_FILTER) " + + "GROUP BY locations.name, stockdiary.reason, stockdiary.datenew, products.name"); + +report.addParameter("stockdiary.DATENEW"); +report.addParameter("stockdiary.DATENEW"); +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); +report.addQBFFilter(paramdates); + +report.addParameter("stockdiary.REASON"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsReason()); + +report.addParameter("suppliers.ID"); +report.addParameter("suppliers.NAME"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsSuppliers()); + +report.addField("DATENEW", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("REASON", com.unicenta.data.loader.Datas.INT); +report.addField("SUPPLIERDOC", com.unicenta.data.loader.Datas.STRING); +report.addField("UNITS", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("PRICE", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TOTALP", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("SUPPLIERNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("PRODUCTNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("REFERENCE", com.unicenta.data.loader.Datas.STRING); +report.addField("CODE", com.unicenta.data.loader.Datas.STRING); +report.addField("LOCATION", com.unicenta.data.loader.Datas.STRING); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_diary.jrxml b/src/main/resources/com/unicenta/reports/inventory_diary.jrxml new file mode 100644 index 0000000..d8249fd --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_diary.jrxml @@ -0,0 +1,438 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/inventory_diff.bs b/src/main/resources/com/unicenta/reports/inventory_diff.bs new file mode 100644 index 0000000..05f3907 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_diff.bs @@ -0,0 +1,74 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.InventoryDiff"); +report.setReport("/com/unicenta/reports/inventory_diff"); +report.setResourceBundle("com/unicenta/reports/inventory_messages"); + +report.setSentence("SELECT " + + "locations.ID AS LOCATIONID, locations.NAME AS LOCATIONNAME, " + + "products.REFERENCE, products.NAME, " + + "products.CATEGORY, categories.NAME AS CATEGORYNAME, " + + "MIN(products.SUPPLIER), " + + "SUM(CASE WHEN stockdiary.UNITS <0 THEN stockdiary.UNITS ELSE 0 END) AS UNITSOUT, " + + "SUM(CASE WHEN stockdiary.UNITS <0 THEN stockdiary.UNITS * stockdiary.PRICE ELSE 0 END) AS TOTALOUT, " + + "SUM(CASE WHEN stockdiary.UNITS >=0 THEN stockdiary.UNITS ELSE 0 END) AS UNITSIN, " + + "SUM(CASE WHEN stockdiary.UNITS >=0 THEN stockdiary.UNITS * stockdiary.PRICE ELSE 0 END) AS TOTALIN, " + + "SUM(stockdiary.UNITS) AS UNITSDIFF, " + + "SUM(stockdiary.UNITS * stockdiary.PRICE) AS TOTALDIFF " + + "FROM stockdiary JOIN locations ON stockdiary.LOCATION = locations.ID, " + + "products LEFT OUTER JOIN categories ON products.CATEGORY = categories.ID " + + "WHERE products.ID = stockdiary.PRODUCT " + + "AND ?(QBF_FILTER) " + + "GROUP BY locations.ID, locations.NAME, products.REFERENCE, products.NAME, products.CATEGORY, categories.NAME " + + "ORDER BY locations.ID, categories.NAME, products.NAME"); + +report.addParameter("stockdiary.DATENEW"); +report.addParameter("stockdiary.DATENEW"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); +report.addQBFFilter(paramdates); + +report.addParameter("locations.ID"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsLocationWithFirst()); + +report.addParameter("stockdiary.REASON"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsReason()); + +report.addField("LOCATIONID", com.unicenta.data.loader.Datas.STRING); +report.addField("LOCATIONNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("REFERENCE", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORY", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORYNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("SUPPLIER", com.unicenta.data.loader.Datas.STRING); +report.addField("UNITSOUT", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TOTALOUT", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("UNITSIN", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TOTALIN", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("UNITSDIFF", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TOTALDIFF", com.unicenta.data.loader.Datas.DOUBLE); + +report; + diff --git a/src/main/resources/com/unicenta/reports/inventory_diff.jrxml b/src/main/resources/com/unicenta/reports/inventory_diff.jrxml new file mode 100644 index 0000000..14e28b3 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_diff.jrxml @@ -0,0 +1,607 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/inventory_diffdetail.bs b/src/main/resources/com/unicenta/reports/inventory_diffdetail.bs new file mode 100644 index 0000000..ea1afc3 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_diffdetail.bs @@ -0,0 +1,76 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.InventoryDiffDetail"); +report.setReport("/com/unicenta/reports/inventory_diffdetail"); +report.setResourceBundle("com/unicenta/reports/inventory_messages"); + +report.setSentence("SELECT " + + "locations.ID AS LOCATIONID, MIN(locations.NAME) AS LOCATIONNAME, " + + "products.REFERENCE, MIN(products.NAME), " + + "MIN(stockdiary.ATTRIBUTESETINSTANCE_ID), attributesetinstance.DESCRIPTION, " + + "products.CATEGORY, MIN(categories.NAME) AS CATEGORYNAME, " + + "SUM(CASE WHEN stockdiary.UNITS <0 THEN stockdiary.UNITS ELSE 0 END) AS UNITSOUT, " + + "SUM(CASE WHEN stockdiary.UNITS <0 THEN stockdiary.UNITS * stockdiary.PRICE ELSE 0 END) AS TOTALOUT, " + + "SUM(CASE WHEN stockdiary.UNITS >=0 THEN stockdiary.UNITS ELSE 0 END) AS UNITSIN, " + + "SUM(CASE WHEN stockdiary.UNITS >=0 THEN stockdiary.UNITS * stockdiary.PRICE ELSE 0 END) AS TOTALIN, " + + "SUM(stockdiary.UNITS) AS UNITSDIFF, " + + "SUM(stockdiary.UNITS * stockdiary.PRICE) AS TOTALDIFF " + + "FROM stockdiary " + + "JOIN locations ON stockdiary.LOCATION = locations.ID " + + "JOIN products ON products.ID = stockdiary.PRODUCT " + + "LEFT OUTER JOIN categories ON products.CATEGORY = categories.ID " + + "LEFT OUTER JOIN attributesetinstance ON stockdiary.ATTRIBUTESETINSTANCE_ID = attributesetinstance.ID " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY locations.ID, products.CATEGORY, products.REFERENCE, DESCRIPTION " + + "ORDER BY locations.ID, MIN(categories.NAME), MIN(products.NAME)"); + +report.addParameter("stockdiary.DATENEW"); +report.addParameter("stockdiary.DATENEW"); +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); + +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); +report.addQBFFilter(paramdates); + +report.addParameter("locations.ID"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsLocationWithFirst()); + +report.addParameter("stockdiary.REASON"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsReason()); + +report.addField("LOCATIONID", com.unicenta.data.loader.Datas.STRING); +report.addField("LOCATIONNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("REFERENCE", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("ATTINSTANCEID", com.unicenta.data.loader.Datas.STRING); +report.addField("ATTINSTANCEDESC", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORY", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORYNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("UNITSOUT", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TOTALOUT", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("UNITSIN", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TOTALIN", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("UNITSDIFF", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TOTALDIFF", com.unicenta.data.loader.Datas.DOUBLE); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_diffdetail.jrxml b/src/main/resources/com/unicenta/reports/inventory_diffdetail.jrxml new file mode 100644 index 0000000..53f4a70 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_diffdetail.jrxml @@ -0,0 +1,637 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/inventory_listdetail.bs b/src/main/resources/com/unicenta/reports/inventory_listdetail.bs new file mode 100644 index 0000000..595af21 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_listdetail.bs @@ -0,0 +1,78 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.InventoryListDetail"); +report.setReport("/com/unicenta/reports/inventory_listdetail"); +report.setResourceBundle("com/unicenta/reports/inventory_messages"); + +report.setSentence("SELECT " + + "MIN(stockcurrent.LOCATION) AS LOCATIONID, " + + "MIN(locations.NAME) AS LOCATIONNAME, " + + "products.REFERENCE, " + + "MIN(products.NAME) AS NAME, " + + "MIN(stockcurrent.ATTRIBUTESETINSTANCE_ID), " + + "attributesetinstance.DESCRIPTION, " + + "products.CATEGORY, " + + "MIN(categories.NAME) AS CATEGORYNAME, " + + "MIN(products.SUPPLIER), " + + "MIN(stockcurrent.UNITS), " + + "COALESCE(MIN(stocklevel.STOCKSECURITY), 0) AS STOCKSECURITY, " + + "COALESCE(MIN(stocklevel.STOCKMAXIMUM), 0) AS STOCKMAXIMUM, " + + "MIN(suppliers.NAME) " + + "FROM stockcurrent " + + "JOIN locations ON stockcurrent.LOCATION = locations.ID " + + "JOIN products ON stockcurrent.PRODUCT = products.ID " + + "JOIN categories ON products.CATEGORY = categories.ID " + + "LEFT OUTER JOIN stocklevel ON stockcurrent.LOCATION = stocklevel.LOCATION AND stockcurrent.PRODUCT = stocklevel.PRODUCT " + + "LEFT OUTER JOIN attributesetinstance ON stockcurrent.ATTRIBUTESETINSTANCE_ID = attributesetinstance.ID " + + "LEFT OUTER JOIN suppliers suppliers ON (suppliers.ID = products.SUPPLIER) " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY locations.ID, products.CATEGORY, products.REFERENCE, DESCRIPTION " + + "ORDER BY MIN(categories.NAME), MIN(products.NAME), MIN(stockcurrent.LOCATION)"); + +report.addParameter("stockcurrent.LOCATION"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsLocationWithFirst()); + +report.addParameter("suppliers.ID"); +report.addParameter("suppliers.NAME"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsSuppliers()); + + +report.addParameter("products.NAME"); +report.addParameter("products.CATEGORY"); +report.addParameter("products.CODE"); +report.addParameter("stockcurrent.UNITS"); +report.addQBFFilter(new com.unicenta.pos.ticket.ProductFilter1()); + +report.addField("LOCATIONID", com.unicenta.data.loader.Datas.STRING); +report.addField("LOCATIONNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("REFERENCE", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("ATTINSTANCEID", com.unicenta.data.loader.Datas.STRING); +report.addField("ATTINSTANCEDESC", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORY", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORYNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("SUPPLIER", com.unicenta.data.loader.Datas.STRING); +report.addField("UNITS", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("STOCKSECURITY", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("STOCKMAXIMUM", com.unicenta.data.loader.Datas.DOUBLE); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_listdetail.jrxml b/src/main/resources/com/unicenta/reports/inventory_listdetail.jrxml new file mode 100644 index 0000000..0f1ea6c --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_listdetail.jrxml @@ -0,0 +1,452 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $F{STOCKMAXIMUM}.doubleValue() +? com.unicenta.format.Formats.DOUBLE.formatValue($V{UNITSTOTALWAREHOUSE}) +: ""]]> + + + + + + + + + + + + + + = $F{STOCKSECURITY}.doubleValue() + && $V{UNITSTOTALWAREHOUSE}.doubleValue()<= $F{STOCKMAXIMUM}.doubleValue() +? com.unicenta.format.Formats.DOUBLE.formatValue($V{UNITSTOTALWAREHOUSE}) +: ""]]> + + + + + + + + + + + + <band height="52"> + <rectangle radius="5"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="89d02ae2-c5a6-455f-843f-f20b531f0be7"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-13" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="83297b75-6a33-4643-82ec-123284c1e7a6"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title.listdetail}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="400" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="2ad49871-ae6f-4fbb-9b3d-40867e979a79"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField" x="400" y="15" width="135" height="15" uuid="c80a320f-6f9e-4743-a527-65289f62b6a9"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/inventory_messages.properties b/src/main/resources/com/unicenta/reports/inventory_messages.properties new file mode 100644 index 0000000..08482dc --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_messages.properties @@ -0,0 +1,61 @@ +label.account=Account : +label.accountname = Acc' Name : +label.category = Category : +label.code=Code +label.date=Date +label.diff=Difference +label.in=In +label.location=Location : +label.max=Max. +label.min=Min. +label.name=Name +label.out=Out +label.period=Period: +label.price=Unit Value +label.pricebuy=Price Buy +label.pricesell=Price Sell +label.printed=Printed +label.product=Product +label.productname=Prod.Name +label.qty=Qty +label.reason=Reason +label.ref=Ref. +label.reference=Reference +label.sec=Min. +label.sumdiff=Total Difference +label.sumin=Total In +label.sumout=Total Out +label.supplier=Supplier +label.supplierdoc=Doc. Ref. +label.suppliername=Supplier Name +label.taxid=Account ID +label.title.broken=Inventory: Broken +label.title.current=Inventory: Current +label.title.diary=Inventory Diary +label.title.diffdetail=Inventory: Difference Detail +label.title.difference=Inventory: Difference +label.title.inventory=Inventory: Location and Category +label.title.listdetail= Inventory: List Detail +label.total=Total +label.totalG=Grand Total +label.totalP=Amount +label.ttype=Type +label.units.instock=In Stock +label.units=Units +label.uom=UOM +label.valuebuy=Buy Value +label.valuecost=St. Cost +label.valuesell=Sell Value +label.valuevolume=Storage +reason.1=Purchase Supplier +reason.-1=Sales +reason.1000=Transfer +reason.-2=Return - Supplier +reason.2=Return Customer +reason.-3=Breakage +reason.4=Adjust - Add +reason.-4=Adjust - Minus +reason.-5=Sample - Out +reason.-6=Free +reason.-7=Used +reason.-8=Rectify - Subtract diff --git a/src/main/resources/com/unicenta/reports/inventory_messages_al_SQ.properties b/src/main/resources/com/unicenta/reports/inventory_messages_al_SQ.properties new file mode 100644 index 0000000..d0c635b --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_messages_al_SQ.properties @@ -0,0 +1,11 @@ +label.max=Maksimum +label.name=Emri +label.printed=Printuar +label.ref=Ref. +label.sec=Minimum +label.title=Inventari: Lokacioni dhe Kategorit +label.units=njesi +label.valuebuy=Vlera e Blerjes +label.valuecost=Cmimi +label.valuesell=Vlera e shitjes +label.valuevolume=Sasia \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_messages_ar.properties b/src/main/resources/com/unicenta/reports/inventory_messages_ar.properties new file mode 100644 index 0000000..f1e8c20 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_messages_ar.properties @@ -0,0 +1,12 @@ +label.account=\u0645\u062d\u0627\u0633\u0628\u0629 +label.max=\u0627\u0644\u0627\u0639\u0644\u0649 +label.name=\u0627\u0644\u0627\u0633\u0645 +label.printed=\u0645\u0637\u0628\u0648\u0639 +label.ref=\u0627\u0644\u0645\u0631\u062c\u0639. +label.sec=\u0627\u0644\u0627\u062f\u0646\u0649 +label.title=\u0627\u0644\u062c\u0631\u062f: \u0627\u0644\u0645\u0648\u0642\u0639 \u0648\u0627\u0644\u062a\u0635\u0646\u064a\u0641 +label.units=\u0627\u0644\u0648\u062d\u062f\u0627\u062a +label.valuebuy=\u0627\u062c\u0645\u0627\u0644\u064a \u0627\u0644\u062a\u0643\u0644\u0641\u0629 +label.valuecost=\u0627\u0644\u062a\u0643\u0644\u0641\u0629 +label.valuesell=\u0642\u064a\u0645\u0629 \u0627\u0644\u0628\u064a\u0639 \u0628\u0627\u0644\u062a\u062c\u0632\u0626\u0629 +label.valuevolume=\u0627\u0644\u0643\u0645\u064a\u0629 \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_messages_de.properties b/src/main/resources/com/unicenta/reports/inventory_messages_de.properties new file mode 100644 index 0000000..c3a6a91 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_messages_de.properties @@ -0,0 +1,15 @@ +label.account=Konto : +label.accountname=Kontobezeichnung +label.location=Platz : +label.max=Max. +label.min=Min. +label.name=Name +label.printed=Erstellt am: +label.ref=Ref. +label.sec=Minimum +label.title=Inventar: Lagerplatz & Kategorie +label.units=St\u00fcckzahl +label.valuebuy=Einkaufspreis (EK) +label.valuecost=Kosten +label.valuesell=Verkaufspreis (VK) +label.valuevolume=Anzahl \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_messages_el.properties b/src/main/resources/com/unicenta/reports/inventory_messages_el.properties new file mode 100644 index 0000000..e46434e --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_messages_el.properties @@ -0,0 +1,12 @@ +label.account=\u039b\u03bf\u03b3\u03b1\u03c1\u03b9\u03b1\u03c3\u03bc\u03cc\u03c2 +label.max=\u039c\u03ad\u03b3\u03b9\u03c3\u03c4\u03bf +label.name=\u038c\u03bd\u03bf\u03bc\u03b1 +label.printed=Printed +label.ref=\u0391\u03bd\u03b1\u03c6. +label.sec=\u039a\u03b1\u03c4\u03ce\u03c4\u03b5\u03c1\u03bf +label.title=\u039a\u03b1\u03c4\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae: \u03a4\u03bf\u03c0\u03bf\u03b8\u03b5\u03c3\u03af\u03b1 \u039a\u03b1\u03b9 \u039a\u03b1\u03c4\u03b7\u03b3\u03bf\u03c1\u03af\u03b1 +label.units=\u039c\u03bf\u03bd\u03ac\u03b4\u03b5\u03c2 +label.valuebuy=\u0391\u03be\u03af\u03b1 \u039a\u03cc\u03c3\u03c4\u03bf\u03c5\u03c2 +label.valuecost=\u039a\u03cc\u03c3\u03c4\u03bf\u03c2 +label.valuesell=\u0391\u03be\u03af\u03b1 \u039b\u03b9\u03b1\u03bd\u03b9\u03ba\u03ae\u03c2 +label.valuevolume=\u038c\u03b3\u03ba\u03bf\u03c2 \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_messages_en_US.properties b/src/main/resources/com/unicenta/reports/inventory_messages_en_US.properties new file mode 100644 index 0000000..10aab0b --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_messages_en_US.properties @@ -0,0 +1,61 @@ +label.account=Account : +label.accountname = Acc' Name : +label.category = Category : +label.code=Code +label.date=Date +label.diff=Difference +label.in=In +label.location=Location : +label.max=Max. +label.min=Min. +label.name=Name +label.out=Out +label.period=Period: +label.price=Unit Value +label.pricebuy=Price Buy +label.pricesell=Price Sell +label.printed=Printed +label.product=Product +label.productname=Prod.Name +label.qty=Qty +label.reason=Reason +label.ref=Ref. +label.reference=Reference +label.sec=Min. +label.sumdiff=Total Difference +label.sumin=Total In +label.sumout=Total Out +label.supplier=Supplier +label.supplierdoc=Doc. Ref. +label.suppliername=Supplier Name +label.taxid=Account ID +label.title.broken=Inventory: Broken +label.title.current=Inventory: Current +label.title.diary=Inventory Diary +label.title.diffdetail=Inventory: Difference Detail +label.title.difference=Inventory: Difference +label.title.inventory=Inventory: Location and Category +label.title.listdetail= Inventory: List Detail +label.total=Total +label.totalG=Grand Total +label.totalP=Amount +label.ttype=Type +label.units.instock=In Stock +label.units=Units +label.uom=UOM +label.valuebuy=Buy Value +label.valuecost=St. Cost +label.valuesell=Sell Value +label.valuevolume=Storage +reason.1=Purchase Supplier +reason.-1=Sales +reason.1000=Transfer +reason.-2=Return - Supplier +reason.2=Return Customer +reason.-3=Breakage +reason.4=Adjust - Add +reason.-4=Adjust - Minus +reason.-5=Sample - Out +reason.-6=Free +reason.-7=Used +reason.-8=Rectify Error- Minus \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_messages_es.properties b/src/main/resources/com/unicenta/reports/inventory_messages_es.properties new file mode 100644 index 0000000..30b1430 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_messages_es.properties @@ -0,0 +1,62 @@ +label.account=Cuenta +label.accountname=Nombre de la cuenta : +label.category=Categor\u00eda : +label.code=C\u00f3digo +label.date=Fecha +label.diff=Diferencia +label.in=En +label.location=Almac\u00e9n : +label.max=M\u00e1ximo +label.min=M\u00ednimo +label.name=Nombre +label.out=Fuera +label.period=Per\u00edodo +label.price=Valor unitario +label.pricebuy=Precio de compra +label.pricesell=Precio de venta +label.printed=Imprimir +label.product=Productos +label.productname=Prod. Nombre +label.qty=Cantidad +label.reason=Raz\u00f3n +label.ref=Ref. +label.reference=Referencia +label.sec=M\u00ednimo +label.sumdiff=Diferencia Total +label.sumin=Total En +label.sumout=Total Fuera +label.supplier=Proveedor +label.supplierdoc=Doc. Ref. +label.suppliername=Nombre del proveedor +label.taxid=ID Cuenta +label.title.broken=Inventario : Roto +label.title.current=Inventario : Actual +label.title.diary=Diario de Inventario +label.title.diffdetail=Inventario: Detalle de la diferencia +label.title.difference=Inventario:Diferencia +label.title.inventory=Inventario: Almac\u00e9n y categor\u00eda +label.title.listdetail=Inventario: Lista detalle +label.title=Almacenes +label.total=Total +label.totalG=Gran Total +label.totalP=Cantidad +label.ttype=Tipo +label.units.instock=En Stock +label.units=Unidades +label.uom=UOM +label.valuebuy=Valor compra +label.valuecost=Costo +label.valuesell=Valor venta +label.valuevolume=Volumen +reason.1=Proveedor de compras +reason.-1=Ventas +reason.1000=Transferir +reason.-2=Retorno - Proveedor +reason.2=Retorno Cliente +reason.-3=Rotura +reason.4=Ajustar - A\u00f1adir +reason.-4=Ajustar - Menos +reason.-5=Ejemplo - salida +reason.-6=Gratis +reason.-7=Usado +reason.-8=Rectificar - Restar \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_messages_es_AR.properties b/src/main/resources/com/unicenta/reports/inventory_messages_es_AR.properties new file mode 100644 index 0000000..8dde015 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_messages_es_AR.properties @@ -0,0 +1,11 @@ +label.account=Cuenta +label.max=M\u00e1ximo +label.name=Nombre +label.ref=Ref. +label.sec=M\u00ednimo +label.title=Almacenes +label.units=Unidades +label.valuebuy=Valor de compra +label.valuecost=Costo +label.valuesell=Valor de venta +label.valuevolume=Volumen diff --git a/src/main/resources/com/unicenta/reports/inventory_messages_es_MX.properties b/src/main/resources/com/unicenta/reports/inventory_messages_es_MX.properties new file mode 100644 index 0000000..6f2f5a7 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_messages_es_MX.properties @@ -0,0 +1,10 @@ +label.max=Mximo +label.name=Nombre +label.ref=Ref. +label.sec=Seguridad +label.title=Almacenes +label.units=Unidades +label.valuebuy=Valor de compra +label.valuecost=Costo +label.valuesell=Valor de venta +label.valuevolume=Volumen \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_messages_et.properties b/src/main/resources/com/unicenta/reports/inventory_messages_et.properties new file mode 100644 index 0000000..f64a152 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_messages_et.properties @@ -0,0 +1,11 @@ +label.max=Maksimum +label.name=Nimetus +label.printed=Tr\u00fckitud +label.ref=Kood +label.sec=Miinimum +label.title=Kaubaj\u00e4\u00e4k: ladu ja tooter\u00fchm +label.units=Kogus +label.valuebuy=Omahind +label.valuecost=Kulud +label.valuesell=M\u00fc\u00fcgihind +label.valuevolume=Kogus \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_messages_fr.properties b/src/main/resources/com/unicenta/reports/inventory_messages_fr.properties new file mode 100644 index 0000000..b85145c --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_messages_fr.properties @@ -0,0 +1,61 @@ +label.account=Compte : +label.accountname=Nom de compte +label.category = Categori\u00e9 : +label.code=Code barre +label.date=Date +label.diff=Stock Final +label.in=Entr\u00e9e +label.location=Entrepot +label.max=Max. +label.min=Min. +label.name=Nom +label.out=Sortie +label.period=P\u00e9riode: +label.price=Valeur Unit\u00e9 +label.pricebuy=Prix d'achat +label.pricesell=Prix Vente HT +label.printed=Imprim\u00e9 +label.product=Produit +label.productname=Produit +label.qty=Qt\u00e9 +label.reason=Raison +label.ref=R\u00e9f. +label.reference=R\u00e9f\u00e9rence +label.sec=Min. +label.sumdiff=Total diff\u00e9rence +label.sumin=Total entr\u00e9e +label.sumout=Total sortie +label.supplier=Fournisseur +label.supplierdoc=Doc. R\u00e9f. +label.suppliername=Nom Fournisseur +label.taxid=N\u00b0 Compte +label.title.broken=Inventaire: minimum atteint +label.title.current=Inventaire: actuel +label.title.diary=Inventaire: Journal +label.title.diffdetail=Journal d'inventaire d\u00e9taill\u00e9 +label.title.difference=Journal d'inventaire +label.title.inventory=Inventaire +label.title.listdetail= Inventaire actuel d\u00e9taill\u00e9 +label.total=Total +label.totalG=Total +label.totalP=Valeur +label.ttype=Type +label.units.instock=En Stock +label.units=Unit\u00e9s +label.uom=UOM +label.valuebuy=Valeur achat +label.valuecost=Valeur st. +label.valuesell=Valeur Revente HT +label.valuevolume=Stockage +reason.1=Entr\u00e9e Marchandises +reason.-1=Ventes +reason.1000=Transf\u00e9rer +reason.2=Retour clients +reason.-2=Retour fournisseurs +reason.-3=Casse +reason.-4=Manque - Retrancher +reason.4=Rectifier - Additioner +reason.-5=Echantillon +reason.-6=Offert +reason.-7=Us\u00e9 +reason.-8=Rectifier - Soustraire \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_messages_hr.properties b/src/main/resources/com/unicenta/reports/inventory_messages_hr.properties new file mode 100644 index 0000000..98c3c53 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_messages_hr.properties @@ -0,0 +1,11 @@ +label.max=Maksimum +label.name=Ime +label.printed=Ispisano +label.ref=\u0160ifra +label.sec=Sigurnost +label.title=Skladi\u0161ta +label.units=Komada +label.valuebuy=Nabavna vrijednost +label.valuecost=Tro\u0161kovi +label.valuesell=Prodajna vrijednost +label.valuevolume=Koli\u010dina diff --git a/src/main/resources/com/unicenta/reports/inventory_messages_it.properties b/src/main/resources/com/unicenta/reports/inventory_messages_it.properties new file mode 100644 index 0000000..65eb01a --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_messages_it.properties @@ -0,0 +1,12 @@ +label.location=Posto : +label.max=Massimo +label.name=Nome +label.printed=Stampato +label.ref=Rif. +label.sec=Minimo +label.title=Inventario: Posizione e Categoria +label.units=Unit\u00e0 +label.valuebuy=Valore di Costo +label.valuecost=Costo +label.valuesell=Valore al Dettaglio +label.valuevolume=Volume \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/inventory_messages_nl.properties b/src/main/resources/com/unicenta/reports/inventory_messages_nl.properties new file mode 100644 index 0000000..e17dfc7 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/inventory_messages_nl.properties @@ -0,0 +1,62 @@ +label.account=Account +label.accountname=Accountnaam +label.category=Categorie : +label.code=Code +label.date=Datum +label.diff=Verschil +label.in=In +label.location=Plaats : +label.max=Max. +label.min=Min. +label.name=Naam +label.out=Uit +label.period=Periode: +label.price=eenheid Waarde +label.pricebuy=Prijs Bestel +label.pricesell=\nPrijs Verkopen +label.printed=Afgedrukt +label.product=Artikel +label.productname=productnaam +label.qty=Qty +label.reason=Aantal stuks +label.ref=Ref. +label.reference=Referentie +label.sec=Min. +label.sumdiff=Totaal Verschil +label.sumin=Total In +label.sumout=Total Uit +label.supplier=Leverancier +label.supplierdoc=Doc. Ref. +label.suppliername=Naam van leverancier +label.taxid=Account ID +label.title.broken=Inventory: Gebroken +label.title.current=Inventory: Actueel +label.title.diary=Inventory Diary +label.title.diffdetail=Inventaris: Verschil Detail +label.title.difference=Inventaris: Verschil +label.title.inventory=Inventaris: Location en categorie +label.title.listdetail=Inventaris: Lijst Detail +label.title=Voorraadlijst: Locatie en Categorie +label.total=Totaal +label.totalG=Eindtotaal\n +label.totalP=Bedrag +label.ttype=Type +label.units.instock=Op voorraad +label.units=Aantal +label.uom=UOM +label.valuebuy=Inkoop waarde +label.valuecost=Kosten +label.valuesell=Verkoop waarde +label.valuevolume=Volume +reason.1=Aankoop Leverancie +reason.-1=Verkoop +reason.1000=Overdracht +reason.2=Keer terug naar de klant +reason.-2=Keer terug naar leverancier +reason.-3=Breken +reason.-4=Aanpassen - minus +reason.4=Aanpassen - toe te voegen +reason.-5=Voorbeeld - Uit +reason.-6=Gratis +reason.-7=Gebruikt +reason.-8=Corrigeren - minus \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_barcode_sheet.bs b/src/main/resources/com/unicenta/reports/labels_barcode_sheet.bs new file mode 100644 index 0000000..6727816 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_barcode_sheet.bs @@ -0,0 +1,26 @@ + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.BarcodeSheet"); +report.setReport("/com/unicenta/reports/labels_barcode_sheet"); +report.setResourceBundle("com/unicenta/reports/labels_messages"); + +report.setSentence("SELECT " + + "products.CODE, products.CODETYPE, products.NAME, " + + "categories.ID AS CATEGORY, " + + "categories.NAME AS CATEGORYNAME " + + "FROM products LEFT OUTER JOIN categories ON products.CATEGORY = categories.ID " + + "WHERE ?(QBF_FILTER) " + + "ORDER BY categories.NAME, products.NAME"); + +report.addParameter("products.NAME"); +report.addParameter("products.CATEGORY"); +report.addParameter("products.CODE"); +report.addQBFFilter(new com.unicenta.pos.ticket.ProductFilter4()); + +report.addField("CODE", com.unicenta.data.loader.Datas.STRING); +report.addField("CODETYPE", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); + +report; + diff --git a/src/main/resources/com/unicenta/reports/labels_barcode_sheet.jrxml b/src/main/resources/com/unicenta/reports/labels_barcode_sheet.jrxml new file mode 100644 index 0000000..144e544 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_barcode_sheet.jrxml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + <band splitType="Stretch"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/labels_barcode_shelfedge.bs b/src/main/resources/com/unicenta/reports/labels_barcode_shelfedge.bs new file mode 100644 index 0000000..6165da9 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_barcode_shelfedge.bs @@ -0,0 +1,57 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.BarcodeSheet"); +report.setReport("/com/unicenta/reports/labels_barcode_shelfedge"); +report.setResourceBundle("com/unicenta/reports/labels_messages"); + +report.setSentence("SELECT " + + "products.ID, products.REFERENCE, " + + "products.CODE, products.CODETYPE, products.NAME, " + + "products.PRICEBUY, products.PRICESELL, " + + "T.ID AS TAX, T.RATE + 1 AS TAXRATE, " + + "categories.ID AS CATEGORY, categories.NAME AS CATEGORYNAME, " + + "products.SUPPLIER " + + "FROM products LEFT OUTER JOIN categories " + + "ON products.CATEGORY = categories.ID " + + "LEFT OUTER JOIN taxes T ON products.TAXCAT = T.ID " + + "WHERE ?(QBF_FILTER) " + + "ORDER BY products.NAME"); + +report.addParameter("products.NAME"); +report.addParameter("products.CATEGORY"); +report.addParameter("products.CODE"); +report.addQBFFilter(new com.unicenta.pos.ticket.ProductFilter4()); + +report.addField("ID", com.unicenta.data.loader.Datas.STRING); +report.addField("REFERENCE", com.unicenta.data.loader.Datas.STRING); +report.addField("CODE", com.unicenta.data.loader.Datas.STRING); +report.addField("CODETYPE", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("PRICEBUY", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("PRICESELL", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TAX", com.unicenta.data.loader.Datas.STRING); +report.addField("TAXRATE", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("CATEGORY", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORYNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("SUPPLIER", com.unicenta.data.loader.Datas.STRING); + +report \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_barcode_shelfedge.jrxml b/src/main/resources/com/unicenta/reports/labels_barcode_shelfedge.jrxml new file mode 100644 index 0000000..d297814 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_barcode_shelfedge.jrxml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/labels_messages.properties b/src/main/resources/com/unicenta/reports/labels_messages.properties new file mode 100644 index 0000000..471c2b5 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_messages.properties @@ -0,0 +1,4 @@ +label.printed=Printed +label.sellprice=Sell Price Net +label.tax=Tax +label.title=Product Labels \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_messages_al_SQ.properties b/src/main/resources/com/unicenta/reports/labels_messages_al_SQ.properties new file mode 100644 index 0000000..fc83e26 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_messages_al_SQ.properties @@ -0,0 +1,3 @@ +label.printed=Printuar +label.tax=Tax +label.title=Etiketa e Produktit \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_messages_ar.properties b/src/main/resources/com/unicenta/reports/labels_messages_ar.properties new file mode 100644 index 0000000..43833b8 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_messages_ar.properties @@ -0,0 +1,3 @@ +label.printed=\u0645\u0637\u0628\u0648\u0639 +label.tax=Tax +label.title=\u0645\u0633\u0645\u064a\u0627\u062a \u0627\u0644\u0645\u0646\u062a\u062c\u0627\u062a \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_messages_de.properties b/src/main/resources/com/unicenta/reports/labels_messages_de.properties new file mode 100644 index 0000000..428139e --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_messages_de.properties @@ -0,0 +1,3 @@ +label.printed=Erstellt am: +label.tax=Steuer +label.title=Produkt-Etiketten \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_messages_el.properties b/src/main/resources/com/unicenta/reports/labels_messages_el.properties new file mode 100644 index 0000000..91904fd --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_messages_el.properties @@ -0,0 +1,3 @@ +label.printed=Printed +label.tax=\u03a6\u03cc\u03c1\u03bf\u03c2 +label.title=\u0395\u03c4\u03b9\u03ba\u03ad\u03c4\u03b5\u03c2 \u03a0\u03c1\u03bf\u03b9\u03cc\u03bd\u03c4\u03c9\u03bd \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_messages_en_US.properties b/src/main/resources/com/unicenta/reports/labels_messages_en_US.properties new file mode 100644 index 0000000..471c2b5 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_messages_en_US.properties @@ -0,0 +1,4 @@ +label.printed=Printed +label.sellprice=Sell Price Net +label.tax=Tax +label.title=Product Labels \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_messages_es.properties b/src/main/resources/com/unicenta/reports/labels_messages_es.properties new file mode 100644 index 0000000..80b57d4 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_messages_es.properties @@ -0,0 +1,2 @@ +label.printed=Imprimir +label.title=Etiquetas de productos \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_messages_es_AR.properties b/src/main/resources/com/unicenta/reports/labels_messages_es_AR.properties new file mode 100644 index 0000000..4da07e3 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_messages_es_AR.properties @@ -0,0 +1,3 @@ +label.printed=Impreso +label.tax=Impuesto +label.title=Etiquetas de productos \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_messages_es_MX.properties b/src/main/resources/com/unicenta/reports/labels_messages_es_MX.properties new file mode 100644 index 0000000..4da07e3 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_messages_es_MX.properties @@ -0,0 +1,3 @@ +label.printed=Impreso +label.tax=Impuesto +label.title=Etiquetas de productos \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_messages_et.properties b/src/main/resources/com/unicenta/reports/labels_messages_et.properties new file mode 100644 index 0000000..8b1bbfb --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_messages_et.properties @@ -0,0 +1,4 @@ +label.printed=Tr\u00fckitud +label.sellprice= +label.tax=KM +label.title=Hinnasildid \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_messages_fr.properties b/src/main/resources/com/unicenta/reports/labels_messages_fr.properties new file mode 100644 index 0000000..4a3b547 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_messages_fr.properties @@ -0,0 +1,3 @@ +label.printed=Imprim\u00e9 +label.tax=TVA +label.title=Etiquettes produits \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_messages_hr.properties b/src/main/resources/com/unicenta/reports/labels_messages_hr.properties new file mode 100644 index 0000000..b13d35a --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_messages_hr.properties @@ -0,0 +1,3 @@ +label.printed=Ispisano +label.tax=Porez +label.title=Natpisi artikala \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_messages_it.properties b/src/main/resources/com/unicenta/reports/labels_messages_it.properties new file mode 100644 index 0000000..82576f5 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_messages_it.properties @@ -0,0 +1,4 @@ +label.printed=Stampato +label.sellprice= +label.tax=Tassa +label.title=Etichette Prodotto \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_messages_nl.properties b/src/main/resources/com/unicenta/reports/labels_messages_nl.properties new file mode 100644 index 0000000..fee6472 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_messages_nl.properties @@ -0,0 +1,3 @@ +label.printed=Afgedrukt +label.tax=BTW +label.title=Artikel Etiketten \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_product.bs b/src/main/resources/com/unicenta/reports/labels_product.bs new file mode 100644 index 0000000..696331f --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_product.bs @@ -0,0 +1,61 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.ProductLabels"); +report.setReport("/com/unicenta/reports/labels_product"); +report.setResourceBundle("com/unicenta/reports/labels_messages"); + +report.setSentence("SELECT " + + "MIN(products.ID), MIN(products.REFERENCE), MIN(products.CODE), MIN(products.CODETYPE), " + + "MIN(products.NAME), MIN(products.PRICEBUY), " + + "MIN(products.PRICESELL), MIN(T.ID) AS TAX, MIN(T.RATE) + 1 AS TAXRATE, " + + "MIN(categories.ID) AS CATEGORY, MIN(categories.NAME) AS CATEGORYNAME, " + + "MIN(products.SUPPLIER) " + + "FROM ((products products " + + "INNER JOIN stockcurrent stockcurrent " + + "ON (products.ID = stockcurrent.PRODUCT)) " + + "LEFT OUTER JOIN categories categories " + + "ON (products.CATEGORY = categories.ID)) " + + "LEFT OUTER JOIN taxes T " + + "ON (products.TAXCAT = T.ID) " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY products.REFERENCE " + + "ORDER BY MIN(categories.NAME), MIN(products.NAME)"); + +report.addParameter("products.NAME"); +report.addParameter("products.CATEGORY"); +report.addParameter("products.CODE"); +report.addQBFFilter(new com.unicenta.pos.ticket.ProductFilter4()); + +report.addField("ID", com.unicenta.data.loader.Datas.STRING); +report.addField("REFERENCE", com.unicenta.data.loader.Datas.STRING); +report.addField("CODE", com.unicenta.data.loader.Datas.STRING); +report.addField("CODETYPE", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("PRICEBUY", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("PRICESELL", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TAX", com.unicenta.data.loader.Datas.STRING); +report.addField("TAXRATE", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("CATEGORY", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORYNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("SUPPLIER", com.unicenta.data.loader.Datas.STRING); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/labels_product.jrxml b/src/main/resources/com/unicenta/reports/labels_product.jrxml new file mode 100644 index 0000000..14420f7 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/labels_product.jrxml @@ -0,0 +1,262 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="52"> + <rectangle radius="5"> + <reportElement key="rectangle-2" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="5c281873-3dc7-42c0-8c1b-1ecda14173ee"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-8" mode="Transparent" x="0" y="0" width="375" height="28" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="fbe1c2be-2e4e-47fe-a698-33db213f1c60"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField" x="400" y="15" width="135" height="15" uuid="10007690-4424-46f9-926c-58149342cb7f"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="400" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="0493b45e-04a3-450c-a80b-e41cd6bc5f88"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/logo.png b/src/main/resources/com/unicenta/reports/logo.png new file mode 100644 index 0000000..78fd3b8 Binary files /dev/null and b/src/main/resources/com/unicenta/reports/logo.png differ diff --git a/src/main/resources/com/unicenta/reports/products.bs b/src/main/resources/com/unicenta/reports/products.bs new file mode 100644 index 0000000..914eb05 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products.bs @@ -0,0 +1,69 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.Products"); +report.setReport("/com/unicenta/reports/products"); +report.setResourceBundle("com/unicenta/reports/products_messages"); + +report.setSentence("SELECT products.ID, " + + "MIN(products.REFERENCE), " + + "MIN(products.CODE), " + + "MIN(products.NAME), " + + "MIN(products.PRICEBUY), " + + "MIN(products.PRICESELL), " + + "MIN(T.ID) AS TAX, " + + "MIN(T.RATE) + 1 AS TAXRATE, " + + "MIN(categories.ID) AS CATEGORY, " + + "MIN(categories.NAME) AS CATEGORYNAME, " + + "MIN(stockcurrent.UNITS) " + + "FROM ((products products " + + "INNER JOIN taxes T " + + "ON (products.taxcat = T.id)) " + + "INNER JOIN categories categories " + + "ON (products.category = categories.id)) " + + "LEFT OUTER JOIN stockcurrent stockcurrent " + + "ON (stockcurrent.product = products.id) " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY products.ID " + + "ORDER BY CATEGORYNAME ASC, MIN(products.NAME) ASC"); + +report.addParameter("stockcurrent.LOCATION"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsLocationWithFirst()); + +report.addParameter("products.NAME"); +report.addParameter("products.CATEGORY"); +report.addParameter("products.CODE"); +report.addParameter("stockcurrent.UNITS"); +report.addQBFFilter(new com.unicenta.pos.ticket.ProductFilter1()); + +report.addField("ID", com.unicenta.data.loader.Datas.STRING); +report.addField("REFERENCE", com.unicenta.data.loader.Datas.STRING); +report.addField("CODE", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("PRICEBUY", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("PRICESELL", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TAX", com.unicenta.data.loader.Datas.STRING); +report.addField("TAXRATE", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("CATEGORY", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORYNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("UNITS", com.unicenta.data.loader.Datas.DOUBLE); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/products.jrxml b/src/main/resources/com/unicenta/reports/products.jrxml new file mode 100644 index 0000000..afbc1f4 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products.jrxml @@ -0,0 +1,374 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/products_catalog.bs b/src/main/resources/com/unicenta/reports/products_catalog.bs new file mode 100644 index 0000000..1ebafe7 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_catalog.bs @@ -0,0 +1,51 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.Catalog"); +report.setReport("/com/unicenta/reports/products"); +report.setResourceBundle("com/unicenta/reports/products_messages"); + +report.setSentence("SELECT " + + "products.ID, MIN(products.REFERENCE), MIN(products.CODE), MIN(products.NAME), " + + "MIN(products.PRICEBUY), MIN(products.PRICESELL), " + + "MIN(TC.ID) AS TAXCAT, MIN(TC.NAME) AS TAXCATNAME, " + + "MIN(categories.ID)AS CATEGORY, MIN(categories.NAME) AS CATEGORYNAME, " + + "MIN(products.UNITS) " + + "FROM products LEFT OUTER JOIN categories ON products.CATEGORY = categories.ID " + + "LEFT OUTER JOIN TAXcategories TC ON products.TAXCAT = TC.ID " + + "WHERE ?(QBF_FILTER) " + + "ORDER BY categories.NAME, MIN(products.NAME)"); + +report.addParameter("categories.ID"); +report.addQBFFilter(new com.unicenta.pos.ticket.CategoryFilter()); + +report.addField("ID", com.unicenta.data.loader.Datas.STRING); +report.addField("REFERENCE", com.unicenta.data.loader.Datas.STRING); +report.addField("CODE", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("PRICEBUY", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("PRICESELL", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TAXCAT", com.unicenta.data.loader.Datas.STRING); +report.addField("TAXCATNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORY", com.unicenta.data.loader.Datas.STRING); +report.addField("CATEGORYNAME", com.unicenta.data.loader.Datas.STRING); + +report; diff --git a/src/main/resources/com/unicenta/reports/products_messages.properties b/src/main/resources/com/unicenta/reports/products_messages.properties new file mode 100644 index 0000000..7c61efc --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_messages.properties @@ -0,0 +1,40 @@ +# uniCenta oPOS - Touch Friendly Point Of Sale +# Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +# https://unicenta.com/projects/unicentaopos +# +# This file is part of uniCenta oPOS. +# +# uniCenta oPOS 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. +# +# uniCenta oPOS 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 uniCenta oPOS. If not, see . + +label.title=Product List +label.printed=Printed + +label.ref=Ref. +label.code=Barcode +label.name=Name +label.units=Qty +label.cost=Buy Price +label.pricebuy=Buy Price +label.pricenet=Sell Net +label.pricegross=Sell Gross + +label.title=Product Catalogue +label.printed=Printed +label.ref=Ref. +label.name=Name +label.cost=Cost +label.price=Price Nett +label.taxname=Tax +label.taxrate=(No Tax Rate found) +label.pricetax=Price Gross diff --git a/src/main/resources/com/unicenta/reports/products_messages_al_SQ.properties b/src/main/resources/com/unicenta/reports/products_messages_al_SQ.properties new file mode 100644 index 0000000..8e10543 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_messages_al_SQ.properties @@ -0,0 +1,38 @@ +# uniCenta oPOS - Touch Friendly Point Of Sale +# Copyright (c) 2009-2013 uniCenta & previous Openbravo POS works +# https://unicenta.com/projects/unicentaopos +# +# This file is part of uniCenta oPOS. +# +# uniCenta oPOS 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. +# +# uniCenta oPOS 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 uniCenta oPOS. If not, see . + +label.title=Lista e Produkteve +label.printed=Printuar +label.ref=Ref. +label.name=Emri +label.cost=Kosotoja +label.price=Cmimi Nett +label.taxname=Tatimi +label.taxrate=Shkalla e Tatimit +label.pricetax=Cmimi Bruto + +label.title=Katalogu i Produkteve +label.printed=Printuar +label.ref=Ref. +label.name=Emri +label.cost=Kosotoja +label.price=Cmiimi Neto +label.taxname=Tatimi +label.taxrate=(Ska shkalle Tatimi) +label.pricetax=Cmimi Bruto \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/products_messages_ar.properties b/src/main/resources/com/unicenta/reports/products_messages_ar.properties new file mode 100644 index 0000000..fbbaec1 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_messages_ar.properties @@ -0,0 +1,39 @@ +# uniCenta oPOS - touch friendly EPoS +# Copyright (c) 2009 uniCenta oPOS +# https://unicenta.com/projects/unicentaopos +# +# This file is part of uniCenta oPOS. +# +# uniCenta oPOS 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. +# +# uniCenta oPOS 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 uniCenta oPOS. If not, see . + +label.title=\u0642\u0627\u0626\u0645\u0629 \u0627\u0644\u0645\u0646\u062a\u062c\u0627\u062a +label.printed=\u0645\u0637\u0628\u0648\u0639 +label.ref=\u0645\u0631\u062c\u0639. +label.name=\u0627\u0633\u0645 +label.cost=\u062a\u0643\u0644\u0641\u0629 +label.price=\u0635\u0627\u0641\u064a \u0627\u0644\u062a\u0643\u0644\u0641\u0629 +label.taxname=\u0636\u0631\u064a\u0628\u0629 +label.taxrate=\u0646\u0633\u0628\u0629 \u0627\u0644\u0636\u0631\u064a\u0628\u0629 +label.pricetax=\u0627\u0644\u0633\u0639\u0631 \u0627\u0644\u0627\u062c\u0645\u0627\u0644\u064a + +label.title=\u0643\u0627\u062a\u0644\u0648\u062c \u0627\u0644\u0645\u0646\u062a\u062c +label.printed=\u0645\u0637\u0628\u0648\u0639 +label.ref=\u0645\u0631\u062c\u0639. +label.name=\u0627\u0644\u0627\u0633\u0645 +label.cost=\u0627\u0644\u062a\u0643\u0644\u0641\u0629 +label.price=\u0635\u0627\u0641\u0629 \u0627\u0644\u062a\u0643\u0644\u0641\u0629 +label.taxname=\u0636\u0631\u064a\u0628\u0629 +label.taxrate=(\u0644\u0645 \u064a\u062a\u0645 \u0627\u0644\u0639\u062b\u0648\u0631 \u0639\u0644\u0649 \u0646\u0633\u0628\u0629 \u0627\u0644\u0636\u0631\u064a\u0628\u0629) +label.pricetax=\u0627\u062c\u0645\u0627\u0644\u064a \u0627\u0644\u0642\u064a\u0645\u0629 + diff --git a/src/main/resources/com/unicenta/reports/products_messages_de.properties b/src/main/resources/com/unicenta/reports/products_messages_de.properties new file mode 100644 index 0000000..3505568 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_messages_de.properties @@ -0,0 +1,49 @@ +# Openbravo POS is a point of sales application designed for touch screens. +# Copyright (C) 2008 Openbravo, S.L. +# http://sourceforge.net/projects/ +# +# This program 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 2 of the License, or +# (at your option) any later version. +# +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Translations by Sebastian Muszytowski S.Muszytowski@googlemail.com +label.title=Produkt Liste + +label.ref=Ref. + +label.name=Name + +label.price=Preis (netto) + +label.taxname=Steuer + +label.taxrate=Steuersatz + +label.pricetax=Preis (Brutto) +label.cost=Kosten +label.printed=Erstellt am: + label.title=Produkt Katalog + +label.ref=Ref. + +label.name=Name + +label.price=Preis (netto) + +label.taxname=Steuer + +label.taxrate=Steuersatz + +label.pricetax=Preis (brutto) +label.printed=Erstellt am: +label.cost=Kosten diff --git a/src/main/resources/com/unicenta/reports/products_messages_el.properties b/src/main/resources/com/unicenta/reports/products_messages_el.properties new file mode 100644 index 0000000..7bdb3f9 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_messages_el.properties @@ -0,0 +1,38 @@ +# uniCenta oPOS - touch friendly EPoS +# Copyright (c) 2009 uniCenta oPOS +# https://unicenta.com/projects/unicentaopos +# +# This file is part of uniCenta oPOS. +# +# uniCenta oPOS 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. +# +# uniCenta oPOS 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 uniCenta oPOS. If not, see . + +label.title=\u039b\u03af\u03c3\u03c4\u03b1 \u03a0\u03c1\u03bf\u03b9\u03cc\u03bd\u03c4\u03c9\u03bd +label.printed=Printed +label.ref=\u0391\u03bd\u03b1\u03c6. +label.name=\u038c\u03bd\u03bf\u03bc\u03b1 +label.cost=\u039a\u03cc\u03c3\u03c4\u03bf\u03c2 +label.price=Nett \u03a4\u03b9\u03bc\u03ae +label.taxname=\u03a6\u03cc\u03c1\u03bf\u03c2 +label.taxrate=\u03a4\u03b9\u03bc\u03ae \u03a6\u03cc\u03c1\u03bf\u03c5 +label.pricetax=\u039c\u03b9\u03ba\u03c4\u03ae \u03a4\u03b9\u03bc\u03ae + +label.title=\u039a\u03b1\u03c4\u03ac\u03bb\u03bf\u03b3\u03bf\u03c2 \u03a0\u03c1\u03bf\u03b9\u03cc\u03bd\u03c4\u03c9\u03bd +label.printed=Printed +label.ref=\u0391\u03bd\u03b1\u03c6. +label.name=\u038c\u03bd\u03bf\u03bc\u03b1 +label.cost=\u039a\u03cc\u03c3\u03c4\u03bf\u03c2 +label.price=Nett \u03a4\u03b9\u03bc\u03ae +label.taxname=\u03a6\u03cc\u03c1\u03bf\u03c2 +label.taxrate=(\u0394\u03b5\u03bd \u0392\u03c1\u03ad\u03b8\u03b7\u03ba\u03b5 \u03a4\u03b9\u03bc\u03ae \u03a6\u03cc\u03c1\u03bf\u03c5) +label.pricetax=\u039c\u03b9\u03ba\u03c4\u03ae \u03a4\u03b9\u03bc\u03ae \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/products_messages_en_US.properties b/src/main/resources/com/unicenta/reports/products_messages_en_US.properties new file mode 100644 index 0000000..b1146b0 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_messages_en_US.properties @@ -0,0 +1,39 @@ +# uniCenta oPOS - Touch Friendly Point Of Sale +# Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +# https://unicenta.com/projects/unicentaopos +# +# This file is part of uniCenta oPOS. +# +# uniCenta oPOS 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. +# +# uniCenta oPOS 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 uniCenta oPOS. If not, see . + +label.title=Product List +label.printed=Printed + +label.ref=Ref. +label.name=Name +label.units=Qty +label.cost=Buy Price +label.pricebuy=Buy Price +label.pricenet=Sell Net +label.pricegross=Sell Gross + +label.title=Product Catalogue +label.printed=Printed +label.ref=Ref. +label.name=Name +label.cost=Cost +label.price=Price Nett +label.taxname=Tax +label.taxrate=(No Tax Rate found) +label.pricetax=Price Gross diff --git a/src/main/resources/com/unicenta/reports/products_messages_es.properties b/src/main/resources/com/unicenta/reports/products_messages_es.properties new file mode 100644 index 0000000..3dbee7f --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_messages_es.properties @@ -0,0 +1,38 @@ +# uniCenta oPOS - Touch Friendly Point Of Sale +# Copyright (c) 2009-2013 uniCenta & previous Openbravo POS works +# https://unicenta.com/projects/unicentaopos +# +# This file is part of uniCenta oPOS. +# +# uniCenta oPOS 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. +# +# uniCenta oPOS 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 uniCenta oPOS. If not, see . + +label.cost=Coste +label.printed=Imprimir +label.name=Nombre +label.price=Precio +label.pricetax=Precio + IVA +label.ref=Ref. +label.taxname=Impuesto +label.taxrate=Tasa de IVA +label.title=Listado de productos + +label.name=Nombre +label.printed=Imprimir +label.price=Precio +label.pricetax=Precio+IVA +label.cost=Coste +label.ref=Ref. +label.taxname=Impuesto +label.taxrate=(No se encuentra la Tasa del Impuesto) +label.title=Cat\u00e1logo de productos diff --git a/src/main/resources/com/unicenta/reports/products_messages_es_AR.properties b/src/main/resources/com/unicenta/reports/products_messages_es_AR.properties new file mode 100644 index 0000000..b526883 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_messages_es_AR.properties @@ -0,0 +1,52 @@ +# Openbravo POS is a point of sales application designed for touch screens. +# Copyright (C) 2007-2009 Openbravo, S.L. +# http://sourceforge.net/projects/openbravopos +# +# This file is part of Openbravo POS. +# +# Openbravo 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. +# +# Openbravo 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 Openbravo POS. If not, see . + +label.title=Listado de productos + +label.ref=Ref. + +label.name=Nombre + +label.price=Precio + +label.taxname=Impuesto + +label.taxrate=Tasa de impuesto + +label.pricetax=Precio + Imp. +label.cost=Costo +label.printed=Impreso +label.units=Unidades +label.pricebuy=Precio de compra +label.pricenet=Precio de Venta +label.pricegross=Precio de Venta Bruto + +label.title=Cat\u00E1logo de productos + +label.ref=Ref. + +label.name=Nombre + +label.price=Precio + +label.taxname=Impuesto + +label.taxrate= + +label.pricetax=Precio + Imp. \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/products_messages_es_MX.properties b/src/main/resources/com/unicenta/reports/products_messages_es_MX.properties new file mode 100644 index 0000000..d26e729 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_messages_es_MX.properties @@ -0,0 +1,31 @@ +# Openbravo POS is a point of sales application designed for touch screens. +# Copyright (C) 2007-2009 Openbravo, S.L. +# http://sourceforge.net/projects/openbravopos +# Author: Juan Carlos Gastlum +# This program 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. +# This program 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 Openbravo POS. If not, see . + +label.cost=Costo +label.name=Nombre +label.price=Precio +label.pricetax=Precio + Impuesto +label.ref=Ref. +label.taxname=Impuesto +label.taxrate=Tasa de impuesto +label.title=Lista de producto + +label.name=Nombre +label.price=Precio +label.pricetax=Precio + Impuesto +label.ref=Ref. +label.taxname=Impuesto +label.taxrate=Tasa de impuesto +label.title=Catlogo de producto diff --git a/src/main/resources/com/unicenta/reports/products_messages_et.properties b/src/main/resources/com/unicenta/reports/products_messages_et.properties new file mode 100644 index 0000000..87900eb --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_messages_et.properties @@ -0,0 +1,38 @@ +# uniCenta oPOS - touch friendly EPoS +# Copyright (c) 2009 uniCenta oPOS +# https://unicenta.com/projects/unicentaopos +# +# This file is part of uniCenta oPOS. +# +# uniCenta oPOS 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. +# +# uniCenta oPOS 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 uniCenta oPOS. If not, see . + +label.title=Sortiment +label.printed=Tr\u00fckitud +label.ref=Kood +label.name=Nimetus +label.cost=Ostuhind +label.price=Netohind +label.taxname=KM +label.taxrate=KM % +label.pricetax=Brutohind + +label.title=Product Catalogue +label.printed=Tr\u00fckitud +label.ref=Kood +label.name=Nimetus +label.cost=Omahind +label.price=Netohind +label.taxname=KM +label.taxrate=(maksuvaba) +label.pricetax=Brutohind \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/products_messages_fr.properties b/src/main/resources/com/unicenta/reports/products_messages_fr.properties new file mode 100644 index 0000000..c436956 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_messages_fr.properties @@ -0,0 +1,43 @@ +# Openbravo POS is a point of sales application designed for touch screens. +# Copyright (C) 2009 Openbravo, S.L. +# http://sourceforge.net/projects/openbravopos +# +# This file is part of Openbravo POS. +# +# Openbravo 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. +# +# Openbravo 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 Openbravo POS. If not, see . + +label.title=Liste des produits +label.printed=Imprim\u00e9 + +label.ref=R\u00e9f. +label.name=Nom +label.units=Unit\u00e9 +label.pricebuy=TVA +label.pricenet=Prix HT +label.pricegross=Prix TTC +label.cost=Prix de revient +label.taxname=Nom de l'imp\u00f4t +label.taxrate=Taux d'imposition +label.pricetax=Prix d'imp\u00f4t +label.price=Prix + +label.title=Catalogue des produits +label.ref=R\u00e9f. +label.name=Nom +label.price=Prix +label.taxname=Taxe +label.taxrate=Taux +label.pricetax=Prix + Taxe +label.printed=P\u00e9riode: +label.cost=Co\u00fbt diff --git a/src/main/resources/com/unicenta/reports/products_messages_hr.properties b/src/main/resources/com/unicenta/reports/products_messages_hr.properties new file mode 100644 index 0000000..a03a3f2 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_messages_hr.properties @@ -0,0 +1,53 @@ +# Openbravo POS je PC kasa koja ima podr\u0161ku i za touch screen monitore. +# Copyright (C) 2007-2009 Openbravo, S.L. +# http://sourceforge.net/projects/openbravopos +# +# Preveo na hrvatski: Pro-Sistemi +# +# Ova datoteka je dio Openbravo POS sistema. +# +# Openbravo POS je besplatan software: mo\u017eete ga distribuirati i/ili +# modificirati pod uvjetima GNU General Public Licence koja je objavljena +# od strane Free Software Foundation, bilo licencne verzije 3, ili bilo +# koje kasnije verzije ( mo\u017eda u Va\u0161em slu\u010daju ). +# +# Openbravo POS se distribuira u nadi da \u0107e biti od koristi, ali +# BEZ IKAKVE GARANCIJE; \u010dak i ako je slu\u010daj da je KUPLJEN kao roba ili +# je PREPRAVLJEN radi specifi\u010dnih potreba. Pogledajte +# GNU General Public Licencu za vi\u0161e detalja o tome. +# +# Uz Openbravo POS ste trebali dobiti kopiju GNU General Public Licence. +# Ako niste, pogledajte je na . + +label.title=Popis artikala + +label.ref=\u0160ifra + +label.name=Ime + +label.cost=Tro\u0161kovi + +label.price=Cijena + +label.taxname=Porez + +label.taxrate=Stopa poreza + +label.pricetax=Cijena+PDV +label.printed=Ispisano + +label.title=Katalog + +label.ref=\u0160ifra + +label.name=Ime + +label.price=Cijena + +label.taxname=Naziv poreza + +label.taxrate=Stopa poreza + +label.pricetax=Cijena+PDV +label.printed=Ispisano +label.cost=Ko\u0161tati diff --git a/src/main/resources/com/unicenta/reports/products_messages_it.properties b/src/main/resources/com/unicenta/reports/products_messages_it.properties new file mode 100644 index 0000000..8b327e1 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_messages_it.properties @@ -0,0 +1,39 @@ +# uniCenta oPOS - Touch Friendly Point Of Sale +# Copyright (c) 2009-2014 uniCenta & previous Openbravo POS works +# https://unicenta.com/projects/unicentaopos +# +# This file is part of uniCenta oPOS. +# +# uniCenta oPOS 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. +# +# uniCenta oPOS 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 uniCenta oPOS. If not, see . + +label.title=Lista Prodotto +label.printed=Stampato +label.ref=Rif. +label.name=Nome +label.cost=Costo +label.price=Prezzo netto +label.taxname=Tassa +label.taxrate=Perc.Tassa +label.pricetax=Prezzo lordo + +label.title=Catalogo Prodotto +label.printed=Stampato +label.ref=Rif. +label.name=Nome +label.cost=Costo +label.price=Prezzo Netto +label.taxname=Tassa +label.taxrate=Perc.Tassa +label.pricetax=Prezzo Lordo + diff --git a/src/main/resources/com/unicenta/reports/products_messages_nl.properties b/src/main/resources/com/unicenta/reports/products_messages_nl.properties new file mode 100644 index 0000000..aa88bfe --- /dev/null +++ b/src/main/resources/com/unicenta/reports/products_messages_nl.properties @@ -0,0 +1,23 @@ +# uniCenta oPOS - Translation File +# Copyright (c) 2014 J.SNijder +# You should have received a copy of the GNU General Public License +# along with uniCenta oPOS. If not, see . +label.price=Prijs +label.pricetax=Prijs + BTW +label.ref=Ref. +label.cost=Kosten +label.name=Naam +label.printed=Afgedrukt +label.taxname=BTW +label.taxrate=BTW Tarief +label.title=Artikel Lijst + +label.title=Product catalogus +label.printed=Afgedrukt +label.ref=Referentie +label.name=Naam +label.price=Prijs +label.pricetax=Prijs + BTW +label.taxname=BTW +label.taxrate=BTW Tarief +label.pricetax=Bruto Prijs \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/salecatalog.bs b/src/main/resources/com/unicenta/reports/salecatalog.bs new file mode 100644 index 0000000..1274f36 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/salecatalog.bs @@ -0,0 +1,70 @@ +// uniCenta oPOS - touch friendly EPoS +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.SaleCatalog"); +report.setReport("/com/unicenta/reports/salecatalog"); +report.setResourceBundle("com/unicenta/reports/sales_messages"); + +report.setSentence("SELECT products.id, " + + "products.reference, products.code, products.codetype, products.name, " + + "products.pricesell, products.image, " + + "T.ID AS TAX, " + + "T.RATE + 1 AS TAXRATE, " + + "categories.name AS CATEGORYNAME, suppliers.name, stockcurrent.location " + + "FROM (((products products " + + "INNER JOIN stockcurrent stockcurrent " + + "ON (products.id = stockcurrent.product)) " + + "LEFT OUTER JOIN taxes T " + + "ON (products.taxcat = T.id)) " + + "LEFT OUTER JOIN categories categories " + + "ON (products.category = categories.id)) " + + "RIGHT OUTER JOIN suppliers suppliers " + + "ON (suppliers.id = products.supplier) " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY products.REFERENCE " + + "ORDER BY CATEGORYNAME ASC, products.name ASC"); + +report.addParameter("products.NAME"); +report.addParameter("products.CATEGORY"); +report.addParameter("products.CODE"); +report.addQBFFilter(new com.unicenta.pos.ticket.ProductFilter4()); + +report.addParameter("suppliers.ID"); +report.addParameter("suppliers.NAME"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsSuppliers()); + +report.addParameter("stockcurrent.LOCATION"); +report.addQBFFilter(new com.unicenta.pos.reports.JParamsLocation()); + +report.addField("ID", com.unicenta.data.loader.Datas.STRING); +report.addField("REFERENCE", com.unicenta.data.loader.Datas.STRING); +report.addField("CODE", com.unicenta.data.loader.Datas.STRING); +report.addField("CODETYPE", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("PRICESELL", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("IMAGE", com.unicenta.data.loader.Datas.IMAGE); +report.addField("TAX", com.unicenta.data.loader.Datas.STRING); +report.addField("TAXRATE", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("CATEGORYNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("SUPPLIER", com.unicenta.data.loader.Datas.STRING); +report.addField("LOCATION", com.unicenta.data.loader.Datas.STRING); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/salecatalog.jrxml b/src/main/resources/com/unicenta/reports/salecatalog.jrxml new file mode 100644 index 0000000..35da71a --- /dev/null +++ b/src/main/resources/com/unicenta/reports/salecatalog.jrxml @@ -0,0 +1,260 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="50"> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-8" mode="Transparent" x="0" y="0" width="309" height="28" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="80a1aa76-7184-489b-a478-2b151ad471a4"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title.salecatalog}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="400" y="2" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="dfad5312-1b35-49dc-956c-5df844d460de"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField" x="400" y="15" width="135" height="15" uuid="0a60fd2f-d9f7-400c-849b-8c5c40fd7023"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <rectangle radius="5"> + <reportElement key="rectangle-1" positionType="Float" mode="Opaque" x="0" y="48" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="eb93e8b8-16bd-4449-b38b-46b559122d9a"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/sales_cashflow.bs b/src/main/resources/com/unicenta/reports/sales_cashflow.bs new file mode 100644 index 0000000..7b65ae5 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_cashflow.bs @@ -0,0 +1,49 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.CashFlow"); +report.setReport("/com/unicenta/reports/sales_cashflow"); +report.setResourceBundle("com/unicenta/reports/sales_messages"); + +report.setSentence("SELECT " + + "payments.payment AS PAYMENT, " + + "SUM(payments.total) AS PAYMENT_TOTAL " + + "FROM payments payments " + + "INNER JOIN receipts receipts " + + "ON (payments.receipt = receipts.id) " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY payments.PAYMENT"); + +report.addParameter("receipts.DATENEW"); +report.addParameter("receipts.DATENEW"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); + +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); + +report.addQBFFilter(paramdates); + +report.addField("PAYMENT", com.unicenta.data.loader.Datas.STRING); +report.addField("PAYMENT_TOTAL", com.unicenta.data.loader.Datas.DOUBLE); + +return report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/sales_cashflow.jrxml b/src/main/resources/com/unicenta/reports/sales_cashflow.jrxml new file mode 100644 index 0000000..c8b7a80 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_cashflow.jrxml @@ -0,0 +1,282 @@ + + + + + + + + + + + + + + + + + + + + + + + + <band height="52" splitType="Stretch"> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-18" mode="Transparent" x="0" y="0" width="359" height="30" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="719119ca-6588-42be-8920-ab0ae9dd2af3"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title.cashflow}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-19" mode="Opaque" x="400" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="cdb8e1d0-d102-411c-9b01-a1d63c0d85dd"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField pattern="dd/MM/yyyy h.mm a"> + <reportElement x="400" y="15" width="135" height="15" uuid="65d82e21-0306-4e0e-9602-38fca8f10033"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="0" y="33" width="50" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="ddeacb3a-15cc-4ed4-9379-be18ee319190"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.period}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-2" mode="Transparent" x="50" y="33" width="110" height="15" uuid="8b68cb01-4410-4a2a-8c44-8893cfa1f002"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.TIMESTAMP.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[1])]]></textFieldExpression> + </textField> + <staticText> + <reportElement key="staticText-1" mode="Transparent" x="160" y="33" width="10" height="15" uuid="75d2ab4b-01a7-45c7-8a38-99539f8f5d70"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[-]]></text> + </staticText> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-3" mode="Transparent" x="170" y="33" width="110" height="15" uuid="dc859b23-1301-496c-a293-06a9daaf3884"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.TIMESTAMP.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[3])]]></textFieldExpression> + </textField> + <rectangle radius="5"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="57c50ea9-42f2-4621-aa78-4b53c1882c54"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/sales_cashregisterlog.bs b/src/main/resources/com/unicenta/reports/sales_cashregisterlog.bs new file mode 100644 index 0000000..6b0ac6e --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_cashregisterlog.bs @@ -0,0 +1,54 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.CashRegisterLog"); +report.setReport("/com/unicenta/reports/sales_cashregisterlog"); +report.setResourceBundle("com/unicenta/reports/sales_messages"); + +report.setSentence("SELECT " + + "receipts.DATENEW, " + + "payments.PAYMENT, " + + "payments.TENDERED, " + + "payments.VOUCHER, " + + "SUM( payments.TOTAL ) AS PAYMENT_TOTAL " + + "FROM receipts " + + "LEFT JOIN payments ON receipts.ID = payments.RECEIPT " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY receipts.DATENEW, payments.PAYMENT, payments.VOUCHER, payments.TENDERED"); + +report.addParameter("receipts.DATENEW"); +report.addParameter("receipts.DATENEW"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); + +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); + +report.addQBFFilter(paramdates); + +report.addField("DATENEW", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("PAYMENT", com.unicenta.data.loader.Datas.STRING); +report.addField("TENDERED", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("VOUCHER", com.unicenta.data.loader.Datas.STRING); +report.addField("PAYMENT_TOTAL", com.unicenta.data.loader.Datas.DOUBLE); + +return report; diff --git a/src/main/resources/com/unicenta/reports/sales_cashregisterlog.jrxml b/src/main/resources/com/unicenta/reports/sales_cashregisterlog.jrxml new file mode 100644 index 0000000..2e402ba --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_cashregisterlog.jrxml @@ -0,0 +1,349 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="52"> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-18" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="e3a2ba03-2172-4bbb-a42a-8bf7806711c9"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title.log}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="400" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="d53e31d3-82c2-4203-bb1f-53bc5386fc8e"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField" x="400" y="15" width="135" height="15" uuid="46dfb1b5-1e60-480e-9567-610bafc2a6a7"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-2" mode="Transparent" x="50" y="33" width="110" height="15" uuid="a6131305-2a85-4bec-bd05-01ae378af777"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.TIMESTAMP.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[1])]]></textFieldExpression> + </textField> + <staticText> + <reportElement key="staticText-1" mode="Transparent" x="160" y="33" width="10" height="15" uuid="6e3621ee-b4ef-4e21-b74b-a889dafe4e03"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[- +]]></text> + </staticText> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-3" mode="Transparent" x="170" y="33" width="110" height="15" uuid="da098e9d-9aa8-4204-b03c-11c8f48fc67a"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.TIMESTAMP.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[3])]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-19" mode="Opaque" x="0" y="33" width="50" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="c0ef4e9f-e8d0-4661-8ca5-d69d16867540"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.period}]]></textFieldExpression> + </textField> + <rectangle radius="5"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="69b5c545-111b-46dd-9096-6534ca869233"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/sales_categorysales.bs b/src/main/resources/com/unicenta/reports/sales_categorysales.bs new file mode 100644 index 0000000..f39387b --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_categorysales.bs @@ -0,0 +1,64 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.CategorySales"); +report.setReport("/com/unicenta/reports/sales_categorysales"); +report.setResourceBundle("com/unicenta/reports/sales_messages"); + +report.setSentence("SELECT " + + "MIN(R.datenew), " + + "C.id, " + + "MIN(C.name) AS CATNAME, " + + "SUM(TL.price * TL.units) AS BASE, " + + "SUM((TL.price * TL.units) * TX.rate) AS AMOUNT," + + "SUM((TL.PRICE+(TL.PRICE*TX.RATE))*TL.units) AS TOTAL, " + + "SUM(TL.units) AS UNITS " + + "FROM (((((products P " + + "INNER JOIN categories C ON (P.category = C.id)) " + + "INNER JOIN ticketlines TL ON (TL.product = P.id)) " + + "INNER JOIN taxes TX ON (TL.taxid = TX.id)) " + + "INNER JOIN tickets T ON (TL.ticket = T.id)) " + + "INNER JOIN receipts R ON (T.id = R.id)) " + + "INNER JOIN taxlines TXL ON (TXL.receipt = R.id) AND (TXL.taxid = TX.id) " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY C.id " + + "ORDER BY CATNAME ASC"); + +report.addParameter("R.DATENEW"); +report.addParameter("R.DATENEW"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); +report.addQBFFilter(paramdates); + +report.addParameter("C.id"); +report.addQBFFilter(new com.unicenta.pos.ticket.CategoryFilter()); + +report.addField("DATENEW", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("ID", com.unicenta.data.loader.Datas.STRING); +report.addField("CATNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("BASE", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("AMOUNT", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TOTAL", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("UNITS", com.unicenta.data.loader.Datas.DOUBLE); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/sales_categorysales.jrxml b/src/main/resources/com/unicenta/reports/sales_categorysales.jrxml new file mode 100644 index 0000000..a52ba83 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_categorysales.jrxml @@ -0,0 +1,414 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="52" splitType="Stretch"> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-18" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="4d32d804-f652-40d0-b010-f8c395891f1f"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title.categorysummary}]]></textFieldExpression> + </textField> + <rectangle radius="5"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="f5d49fc0-1c80-40c2-965e-6ff5565d6bc2"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + <staticText> + <reportElement key="staticText-1" mode="Transparent" x="160" y="33" width="10" height="15" uuid="5bd23888-387c-448e-82b0-6ed6e30160d1"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[- +]]></text> + </staticText> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-2" mode="Transparent" x="50" y="33" width="110" height="15" uuid="6e5dda44-dbe4-47ac-93d4-38091d8ac933"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.TIMESTAMP.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[1])]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-3" mode="Transparent" x="170" y="33" width="110" height="15" uuid="7640f4fe-7d8e-4c02-870f-3db1a0968b2e"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.TIMESTAMP.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[3])]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="0" y="33" width="50" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="819abf64-0b00-4f78-90c0-a205f280a4d5"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.period}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-19" mode="Opaque" x="400" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="856e5694-73c1-4106-a3fb-33ad751e11c8"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField" x="400" y="15" width="135" height="15" forecolor="#000000" uuid="aeacadd7-d1ae-4806-a915-4e13fd313442"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/sales_categorysales_1.bs b/src/main/resources/com/unicenta/reports/sales_categorysales_1.bs new file mode 100644 index 0000000..e5d2bd7 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_categorysales_1.bs @@ -0,0 +1,69 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see +// + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.CategorySales1"); +report.setReport("/com/unicenta/reports/sales_categorysales_1"); +report.setResourceBundle("com/unicenta/reports/sales_messages"); + +report.setSentence("SELECT " + + "MIN(R.datenew), " + + "MIN(C.id) AS CATID, " + + "C.name AS CATNAME, " + + "MIN((CASE WHEN C_1.NAME='' THEN C.NAME ELSE C_1.name END)) AS PARENTCAT, " + + "P.name AS PRODNAME, " + + "SUM(TL.price * TL.units) AS BASE, " + + "SUM((TL.price * TL.units) * TX.rate) AS AMOUNT, " + + "SUM((TL.PRICE + (TL.PRICE * TX.RATE)) * TL.units) AS TOTAL, " + + "SUM(TL.units) AS UNITS " + + "FROM ((((((products P " + + "INNER JOIN categories C ON (P.category = C.id)) " + + "INNER JOIN ticketlines TL ON (TL.product = P.id)) " + + "INNER JOIN taxes TX ON (TL.taxid = TX.id)) " + + "INNER JOIN tickets T ON (TL.ticket = T.id)) " + + "INNER JOIN receipts R ON (T.id = R.id)) " + + "INNER JOIN taxlines TXL ON (TXL.receipt = R.id) AND (TXL.taxid = TX.id)) " + + "INNER JOIN categories C_1 ON (C_1.id = C.id) " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY C.name, P.name"); + +report.addParameter("R.DATENEW"); +report.addParameter("R.DATENEW"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); +report.addQBFFilter(paramdates); + +report.addParameter("C.id"); +report.addQBFFilter(new com.unicenta.pos.ticket.CategoryFilter()); + +report.addField("DATENEW", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("CATID", com.unicenta.data.loader.Datas.STRING); +report.addField("CATNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("PARENTCAT", com.unicenta.data.loader.Datas.STRING); +report.addField("PRODNAME", com.unicenta.data.loader.Datas.STRING); +report.addField("BASE", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("AMOUNT", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TOTAL", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("UNITS", com.unicenta.data.loader.Datas.DOUBLE); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/sales_categorysales_1.jrxml b/src/main/resources/com/unicenta/reports/sales_categorysales_1.jrxml new file mode 100644 index 0000000..b0b491d --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_categorysales_1.jrxml @@ -0,0 +1,541 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="52" splitType="Stretch"> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-18" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="b60f4d62-3352-4d45-8d95-d3fa31792d97"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title.categorydetail}]]></textFieldExpression> + </textField> + <rectangle radius="5"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="ee35d675-ffe7-4083-9b97-ce225ed03abe"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + <staticText> + <reportElement key="staticText-1" mode="Transparent" x="160" y="33" width="10" height="15" uuid="6bffc985-5a90-412a-98e0-a3bd5a83cfb1"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[- +]]></text> + </staticText> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-2" mode="Transparent" x="50" y="33" width="110" height="15" uuid="e857b8c5-fb1a-4ade-84e7-86fbc7087dfb"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.TIMESTAMP.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[1])]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-3" mode="Transparent" x="170" y="33" width="110" height="15" uuid="a381929c-e913-4eba-accf-6d9bcd169228"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.TIMESTAMP.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[3])]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="0" y="33" width="50" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="c6a42663-ccab-466b-97a1-1839e7cd27ba"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.period}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-19" mode="Opaque" x="400" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="8c3691fc-492a-449c-a813-edbd78f24b5f"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField" x="400" y="15" width="135" height="15" forecolor="#000000" uuid="3d17baec-27c3-4855-9036-64c1285b135d"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/sales_categorysalesmysql.bs b/src/main/resources/com/unicenta/reports/sales_categorysalesmysql.bs new file mode 100644 index 0000000..fc5bcff --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_categorysalesmysql.bs @@ -0,0 +1,58 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.CategorySales"); +report.setReport("/com/unicenta/reports/sales_categorysales"); +report.setResourceBundle("com/unicenta/reports/sales_messages"); + +// JG - 8 Jan 14 Convert lowercasednname to UPPERCASE for compatability + +report.setSentence("SELECT categories.NAME, " + +"Sum(ticketlines.UNITS) AS QTY, " + +"Sum(ticketlines.PRICE * ticketlines.UNITS) AS CATPRICE, " + +"Sum((products.PRICESELL * ticketlines.UNITS)-((products.ISVPRICE ) * (ticketlines.PRICE * ticketlines.UNITS))) AS DISC, " + +"Sum((ticketlines.PRICE * taxes.RATE)* ticketlines.UNITS) AS CATTAX, " + +"Sum((ticketlines.PRICE * ticketlines.UNITS) + ((ticketlines.PRICE * taxes.RATE)* ticketlines.UNITS)) AS CATTOTAL " + +"FROM (tickets INNER JOIN receipts ON tickets.ID = receipts.ID) INNER JOIN ((categories INNER JOIN products ON categories.ID = products.CATEGORY) INNER JOIN (taxes INNER JOIN ticketlines ON taxes.ID = ticketlines.TAXID) ON products.ID = ticketlines.PRODUCT) ON tickets.ID = ticketlines.TICKET " + +"WHERE ?(QBF_FILTER) " + +"GROUP BY categories.NAME"); + +report.addParameter("receipts.DATENEW"); +report.addParameter("receipts.DATENEW"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); + +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); + +report.addQBFFilter(paramdates); + +report.addField("ID", com.unicenta.data.loader.Datas.STRING); +report.addField("PARENTID", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("QTY", com.unicenta.data.loader.Datas.STRING); +report.addField("CATPRICE", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("DISC", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("CATTAX", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("CATTOTAL", com.unicenta.data.loader.Datas.DOUBLE); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/sales_chart_piesalescat.bs b/src/main/resources/com/unicenta/reports/sales_chart_piesalescat.bs new file mode 100644 index 0000000..a54bd7a --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_chart_piesalescat.bs @@ -0,0 +1,54 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.CategoryProductSalesChart"); +report.setReport("/com/unicenta/reports/sales_chart_piesalescat"); +report.setResourceBundle("com/unicenta/reports/sales_messages"); + +report.setSentence("SELECT "+ + "categories.NAME AS CAT, " + + "SUM(ticketlines.UNITS) AS UNITS, " + + "SUM(ticketlines.PRICE * ticketlines.UNITS) AS TOTAL " + + "FROM ticketlines " + + "LEFT OUTER JOIN products ON ticketlines.PRODUCT = products.ID " + + "LEFT OUTER JOIN categories ON products.CATEGORY = categories.ID " + + "LEFT OUTER JOIN tickets ON ticketlines.TICKET = tickets.ID " + + "LEFT OUTER JOIN receipts ON tickets.ID = receipts.ID " + + "WHERE LENGTH(categories.NAME) > 1 AND ?(QBF_FILTER) " + + "GROUP BY categories.ID, categories.NAME "+ + "ORDER BY categories.NAME ASC"); + +report.addParameter("receipts.DATENEW"); +report.addParameter("receipts.DATENEW"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); + +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); + +report.addQBFFilter(paramdates); + +report.addField("CAT", com.unicenta.data.loader.Datas.STRING); +report.addField("UNITS", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TOTAL", com.unicenta.data.loader.Datas.DOUBLE); + +report; diff --git a/src/main/resources/com/unicenta/reports/sales_chart_piesalescat.jrxml b/src/main/resources/com/unicenta/reports/sales_chart_piesalescat.jrxml new file mode 100644 index 0000000..ccb1742 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_chart_piesalescat.jrxml @@ -0,0 +1,292 @@ + + + + + + + + + + + + + 1 +GROUP BY + CATEGORIES.ID +ORDER BY + CATEGORIES.NAME ASC]]> + + + + + + <band height="52"> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-25" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="19688817-97de-4b9b-a334-4b8f8625314e"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title.pie}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="400" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="f33b28ea-36f1-4503-bc8c-3a6b46d66d83"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="EEEEE dd MMMMM yyyy" isBlankWhenNull="false"> + <reportElement key="textField" x="400" y="19" width="135" height="15" uuid="f410a7e8-5d4b-4448-b007-eb9da73a5402"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-19" mode="Opaque" x="0" y="33" width="50" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="b49ae8ea-e94e-4a2d-8101-885c9047a2df"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.period}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-8" mode="Transparent" x="50" y="33" width="110" height="15" uuid="ae1392ff-2cf7-4645-ad5a-4d9ed609aac4"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.DATE.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[1])]]></textFieldExpression> + </textField> + <staticText> + <reportElement key="staticText-1" mode="Transparent" x="160" y="33" width="10" height="15" uuid="89d6c90c-cae6-4cce-b522-567439026d8a"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[- +]]></text> + </staticText> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-9" mode="Transparent" x="170" y="33" width="110" height="15" uuid="0eec4fd4-123f-4443-a2af-92179893c836"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.DATE.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[3])]]></textFieldExpression> + </textField> + <rectangle radius="5"> + <reportElement key="rectangle-2" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="dddf65d2-d40f-407d-b1b0-00207c11558b"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/sales_chart_pro_test.bs b/src/main/resources/com/unicenta/reports/sales_chart_pro_test.bs new file mode 100644 index 0000000..8238058 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_chart_pro_test.bs @@ -0,0 +1,60 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.ProductSales"); +report.setReport("/com/unicenta/reports/sales_chart_pro_test"); +report.setResourceBundle("com/unicenta/reports/sales_messages"); + +report.setSentence( + "SELECT " + + "products.REFERENCE, " + + "products.NAME, " + + "SUM(ticketlines.UNITS) AS UNITS, " + + "SUM(ticketlines.UNITS * ticketlines.PRICE) AS TOTAL " + + "FROM receipts, tickets, ticketlines, products " + + "WHERE receipts.ID = tickets.ID AND tickets.ID = ticketlines.TICKET AND ticketlines.PRODUCT = products.ID AND ?(QBF_FILTER) " + + "GROUP BY products.REFERENCE, products.NAME " + + "ORDER BY products.NAME"); + +report.addParameter("receipts.DATENEW"); +report.addParameter("receipts.DATENEW"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); + +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); + +report.addQBFFilter(paramdates); +report.addParameter("products.NAME"); +report.addParameter("products.PRICEBUY"); +report.addParameter("products.PRICESELL"); +report.addParameter("products.CATEGORY"); +report.addParameter("products.CODE"); +report.addQBFFilter(new com.unicenta.pos.ticket.ProductFilter()); + +report.addField("REFERENCE", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("UNITS", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TOTAL", com.unicenta.data.loader.Datas.DOUBLE); + +report; + diff --git a/src/main/resources/com/unicenta/reports/sales_chart_pro_test.jrxml b/src/main/resources/com/unicenta/reports/sales_chart_pro_test.jrxml new file mode 100644 index 0000000..24e8cbe --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_chart_pro_test.jrxml @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + + + + <band height="52"> + <rectangle radius="5"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="09c85ec6-ef9a-41eb-910d-7777c6e487e0"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-1" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="aaf15cbc-0ac1-4d3c-a061-23234dc784fd"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title.product}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-2" mode="Transparent" x="50" y="33" width="110" height="15" uuid="16775a43-7b4c-47b0-8a78-10556ed05255"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.DATE.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[1])]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-3" mode="Transparent" x="170" y="33" width="110" height="15" uuid="b8440b59-f6e6-4367-919e-9eaa6b328261"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.DATE.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[3])]]></textFieldExpression> + </textField> + <staticText> + <reportElement key="staticText-1" mode="Transparent" x="160" y="33" width="10" height="15" uuid="08ce72be-51c1-4d3b-b5d7-3cf6aea719f2"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[- +]]></text> + </staticText> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="0" y="33" width="50" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="f229e5ad-bc57-408c-826d-abcf49b027c2"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.period}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-19" mode="Opaque" x="400" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="6c2a1a42-f2db-43e0-894b-85bb761a59be"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField" x="400" y="20" width="135" height="15" uuid="93925f65-97c8-464a-8338-205be0097ef1"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/sales_chart_productsales.bs b/src/main/resources/com/unicenta/reports/sales_chart_productsales.bs new file mode 100644 index 0000000..93ef729 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_chart_productsales.bs @@ -0,0 +1,60 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.ProductSales"); +report.setReport("/com/unicenta/reports/sales_chart_productsales"); +report.setResourceBundle("com/unicenta/reports/sales_messages"); + +report.setSentence( + "SELECT " + + "products.REFERENCE, " + + "products.NAME, " + + "SUM(ticketlines.UNITS) AS UNITS, " + + "SUM(ticketlines.UNITS * ticketlines.PRICE) AS TOTAL " + + "FROM receipts, tickets, ticketlines, products " + + "WHERE receipts.ID = tickets.ID AND tickets.ID = ticketlines.TICKET AND ticketlines.PRODUCT = products.ID AND ?(QBF_FILTER) " + + "GROUP BY products.REFERENCE, products.NAME " + + "ORDER BY products.NAME"); + +report.addParameter("receipts.DATENEW"); +report.addParameter("receipts.DATENEW"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); + +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); + +report.addQBFFilter(paramdates); +report.addParameter("products.NAME"); +report.addParameter("products.PRICEBUY"); +report.addParameter("products.PRICESELL"); +report.addParameter("products.CATEGORY"); +report.addParameter("products.CODE"); +report.addQBFFilter(new com.unicenta.pos.ticket.ProductFilter()); + +report.addField("REFERENCE", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("UNITS", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("TOTAL", com.unicenta.data.loader.Datas.DOUBLE); + +report; + diff --git a/src/main/resources/com/unicenta/reports/sales_chart_productsales.jrxml b/src/main/resources/com/unicenta/reports/sales_chart_productsales.jrxml new file mode 100644 index 0000000..8489da7 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_chart_productsales.jrxml @@ -0,0 +1,225 @@ + + + + + + + + + + + + + + + + + + + + + + + <band height="52"> + <rectangle radius="5"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="50" width="535" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="09c85ec6-ef9a-41eb-910d-7777c6e487e0"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-1" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="aaf15cbc-0ac1-4d3c-a061-23234dc784fd"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title.product}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-2" mode="Transparent" x="50" y="33" width="110" height="15" uuid="16775a43-7b4c-47b0-8a78-10556ed05255"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.DATE.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[1])]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-3" mode="Transparent" x="170" y="33" width="110" height="15" uuid="b8440b59-f6e6-4367-919e-9eaa6b328261"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.DATE.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[3])]]></textFieldExpression> + </textField> + <staticText> + <reportElement key="staticText-1" mode="Transparent" x="160" y="33" width="10" height="15" uuid="08ce72be-51c1-4d3b-b5d7-3cf6aea719f2"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[- +]]></text> + </staticText> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="0" y="33" width="50" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="f229e5ad-bc57-408c-826d-abcf49b027c2"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.period}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-19" mode="Opaque" x="400" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="6c2a1a42-f2db-43e0-894b-85bb761a59be"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField" x="400" y="20" width="135" height="15" uuid="93925f65-97c8-464a-8338-205be0097ef1"/> + <textElement textAlignment="Right"> + <font fontName="SansSerif" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/sales_chart_sales.bs b/src/main/resources/com/unicenta/reports/sales_chart_sales.bs new file mode 100644 index 0000000..4e42855 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_chart_sales.bs @@ -0,0 +1,52 @@ +// uniCenta oPOS - Touch Friendly Point Of Sale +// Copyright (c) 2009-201 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.SalesChart"); +report.setReport("/com/unicenta/reports/sales_chart_sales"); +report.setResourceBundle("com/unicenta/reports/sales_messages"); + +report.setSentence("SELECT categories.ID, categories.NAME, " + + "Sum(ticketlines.UNITS) AS QTY," + + "Sum((ticketlines.PRICE * ticketlines.UNITS) + ((ticketlines.PRICE * taxes.RATE)* ticketlines.UNITS)) AS CATTOTAL " + + "FROM (tickets INNER JOIN receipts ON tickets.ID = receipts.ID) " + + "INNER JOIN ((categories INNER JOIN products ON categories.ID = products.CATEGORY) " + + "INNER JOIN (taxes INNER JOIN ticketlines ON taxes.ID = ticketlines.TAXID) " + + "ON products.ID = ticketlines.PRODUCT) ON tickets.ID = ticketlines.TICKET " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY categories.ID, categories.NAME"); + +report.addParameter("receipts.DATENEW"); +report.addParameter("receipts.DATENEW"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); + +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); + +report.addQBFFilter(paramdates); + +report.addField("ID", com.unicenta.data.loader.Datas.STRING); +report.addField("NAME", com.unicenta.data.loader.Datas.STRING); +report.addField("QTY", com.unicenta.data.loader.Datas.DOUBLE); +report.addField("CATTOTAL", com.unicenta.data.loader.Datas.DOUBLE); + +report; diff --git a/src/main/resources/com/unicenta/reports/sales_chart_sales.jrxml b/src/main/resources/com/unicenta/reports/sales_chart_sales.jrxml new file mode 100644 index 0000000..618c8c0 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_chart_sales.jrxml @@ -0,0 +1,221 @@ + + + + + + + + + + + + + + + + + + + + + + + <band height="54"> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Transparent" x="0" y="0" width="375" height="30" forecolor="#33CCFF" backcolor="#FFFFFF" uuid="69e44e6c-86e5-4946-bc7d-81347f487361"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None"> + <font fontName="SansSerif" size="14" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.title.bycategory}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-19" mode="Opaque" x="647" y="0" width="135" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="e23f830c-8dc9-4980-b64c-ecadac76dc80"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Top" rotation="None"> + <font fontName="Arial" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.printed}]]></textFieldExpression> + </textField> + <textField evaluationTime="Report" pattern="dd/MM/yyyy h.mm a" isBlankWhenNull="false"> + <reportElement key="textField" x="647" y="14" width="135" height="15" uuid="95b8b2fa-9438-4151-83ea-6572050592de"/> + <textElement textAlignment="Right"> + <font fontName="Arial" size="10"/> + </textElement> + <textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="false"> + <reportElement key="textField-10" mode="Opaque" x="0" y="33" width="50" height="15" forecolor="#000000" backcolor="#FFFFFF" uuid="bb5128eb-b94e-44cc-ace9-d4db9f47ae91"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[$R{label.period}]]></textFieldExpression> + </textField> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-8" mode="Transparent" x="50" y="33" width="110" height="15" uuid="4fb626d6-608a-4c7c-a4c0-085b9b433e16"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Right" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.TIMESTAMP.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[1])]]></textFieldExpression> + </textField> + <staticText> + <reportElement key="staticText-6" mode="Transparent" x="160" y="33" width="10" height="15" uuid="330aadca-d0f0-4844-962c-68bde20d553b"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Center" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <text><![CDATA[- +]]></text> + </staticText> + <textField pattern="" isBlankWhenNull="true"> + <reportElement key="textField-9" mode="Transparent" x="170" y="33" width="110" height="15" uuid="4bd37982-8136-4a3a-886c-b1f35b6c5d08"/> + <box> + <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/> + <bottomPen lineWidth="0.0" lineColor="#000000"/> + <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#FFFFFF"/> + </box> + <textElement textAlignment="Left" verticalAlignment="Middle" rotation="None"> + <font fontName="SansSerif" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/> + <paragraph lineSpacing="Single"/> + </textElement> + <textFieldExpression><![CDATA[com.unicenta.format.Formats.TIMESTAMP.formatValue((java.util.Date)((Object[])((Object[])$P{ARG})[0])[3])]]></textFieldExpression> + </textField> + <rectangle radius="5"> + <reportElement key="rectangle-1" mode="Opaque" x="0" y="50" width="782" height="2" forecolor="#33CCFF" backcolor="#33CCFF" uuid="618299eb-99bb-42b7-bd70-53fe43f20329"/> + <graphicElement fill="Solid"> + <pen lineWidth="0.25" lineStyle="Solid"/> + </graphicElement> + </rectangle> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/unicenta/reports/sales_chart_timeseriesproduct.bs b/src/main/resources/com/unicenta/reports/sales_chart_timeseriesproduct.bs new file mode 100644 index 0000000..1e1770b --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_chart_timeseriesproduct.bs @@ -0,0 +1,73 @@ +// uniCenta oPOS - touch friendly EPoS +// Copyright (c) 2009-2018 uniCenta & previous Openbravo POS works +// https://unicenta.com +// +// This file is part of uniCenta oPOS +// +// uniCenta oPOS 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. +// +// uniCenta oPOS 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 uniCenta oPOS. If not, see . + +report = new com.unicenta.pos.reports.PanelReportBean(); + +report.setTitleKey("Menu.TimeSeriesProduct"); +report.setReport("/com/unicenta/reports/sales_chart_timeseriesproduct"); +report.setResourceBundle("com/unicenta/reports/sales_messages"); + +report.setSentence("SELECT " + + "MIN(products.code) AS code, " + + "MIN(products.codetype) AS codetype, " + + "MIN(products.reference) AS prodref, " + + "MIN(products.name) AS prodname, " + + "DATE(receipts.datenew) AS datesold, " + + "MIN(receipts.datenew) AS datestamp, " + + "count(ticketlines.UNITS) AS unitssold " + + "FROM ((ticketlines ticketlines " + + "INNER JOIN products products " + + "ON (ticketlines.PRODUCT = products.id)) " + + "INNER JOIN tickets tickets " + + "ON (TICKET = tickets.id)) " + + "INNER JOIN receipts receipts " + + "ON (tickets.id = receipts.id) " + + "WHERE ?(QBF_FILTER) " + + "GROUP BY DATE(receipts.datenew) " + + "ORDER BY 5 ASC"); + +report.addParameter("receipts.DATENEW"); +report.addParameter("receipts.DATENEW"); + +paramdates = new com.unicenta.pos.reports.JParamsDatesInterval(); + +paramdates.setStartDate(com.unicenta.beans.DateUtils.getToday()); +// JG - 8 Jan 14 paramdates.setEndDate(com.unicenta.beans.DateUtils.getToday()); +paramdates.setEndDate(com.unicenta.beans.DateUtils.getTodayMinutes()); + +report.addQBFFilter(paramdates); + +report.addParameter("products.NAME"); +//report.addParameter("products.ID"); +report.addParameter("products.CATEGORY"); +report.addParameter("products.PRICEBUY"); +report.addParameter("products.PRICESELL"); +report.addParameter("products.CODE"); + +report.addQBFFilter(new com.unicenta.pos.ticket.ProductFilter2()); + +report.addField("code", com.unicenta.data.loader.Datas.STRING); +report.addField("codetype", com.unicenta.data.loader.Datas.STRING); +report.addField("prodref", com.unicenta.data.loader.Datas.STRING); +report.addField("prodname", com.unicenta.data.loader.Datas.STRING); +report.addField("datesold", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("datestamp", com.unicenta.data.loader.Datas.TIMESTAMP); +report.addField("unitssold", com.unicenta.data.loader.Datas.DOUBLE); + +report; \ No newline at end of file diff --git a/src/main/resources/com/unicenta/reports/sales_chart_timeseriesproduct.jrxml b/src/main/resources/com/unicenta/reports/sales_chart_timeseriesproduct.jrxml new file mode 100644 index 0000000..8a67864 --- /dev/null +++ b/src/main/resources/com/unicenta/reports/sales_chart_timeseriesproduct.jrxml @@ -0,0 +1,292 @@ + + + + + + + + + + +