Browse Source

disable jobs that passed payroll start date

master
patrick 6 years ago
parent
commit
dea9c6f203
3 changed files with 53 additions and 19 deletions
  1. +8
    -0
      css/bts_office.css
  2. +1
    -1
      html/jobv1.html
  3. +44
    -18
      js/bts_office.js

+ 8
- 0
css/bts_office.css View File

background-color: yellow; 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 */ /* end of div table */
/* pop up message box */ /* pop up message box */
.bts_message .ult_modal-body { .bts_message .ult_modal-body {

+ 1
- 1
html/jobv1.html View File

{{#jobs}} {{#jobs}}
<div class="divTable jobTable blueTable {{#saved}} saved {{/saved}} {{^saved}} dirty {{/saved}} {{#is_week1}}week1job{{/is_week1}} {{#is_week2}} week2job {{/is_week2}}"
<div class="divTable jobTable blueTable {{#disabled}} disabled {{/disabled}} {{#saved}} saved {{/saved}} {{^saved}} dirty {{/saved}} {{#is_week1}}week1job{{/is_week1}} {{#is_week2}} week2job {{/is_week2}}"
{{#id}} id="job_{{id}}" {{/id}} {{^id}} id="{{newjob_id}}" {{/id}} {{#id}} id="job_{{id}}" {{/id}} {{^id}} id="{{newjob_id}}" {{/id}}
data-id="{{id}}" {{^id}} data-newjob_id="{{newjob_id}}" {{/id}} data-id="{{id}}" {{^id}} data-newjob_id="{{newjob_id}}" {{/id}}
data-tos="{{tos}}" data-rate="{{rate}}" data-staff="{{staff}}" data-client="{{client}}" data-tos="{{tos}}" data-rate="{{rate}}" data-staff="{{staff}}" data-client="{{client}}"

+ 44
- 18
js/bts_office.js View File

}); });
$(document).on('click', 'div.workspace div.bedit span.ticon-edit', function(){ $(document).on('click', 'div.workspace div.bedit span.ticon-edit', function(){
var el = $(this).closest('div.jobTable');
el.addClass('Editing');
var el = $(this).closest('div.jobTable');
var newjob_id = el.attr('data-newjob_id'); var newjob_id = el.attr('data-newjob_id');
if (typeof newjob_id != 'undefined' && newjob_id != ''){ if (typeof newjob_id != 'undefined' && newjob_id != ''){
do_edit_new_job(newjob_id); do_edit_new_job(newjob_id);
{ {
return new Date(bts().pay_calendar.start + " 00:00:00"); return new Date(bts().pay_calendar.start + " 00:00:00");
} }
function allow_editing(job){
if (! job instanceof Job)
return false;

//TODO:
function allow_editing(date){
var begin = new Date(date); var begin = new Date(date);
var pay_begin = get_payroll_start(); var pay_begin = get_payroll_start();
return date > pay_begin;
return begin > pay_begin;
} }
// $(document).on('click', 'div.bts_editor div.ult-overlay-close', function(){ // $(document).on('click', 'div.bts_editor div.ult-overlay-close', function(){
// $('.Editing').addClass('blink_me'); // $('.Editing').addClass('blink_me');
this.rating_range(this); this.rating_range(this);
this.identify_job_week(this); this.identify_job_week(this);
this.job_acked(this); this.job_acked(this);
this.job_disabled(this);
} }
tos_name(e){ tos_name(e){
} }
job_acked(e){ job_acked(e){
if (typeof e == 'undefined'){
console.log('break;');
}
if (e.ack != 0){ if (e.ack != 0){
e.is_confirmed = true; 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(){ is_job_valid(){


var error_found = false; var error_found = false;
}else{ }else{
return 1 * rate_info.RatePerUnit; return 1 * rate_info.RatePerUnit;
} }
}
}
allow_edit(){
return allow_editing(this.start);
}
}; };
class JobEditor{ //save data for the record, and display it as GUI class JobEditor{ //save data for the record, and display it as GUI
constructor(selector, job){ constructor(selector, job){
if( -1 != value.indexOf(strDate) ) //found if( -1 != value.indexOf(strDate) ) //found
{ {
var el = $(e).closest('div.jobTable'); 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 id = el.data().id;
var j = bts().job_map[id]; var j = bts().job_map[id];
var newj = clone_data_create_new_job(j.get_record(),7);//add 7 days var newj = clone_data_create_new_job(j.get_record(),7);//add 7 days
}); });
show_jobs(jobs); show_jobs(jobs);
debounced_calculate(); debounced_calculate();
alert("Copied " + jobs.length + " jobs");
}); });


$('div.weekly div.weekname.next > input').click(function(e){ $('div.weekly div.weekname.next > input').click(function(e){
}); });
show_jobs(new_jobs); show_jobs(new_jobs);
unblink_all_date(); unblink_all_date();
alert("Copied " + new_jobs.length + " jobs");
}); });
$('div.week1,div.week2').click(function(e){ $('div.week1,div.week2').click(function(e){
if (tb.is(':visible') && tb.hasClass('saved')){ if (tb.is(':visible') && tb.hasClass('saved')){
var id = tb.data().id; var id = tb.data().id;
var j = bts().job_map[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 var newj = clone_data_create_new_job(j.get_record() , 7); // +7 days
return newj; return newj;
} }
$('div.jobTable[data-staff="' + id + '"]:visible').each(function(){ $('div.jobTable[data-staff="' + id + '"]:visible').each(function(){
var el = this; var el = this;
var match = find_driving_partner_job(el); var match = find_driving_partner_job(el);
if (match == false)
return;
var staff = $('#' + match).data().staff; var staff = $('#' + match).data().staff;
if (typeof kms[staff] =='undefined'){ if (typeof kms[staff] =='undefined'){
} }
}); });
if (matches.length != 1){ 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); 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-driver', matches[0].driver);
$(selector).attr('data-parent', matches[0].parent); $(selector).attr('data-parent', matches[0].parent);
function do_edit_job(id) function do_edit_job(id)
{ {
open_modal('editor');
set_modal_title('editor', "Editing Job: " + id);

//make a copy of the job //make a copy of the job
var child = bts().job_map[id]; 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; var job_copy = Object.assign(Object.create(Object.getPrototypeOf(child)), child); //a shallow copy only;
job_copy.editorid = bts_random_number(); job_copy.editorid = bts_random_number();
//set_modal_data('editor', {jobid: id, job_copy:job_copy}); //set_modal_data('editor', {jobid: id, job_copy:job_copy});

Loading…
Cancel
Save