Commit 9e5d364c34f0b0ce74ed675c6790738313bf1c3a

Authored by trainee
1 parent 16d48521
Exists in master

finish search + add new api

src/app/dashboard/dashboard.component.html
@@ -664,7 +664,7 @@ @@ -664,7 +664,7 @@
664 <h1 class="icon-bubble font-green-sharp"> 664 <h1 class="icon-bubble font-green-sharp">
665 <span class="caption-subject font-green-sharp sbold font"> Active</span> 665 <span class="caption-subject font-green-sharp sbold font"> Active</span>
666 </h1> 666 </h1>
667 - <button *ngFor="let name of ButtonValue" (click)="getButton(name.valueN)" >{{ name.name }}</button> 667 + <button *ngFor="let name of ButtonValue" (click)="getButton(name.valueN)">{{ name.name }}</button>
668 <div class="input-group" style="float: right; margin-top: 11px;"> 668 <div class="input-group" style="float: right; margin-top: 11px;">
669 <div class="input-icon right"> 669 <div class="input-icon right">
670 <i class="icon-magnifier"> 670 <i class="icon-magnifier">
src/app/dashboard/dashboard.component.ts
@@ -70,6 +70,8 @@ export class DashboardComponent implements OnInit { @@ -70,6 +70,8 @@ export class DashboardComponent implements OnInit {
70 resultNum7:number = 0; 70 resultNum7:number = 0;
71 resultDataOnHold7: any; 71 resultDataOnHold7: any;
72 72
  73 + Show: any = [];
  74 +
73 ButtonValue = [ 75 ButtonValue = [
74 { 76 {
75 name : 'apd', 77 name : 'apd',
@@ -81,7 +83,7 @@ export class DashboardComponent implements OnInit { @@ -81,7 +83,7 @@ export class DashboardComponent implements OnInit {
81 }, 83 },
82 ]; 84 ];
83 85
84 - Show: any; 86 +
85 87
86 88
87 89
@@ -106,6 +108,7 @@ export class DashboardComponent implements OnInit { @@ -106,6 +108,7 @@ export class DashboardComponent implements OnInit {
106 this.resultData[i].birth_date = this._common.convertDate(this.resultData[i].birth_date); 108 this.resultData[i].birth_date = this._common.convertDate(this.resultData[i].birth_date);
107 this.resultNum = this.resultData.length; 109 this.resultNum = this.resultData.length;
108 } 110 }
  111 +
109 } else { 112 } else {
110 this.resultData = []; 113 this.resultData = [];
111 } 114 }
@@ -444,8 +447,8 @@ export class DashboardComponent implements OnInit { @@ -444,8 +447,8 @@ export class DashboardComponent implements OnInit {
444 try { 447 try {
445 const data7 = { 448 const data7 = {
446 // tslint:disable-next-line:max-line-length 449 // tslint:disable-next-line:max-line-length
447 - 'query': 'SELECT vtiger_account.accountname AS custgroupName , vtiger_troubletickets.ticketid AS id , IF( vtiger_groups.groupname IS NOT NULL , vtiger_groups.groupname , vu.user_name) AS team , vtiger_troubletickets.title , vtiger_troubletickets. STATUS , vtiger_troubletickets.priority , CONCAT( \'http%3A%2F%2Fvtiger.sourcecode.co.th%2Findex.php%3Faction%3DDetailView%26module%3DHelpDesk%26parenttab%3DSupport%26record%3D\' , vtiger_troubletickets.ticketid) AS link ,( SELECT CONCAT( xx.createdtime , \' : \' , xx.comments) FROM vtiger_ticketcomments xx WHERE xx.ticketid = vtiger_troubletickets.ticketid ORDER BY xx.createdtime DESC LIMIT 1) AS COMMENT , CASE vtiger_troubletickets. STATUS WHEN \'Closed\' THEN( unix_timestamp(vtiger_crmentity.modifiedtime) - unix_timestamp(vtiger_crmentity.createdtime)) / 86400 ELSE( unix_timestamp(now()) - unix_timestamp(vtiger_crmentity.createdtime)) / 86400 END AS days , vtiger_ticketcf.cf_568 AS type , IFNULL(( SELECT \'Wait for response by\' FROM vtiger_ticket_history WHERE vtiger_troubletickets.ticketid = vtiger_ticket_history.ticketid AND assigned_type = \'Wait for response\' ORDER BY updatetime DESC LIMIT 0 , 1) , \'Created by\') userType , IFNULL(( SELECT concat(\'\' , assigned_by , \'\') FROM vtiger_ticket_history WHERE vtiger_troubletickets.ticketid = vtiger_ticket_history.ticketid AND assigned_type = \'Wait for response\' ORDER BY updatetime DESC LIMIT 0 , 1) , vtiger_users.user_name) username , vtiger_crmentity.description , vtiger_crmentity.createdtime , vtiger_crmentity.modifiedtime , vtiger_cf_568.cf_568id FROM vtiger_crmentity JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smcreatorid JOIN vtiger_troubletickets ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid JOIN vtiger_account ON vtiger_account.accountid = vtiger_troubletickets.parent_id JOIN vtiger_ticketcf ON vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid JOIN vtiger_cf_568 ON vtiger_cf_568.cf_568 = vtiger_ticketcf.cf_568 LEFT OUTER JOIN vtiger_groups ON vtiger_crmentity.smownerid = vtiger_groups.groupid LEFT OUTER JOIN vtiger_users vu ON vtiger_crmentity.smownerid = vu.id WHERE 1 AND vtiger_crmentity.setype = \'HelpDesk\' AND vtiger_crmentity.deleted = 0 AND vtiger_ticketcf.cf_568 != \'\' AND vtiger_cf_568.cf_568id NOT IN(8 , 9 , 10) AND( LCASE(vtiger_cf_568.cf_568) != \'set (ติดตั้ง)\' AND LCASE(vtiger_troubletickets. STATUS) NOT IN(\'closed\' , \'Wait For Customer\')) GROUP BY vtiger_troubletickets.ticketid ORDER BY vtiger_crmentity.createdtime ASC LIMIT 0 , 100',  
448 - 'params': ['vtiger_crmentity'] 450 + "query": "SELECT vtiger_account.accountname AS custgroupName , vtiger_troubletickets.ticketid AS id , IF( vtiger_groups.groupname IS NOT NULL , vtiger_groups.groupname , vu.user_name) AS team , vtiger_troubletickets.title , vtiger_troubletickets. STATUS , vtiger_troubletickets.priority , CONCAT( 'http%3A%2F%2Fvtiger.sourcecode.co.th%2Findex.php%3Faction%3DDetailView%26module%3DHelpDesk%26parenttab%3DSupport%26record%3D' , vtiger_troubletickets.ticketid) AS link ,( SELECT CONCAT( xx.createdtime , ' : ' , xx.comments) FROM vtiger_ticketcomments xx WHERE xx.ticketid = vtiger_troubletickets.ticketid ORDER BY xx.createdtime DESC LIMIT 1) AS COMMENT , CASE vtiger_troubletickets. STATUS WHEN 'Closed' THEN( unix_timestamp(vtiger_crmentity.modifiedtime) - unix_timestamp(vtiger_crmentity.createdtime)) / 86400 ELSE( unix_timestamp(now()) - unix_timestamp(vtiger_crmentity.createdtime)) / 86400 END AS days , vtiger_ticketcf.cf_568 AS type , IFNULL(( SELECT 'Wait for response by' FROM vtiger_ticket_history WHERE vtiger_troubletickets.ticketid = vtiger_ticket_history.ticketid AND assigned_type = 'Wait for response' ORDER BY updatetime DESC LIMIT 0 , 1) , 'Created by') userType , IFNULL(( SELECT concat('' , assigned_by , '') FROM vtiger_ticket_history WHERE vtiger_troubletickets.ticketid = vtiger_ticket_history.ticketid AND assigned_type = 'Wait for response' ORDER BY updatetime DESC LIMIT 0 , 1) , vtiger_users.user_name) username , vtiger_crmentity.description , vtiger_crmentity.createdtime , vtiger_crmentity.modifiedtime , vtiger_cf_568.cf_568id FROM vtiger_crmentity JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smcreatorid JOIN vtiger_troubletickets ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid JOIN vtiger_account ON vtiger_account.accountid = vtiger_troubletickets.parent_id JOIN vtiger_ticketcf ON vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid JOIN vtiger_cf_568 ON vtiger_cf_568.cf_568 = vtiger_ticketcf.cf_568 LEFT OUTER JOIN vtiger_groups ON vtiger_crmentity.smownerid = vtiger_groups.groupid LEFT OUTER JOIN vtiger_users vu ON vtiger_crmentity.smownerid = vu.id WHERE 1 AND vtiger_crmentity.setype = 'HelpDesk' AND vtiger_crmentity.deleted = 0 AND vtiger_ticketcf.cf_568 != '' AND vtiger_cf_568.cf_568id NOT IN(8 , 9 , 10) AND( LCASE(vtiger_cf_568.cf_568) != 'set (ติดตั้ง)' AND LCASE(vtiger_troubletickets. STATUS) NOT IN('closed' , 'Wait For Customer')) GROUP BY vtiger_troubletickets.ticketid ORDER BY vtiger_crmentity.createdtime ASC ",
  451 + "params": ["vtiger_crmentity"]
449 }; 452 };
450 const response = await this._apiService.post('dynamic', data7); 453 const response = await this._apiService.post('dynamic', data7);
451 if (response !== null) { 454 if (response !== null) {
@@ -457,9 +460,12 @@ export class DashboardComponent implements OnInit { @@ -457,9 +460,12 @@ export class DashboardComponent implements OnInit {
457 this.resultData7[i].link = this._common.decodeURI(this.resultData7[i].link); 460 this.resultData7[i].link = this._common.decodeURI(this.resultData7[i].link);
458 this.resultData7[i].birth_date = this._common.convertDate(this.resultData7[i].birth_date); 461 this.resultData7[i].birth_date = this._common.convertDate(this.resultData7[i].birth_date);
459 this.resultNum7 = this.resultData7.length; 462 this.resultNum7 = this.resultData7.length;
460 - 463 + this.Show.push(this.resultData7[i]);
461 } 464 }
462 - this.Show = Object.assign(this.resultData7); 465 +
  466 + // this.Show = Object.assign(this.resultData7);
  467 + console.log('hi',this.Show)
  468 +
463 } else { 469 } else {
464 this.resultData7 = []; 470 this.resultData7 = [];
465 } 471 }
@@ -504,12 +510,12 @@ export class DashboardComponent implements OnInit { @@ -504,12 +510,12 @@ export class DashboardComponent implements OnInit {
504 getButton(valueN){ 510 getButton(valueN){
505 console.log(valueN); 511 console.log(valueN);
506 512
507 - if (this.resultData7.length === 0) {  
508 - return this.resultData7; 513 + if (this.Show.length === 0) {
  514 + return this.Show;
509 } 515 }
510 516
511 const resultArray = []; 517 const resultArray = [];
512 - for (const item of this.resultData7) { 518 + for (const item of this.Show) {
513 console.log('item: ', item); 519 console.log('item: ', item);
514 520
515 var st = ''; 521 var st = '';
@@ -525,7 +531,9 @@ export class DashboardComponent implements OnInit { @@ -525,7 +531,9 @@ export class DashboardComponent implements OnInit {
525 } 531 }
526 532
527 } 533 }
  534 +
528 this.resultData7 = resultArray; 535 this.resultData7 = resultArray;
  536 +
529 537
530 } 538 }
531 /////////////Get data come to use////////////////////// 539 /////////////Get data come to use//////////////////////
@@ -848,8 +856,8 @@ async getDataOnHold6() { @@ -848,8 +856,8 @@ async getDataOnHold6() {
848 try { 856 try {
849 const data7 = { 857 const data7 = {
850 // tslint:disable-next-line:max-line-length 858 // tslint:disable-next-line:max-line-length
851 - 'query': 'SELECT vtiger_account.accountname AS custgroupName , vtiger_troubletickets.ticketid AS id , IF( vtiger_groups.groupname IS NOT NULL , vtiger_groups.groupname , vu.user_name) AS team , vtiger_troubletickets.title , vtiger_troubletickets. STATUS , vtiger_troubletickets.priority , CONCAT( \'http%3A%2F%2Fvtiger.sourcecode.co.th%2Findex.php%3Faction%3DDetailView%26module%3DHelpDesk%26parenttab%3DSupport%26record%3D\' , vtiger_troubletickets.ticketid) AS link ,( SELECT CONCAT( xx.createdtime , \' : \' , xx.comments) FROM vtiger_ticketcomments xx WHERE xx.ticketid = vtiger_troubletickets.ticketid ORDER BY xx.createdtime DESC LIMIT 1) AS COMMENT , CASE vtiger_troubletickets. STATUS WHEN \'Closed\' THEN( unix_timestamp(vtiger_crmentity.modifiedtime) - unix_timestamp(vtiger_crmentity.createdtime)) / 86400 ELSE( unix_timestamp(now()) - unix_timestamp(vtiger_crmentity.createdtime)) / 86400 END AS days , vtiger_ticketcf.cf_568 AS type , IFNULL(( SELECT \'Wait for response by\' FROM vtiger_ticket_history WHERE vtiger_troubletickets.ticketid = vtiger_ticket_history.ticketid AND assigned_type = \'Wait for response\' ORDER BY updatetime DESC LIMIT 0 , 1) , \'Created by\') userType , IFNULL(( SELECT concat(\'\' , assigned_by , \'\') FROM vtiger_ticket_history WHERE vtiger_troubletickets.ticketid = vtiger_ticket_history.ticketid AND assigned_type = \'Wait for response\' ORDER BY updatetime DESC LIMIT 0 , 1) , vtiger_users.user_name) username , vtiger_crmentity.description , vtiger_crmentity.createdtime , vtiger_crmentity.modifiedtime , vtiger_cf_568.cf_568id FROM vtiger_crmentity JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smcreatorid JOIN vtiger_troubletickets ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid JOIN vtiger_account ON vtiger_account.accountid = vtiger_troubletickets.parent_id JOIN vtiger_ticketcf ON vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid JOIN vtiger_cf_568 ON vtiger_cf_568.cf_568 = vtiger_ticketcf.cf_568 LEFT OUTER JOIN vtiger_groups ON vtiger_crmentity.smownerid = vtiger_groups.groupid LEFT OUTER JOIN vtiger_users vu ON vtiger_crmentity.smownerid = vu.id WHERE 1 AND vtiger_crmentity.setype = \'HelpDesk\' AND vtiger_crmentity.deleted = 0 AND vtiger_ticketcf.cf_568 != \'\' AND vtiger_cf_568.cf_568id NOT IN(8 , 9 , 10) AND( LCASE(vtiger_cf_568.cf_568) != \'set (ติดตั้ง)\' AND LCASE(vtiger_troubletickets. STATUS) NOT IN(\'closed\' , \'Wait For Customer\')) GROUP BY vtiger_troubletickets.ticketid ORDER BY vtiger_crmentity.createdtime ASC LIMIT 0 , 100',  
852 - 'params': ['vtiger_crmentity'] 859 + "query": "SELECT vtiger_account.accountname AS custgroupName , vtiger_troubletickets.ticketid AS id , IF( vtiger_groups.groupname IS NOT NULL , vtiger_groups.groupname , vu.user_name) AS team , vtiger_troubletickets.title , vtiger_troubletickets. STATUS , vtiger_troubletickets.priority , CONCAT( 'http%3A%2F%2Fvtiger.sourcecode.co.th%2Findex.php%3Faction%3DDetailView%26module%3DHelpDesk%26parenttab%3DSupport%26record%3D' , vtiger_troubletickets.ticketid) AS link ,( SELECT CONCAT( xx.createdtime , ' : ' , xx.comments) FROM vtiger_ticketcomments xx WHERE xx.ticketid = vtiger_troubletickets.ticketid ORDER BY xx.createdtime DESC LIMIT 1) AS COMMENT , CASE vtiger_troubletickets. STATUS WHEN 'Closed' THEN( unix_timestamp(vtiger_crmentity.modifiedtime) - unix_timestamp(vtiger_crmentity.createdtime)) / 86400 ELSE( unix_timestamp(now()) - unix_timestamp(vtiger_crmentity.createdtime)) / 86400 END AS days , vtiger_ticketcf.cf_568 AS type , IFNULL(( SELECT 'Wait for response by' FROM vtiger_ticket_history WHERE vtiger_troubletickets.ticketid = vtiger_ticket_history.ticketid AND assigned_type = 'Wait for response' ORDER BY updatetime DESC LIMIT 0 , 1) , 'Created by') userType , IFNULL(( SELECT concat('' , assigned_by , '') FROM vtiger_ticket_history WHERE vtiger_troubletickets.ticketid = vtiger_ticket_history.ticketid AND assigned_type = 'Wait for response' ORDER BY updatetime DESC LIMIT 0 , 1) , vtiger_users.user_name) username , vtiger_crmentity.description , vtiger_crmentity.createdtime , vtiger_crmentity.modifiedtime , vtiger_cf_568.cf_568id FROM vtiger_crmentity JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smcreatorid JOIN vtiger_troubletickets ON vtiger_crmentity.crmid = vtiger_troubletickets.ticketid JOIN vtiger_account ON vtiger_account.accountid = vtiger_troubletickets.parent_id JOIN vtiger_ticketcf ON vtiger_ticketcf.ticketid = vtiger_troubletickets.ticketid JOIN vtiger_cf_568 ON vtiger_cf_568.cf_568 = vtiger_ticketcf.cf_568 LEFT OUTER JOIN vtiger_groups ON vtiger_crmentity.smownerid = vtiger_groups.groupid LEFT OUTER JOIN vtiger_users vu ON vtiger_crmentity.smownerid = vu.id WHERE 1 AND vtiger_crmentity.setype = 'HelpDesk' AND vtiger_crmentity.deleted = 0 AND vtiger_ticketcf.cf_568 != '' AND vtiger_cf_568.cf_568id NOT IN(8 , 9 , 10) AND( LCASE(vtiger_cf_568.cf_568) != 'set (ติดตั้ง)' AND LCASE(vtiger_troubletickets. STATUS) NOT IN('closed' , 'Wait For Customer')) GROUP BY vtiger_troubletickets.ticketid ORDER BY vtiger_crmentity.createdtime ASC ",
  860 + "params": ["vtiger_crmentity"]
853 }; 861 };
854 const response = await this._apiService.post('dynamic', data7); 862 const response = await this._apiService.post('dynamic', data7);
855 if (response !== null) { 863 if (response !== null) {
@@ -860,6 +868,7 @@ async getDataOnHold6() { @@ -860,6 +868,7 @@ async getDataOnHold6() {
860 for (const i in this.resultData7) { 868 for (const i in this.resultData7) {
861 this.resultData7[i].link = this._common.decodeURI(this.resultData7[i].link); 869 this.resultData7[i].link = this._common.decodeURI(this.resultData7[i].link);
862 this.resultData7[i].birth_date = this._common.convertDate(this.resultData7[i].birth_date); 870 this.resultData7[i].birth_date = this._common.convertDate(this.resultData7[i].birth_date);
  871 + this.Show.push(this.resultData7[i]);
863 } 872 }
864 } else { 873 } else {
865 this.resultData7 = []; 874 this.resultData7 = [];
src/app/dashboard/filter.pipe.ts
@@ -17,19 +17,19 @@ export class FilterPipe implements PipeTransform { @@ -17,19 +17,19 @@ export class FilterPipe implements PipeTransform {
17 console.log('item: ', item); 17 console.log('item: ', item);
18 18
19 var st = ''; 19 var st = '';
20 - // st = item['team'].toLowerCase() + item['COMMENT'].toLowerCase() + item['custgroupName'].toLowerCase() + item['STATUS'].toLowerCase() ;  
21 - // if(item['team']){  
22 - // st += item['team'].toLowerCase();  
23 - // }  
24 - // if(item['COMMENT']){  
25 - // st += item['COMMENT'].toLowerCase();  
26 - // }  
27 - // if(item['custgroupName']){  
28 - // st += item['custgroupName'].toLowerCase();  
29 - // }  
30 - // if(item['STATUS']){  
31 - // st += item['STATUS'].toLowerCase();  
32 - // } 20 + //st = item['team'].toLowerCase() + item['COMMENT'].toLowerCase() + item['custgroupName'].toLowerCase() + item['STATUS'].toLowerCase() ;
  21 + if(item['team']){
  22 + st += item['team'].toLowerCase();
  23 + }
  24 + if(item['COMMENT']){
  25 + st += item['COMMENT'].toLowerCase();
  26 + }
  27 + if(item['custgroupName']){
  28 + st += item['custgroupName'].toLowerCase();
  29 + }
  30 + if(item['STATUS']){
  31 + st += item['STATUS'].toLowerCase();
  32 + }
33 if(item['type']){ 33 if(item['type']){
34 st += item['type'].toLowerCase(); 34 st += item['type'].toLowerCase();
35 } 35 }