-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
List Absent pupils in date range (to PDF), #6
- Loading branch information
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{View} = require 'space-pen' | ||
|
||
{Class, Config, Session} = require '../../../database' | ||
|
||
module.exports = | ||
class AttendanceRangePDF extends View | ||
@content: (dates) -> | ||
klass = 0 | ||
@div class: 'pdf', => | ||
@h1 Config.setting('name') | ||
@h2 'Absent Pupils in Range' | ||
for date in dates | ||
for session in Session.all() | ||
@h3 session.name + ' ' + Session.displayDate(date) | ||
@ul => | ||
for pupil in Session.absentPupilsInSession(session.idSessions, new Date(Date.parse(date))) | ||
@li pupil.firstName + ' ' + pupil.lastName + ' (' + Class.find('idClass', pupil.classId).name + ')' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{View} = require 'space-pen' | ||
|
||
{Register} = require '../../../database' | ||
|
||
AttendanceRangePDF = require '../pdfs/attendance-range' | ||
|
||
wkhtmltopdf = require '../../../bindings/wkhtmltopdf' | ||
|
||
module.exports = | ||
class AttendanceRangeView extends View | ||
@content: -> | ||
@div class: 'metro window-overlay', id: 'modalContainer', => | ||
@div class: 'window flat shadow', => | ||
@div class: 'caption', => | ||
@button class: 'btn-close', click: 'closeWindow' | ||
@div class: 'title', 'Select Range' | ||
@div class: 'content', => | ||
@form => | ||
@label 'From' | ||
@div class: 'input-control text', => | ||
@input type: 'date', id: 'fromDate' | ||
@label 'To' | ||
@div class: 'input-control text', => | ||
@input type: 'date', id: 'toDate' | ||
@div class: 'form-actions', => | ||
@button class: 'primary', click: 'print', 'Print' | ||
@button click: 'closeWindow', 'Cancel' | ||
|
||
closeWindow: (event, element) -> | ||
$('#modalContainer').remove() | ||
return false | ||
|
||
print: (event, element) -> | ||
registers = Register.inRange($('#fromDate').val(), $('#toDate').val()) | ||
dates = [] | ||
for register in registers | ||
if dates.indexOf(register.date) == -1 | ||
dates.push register.date | ||
|
||
$('#mainBody').append(new AttendanceRangePDF(dates)) | ||
|
||
path = "C:\\pdf\\attendance.pdf" | ||
|
||
wkhtmltopdf.render($('.pdf').html(), path) | ||
|
||
$('.pdf').remove() | ||
|
||
@closeWindow(event, element) | ||
return false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters