Browse Source

Flexibilização para certificados com assinaturas diferentes conforme data de conclusão

master
Matheus Garcia 6 years ago
parent
commit
a3c2a6f0ff
  1. 23
      locallib.php
  2. 5
      type/ILB_Sem_tutoria_2014/certificate.php

23
locallib.php

@ -1158,8 +1158,8 @@ function certificate_draw_frame_letter($pdf, $certificate) {
* @param int $w the width
* @param int $h the height
*/
function certificate_print_image($pdf, $certificate, $type, $x, $y, $w, $h) {
global $CFG;
function certificate_print_image($pdf, $certificate, $type, $x, $y, $w, $h, $cert_date = null) {
global $CFG, $DB;
switch($type) {
case CERT_IMAGE_BORDER :
@ -1172,10 +1172,25 @@ function certificate_print_image($pdf, $certificate, $type, $x, $y, $w, $h) {
$path = "$CFG->dirroot/mod/certificate/pix/$type/$certificate->printseal";
$uploadpath = "$CFG->dataroot/mod/certificate/pix/$type/$certificate->printseal";
break;
case CERT_IMAGE_SIGNATURE :
$attr = 'printsignature';
$path = "$CFG->dirroot/mod/certificate/pix/$type/$certificate->printsignature";
$uploadpath = "$CFG->dataroot/mod/certificate/pix/$type/$certificate->printsignature";
if($certificate->printsignature == 'automatica.jpeg' && ($cert_date != null)) {
$record = $DB->get_record_sql(
'SELECT nome_arquivo ' .
'FROM {ilb_assinaturas} ' .
'WHERE ? BETWEEN dat_ini_validade AND coalesce(dat_fim_validade, extract(epoch from current_timestamp))',
[$cert_date]
);
$arq_assinatura = $record->nome_arquivo;
}else {
$arq_assinatura = $certificate->printsignature;
}
$path = "$CFG->dirroot/mod/certificate/pix/$type/$arq_assinatura";
$uploadpath = "$CFG->dataroot/mod/certificate/pix/$type/$arq_assinatura";
break;
case CERT_IMAGE_WATERMARK :
$attr = 'printwmark';

5
type/ILB_Sem_tutoria_2014/certificate.php

@ -38,10 +38,11 @@ require_once("$CFG->dirroot/enrol/locallib.php");
$cc = new completion_completion(array('userid'=>$USER->id, 'course'=>$course->id));
$enrol_manager = new course_enrolment_manager($PAGE, $course);
$user_enrol = end($enrol_manager->get_user_enrolments($USER->id));
$user_enrol = $enrol_manager->get_user_enrolments($USER->id);
$start_date = $user_enrol->timestart;
$end_date = $cc->timecompleted;
$cert_date = $end_date;
$fmt = '%d/%m/%Y'; // Default format
if ($certificate->datefmt == 1) {
@ -143,7 +144,7 @@ $pdf->SetAlpha(0.2);
certificate_print_image($pdf, $certificate, CERT_IMAGE_WATERMARK, $wmarkx, $wmarky, $wmarkw, $wmarkh);
$pdf->SetAlpha(1);
certificate_print_image($pdf, $certificate, CERT_IMAGE_SEAL, $sealx, $sealy, '', '');
certificate_print_image($pdf, $certificate, CERT_IMAGE_SIGNATURE, $sigx, $sigy, '', '');
certificate_print_image($pdf, $certificate, CERT_IMAGE_SIGNATURE, $sigx, $sigy, '', '', $cert_date);
// Add text
$pdf->SetTextColor(0, 0, 0);

Loading…
Cancel
Save