diff --git a/css/bts_office.css b/css/bts_office.css index 2509c0a..440e442 100644 --- a/css/bts_office.css +++ b/css/bts_office.css @@ -1042,6 +1042,14 @@ div.divTable .invalid { background-color: yellow; } + +div.blueTable.divTable.jobTable.disabled *{ + background-color: lightgrey; + color:black; +} +div.blueTable.divTable.jobTable.disabled span.ticon{ + display:none; +} /* end of div table */ /* pop up message box */ .bts_message .ult_modal-body { diff --git a/html/jobv1.html b/html/jobv1.html index e21d67a..56cee92 100644 --- a/html/jobv1.html +++ b/html/jobv1.html @@ -1,5 +1,5 @@ {{#jobs}} -
pay_begin; + return begin > pay_begin; } // $(document).on('click', 'div.bts_editor div.ult-overlay-close', function(){ // $('.Editing').addClass('blink_me'); @@ -542,6 +536,7 @@ this.rating_range(this); this.identify_job_week(this); this.job_acked(this); + this.job_disabled(this); } tos_name(e){ @@ -601,14 +596,18 @@ } job_acked(e){ - if (typeof e == 'undefined'){ - console.log('break;'); - } if (e.ack != 0){ e.is_confirmed = true; } } - + job_disabled(e){ + var allow = allow_editing(e.start); + if (!allow) + e.disabled =true; + else + delete e.disabled; + + } is_job_valid(){ var error_found = false; @@ -673,7 +672,11 @@ }else{ return 1 * rate_info.RatePerUnit; } - } + } + + allow_edit(){ + return allow_editing(this.start); + } }; class JobEditor{ //save data for the record, and display it as GUI constructor(selector, job){ @@ -1459,7 +1462,7 @@ if( -1 != value.indexOf(strDate) ) //found { var el = $(e).closest('div.jobTable'); - if (el.is(":visible") && el.hasClass('saved')){ + if (el.is(":visible") && el.hasClass('saved') && ! el.hasClass('disabled')){ var id = el.data().id; var j = bts().job_map[id]; var newj = clone_data_create_new_job(j.get_record(),7);//add 7 days @@ -1471,6 +1474,7 @@ }); show_jobs(jobs); debounced_calculate(); + alert("Copied " + jobs.length + " jobs"); }); $('div.weekly div.weekname.next > input').click(function(e){ @@ -1510,6 +1514,7 @@ }); show_jobs(new_jobs); unblink_all_date(); + alert("Copied " + new_jobs.length + " jobs"); }); $('div.week1,div.week2').click(function(e){ @@ -1523,6 +1528,8 @@ if (tb.is(':visible') && tb.hasClass('saved')){ var id = tb.data().id; var j = bts().job_map[id]; + if (! j.allow_edit()) + return false; var newj = clone_data_create_new_job(j.get_record() , 7); // +7 days return newj; } @@ -1945,6 +1952,8 @@ $('div.jobTable[data-staff="' + id + '"]:visible').each(function(){ var el = this; var match = find_driving_partner_job(el); + if (match == false) + return; var staff = $('#' + match).data().staff; if (typeof kms[staff] =='undefined'){ @@ -1980,7 +1989,11 @@ } }); if (matches.length != 1){ + $(selector).find('.bstart').addClass("error"); + $(selector).find(".bstart_err").html("No matching Job"); + ensure_visible(selector); console.warn("1 driving job has more than 1 matching", $(selector).attr('id'), matches); + return false; } $(selector).attr('data-driver', matches[0].driver); $(selector).attr('data-parent', matches[0].parent); @@ -2267,11 +2280,24 @@ function do_edit_job(id) { - open_modal('editor'); - set_modal_title('editor', "Editing Job: " + id); - //make a copy of the job var child = bts().job_map[id]; + if (! child.allow_edit()){ + var msg =`You should not Edit this job, + it's locked by Xero, + Unless you insist to proceed + Are you sure you want edit it? + `; + if(!confirm(msg)) + return; + } + + var el = $("#job_" + id); + el.addClass('Editing'); + + open_modal('editor'); + set_modal_title('editor', "Editing Job: " + id); + var job_copy = Object.assign(Object.create(Object.getPrototypeOf(child)), child); //a shallow copy only; job_copy.editorid = bts_random_number(); //set_modal_data('editor', {jobid: id, job_copy:job_copy});