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

106 строки
3.6 KiB

  1. /**
  2. * Created by Benny on 14.11.2014.
  3. */
  4. "use strict";
  5. var TB = TB || {};
  6. TB.Ext = TB.Ext || {};
  7. /**
  8. * Currently using https://github.com/bpampuch/pdfmake
  9. */
  10. TB.Ext.PDF = {
  11. getDocDefinition : function( content ) {
  12. return {
  13. header : { text: 'tbuddy.de', margin: [ 10, 2, 2, 2 ] },
  14. content : content,
  15. footer : { text: 'Erstellt mit tbuddy.de ', alignment: 'right', margin: [ 2, 2, 10, 2 ] },
  16. styles : {
  17. h1 : {
  18. fontSize: 22,
  19. bold: true
  20. }
  21. }
  22. };
  23. },
  24. downloadAppointment : function( data ) {
  25. var tableAcceptedBody, docDefinition, filename,
  26. content = [],
  27. eventTitle,
  28. appointment = data.appointment,
  29. listAccepted = data.listAccepted;
  30. eventTitle = ( appointment.subject ) ? appointment.subject : appointment.home + ' - ' + appointment.guest;
  31. // Download filename
  32. filename = eventTitle;
  33. filename += ' ' + TB.Utils.getDatetimeStringFromUnixTimestamp( appointment.starttime );
  34. filename += '.pdf';
  35. // Generate game header
  36. content.push( { text: eventTitle, style : 'h1' } );
  37. content.push( " " );
  38. if ( appointment.subject ) {
  39. content.push( {
  40. table : {
  41. headerRows: 0,
  42. widths: [ 'auto', '*'],
  43. body : [
  44. [ 'Datum', TB.Utils.getDatetimeStringFromUnixTimestamp( appointment.starttime ) ],
  45. [ 'Kommentar', ( appointment.comment ) ? appointment.comment : '---' ]
  46. ]
  47. }
  48. });
  49. // List of player
  50. content.push( " " );
  51. content.push( { text: "Teilnehmer", style: 'h1' } );
  52. } else {
  53. content.push( {
  54. table : {
  55. headerRows: 0,
  56. widths: [ 'auto', '*'],
  57. body : [
  58. [ 'ID Nummer', TB.GUI.getValue( appointment.id_nr, '---' ) ],
  59. [ 'Heim Verein', appointment.home ],
  60. [ 'Gast Verein', appointment.guest ],
  61. [ 'Datum', TB.Utils.getDatetimeStringFromUnixTimestamp( appointment.starttime ) ],
  62. [ 'Kommentar', ( appointment.comment ) ? appointment.comment : '---' ]
  63. ]
  64. }
  65. });
  66. // List of player
  67. content.push( " " );
  68. content.push( { text: "Buddy", style: 'h1' } );
  69. }
  70. // Generate list of attending player
  71. $.each( listAccepted, function( i, p ) {
  72. content.push( " " );
  73. content.push( { text: 'Buddy #' + (i+1) } );
  74. content.push( {
  75. table : {
  76. headerRows: 0,
  77. widths: [ 'auto', '*'],
  78. body : [
  79. [ 'Vor- und Nachname', TB.GUI.playerName( p ) ],
  80. [ 'Passnummer', ( p.player_pass_no ) ? p.player_pass_no : '---' ],
  81. [ 'Geburtstdatum', ( p.birthday ) ? TB.Utils.convertSQLDateToDatepickerDate( p.birthday ) : '---' ],
  82. [ 'Zusage am', TB.Utils.getDatetimeStringFromUnixTimestamp( p.last_update ) ]
  83. ]
  84. }
  85. });
  86. });
  87. docDefinition = this.getDocDefinition( content );
  88. // Create and download
  89. pdfMake.createPdf(docDefinition).download( filename );
  90. }
  91. };