Attached Files | posterminal_v1.diff [^] (9,278 bytes) 2016-06-01 17:34 [Show Content] [Hide Content]diff --git a/src/org/openbravo/retail/posterminal/BrandProductHQLCriteria.java b/src/org/openbravo/retail/posterminal/BrandProductHQLCriteria.java
--- a/src/org/openbravo/retail/posterminal/BrandProductHQLCriteria.java
+++ b/src/org/openbravo/retail/posterminal/BrandProductHQLCriteria.java
@@ -10,6 +10,9 @@
import javax.enterprise.context.ApplicationScoped;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONTokener;
import org.openbravo.client.kernel.ComponentProvider.Qualifier;
import org.openbravo.mobile.core.process.HQLCriteriaProcess;
@@ -32,12 +35,16 @@
}
private String[] getParams(String params) {
- String[] array_params = new String[params.length()];
- String[] array = (params.substring(1, params.length() - 1)).split(",");
- for (int i = 0; i < array.length; i++) {
- array_params[i] = array[i].substring(1, array[i].length() - 1);
+ try {
+ JSONArray array = new JSONArray(new JSONTokener(params));
+ String[] array_params = new String[array.length()];
+ for (int i = 0; i < array.length(); i++) {
+ array_params[i] = array.getString(i);
+ }
+ return array_params;
+ } catch (JSONException e) {
+ return new String[] { "%", "__all__" };
}
- return array_params;
}
public String getAllQuery() {
@@ -45,7 +52,7 @@
}
public String getProdCategoryQuery() {
- return " exists (select 1 from Product as p where p.brand.id = brand.id and upper(p.name) like upper ('$1') and p.productCategory.id = '$2')";
+ return " exists (select 1 from Product as p where p.brand.id = brand.id and upper(p.name) like upper ('$1') and p.productCategory.id in ( $2 ))";
}
public String getBestsellers() {
diff --git a/src/org/openbravo/retail/posterminal/PCharacteristicHQLCriteria.java b/src/org/openbravo/retail/posterminal/PCharacteristicHQLCriteria.java
--- a/src/org/openbravo/retail/posterminal/PCharacteristicHQLCriteria.java
+++ b/src/org/openbravo/retail/posterminal/PCharacteristicHQLCriteria.java
@@ -10,6 +10,9 @@
import javax.enterprise.context.ApplicationScoped;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONTokener;
import org.openbravo.client.kernel.ComponentProvider.Qualifier;
import org.openbravo.mobile.core.process.HQLCriteriaProcess;
@@ -32,12 +35,16 @@
}
private String[] getParams(String params) {
- String[] array_params = new String[params.length()];
- String[] array = (params.substring(1, params.length() - 1)).split(",");
- for (int i = 0; i < array.length; i++) {
- array_params[i] = array[i].substring(1, array[i].length() - 1);
+ try {
+ JSONArray array = new JSONArray(new JSONTokener(params));
+ String[] array_params = new String[array.length()];
+ for (int i = 0; i < array.length(); i++) {
+ array_params[i] = array.getString(i);
+ }
+ return array_params;
+ } catch (JSONException e) {
+ return new String[] { "%", "__all__" };
}
- return array_params;
}
public String getAllQuery() {
diff --git a/src/org/openbravo/retail/posterminal/ProductCharacteristicHQLCriteria.java b/src/org/openbravo/retail/posterminal/ProductCharacteristicHQLCriteria.java
--- a/src/org/openbravo/retail/posterminal/ProductCharacteristicHQLCriteria.java
+++ b/src/org/openbravo/retail/posterminal/ProductCharacteristicHQLCriteria.java
@@ -10,6 +10,9 @@
import javax.enterprise.context.ApplicationScoped;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONTokener;
import org.openbravo.client.kernel.ComponentProvider.Qualifier;
import org.openbravo.mobile.core.process.HQLCriteriaProcess;
@@ -32,12 +35,16 @@
}
private String[] getParams(String params) {
- String[] array_params = new String[params.length()];
- String[] array = (params.substring(1, params.length() - 1)).split(",");
- for (int i = 0; i < array.length; i++) {
- array_params[i] = array[i].substring(1, array[i].length() - 1);
+ try {
+ JSONArray array = new JSONArray(new JSONTokener(params));
+ String[] array_params = new String[array.length()];
+ for (int i = 0; i < array.length(); i++) {
+ array_params[i] = array.getString(i);
+ }
+ return array_params;
+ } catch (JSONException e) {
+ return new String[] { "%", "__all__" };
}
- return array_params;
}
public String getAllQuery() {
diff --git a/web/org.openbravo.retail.posterminal/js/components/modalproductbrand.js b/web/org.openbravo.retail.posterminal/js/components/modalproductbrand.js
--- a/web/org.openbravo.retail.posterminal/js/components/modalproductbrand.js
+++ b/web/org.openbravo.retail.posterminal/js/components/modalproductbrand.js
@@ -125,7 +125,7 @@
}
} else {
var productFilterText = inSender.parent.parent.$.multiColumn.$.rightPanel.$.toolbarpane.$.searchCharacteristic.$.searchCharacteristicTabContent.$.searchProductCharacteristicHeader.$.productFilterText.getValue();
- var productcategory = inSender.parent.parent.$.multiColumn.$.rightPanel.$.toolbarpane.$.searchCharacteristic.$.searchCharacteristicTabContent.$.searchProductCharacteristicHeader.$.productcategory.getValue();
+ var productCategory = inSender.parent.parent.$.multiColumn.$.rightPanel.$.toolbarpane.$.searchCharacteristic.$.searchCharacteristicTabContent.getProductCategoryFilter();
var remoteCriteria = [],
characteristicValue = [],
characteristic = [],
@@ -134,12 +134,13 @@
productText;
criteria = {};
if (products.collection.length > 0) {
- if (productFilterText !== "" || productcategory !== "__all__") {
+ if (productFilterText !== "" || productCategory.value !== "__all__") {
+ var productCat = inSender.parent.parent.$.multiColumn.$.rightPanel.$.toolbarpane.$.searchCharacteristic.$.searchCharacteristicTabContent.$.searchProductCharacteristicHeader.getSelectedCategories();
brandfilter.columns = [];
brandfilter.operator = OB.Dal.FILTER;
brandfilter.value = this.brandValueFilterQualifier;
productText = (OB.MobileApp.model.hasPermission('OBPOS_remote.product' + OB.Dal.USESCONTAINS, true) ? '%' : '') + productFilterText + '%';
- brandfilter.params = [productText, productcategory];
+ brandfilter.params = [productText, productCategory.filter ? productCategory.params[0] : productCat.indexOf('OBPOS_bestsellercategory') >= 0 ? 'OBPOS_bestsellercategory' : [productCategory.value]];
remoteCriteria.push(brandfilter);
}
}
diff --git a/web/org.openbravo.retail.posterminal/js/components/modalproductcharacteristic.js b/web/org.openbravo.retail.posterminal/js/components/modalproductcharacteristic.js
--- a/web/org.openbravo.retail.posterminal/js/components/modalproductcharacteristic.js
+++ b/web/org.openbravo.retail.posterminal/js/components/modalproductcharacteristic.js
@@ -179,10 +179,10 @@
return true;
}
- var productFilterText, productcategory, productCharacteristicModel;
+ var productFilterText, productCategory, productCharacteristicModel;
productFilterText = inSender.parent.parent.$.multiColumn.$.rightPanel.$.toolbarpane.$.searchCharacteristic.$.searchCharacteristicTabContent.$.searchProductCharacteristicHeader.$.productFilterText.getValue();
- productcategory = inSender.parent.parent.$.multiColumn.$.rightPanel.$.toolbarpane.$.searchCharacteristic.$.searchCharacteristicTabContent.$.searchProductCharacteristicHeader.$.productcategory.getValue();
+ productCategory = inSender.parent.parent.$.multiColumn.$.rightPanel.$.toolbarpane.$.searchCharacteristic.$.searchCharacteristicTabContent.getProductCategoryFilter();
productCharacteristicModel = inSender.parent.parent.$.multiColumn.$.rightPanel.$.toolbarpane.$.searchCharacteristic.$.searchCharacteristicTabContent.$.searchProductCharacteristicHeader.parent.model;
var remoteCriteria = [],
@@ -216,12 +216,13 @@
}
}
- if (productFilterText !== "" || productcategory !== "__all__") {
+ if (productFilterText !== "" || productCategory.value !== "__all__") {
+ var productCat = inSender.parent.parent.$.multiColumn.$.rightPanel.$.toolbarpane.$.searchCharacteristic.$.searchCharacteristicTabContent.$.searchProductCharacteristicHeader.getSelectedCategories();
productFilter.columns = [];
productFilter.operator = OB.Dal.FILTER;
productFilter.value = this.productCharacteristicValueFilterQualifier;
productText = (OB.MobileApp.model.hasPermission('OBPOS_remote.product' + OB.Dal.USESCONTAINS, true) ? '%' : '') + productFilterText + '%';
- productFilter.params = [productText, productcategory];
+ productFilter.params = [productText, productCategory.filter ? productCategory.params[0] : productCat.indexOf('OBPOS_bestsellercategory') >= 0 ? 'OBPOS_bestsellercategory' : [productCategory.value]];
remoteCriteria.push(productFilter);
}
if (me.parent.parent.model.get('filter').length > 0) {
mobile-core_v1.diff [^] (7,058 bytes) 2016-06-01 17:38 [Show Content] [Hide Content]diff --git a/web/org.openbravo.mobile.core/source/retail/component/ob-retail-searchproductcharacteristic.js b/web/org.openbravo.mobile.core/source/retail/component/ob-retail-searchproductcharacteristic.js
--- a/web/org.openbravo.mobile.core/source/retail/component/ob-retail-searchproductcharacteristic.js
+++ b/web/org.openbravo.mobile.core/source/retail/component/ob-retail-searchproductcharacteristic.js
@@ -1134,6 +1134,49 @@
this.$.renderLoading.hide();
this.$.products.show();
},
+ getProductCategoryFilter: function () {
+ var productCategory = null,
+ productCat = this.$.searchProductCharacteristicHeader.getSelectedCategories();
+ if (productCat === "'__all__'" || productCat.indexOf('OBPOS_bestsellercategory') !== -1) {
+ productCategory = {
+ columns: ['productCategory'],
+ operator: 'equals',
+ value: '__all__',
+ isId: true
+ };
+ } else if (productCat.indexOf("'") === 0) {
+ //TODO: improve the way packs and combos are handled
+ if (productCat.indexOf('7899A7A4204749AD92881133C4EE7A57') === -1 && productCat.indexOf('BE5D42E554644B6AA262CCB097753951') === -1) {
+ var paramIDs = [];
+ productCat.split(', ').forEach(function (catId) {
+ paramIDs.push(catId.replace("'", '').replace("'", ''));
+ });
+ productCategory = {
+ columns: [],
+ operator: OB.Dal.FILTER,
+ value: 'Category_Tree_Filter',
+ filter: 'Category_Tree_Filter',
+ params: [paramIDs]
+ };
+ } else {
+ //pack or combo selected
+ productCategory = {
+ columns: ['productCategory'],
+ operator: 'equals',
+ value: productCat.replace("'", '').replace("'", ''),
+ isId: true
+ };
+ }
+ } else {
+ productCategory = {
+ columns: ['productCategory'],
+ operator: 'equals',
+ value: productCat,
+ isId: true
+ };
+ }
+ return productCategory;
+ },
searchAction: function (inSender, inEvent) {
this.$.products.hide();
this.$.renderLoading.show();
@@ -1347,12 +1390,7 @@
characteristicfilter = {},
brandfilter = {},
chFilter = {},
- productCategory = {
- columns: ['productCategory'],
- operator: 'equals',
- value: inEvent.productCat,
- isId: true
- };
+ productCategory = me.getProductCategoryFilter();
var productText;
if (me.model.get('brandFilter').length > 0) {
@@ -1370,13 +1408,13 @@
}
}
- if (productFilterText !== undefined && productcategory !== undefined) {
- if (!_.isEmpty(productFilterText.getValue()) || (productcategory.getValue() && productcategory.getValue() !== "__all__")) {
+ if (productFilterText !== undefined && productCategory) {
+ if (!_.isEmpty(productFilterText.getValue()) || productCategory.value !== "__all__") {
characteristicfilter.columns = [];
characteristicfilter.operator = OB.Dal.FILTER;
characteristicfilter.value = me.productCharacteristicFilterQualifier;
productText = (OB.MobileApp.model.hasPermission('OBPOS_remote.product' + OB.Dal.USESCONTAINS, true) ? '%' : '') + productFilterText.getValue() + '%';
- characteristicfilter.params = [productText, productcategory.getValue()];
+ characteristicfilter.params = [productText, productCategory.filter ? productCategory.params[0] : inEvent.productCat.indexOf('OBPOS_bestsellercategory') >= 0 ? 'OBPOS_bestsellercategory' : [productCategory.value]];
remoteCriteria.push(characteristicfilter);
}
}
@@ -1531,7 +1569,8 @@
characteristic = [],
characteristicValue = [];
var brandfilter = {},
- productCategory, productCategoryElem, characteristicfilter = {
+ productCategory = me.getProductCategoryFilter(),
+ characteristicfilter = {
columns: [],
operator: OB.Dal.FILTER,
value: 'Characteristic_Filter',
@@ -1549,60 +1588,21 @@
fieldType: 'forceString'
};
- if (inEvent.productCat === "'__all__'") {
- productCategory = {
- columns: ['productCategory'],
- operator: 'equals',
- value: '__all__',
- isId: true
- };
- } else if (inEvent.productCat.indexOf('OBPOS_bestsellercategory') !== -1) {
- productCategory = {
- columns: ['productCategory'],
- operator: 'equals',
- value: '__all__',
- isId: true
- };
- var bestsellers = {
- columns: ['bestseller'],
- operator: 'equals',
- value: true,
- boolean: true
- };
- remoteCriteria.push(bestsellers);
- } else if (inEvent.productCat.indexOf("'") === 0) {
- //TODO: improve the way packs and combos are handled
- if (inEvent.productCat.indexOf('7899A7A4204749AD92881133C4EE7A57') === -1 && inEvent.productCat.indexOf('BE5D42E554644B6AA262CCB097753951') === -1) {
- var paramIDs = [];
- inEvent.productCat.split(', ').forEach(function (catId) {
- paramIDs.push(catId.replace("'", '').replace("'", ''));
- });
- productCategoryElem = {
- columns: [],
- operator: OB.Dal.FILTER,
- value: 'Category_Tree_Filter',
- filter: 'Category_Tree_Filter',
- params: [paramIDs]
+ if (inEvent.productCat !== "'__all__'") {
+ if (inEvent.productCat.indexOf('OBPOS_bestsellercategory') !== -1) {
+ var bestsellers = {
+ columns: ['bestseller'],
+ operator: 'equals',
+ value: true,
+ boolean: true
};
- remoteCriteria.push(productCategoryElem);
- remoteCriteria.push(ispack);
- } else {
- //pack or combo selected
- productCategory = {
- columns: ['productCategory'],
- operator: 'equals',
- value: inEvent.productCat.replace("'", '').replace("'", ''),
- isId: true
- };
+ remoteCriteria.push(bestsellers);
+ } else if (inEvent.productCat.indexOf("'") === 0) {
+ //TODO: improve the way packs and combos are handled
+ if (inEvent.productCat.indexOf('7899A7A4204749AD92881133C4EE7A57') === -1 && inEvent.productCat.indexOf('BE5D42E554644B6AA262CCB097753951') === -1) {
+ remoteCriteria.push(ispack);
+ }
}
-
- } else {
- productCategory = {
- columns: ['productCategory'],
- operator: 'equals',
- value: inEvent.productCat,
- isId: true
- };
}
if (this.model.get('brandFilter').length > 0) {
for (i = 0; i < this.model.get('brandFilter').length; i++) {
mobile-core_v2.diff [^] (1,050 bytes) 2016-06-23 12:27 [Show Content] [Hide Content]diff --git a/web/org.openbravo.mobile.core/source/retail/component/ob-retail-searchproductcharacteristic.js b/web/org.openbravo.mobile.core/source/retail/component/ob-retail-searchproductcharacteristic.js
--- a/web/org.openbravo.mobile.core/source/retail/component/ob-retail-searchproductcharacteristic.js
+++ b/web/org.openbravo.mobile.core/source/retail/component/ob-retail-searchproductcharacteristic.js
@@ -1141,7 +1141,7 @@
productCategory = {
columns: ['productCategory'],
operator: 'equals',
- value: '__all__',
+ value: productCat.indexOf('OBPOS_bestsellercategory') !== -1 ? 'OBPOS_bestsellercategory' : '__all__',
isId: true
};
} else if (productCat.indexOf("'") === 0) {
@@ -1596,6 +1596,7 @@
value: true,
boolean: true
};
+ productCategory = null;
remoteCriteria.push(bestsellers);
} else if (inEvent.productCat.indexOf("'") === 0) {
//TODO: improve the way packs and combos are handled
mobile-core_v3.diff [^] (2,357 bytes) 2016-06-27 11:41 [Show Content] [Hide Content]diff --git a/web/org.openbravo.mobile.core/source/retail/component/ob-retail-searchproductcharacteristic.js b/web/org.openbravo.mobile.core/source/retail/component/ob-retail-searchproductcharacteristic.js
--- a/web/org.openbravo.mobile.core/source/retail/component/ob-retail-searchproductcharacteristic.js
+++ b/web/org.openbravo.mobile.core/source/retail/component/ob-retail-searchproductcharacteristic.js
@@ -1366,14 +1366,12 @@
function filterProductCharacterisctics() {
synchId = OB.UTIL.SynchronizationHelper.busyUntilFinishes('filterProductCharacterisctics');
- var productFilterText, productcategory;
+ var productFilterText;
var brandparams = [];
if (inSender.$.searchProductCharacteristicHeader !== undefined) {
productFilterText = inSender.$.searchProductCharacteristicHeader.$.productFilterText;
- productcategory = inSender.$.searchProductCharacteristicHeader.$.productcategory;
} else {
productFilterText = inSender.$.productFilterText;
- productcategory = inSender.$.productcategory;
}
if (me.model.get('brandFilter').length > 0) {
for (i = 0; i < me.model.get('brandFilter').length; i++) {
@@ -1410,11 +1408,12 @@
if (productFilterText !== undefined && productCategory) {
if (!_.isEmpty(productFilterText.getValue()) || productCategory.value !== "__all__") {
+ var category = inEvent.productCat.indexOf('OBPOS_bestsellercategory') >= 0 ? 'OBPOS_bestsellercategory' : (inEvent.productCat.indexOf('__all__') >= 0 ? '__all__' : [productCategory.value]);
characteristicfilter.columns = [];
characteristicfilter.operator = OB.Dal.FILTER;
characteristicfilter.value = me.productCharacteristicFilterQualifier;
productText = (OB.MobileApp.model.hasPermission('OBPOS_remote.product' + OB.Dal.USESCONTAINS, true) ? '%' : '') + productFilterText.getValue() + '%';
- characteristicfilter.params = [productText, productCategory.filter ? productCategory.params[0] : inEvent.productCat.indexOf('OBPOS_bestsellercategory') >= 0 ? 'OBPOS_bestsellercategory' : [productCategory.value]];
+ characteristicfilter.params = [productText, productCategory.filter ? productCategory.params[0] : category];
remoteCriteria.push(characteristicfilter);
}
}
posterminal_v2.diff [^] (3,575 bytes) 2016-06-27 11:42 [Show Content] [Hide Content]diff --git a/web/org.openbravo.retail.posterminal/js/components/modalproductbrand.js b/web/org.openbravo.retail.posterminal/js/components/modalproductbrand.js
--- a/web/org.openbravo.retail.posterminal/js/components/modalproductbrand.js
+++ b/web/org.openbravo.retail.posterminal/js/components/modalproductbrand.js
@@ -135,12 +135,13 @@
criteria = {};
if (products.collection.length > 0) {
if (productFilterText !== "" || productCategory.value !== "__all__") {
- var productCat = inSender.parent.parent.$.multiColumn.$.rightPanel.$.toolbarpane.$.searchCharacteristic.$.searchCharacteristicTabContent.$.searchProductCharacteristicHeader.getSelectedCategories();
+ var productCat = inSender.parent.parent.$.multiColumn.$.rightPanel.$.toolbarpane.$.searchCharacteristic.$.searchCharacteristicTabContent.$.searchProductCharacteristicHeader.getSelectedCategories(),
+ category = productCat.indexOf('OBPOS_bestsellercategory') >= 0 ? 'OBPOS_bestsellercategory' : (productCat.indexOf('__all__') >= 0 ? '__all__' : [productCategory.value]);
brandfilter.columns = [];
brandfilter.operator = OB.Dal.FILTER;
brandfilter.value = this.brandValueFilterQualifier;
productText = (OB.MobileApp.model.hasPermission('OBPOS_remote.product' + OB.Dal.USESCONTAINS, true) ? '%' : '') + productFilterText + '%';
- brandfilter.params = [productText, productCategory.filter ? productCategory.params[0] : productCat.indexOf('OBPOS_bestsellercategory') >= 0 ? 'OBPOS_bestsellercategory' : [productCategory.value]];
+ brandfilter.params = [productText, productCategory.filter ? productCategory.params[0] : category];
remoteCriteria.push(brandfilter);
}
}
diff --git a/web/org.openbravo.retail.posterminal/js/components/modalproductcharacteristic.js b/web/org.openbravo.retail.posterminal/js/components/modalproductcharacteristic.js
--- a/web/org.openbravo.retail.posterminal/js/components/modalproductcharacteristic.js
+++ b/web/org.openbravo.retail.posterminal/js/components/modalproductcharacteristic.js
@@ -217,12 +217,13 @@
}
if (productFilterText !== "" || productCategory.value !== "__all__") {
- var productCat = inSender.parent.parent.$.multiColumn.$.rightPanel.$.toolbarpane.$.searchCharacteristic.$.searchCharacteristicTabContent.$.searchProductCharacteristicHeader.getSelectedCategories();
+ var productCat = inSender.parent.parent.$.multiColumn.$.rightPanel.$.toolbarpane.$.searchCharacteristic.$.searchCharacteristicTabContent.$.searchProductCharacteristicHeader.getSelectedCategories(),
+ category = productCat.indexOf('OBPOS_bestsellercategory') >= 0 ? 'OBPOS_bestsellercategory' : (productCat.indexOf('__all__') >= 0 ? '__all__' : [productCategory.value]);
productFilter.columns = [];
productFilter.operator = OB.Dal.FILTER;
productFilter.value = this.productCharacteristicValueFilterQualifier;
productText = (OB.MobileApp.model.hasPermission('OBPOS_remote.product' + OB.Dal.USESCONTAINS, true) ? '%' : '') + productFilterText + '%';
- productFilter.params = [productText, productCategory.filter ? productCategory.params[0] : productCat.indexOf('OBPOS_bestsellercategory') >= 0 ? 'OBPOS_bestsellercategory' : [productCategory.value]];
+ productFilter.params = [productText, productCategory.filter ? productCategory.params[0] : category];
remoteCriteria.push(productFilter);
}
if (me.parent.parent.model.get('filter').length > 0) {
|