Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adiciona nomes dos diretores nos PDFs #346

Merged
merged 5 commits into from
Jul 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions server/controllers/defenses/TccGenerate.js
@@ -1,6 +1,7 @@
const PDFDocument = require('pdfkit')
const errors = require('../../../shared/errors')
const utils = require('../../utils')
const Settings = require('../../models/Setting')
const Defense = require('../../models/Defense')
const Cd = require('../../models/tccdocs/cd')
const Ata = require('../../models/tccdocs/ata')
Expand Down Expand Up @@ -48,6 +49,7 @@ module.exports = async function generateAllDocs(ctx) {
}
const defenseDate = defenseFind.get('date')
const date = new Date()
date.setHours(date.getHours() - 3)
const dados = {
curso: utils.translate(defenseFind.get('course')),
tituloTCC: defenseFind.get('title'),
Expand All @@ -66,10 +68,10 @@ module.exports = async function generateAllDocs(ctx) {
mesDefesa: utils.translate(Number(defenseDate.split('/')[1])),
anoDefesa: defenseDate.split('/')[2],
dia: date.getUTCDate(),
mes: utils.translate(date.getUTCMonth()),
mes: utils.translate(date.getUTCMonth() + 1),
ano: date.getUTCFullYear(),
tituloDiretor: utils.translate('temp'),
diretor: 'temp',
tituloDiretor: 'Prof(a). ',
diretor: 'NÃO ENCONTRADO NAS CONFIGURAÇÕES!',
matricula: defenseFind.get('registrationNumbers'),
discente: defenseFind.get('students').split(', ')[0],
palavrasChave: defenseFind.get('keywords'),
Expand All @@ -80,6 +82,11 @@ module.exports = async function generateAllDocs(ctx) {
aprovado: !defenseFind.get('passed') ? 'reprovado' : 'aprovado',
conceito: 'insuficiente'
}
const findFacompDirector = await Settings.where(
'key',
'facultyDirectorName'
).fetch()
if (findFacompDirector) dados.diretor = findFacompDirector.get('value')
if (defenseFind.get('advisorIsTeacher'))
dados.tituloOrientador = `Prof(a). ${dados.tituloOrientador}`
if (defenseFind.get('coAdvisorIsTeacher'))
Expand Down
3 changes: 2 additions & 1 deletion server/controllers/defenses/Update.js
Expand Up @@ -114,7 +114,8 @@ module.exports = async function updateDefense(ctx) {
return
}

if (payload.status === 'done' && payload.grade === undefined) {
const grade = payload.grade || defense.get('grade')
if (payload.status === 'done' && !grade) {
ctx.status = 422
ctx.body = { code: errors.MISSING_GRADE }
return
Expand Down
3 changes: 2 additions & 1 deletion server/controllers/students/AttendanceRegister.js
Expand Up @@ -26,9 +26,10 @@ module.exports = async function generateAttendanceRegister(ctx) {
studentList = students.map(student => student.get('name'), [])
}
const today = new Date()
today.setHours(today.getHours() - 3)
const data = {
dia: today.getUTCDate(),
mes: utils.translate(today.getUTCMonth()),
mes: utils.translate(today.getUTCMonth() + 1),
ano: today.getUTCFullYear(),
nomeDosAlunos: studentList,
curso:
Expand Down
14 changes: 13 additions & 1 deletion server/controllers/students/ConcludingCertificate.js
@@ -1,6 +1,7 @@
const PDFDocument = require('pdfkit')
const Student = require('../../models/Student')
const Defense = require('../../models/Defense')
const Settings = require('../../models/Setting')
const utils = require('../../utils')
const errors = require('../../../shared/errors')
const CertificadoConlusao = require('../../models/tccdocs/certificadoConclusao')
Expand Down Expand Up @@ -32,9 +33,10 @@ module.exports = async function generateConcludingCertificate(ctx) {
return
}
const today = new Date()
today.setHours(today.getHours() - 3)
const data = {
dia: today.getUTCDate(),
mes: utils.translate(today.getUTCMonth()),
mes: utils.translate(today.getUTCMonth() + 1),
ano: today.getUTCFullYear(),
curso:
studentFind.get('course') === 'cbcc'
Expand All @@ -46,6 +48,16 @@ module.exports = async function generateConcludingCertificate(ctx) {
tituloDiretor: 'Prof(a). ',
diretor: 'NÃO ENCONTRADO NAS CONFIGURAÇÕES!'
}
const findFacompDirector = await Settings.where(
'key',
'facultyDirectorName'
).fetch()
if (findFacompDirector) data.diretor = findFacompDirector.get('value')
const findIcenDirector = await Settings.where(
'key',
'departamentDirector'
).fetch()
if (findIcenDirector) data.diretorInstituto = findIcenDirector.get('value')
const doc = new PDFDocument({
layout: 'landscape',
size: [595, 841]
Expand Down