Skip to content

Commit

Permalink
Allow user to print out a paper register, part of fire registers for #6
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcath committed Oct 17, 2014
1 parent c35f2f8 commit 3e59741
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/client/views/home.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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: ->
Expand Down Expand Up @@ -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)

Expand All @@ -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
19 changes: 19 additions & 0 deletions lib/client/views/pdfs/paper-register.coffee
Original file line number Diff line number Diff line change
@@ -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 '[]'

0 comments on commit 3e59741

Please sign in to comment.