|
|
|
@@ -252,9 +252,11 @@ function on_download_ndis_csv (){} |
|
|
|
}); |
|
|
|
|
|
|
|
$(document).on("afterShow.vc.accordion", function(e, opt) { |
|
|
|
console.log("%o, %o", e, opt); |
|
|
|
//console.log("%o, %o", e, opt); |
|
|
|
if (e.target.hash =="#1565353205981-c3582e44-83d2"){ |
|
|
|
get_timesheet_from_xero(); |
|
|
|
}else if (e.target.hash =="#1568049914546-bc20bf7d-07c3") { |
|
|
|
refresh_ndis_csv(); |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
@@ -313,14 +315,133 @@ function on_download_ndis_csv (){} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
datebox(); |
|
|
|
setup_invoice_start_finish(); |
|
|
|
|
|
|
|
/* ------------- ndis csv ------------------------- */ |
|
|
|
function refresh_ndis_csv () |
|
|
|
{ |
|
|
|
setup_ndis_start_finish(); |
|
|
|
setup_clients_pick(); |
|
|
|
on_download_ndis_csv = do_download_ndis; |
|
|
|
} |
|
|
|
function setup_ndis_start_finish() |
|
|
|
{ |
|
|
|
var date = new Date(); |
|
|
|
var firstDay = new Date(date.getFullYear(), |
|
|
|
date.getMonth(), 1); |
|
|
|
var lastDay = new Date(date.getFullYear(), |
|
|
|
date.getMonth(), daysInMonth(date.getMonth()+1, |
|
|
|
date.getFullYear())); |
|
|
|
$('#ndis_start').attr('value', format_date(firstDay)); |
|
|
|
$('#ndis_finish').attr('value', format_date(lastDay)); |
|
|
|
|
|
|
|
$('input[name="start"]').attr('value', format_date(firstDay)); |
|
|
|
$('input[name="finish"]').attr('value', format_date(lastDay)); |
|
|
|
} |
|
|
|
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 |
|
|
|
$.post(bts().ajax_url, { // POST request |
|
|
|
_ajax_nonce: bts().nonce, // nonce |
|
|
|
action: "list_client", // action |
|
|
|
}, function(response, status, xhr){ |
|
|
|
if (response.status =='success'){ |
|
|
|
bts().client = response.users; |
|
|
|
bts().client_map = {}; |
|
|
|
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); |
|
|
|
}); |
|
|
|
}else{ |
|
|
|
alert('error getting Client list'); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function get_template(id, options) |
|
|
|
{ |
|
|
|
if (typeof id == 'undefined' || id =="") |
|
|
|
return ""; |
|
|
|
var html = $(id).allHTML(); |
|
|
|
var el = $(html); |
|
|
|
|
|
|
|
if (typeof options == 'undefined') |
|
|
|
{ |
|
|
|
el.removeAttr('id'); |
|
|
|
return el.allHTML(); |
|
|
|
} |
|
|
|
|
|
|
|
if (typeof options.remove_classes != "undefined") |
|
|
|
{ |
|
|
|
options.remove_classes.forEach(function(e,i){ |
|
|
|
el.removeClass(e); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
if (typeof options.remove_class != "undefined") |
|
|
|
{ |
|
|
|
el.removeClass(options.remove_class); |
|
|
|
} |
|
|
|
|
|
|
|
if (typeof options.add_class != 'undefined') |
|
|
|
{ |
|
|
|
el.addClass(options.add_class); |
|
|
|
} |
|
|
|
|
|
|
|
if (typeof options.add_classes != 'undefined'){ |
|
|
|
el.addClass(options.add_classes.join(" ")); |
|
|
|
} |
|
|
|
|
|
|
|
if (typeof options.id !='undefined') |
|
|
|
{ |
|
|
|
el.attr('id', options.id); |
|
|
|
} |
|
|
|
html = el.allHTML(); |
|
|
|
|
|
|
|
if (typeof options.begin != 'undefined' && options.begin != '') { |
|
|
|
html = options.begin + html; |
|
|
|
} |
|
|
|
if (typeof options.end != 'undefined' && options.end != '') { |
|
|
|
html = html + options.end; |
|
|
|
} |
|
|
|
return html; |
|
|
|
} |
|
|
|
|
|
|
|
$('#ndis_start').change(function(e){ |
|
|
|
var val = $(this).attr('value'); |
|
|
|
$('input[name="start"]').attr('value', val); |
|
|
|
}); |
|
|
|
|
|
|
|
on_download_ndis_csv = do_download_ndis; |
|
|
|
$('#ndis_finish').change(function(e){ |
|
|
|
var val = $(this).attr('value'); |
|
|
|
$('input[name="finish"]').attr('value', val); |
|
|
|
}); |
|
|
|
|
|
|
|
function do_download_ndis(){ |
|
|
|
var form = $('#ndis'); |
|
|
|
$('input[name="start"]').attr('value', "start中"); |
|
|
|
$('input[name="finish"]').attr('value', "finish文"); |
|
|
|
|
|
|
|
var clients = ["client1", "client2", "client3", "client4"]; |
|
|
|
clients.forEach(function(e,i){ |
|
|
|
@@ -332,7 +453,12 @@ function on_download_ndis_csv (){} |
|
|
|
} |
|
|
|
}); |
|
|
|
form.submit(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
datebox(); |
|
|
|
setup_invoice_start_finish(); |
|
|
|
|
|
|
|
|
|
|
|
/*_____________________________________________*/ |
|
|
|
}); |
|
|
|
})(jQuery); |