Sfoglia il codice sorgente

template test done

master
patrick 6 anni fa
parent
commit
c8298f3b3b
3 ha cambiato i file con 143 aggiunte e 10 eliminazioni
  1. +6
    -0
      js/ts.js
  2. +133
    -7
      js/xeroc.js
  3. +4
    -3
      ts.php

+ 6
- 0
js/ts.js Vedi File

@@ -17,6 +17,12 @@ function bts_random_number()
return Math.floor(Math.random() * Math.floor(99999)); // a random number;
}

jQuery.fn.allHTML = function(s) {
return s
? this.before(s).remove()
: jQuery("<p>").append(this.eq(0).clone()).html();
};

//https://gist.github.com/gordonbrander/2230317
function bts_unique_ID(){
function chr4(){

+ 133
- 7
js/xeroc.js Vedi File

@@ -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);

+ 4
- 3
ts.php Vedi File

@@ -167,8 +167,8 @@ class AcareOffice{
header("Content-Disposition:attachment; filename=$filename");
header("Content-Type: application/force-download");
//readfile(dirname(__FILE__) . "/img/circle.png");
echo "content of this file " . print_r($clients, true) . print_r($_POST, true);
$csv_header = "RegistrationNumber,NDISNumber,SupportsDeliveredFrom,SupportsDeliveredTo,SupportNumber,ClaimReference,Quantity,Hours,UnitPrice,GSTCode,AuthorisedBy,ParticipantApproved,InKindFundingProgram,ClaimType,CancellationReason\n";
echo "$csv_header" . print_r($clients, true) . print_r($_POST, true);
exit();
}
@@ -1559,4 +1559,5 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
//$bb->create_invoice_by_client("8cb3d205-6cdc-4187-ae39-9216923dd86d", "2019-07-01", "2019-07-31");
//$idx = $bb->convert_date_to_idx("2019-07-02 14:30:00", "2019-07-01", "2019-07-02");
//wp_send_json($idx);
//$bb->create_timesheet_from_db("2019-07-01", "2019-07-14");
//$bb->create_timesheet_from_db("2019-07-01", "2019-07-14");


Loading…
Annulla
Salva