| @@ -333,7 +333,8 @@ | |||
| var el = $('#job_' + job.id).addClass("blink_me"); | |||
| setTimeout(function(){ | |||
| el.removeClass('blink_me'); | |||
| }, 1500); | |||
| }, 1500); | |||
| debounced_calculate(); | |||
| }); | |||
| $(document).on('click', 'div.divTableHead.bdelete span.ticon-trash', function(){ | |||
| @@ -426,7 +427,7 @@ | |||
| if (response.status=='success'){ | |||
| var id = el.attr('data-id'); | |||
| delete bts().job_map[id]; | |||
| console.log("delete %s , job_map[%s]=%o ", id, id, bts().job_map[id]); | |||
| //console.log("delete %s , job_map[%s]=%o ", id, id, bts().job_map[id]); | |||
| el.addClass('blink_me'); | |||
| el.fadeOut(900); | |||
| setTimeout(function(){ | |||
| @@ -439,6 +440,7 @@ | |||
| }); | |||
| } | |||
| } | |||
| debounced_calculate(); | |||
| }); | |||
| $(document).on('mouseenter', 'div.divTableCell', function(){ | |||
| @@ -1470,24 +1472,25 @@ | |||
| if (!confirm ('copy entire week to next week? ')) | |||
| return; | |||
| var jobs = []; | |||
| var job_els =[]; | |||
| $('div.week1 >div').each(function(i,e){ | |||
| var date = new Date($(e).find('span.weekday').data().date); | |||
| var strDate = format_date(date); //yyyy-mm-dd | |||
| $('div.bstart input').each(function(i,e){ | |||
| var value = $(e).attr('value'); | |||
| $('div.bstart:visible').each(function(i,e){ | |||
| var value = $(e).html(); | |||
| if( -1 != value.indexOf(strDate) ) //found | |||
| { | |||
| var el = $(e).closest('div.divTable'); | |||
| if (el.is(":visible")){ | |||
| var j = el.data().job; | |||
| var newj = clone_data_create_new_job(j.get_record_from_ui(),7);//add 7 days | |||
| job_els.push(newj.el); | |||
| var el = $(e).closest('div.jobTable'); | |||
| if (el.is(":visible") && el.hasClass('saved')){ | |||
| 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 | |||
| add_new_job_to_map(newj); | |||
| jobs.push(newj); | |||
| } | |||
| } | |||
| }); | |||
| }); | |||
| show_jobs(job_els); | |||
| show_jobs(jobs); | |||
| debounced_calculate(); | |||
| }); | |||
| @@ -1511,19 +1514,21 @@ | |||
| $('div.week1 > div').click(function(e){ | |||
| e.stopPropagation(); | |||
| if ($('div.bstart input.blink_me').length == 0){ | |||
| if ($('div.bstart.blink_me').length == 0){ | |||
| alert("nothing to copy"); | |||
| return; | |||
| } | |||
| if (!confirm ('copy to next week')) | |||
| return; | |||
| var jobs_el = []; | |||
| $('div.bstart input.blink_me').each(function(i,e){ | |||
| var new_jobs = []; | |||
| $('div.bstart.blink_me').each(function(i,e){ | |||
| var r = copy_single_day_to_next_week(e); | |||
| if (r != false) | |||
| jobs_el.push(r.el); | |||
| if (r != false){ | |||
| add_new_job_to_map(r); | |||
| new_jobs.push(r); | |||
| } | |||
| }); | |||
| show_jobs(jobs_el); | |||
| show_jobs(new_jobs); | |||
| unblink_all_date(); | |||
| }); | |||
| @@ -1535,7 +1540,7 @@ | |||
| function copy_single_day_to_next_week(el){ | |||
| var tb = $(el).closest('div.jobTable'); | |||
| if (tb.is(':visible')){ | |||
| if (tb.is(':visible') && tb.hasClass('saved')){ | |||
| var id = tb.data().id; | |||
| var j = bts().job_map[id]; | |||
| var newj = clone_data_create_new_job(j.get_record() , 7); // +7 days | |||
| @@ -1595,11 +1600,16 @@ | |||
| var strDate = format_date(date); //yyyy-mm-dd | |||
| var els=[]; | |||
| unblink_all_date(); | |||
| $('div.bstart input').each(function(i,e){ | |||
| var first_into_view = false; //make sure first row in match is visible | |||
| $('div.bstart').each(function(i,e){ | |||
| if ( $(e).is(":visible") ){ | |||
| var value = $(e).attr('value'); | |||
| var value = $(e).html(); | |||
| if( -1 != value.indexOf(strDate) ) //found | |||
| { | |||
| if ( !first_into_view ){ //scroll to top | |||
| first_into_view = true; | |||
| $(e).get(0).scrollIntoView(); | |||
| } | |||
| els.push(e); | |||
| $(e).addClass('blink_me'); | |||
| } | |||
| @@ -1609,7 +1619,7 @@ | |||
| function unblink_all_date(){ | |||
| $('div.bstart input').removeClass('blink_me'); | |||
| $('div.bstart').removeClass('blink_me'); | |||
| } | |||
| $('div.sheettitle h1 span').click(function(){ | |||
| @@ -1689,14 +1699,15 @@ | |||
| return s.indexOf('hour') != -1; | |||
| } | |||
| function show_jobs(job_els, in_ajax){ | |||
| if (job_els.length >0){ | |||
| $('div.workspace').append(job_els); | |||
| job_els[0].get(0).scrollIntoView(); | |||
| console.log('loading ... %d jobs', job_els.length); | |||
| function show_jobs(jobs){ | |||
| if (jobs.length >0){ | |||
| var templ = $("#jobv1_item").html(); | |||
| var html = Mustache.render(templ, {jobs:jobs}); //job id should be available; | |||
| var el = $(html); | |||
| $('div.workspace').append(el); | |||
| el.get(0).scrollIntoView(); | |||
| } | |||
| if (typeof in_ajax =='undefined') | |||
| dtp_init(); | |||
| debounced_calculate(); | |||
| } | |||
| function format_date(date){ | |||
| @@ -1739,7 +1750,7 @@ | |||
| $('div.bts_message_button').trigger('click'); | |||
| }); | |||
| $('button[name="confirmschedule"]').click(function(){ | |||
| $('button[name="confirmschedule"]').click(function(){//TODO: check error before confirm | |||
| if (!confirm('sending email to each staff for their job arrangement?')) | |||
| return; | |||
| $('div.bts_message .ult-overlay-close-inside').hide(); | |||
| @@ -1888,6 +1899,16 @@ | |||
| var id = $(e).attr('data-id'); | |||
| var job = bts().job_map[id]; | |||
| if (id == ''){ | |||
| //is this a new Job without id? | |||
| var newjob_id = $(e).attr('data-newjob_id'); | |||
| if ( typeof newjob_id != "undefined"){ | |||
| id = newjob_id; | |||
| job = bts().job_map_new[newjob_id]; | |||
| } | |||
| } | |||
| if (typeof job === 'undefined' || !job.is_job_valid() ) | |||
| return; | |||
| var ps = job.get_payment_summary(); | |||