Skip to content

Commit cfaabba

Browse files
authored
Merge pull request #677 from PAWECOGmbH/development
Dev to Staging
2 parents 0138d5f + 467e50e commit cfaabba

2 files changed

Lines changed: 58 additions & 7 deletions

File tree

www/backend/core/com/sysadmin.cfc

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,35 @@ component displayname="sysadmin" output="false" {
332332

333333
local.entries = 10;
334334

335+
// Sorting logic dependent on arguments.sort
336+
switch (arguments.sort){
337+
case "strCompanyName ASC":
338+
local.orderClause = "
339+
CASE
340+
WHEN customers.strCompanyName IS NULL OR customers.strCompanyName = '' THEN 1
341+
ELSE 0
342+
END,
343+
customers.strCompanyName ASC";
344+
break;
345+
346+
case "strCompanyName DESC":
347+
local.orderClause = "
348+
CASE
349+
WHEN customers.strCompanyName IS NULL OR customers.strCompanyName = '' THEN 1
350+
ELSE 0
351+
END,
352+
customers.strCompanyName DESC";
353+
break;
354+
355+
default:
356+
local.orderClause = arguments.sort;
357+
}
358+
335359
local.qCustomers = queryExecute(
336360
options = {datasource = application.datasource},
337361
sql = "
338362
SELECT DISTINCT customers.intCustomerID, customers.strCompanyName, customers.strContactPerson,
339-
customers.strCity, customers.strEmail, customers.strLogo, customers.strPhone
363+
customers.strCity, customers.strEmail, customers.strLogo, customers.strPhone, customers.dtmInsertDate
340364
FROM customers
341365
342366
INNER JOIN users
@@ -353,31 +377,58 @@ component displayname="sysadmin" output="false" {
353377
customers.strEmail
354378
)
355379
#arguments.search#
356-
ORDER BY #arguments.sort#
380+
ORDER BY #local.orderClause#
357381
LIMIT #arguments.start#, #local.entries#
358382
"
359383
);
360384

361385
return local.qCustomers;
386+
362387
}
363388

364389
public query function getCustomer(required numeric start, required string sort){
365390

366391
local.entries = 10;
367392

393+
// Sorting logic dependent on arguments.sort
394+
switch (arguments.sort){
395+
case "strCompanyName ASC":
396+
local.orderClause = "
397+
CASE
398+
WHEN customers.strCompanyName IS NULL OR customers.strCompanyName = '' THEN 1
399+
ELSE 0
400+
END,
401+
customers.strCompanyName ASC";
402+
break;
403+
404+
case "strCompanyName DESC":
405+
local.orderClause = "
406+
CASE
407+
WHEN customers.strCompanyName IS NULL OR customers.strCompanyName = '' THEN 1
408+
ELSE 0
409+
END,
410+
customers.strCompanyName DESC";
411+
break;
412+
413+
default:
414+
local.orderClause = arguments.sort;
415+
}
416+
368417
local.qCustomers = queryExecute(
369418
options = {datasource = application.datasource},
370419
sql = "
371420
SELECT customers.*, countries.strCountryName
372421
FROM customers
373-
LEFT JOIN countries ON countries.intCountryID = customers.intCountryID
422+
LEFT JOIN countries
423+
ON countries.intCountryID = customers.intCountryID
374424
WHERE customers.blnActive = 1
375-
ORDER BY #arguments.sort#
425+
ORDER BY #local.orderClause#
376426
LIMIT #arguments.start#, #local.entries#
377427
"
378428
);
379429

380430
return local.qCustomers;
431+
381432
}
382433

383434
public query function getTotalInvoicesSearch(required string search, required string term, required numeric start, required string status, required string sort){

www/backend/core/views/sysadmin/customers.cfm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<cfscript>
22
param name="session.cust_search" default="" type="string";
3-
param name="session.cust_sort" default="intPrio" type="string";
3+
param name="session.cust_sort" default="strCompanyName ASC" type="string";
44
param name="session.customers_page" default=1 type="numeric";
55
66
objSysadmin = new backend.core.com.sysadmin();
@@ -111,7 +111,7 @@
111111
<div class="col-lg-4">
112112
<label class="form-label">Search for customer:</label>
113113
<div class="input-group mb-2">
114-
<input type="text" name="search" class="form-control" minlength="1" placeholder="Search for…">
114+
<input type="text" name="search" class="form-control" minlength="3" placeholder="Search for…">
115115
<button class="btn bg-green-lt" type="submit">Go!</button>
116116
<cfif len(trim(searchTerm))>
117117
<button class="btn bg-red-lt" name="delete" type="submit" data-bs-toggle="tooltip" data-bs-placement="top" title="Delete search">
@@ -176,7 +176,7 @@
176176
<cfif len(trim(qCustomers.strCompanyName))>
177177
<div class="font-weight-medium">#qCustomers.strCompanyName# <cfif qCustomers.intCustomerID eq session.customer_id>(SysAdmin)</cfif></div>
178178
<cfelse>
179-
<div class="font-weight-medium">#qCustomers.strContactPerson# (Private)</div>
179+
<div class="font-weight-medium">-</div>
180180
</cfif>
181181
</div>
182182
</a>

0 commit comments

Comments
 (0)