diff --git a/lib/client/views/home.coffee b/lib/client/views/home.coffee index 3544f37..29b8011 100644 --- a/lib/client/views/home.coffee +++ b/lib/client/views/home.coffee @@ -8,6 +8,10 @@ AttendanceSummaryView = require './attendance-summary' DinnersSummaryView = require './dinners-summary' RegisterView = require './register' +PaperRegister = require './pdfs/paper-register' + +wkhtmltopdf = require '../../bindings/wkhtmltopdf' + module.exports = class HomeView extends View @content: -> @@ -41,6 +45,12 @@ module.exports = @div class: 'brand bg-black', => @span class: 'name', 'Select a Class' + @div class: 'tile bg-darkRed', click: 'printPaperRegister', => + @div class: 'tile-content icon', => + @i class: 'icon-cabinet' + @div class: 'brand bg-black', => + @span class: 'name', 'Print Paper Registers' + openAttendanceSummary: (event, element) -> $('#mainBody').html(new AttendanceSummaryView) @@ -57,3 +67,18 @@ module.exports = view.loadData() return false + + printPaperRegister: (event, element) -> + $('#mainBody').append(new PaperRegister) + + path = "C:\\pdf\\paper-registers.pdf" + + wkhtmltopdf.render($('.pdf').html(), path) + + $('.pdf').remove() + + setTimeout(-> + require('shell').openExternal(path) + , 1000) + + return false diff --git a/lib/client/views/pdfs/paper-register.coffee b/lib/client/views/pdfs/paper-register.coffee new file mode 100644 index 0000000..ef11201 --- /dev/null +++ b/lib/client/views/pdfs/paper-register.coffee @@ -0,0 +1,19 @@ +{View} = require 'space-pen' + +{Class, Config, Pupil, Session} = require '../../../database' + +module.exports = + class PaperRegisters extends View + @content: -> + @div class:'pdf', => + for klass in Class.all() + @h1 Config.setting('name') + @h2 klass.name + @table style: 'page-break-after:always;', => + @tr => + @th 'Name' + @th 'Present' + for pupil in Pupil.where('classId', klass.idClass) + @tr => + @td pupil.firstName + ' ' + pupil.lastName + @td '[]'