timesheet source code
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

79 lines
2.5KB

  1. (function ($) {
  2. $(function () {
  3. /*_____________________________________________*/
  4. function test(){
  5. var temp = $('#bts_staff_hours_template').html();
  6. var lines = [];
  7. for (var i=1; i<10; i++){
  8. var data = {
  9. staff_name: 'john',
  10. rate_name : 'some rate name',
  11. staff_id:"abc_"+ i,
  12. };
  13. data.days={};
  14. for (var j =1; j<=14; j++){
  15. data['days_' + j] = j + '/July';
  16. }
  17. lines.push(data);
  18. }
  19. var html = Mustache.render(temp, {lines:lines});
  20. $('#staff').append(html);
  21. }
  22. function datebox(){
  23. $( ".boundary_datepicker" ).datepicker();
  24. $( ".boundary_datepicker" ).datepicker("option", "dateFormat", "yy-mm-dd");
  25. }
  26. function display_hour_lines(response)
  27. {
  28. $('#staff').html();
  29. var temp = $('#bts_staff_hours_template').html();
  30. var html = Mustache.render(temp, response);
  31. $('#staff').append(html);
  32. }
  33. function set_payroll_calendar(cal)
  34. {
  35. $('#cstart').attr('value', cal.start);
  36. $('#cfinish').attr('value', cal.finish);
  37. $('#paydate').attr('value', cal.paydate);
  38. }
  39. function get_timesheet_from_xero(){
  40. $.post(bts().ajax_url, { // POST request
  41. _ajax_nonce: bts().nonce, // nonce
  42. action: "get_timesheet_from_xero", // action
  43. sync: false,
  44. }).done(function(response){
  45. set_payroll_calendar(response.payroll_calendar);
  46. console.log("%o", response);
  47. display_hour_lines(response);
  48. }).fail(function(){
  49. console.warn('failed');
  50. }).always(function(){
  51. console.log('completed');
  52. });
  53. }
  54. function sync_timesheet_from_xero(){
  55. $.post(bts().ajax_url, { // POST request
  56. _ajax_nonce: bts().nonce, // nonce
  57. action: "get_timesheet_from_xero", // action
  58. sync: true,
  59. }).done(function(response){
  60. set_payroll_calendar(response.payroll_calendar);
  61. console.log("%o", response);
  62. display_hour_lines(response);
  63. }).fail(function(){
  64. console.warn('failed');
  65. }).always(function(){
  66. console.log('completed');
  67. });
  68. }
  69. $('#sync_timesheet').click(function(){
  70. sync_timesheet_from_xero();
  71. });
  72. /*_____________________________________________*/
  73. });
  74. })(jQuery);