From e06087269bbcb49cc3f4fed2c51b25afeb420b6e Mon Sep 17 00:00:00 2001 From: patrick Date: Sun, 21 Jul 2019 19:44:20 +1000 Subject: [PATCH] filter staff and clients requires both rather than or --- js/bts_timesheet.js | 74 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 14 deletions(-) diff --git a/js/bts_timesheet.js b/js/bts_timesheet.js index a91a6f0..f19a34b 100644 --- a/js/bts_timesheet.js +++ b/js/bts_timesheet.js @@ -630,25 +630,25 @@ this.mark_rate_invalid(); return false; } - if (this.get_rate() != this.data.rate){ - this.set_err_msg_rate('rate@Xero inactive ' + this.data.rate); - this.mark_rate_invalid(); - this.mark_dirty(); - return false; - } +// if (this.get_rate() != this.data.rate){ +// this.set_err_msg_rate('rate@Xero inactive ' + this.data.rate); +// this.mark_rate_invalid(); +// this.mark_dirty(); +// return false; +// } this.set_err_msg_rate(''); this.mark_rate_valid(); return true; } validate_tos(){ - if (this.get_tos() != this.data.tos){ - this.set_err_msg_tos('require NDIS ' + this.data.tos); - this.mark_tos_invalid(); - this.mark_dirty(); - console.log('tos mark dirty'); - return false; - } +// if (this.get_tos() != this.data.tos){ +// this.set_err_msg_tos('require NDIS ' + this.data.tos); +// this.mark_tos_invalid(); +// this.mark_dirty(); +// console.log('tos mark dirty'); +// return false; +// } this.set_err_msg_tos(''); this.mark_tos_valid(); return true; @@ -1187,19 +1187,65 @@ return; } + //if staffs is empty, we only filter by client + if (staffs === undefined || staffs.length ==0){ + filter_workspace_by_client(clients); + return; + } + + //if clients is empty, we only filter by staff + if (clients===undefined || clients.length ==0){ + filter_workspace_by_staff(staffs); + return; + } + //filter by both + filter_workspace_by_both(staffs, clients); + + } + + function filter_workspace_by_staff(staffs) + { //filter some of them; $('div.workspace div.divTable').each(function(i,e){ var job = $(e).data().job; var s = job.get_staff(); + + if (staffs.indexOf(s) ==-1) + $(this).fadeOut(); + else + $(this).fadeIn(); + }); + } + + function filter_workspace_by_client(clients) + { + //filter some of them; + $('div.workspace div.divTable').each(function(i,e){ + var job = $(e).data().job; var c = job.get_client(); - if (staffs.indexOf(s) ==-1 && clients.indexOf(c) ==-1) + if (clients.indexOf(c) ==-1) $(this).fadeOut(); else $(this).fadeIn(); }); } + function filter_workspace_by_both(staffs, clients) + { + //filter some of them; + $('div.workspace div.divTable').each(function(i,e){ + var job = $(e).data().job; + var s = job.get_staff(); + var c = job.get_client(); + + if (staffs.indexOf(s) ==-1 || clients.indexOf(c) ==-1) + $(this).fadeOut(); + else + $(this).fadeIn(); + }); + } + function filter_workspace_by_weeks(){ var hide_week1 = $('div.week1').hasClass('filtered'); var hide_week2 = $('div.week2').hasClass('filtered');