|
|
|
@@ -31,7 +31,6 @@ function on_download_ndis_csv (){} |
|
|
|
return "<tr class='loading' ><td colspan=4 class='loading'><img src='"+bts().load_job_img +"'><br><h1>Sync to Xero</h1></td></tr>"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function display_hour_lines(response) |
|
|
|
{ |
|
|
|
$('#staff').html(''); |
|
|
|
@@ -339,26 +338,24 @@ function on_download_ndis_csv (){} |
|
|
|
} |
|
|
|
function setup_clients_pick() |
|
|
|
{ |
|
|
|
var options = {}; |
|
|
|
console.log(get_template('#select_ndis_client')); |
|
|
|
options.id = "{{id}}"; |
|
|
|
console.log(get_template('#select_ndis_client', options)); |
|
|
|
options.remove_class = "hidden"; |
|
|
|
console.log(get_template('#select_ndis_client', options)); |
|
|
|
options.remove_classes= ['hidden', 'bts_template']; |
|
|
|
console.log(get_template('#select_ndis_client', options)); |
|
|
|
options.begin="{{#data}}"; |
|
|
|
console.log(get_template('#select_ndis_client', options)); |
|
|
|
options.end="{{/data}}"; |
|
|
|
console.log(get_template('#select_ndis_client', options)); |
|
|
|
options.add_classes=["clas1", "clas2", "class3"]; |
|
|
|
console.log(get_template('#select_ndis_client', options)); |
|
|
|
options.add_class="addclas1"; |
|
|
|
console.log(get_template('#select_ndis_client', options)); |
|
|
|
|
|
|
|
return; |
|
|
|
show_loading_client(); |
|
|
|
$('div.clientlist div.peopleitem').remove(); //clear it |
|
|
|
$('.select_client_check_box').remove(); |
|
|
|
var options = { |
|
|
|
remove_classes: ['hidden', 'bts_template'], |
|
|
|
begin:"{{#users}}", |
|
|
|
end: "{{/users}}", |
|
|
|
add_classes:['select_client_check_box', "c{{login}}"], |
|
|
|
id : "s_{{login}}", |
|
|
|
data: { |
|
|
|
'data-account' : "{{account}}", |
|
|
|
'data-login' : "{{login}}", |
|
|
|
'data-first' : "{{firstname}}", |
|
|
|
'data-display': "{{display_name}}", |
|
|
|
'data-last': "{{lastname}}", |
|
|
|
} |
|
|
|
}; |
|
|
|
var template = get_template('#select_ndis_client', options); |
|
|
|
console.log(template); |
|
|
|
$.post(bts().ajax_url, { // POST request |
|
|
|
_ajax_nonce: bts().nonce, // nonce |
|
|
|
action: "list_client", // action |
|
|
|
@@ -366,20 +363,32 @@ function on_download_ndis_csv (){} |
|
|
|
if (response.status =='success'){ |
|
|
|
bts().client = response.users; |
|
|
|
bts().client_map = {}; |
|
|
|
hide_loading_client(); |
|
|
|
response.users.forEach(function(u){ |
|
|
|
bts().client_map[u.login] = u; |
|
|
|
hide_loading_client(); |
|
|
|
var html = bts_client_html(u); |
|
|
|
jQuery('div.clientlist').append(html); |
|
|
|
new People("#p" + u.login, '#client_item' ,u); |
|
|
|
if (u.payment != 'invoice') |
|
|
|
u.ndis_checked ="checked"; |
|
|
|
}); |
|
|
|
var html = Mustache.render(template,response); |
|
|
|
$('#select_ndis_client').after(html); |
|
|
|
}else{ |
|
|
|
alert('error getting Client list'); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
function get_checked_ndis_clients() |
|
|
|
{ |
|
|
|
var clients=[]; |
|
|
|
$('.select_client_check_box input.client_check').each(function(){ |
|
|
|
if( $(this).prop('checked') ){ |
|
|
|
clients.push($(this).data().login); |
|
|
|
} |
|
|
|
}); |
|
|
|
return clients; |
|
|
|
}; |
|
|
|
|
|
|
|
function show_loading_client(){}; |
|
|
|
function hide_loading_client(){}; |
|
|
|
|
|
|
|
function get_template(id, options) |
|
|
|
{ |
|
|
|
@@ -418,7 +427,14 @@ function on_download_ndis_csv (){} |
|
|
|
if (typeof options.id !='undefined') |
|
|
|
{ |
|
|
|
el.attr('id', options.id); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (typeof options.data != 'undefined'){ |
|
|
|
Object.keys(options.data).forEach(function(key,i){ |
|
|
|
el.attr(key, options.data[key]); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
html = el.allHTML(); |
|
|
|
|
|
|
|
if (typeof options.begin != 'undefined' && options.begin != '') { |
|
|
|
@@ -440,19 +456,27 @@ function on_download_ndis_csv (){} |
|
|
|
$('input[name="finish"]').attr('value', val); |
|
|
|
}); |
|
|
|
|
|
|
|
$('#checkall').click(function(){ |
|
|
|
var val = $(this).prop('checked'); |
|
|
|
$('input.client_check').prop('checked', val); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
function do_download_ndis(){ |
|
|
|
var form = $('#ndis'); |
|
|
|
$('#ndis input.dynamic').remove(); |
|
|
|
|
|
|
|
var clients = ["client1", "client2", "client3", "client4"]; |
|
|
|
clients.forEach(function(e,i){ |
|
|
|
if ( $('#e' + i).length == 0 ){ |
|
|
|
var input = $('<input id="e'+ i +'" type="hidden" name="clients[]" value="' + e +'">'); |
|
|
|
var clients = get_checked_ndis_clients(); |
|
|
|
if ( clients.length > 0 ){ |
|
|
|
clients.forEach(function(e,i){ |
|
|
|
var input = $('<input class="dynamic" type="hidden" name="clients[]" value="' + e +'">'); |
|
|
|
form.append(input); |
|
|
|
}else{ |
|
|
|
$('#e' + i).attr('value', e); |
|
|
|
} |
|
|
|
}); |
|
|
|
form.submit(); |
|
|
|
}); |
|
|
|
form.submit(); |
|
|
|
}else{ |
|
|
|
alert("Please select one or more client"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
datebox(); |