@@ -83,7 +83,7 @@ public class CustomerApiService extends AbstractService { | |||
} | |||
} | |||
sql.append(" ORDER BY ( 0 "); | |||
sql.append(" ORDER BY ( 0+0 "); | |||
if (args != null) { | |||
if (args.containsKey("searchStr")){ | |||
@@ -10,19 +10,18 @@ | |||
******************************************************************************/ | |||
package com.ffii.tbms.reports.service; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import com.ffii.core.dao.JdbcDao; | |||
import com.ffii.core.utils.SecurityUtils; | |||
import com.ffii.core.web.AbstractService; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Isolation; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import com.ffii.core.dao.JdbcDao; | |||
import com.ffii.core.utils.SecurityUtils; | |||
import com.ffii.core.web.AbstractService; | |||
@Service | |||
public class CustomerReportService extends AbstractService { | |||
@@ -37,8 +36,8 @@ public class CustomerReportService extends AbstractService { | |||
StringBuilder sql = new StringBuilder( " SELECT " | |||
+ " c.created, " | |||
+" CONCAT(IF(c.firstName IS NULL, '', CONCAT(c.firstName, ' ')), " | |||
+" IF(c.surname IS NULL, '', CONCAT(c.surname, ' '))) AS customerName, " | |||
+ " CONCAT(IF(c.firstName IS NULL, '', CONCAT(c.firstName, ' ')), " | |||
+ " IF(c.surname IS NULL, '', CONCAT(c.surname, ' '))) AS customerName, " | |||
+ " c.nameCh, " | |||
+ " c.phone1, " | |||
+ " c.phone2, " | |||
@@ -66,10 +65,48 @@ public class CustomerReportService extends AbstractService { | |||
if(args != null){ | |||
if(args.containsKey("sysGroupId")) | |||
sql.append(" AND c.sysGroupId = :sysGroupId "); | |||
if(args.containsKey("customerName")){ | |||
String str = args.get("customerName").toString(); | |||
String[] array = str.split(" "); | |||
str = ""; | |||
for(int i = 0; i<array.length; i++){ | |||
str += " AND ( c.surname LIKE '"+array[i]+"%' "; | |||
str += " OR c.nameCh LIKE '"+array[i]+"%' "; | |||
str += " OR c.firstName LIKE '"+array[i]+"%' ) "; | |||
} | |||
sql.append(str); | |||
} | |||
if(args.containsKey("email")) | |||
sql.append(" AND (c.email LIKE :email) "); | |||
if(args.containsKey("address")) | |||
sql.append(" AND (c.address LIKE :address) "); | |||
if(args.containsKey("remarks")) | |||
sql.append(" AND (c.remarks LIKE :remarks) "); | |||
if(args.containsKey("dateFrom")) | |||
sql.append(" AND (c.created > :dateFrom) "); | |||
if(args.containsKey("dateTo")) | |||
sql.append(" AND (c.created < :dateTo) "); | |||
} | |||
sql.append(" GROUP BY c.id HAVING 1=1 "); | |||
if(args != null){ | |||
if(args.containsKey("amountFrom")) | |||
sql.append(" AND (orderAmount >= :amountFrom) "); | |||
if(args.containsKey("amountTo")) | |||
sql.append(" AND (orderAmount <= :amountTo) "); | |||
} | |||
sql.append(" GROUP BY c.id " | |||
+ " ORDER BY c.created "); | |||
sql.append(" ORDER BY (0+0 "); | |||
if (args != null) { | |||
if (args.containsKey("customerName")){ | |||
sql.append(" + IF( c.surname = :customerName,1,0) + IF( c.surname LIKE '"+args.get("customerName")+"%',1,0) "); | |||
sql.append(" + IF( c.firstName = :customerName,1,0) + IF( c.firstName LIKE '"+args.get("customerName")+"%',1,0) "); | |||
sql.append(" + IF( c.nameCh = :customerName,1,0) + IF( c.nameCh LIKE '"+args.get("customerName")+"%',1,0) "); | |||
} | |||
} | |||
sql.append(" ) DESC, c.created "); | |||
return jdbcDao.queryForList(sql.toString(), args); | |||
} | |||
@@ -51,6 +51,13 @@ public class CustomerReportController extends AbstractController { | |||
Map<String, Object> args = new HashMap<String, Object>(); | |||
CriteriaUtils.addDate(request, args, "dateFrom"); | |||
CriteriaUtils.addDateTo(request, args, "dateTo"); | |||
CriteriaUtils.addStringLike(request, args, "customerName"); | |||
CriteriaUtils.addStringLike(request, args, "phone"); | |||
CriteriaUtils.addStringLike(request, args, "email"); | |||
CriteriaUtils.addStringLike(request, args, "address"); | |||
CriteriaUtils.addStringLike(request, args, "remarks"); | |||
CriteriaUtils.addInteger(request, args, "amountFrom"); | |||
CriteriaUtils.addInteger(request, args, "amountTo"); | |||
List<Map<String, Object>> records = service.search(args); | |||
@@ -70,14 +77,16 @@ public class CustomerReportController extends AbstractController { | |||
Map<String, Object> args = new HashMap<String, Object>(); | |||
CriteriaUtils.addDate(request, args, "dateFrom"); | |||
CriteriaUtils.addDateTo(request, args, "dateTo"); | |||
//CriteriaUtils.addInteger(request, args, "start"); | |||
//CriteriaUtils.addInteger(request, args, "limit"); | |||
CriteriaUtils.addString(request, args, "customerName"); | |||
CriteriaUtils.addStringLike(request, args, "phone"); | |||
CriteriaUtils.addStringLike(request, args, "email"); | |||
CriteriaUtils.addStringLike(request, args, "address"); | |||
CriteriaUtils.addStringLike(request, args, "remarks"); | |||
CriteriaUtils.addInteger(request, args, "amountFrom"); | |||
CriteriaUtils.addInteger(request, args, "amountTo"); | |||
List<Map<String, Object>> records = service.search(args); | |||
//Map<String, Object> count = service.count(args); | |||
//model.addAttribute("total", NumberUtils.intValue(count.get("count"))); | |||
model.addAttribute(Params.RECORDS, records); | |||
model.addAttribute(Params.SUCCESS, Boolean.TRUE); | |||
@@ -144,21 +144,7 @@ Ext.define('App.store.Report_OrderStore', { | |||
idProperty: 'orderId' | |||
} | |||
}, | |||
reader: new Ext.data.JsonReader({}, [ | |||
{name: 'orderId'}, | |||
{name: 'date' }, | |||
{name: 'code'}, | |||
{name: 'orderNo'}, | |||
{name: 'customerName'}, | |||
{name: 'status'}, | |||
{name: 'remarks'}, | |||
{name: 'status'}, | |||
{name: 'item'}, | |||
{name: 'orderAmount'}, | |||
{name: 'outstanding'}, | |||
{name: 'paymentAmount'}, | |||
]), | |||
/* | |||
fields: [ | |||
{ | |||
name: 'orderId', | |||
@@ -209,7 +195,6 @@ Ext.define('App.store.Report_OrderStore', { | |||
type: 'string' | |||
}, | |||
], | |||
*/ | |||
}, | |||
cfg)]); | |||
} | |||
@@ -241,6 +226,10 @@ Ext.define('App.store.Report_CustomerStore', { | |||
{ | |||
name: "created", | |||
type: 'date', | |||
convert: function (value) { | |||
var d = new Date(value); | |||
return Ext.util.Format.date(d, 'Y/m/d') | |||
}, | |||
}, | |||
{ | |||
name: "customerName", | |||
@@ -186,7 +186,6 @@ Ext.define("App.view.OrderForm", { | |||
field.isPressing = true; | |||
} | |||
} | |||
},{ | |||
xtype: 'label', | |||
html: '<i class="fas fa-spinner fa-pulse" style="color:white"></i>', | |||
@@ -5,6 +5,7 @@ Ext.define('App.view.Report_CustomerContainer', { | |||
focusable:true, | |||
layout: 'vbox', | |||
defaults: { | |||
width: '100%', | |||
margin: '2 4 2 4' | |||
@@ -62,17 +63,48 @@ Ext.define('App.view.Report_CustomerContainer', { | |||
{ | |||
xtype: 'datefield', | |||
fieldLabel: App.localeRes('Date From'), | |||
allowBlank: false, | |||
name: 'dateFrom', | |||
value: firstDay | |||
}, | |||
{ | |||
xtype: 'datefield', | |||
fieldLabel: App.localeRes('Date To'), | |||
allowBlank: false, | |||
name: 'dateTo', | |||
value: lastDay | |||
} | |||
}, | |||
{ | |||
xtype: 'textfield', | |||
fieldLabel: App.localeRes('Customer Name'), | |||
name: 'customerName', | |||
}, | |||
{ | |||
xtype: 'textfield', | |||
fieldLabel: App.localeRes('Phone'), | |||
name: 'phone', | |||
}, | |||
{ | |||
xtype: 'textfield', | |||
fieldLabel: App.localeRes('Email'), | |||
name: 'email', | |||
}, | |||
{ | |||
xtype: 'textfield', | |||
fieldLabel: App.localeRes('Address'), | |||
name: 'address', | |||
}, | |||
{ | |||
xtype: 'textfield', | |||
fieldLabel: App.localeRes('Remarks'), | |||
name: 'remarks', | |||
}, | |||
{ | |||
xtype: 'numberfield', | |||
fieldLabel: App.localeRes('Amount From'), | |||
name: 'amountFrom', | |||
}, | |||
{ | |||
xtype: 'numberfield', | |||
fieldLabel: App.localeRes('Amount To'), | |||
name: 'amountTo', | |||
}, | |||
] | |||
} | |||
], | |||
@@ -132,6 +164,9 @@ Ext.define('App.view.Report_CustomerGrid', { | |||
scrollable: { | |||
alwaysShow: true | |||
}, | |||
viewConfig : { | |||
enableTextSelection: true, | |||
}, | |||
reloadStore: function() { | |||
var me = this; | |||
@@ -142,10 +177,6 @@ Ext.define('App.view.Report_CustomerGrid', { | |||
initComponent: function() { | |||
var me = this; | |||
Ext.apply(me, { | |||
bbar: { | |||
xtype: 'pagingtoolbar', | |||
displayInfo: true | |||
}, | |||
store: Ext.create('App.store.Report_CustomerStore', {}), | |||
columns: [ | |||
{ | |||
@@ -153,15 +184,16 @@ Ext.define('App.view.Report_CustomerGrid', { | |||
width: 80 | |||
}, | |||
{ | |||
xtype: 'datecolumn', | |||
xtype: 'gridcolumn', | |||
dataIndex: 'created', | |||
text: App.localeRes('Creation Date'), | |||
flex: 1 | |||
format: 'Y-m-d' | |||
}, | |||
{ | |||
xtype: 'gridcolumn', | |||
dataIndex: 'customerName', | |||
text: App.localeRes('Customer (Eng)'), | |||
width: 150, | |||
}, | |||
{ | |||
xtype: 'gridcolumn', | |||
@@ -182,11 +214,13 @@ Ext.define('App.view.Report_CustomerGrid', { | |||
xtype: 'gridcolumn', | |||
dataIndex: 'email', | |||
text: App.localeRes('Email'), | |||
width: 150, | |||
}, | |||
{ | |||
xtype: 'gridcolumn', | |||
dataIndex: 'address', | |||
text: App.localeRes('Address'), | |||
width: 150, | |||
}, | |||
{ | |||
xtype: 'gridcolumn', | |||