diff --git a/src/main/java/com/openbravo/pos/customers/DataLogicCustomers.java b/src/main/java/com/openbravo/pos/customers/DataLogicCustomers.java index 4285b48..26a5a4e 100755 --- a/src/main/java/com/openbravo/pos/customers/DataLogicCustomers.java +++ b/src/main/java/com/openbravo/pos/customers/DataLogicCustomers.java @@ -24,6 +24,7 @@ import com.openbravo.format.Formats; import com.openbravo.pos.forms.AppLocal; import com.openbravo.pos.forms.BeanFactoryDataSingle; +import com.openbravo.pos.forms.DataLogicSales; /** * @author JG uniCenta @@ -48,6 +49,36 @@ public class DataLogicCustomers extends BeanFactoryDataSingle { Datas.BOOLEAN, Datas.STRING}; + private static final String[] fields = new String[] + { + "ID", + "TAXID", + "SEARCHKEY", + "NAME", + "NOTES", + "VISIBLE", + "CARD", + "MAXDEBT", + "CURDATE", + "CURDEBT", + "FIRSTNAME", + "LASTNAME", + "EMAIL", + "PHONE", + "PHONE2", + "FAX", + "ADDRESS", + "ADDRESS2", + "POSTAL", + "CITY", + "REGION", + "COUNTRY", + "TAXCATEGORY", + "IMAGE" + }; + + private static String baseSentence; + /** * * @param s @@ -58,31 +89,7 @@ public void init(Session s){ this.s = s; tcustomers = new TableDefinition(s , "CUSTOMERS" - , new String[] { - "ID", - "TAXID", - "SEARCHKEY", - "NAME", - "NOTES", - "VISIBLE", - "CARD", - "MAXDEBT", - "CURDATE", - "CURDEBT", - "FIRSTNAME", - "LASTNAME", - "EMAIL", - "PHONE", - "PHONE2", - "FAX", - "ADDRESS", - "ADDRESS2", - "POSTAL", - "CITY", - "REGION", - "COUNTRY", - "TAXCATEGORY", - "IMAGE" } + , fields , new String[] { "ID", AppLocal.getIntString("label.taxid"), @@ -160,6 +167,14 @@ public void init(Session s){ Formats.NULL } , new int[] {0} ); + + StringBuilder sqlBuilder = new StringBuilder("SELECT "); + for (int i = 0; i < fields.length; i++) { + sqlBuilder.append(fields[i]); + sqlBuilder.append(", "); + } + sqlBuilder.append(" FROM CUSTOMERS"); + this.baseSentence = sqlBuilder.toString(); } // JG 20 Sept 12 extended for Postal - CustomerList list @@ -299,5 +314,18 @@ public int execInTransaction(Object params) throws BasicException { */ public final TableDefinition getTableCustomers() { return tcustomers; - } + } + + public CustomerInfoExt findCustomersBy(String field, Object value) { + + StringBuilder sqlBuilder = new StringBuilder(this.baseSentence); + sqlBuilder.append(" WHERE "); + sqlBuilder.append(field); + sqlBuilder.append(" = ?"); + + PreparedSentence sentence = new PreparedSentence(this.s, sqlBuilder.toString()); + + // will be implemented for next release + return null; + } } \ No newline at end of file diff --git a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java index 6a6a67c..7d81edd 100644 --- a/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java +++ b/src/main/java/com/openbravo/pos/imports/CustomersImportPanel.java @@ -16,16 +16,12 @@ */ package com.openbravo.pos.imports; -import com.openbravo.basic.BasicException; -import com.openbravo.data.loader.SentenceExec; -import com.openbravo.pos.customers.JPanelCustomerFields; import com.openbravo.data.user.EditorRecord; import com.openbravo.data.user.SaveProvider; import com.openbravo.pos.customers.DataLogicCustomers; +import com.openbravo.pos.customers.JPanelCustomerFields; import com.openbravo.pos.customers.JPanelCustomerList; import com.unicenta.pozapps.forms.AppLocal; -import java.util.logging.Level; -import java.util.logging.Logger; public class CustomersImportPanel extends JPanelCsvImporter { @Override