From a672ba386029e9fcdf3d59cc67c0f1435669268a Mon Sep 17 00:00:00 2001 From: Sesostris Vieira Date: Thu, 6 Feb 2014 20:04:49 -0200 Subject: [PATCH] =?UTF-8?q?Acrescimo=20de=20algumas=20informa=C3=A7=C3=B5e?= =?UTF-8?q?s=20do=20certificado=20e=20melhorias=20no=20HTML?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- block_verify_certificate.php | 34 +++++++------- index.php | 62 +++++++++++++++++++++---- lang/de/block_verify_certificate.php | 2 + lang/en/block_verify_certificate.php | 2 + lang/pt_br/block_verify_certificate.php | 2 + 5 files changed, 77 insertions(+), 25 deletions(-) diff --git a/block_verify_certificate.php b/block_verify_certificate.php index ba99e4e..ff28d38 100644 --- a/block_verify_certificate.php +++ b/block_verify_certificate.php @@ -9,27 +9,27 @@ class block_verify_certificate extends block_base { function applicable_formats() { return array('all' => true); } + function get_content() { - if ($this->content !== NULL) { - return $this->content; - } + if ($this->content !== NULL) { + return $this->content; + } - $this->content = new stdClass; - $this->content->text = '

'.get_string('entercode', 'certificate').'

'; - $url = new moodle_url('/blocks/verify_certificate/index.php'); - $this->content->text .= '
'; + $this->content = new stdClass; + $this->content->text = '

'.get_string('entercode', 'certificate').'

'; + $url = new moodle_url('/blocks/verify_certificate/index.php'); + $this->content->text .= '
'; - $this->content->text .= ''; - $this->content->text .= ''; - $this->content->text .= '
'; - $this->content->footer = ''; + $this->content->text .= ''; + $this->content->text .= ''; + $this->content->text .= '
'; + $this->content->footer = ''; - return $this->content; -} -function instance_allow_config() { - return false; -} + return $this->content; + } + function instance_allow_config() { + return false; + } } -?> \ No newline at end of file diff --git a/index.php b/index.php index fbe0e84..19b6f9c 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,6 @@ dirroot/enrol/locallib.php"); global $DB; @@ -22,12 +23,13 @@ global $DB; // Print results echo $OUTPUT->box_start('generalbox boxaligncenter'); + if (!$issues = $DB->get_records('certificate_issues', array('code' => $code))) { echo get_string('notfound', 'block_verify_certificate'); } else { - echo ""; + echo ''; + echo ''; /// Print Section foreach ($issues as $issue) { if (!$certificate = $DB->get_record('certificate', array('id'=> $issue->certificateid))) { @@ -39,16 +41,60 @@ global $DB; if (!$user = $DB->get_record('user', array('id'=> $issue->userid))) { print_error('user is unreachable'); } + + $enrol_manager = new course_enrolment_manager($PAGE, $course); + $user_enrols = $enrol_manager->get_user_enrolments($user->id); + $start_date = 0; + $end_date = 0; + foreach ($user_enrols as $enrol) { + if ($enrol->timestart > 0) { + $start_date = $enrol->timestart; + } + if ($enrol->timeend > 0) { + $end_date = $enrol->timeend; + } + } + if (($start_date > 0 and $end_date > 0)) { + $fmt = '%d/%m/%Y'; // Default format + if ($certificate->datefmt == 1) { + $fmt = '%B %d, %Y'; + $certificatedate = userdate($ts, '%B %d, %Y') . " a " . userdate($te, '%B %d, %Y'); + } else if ($certificate->datefmt == 2) { + $suffix = certificate_get_ordinal_number_suffix(userdate($ts, '%d')); + $fmt = '%B %d' . $suffix . ', %Y'; + $certificatedate = userdate($ts, '%B %d' . $suffix . ', %Y') . " a " . userdate($te, '%B %d' . $suffix . ', %Y'); + } else if ($certificate->datefmt == 3) { + $fmt = '%d %B %Y'; + $certificatedate = userdate($ts, '%d %B %Y') . " a " . userdate($te, '%d %B %Y'); + } else if ($certificate->datefmt == 4) { + $fmt = '%B %Y'; + $certificatedate = userdate($ts, '%B %Y') . " a " . userdate($te, '%B %Y'); + } else if ($certificate->datefmt == 5) { + $fmt = get_string('strftimedate', 'langconfig'); + $certificatedate = userdate($ts, get_string('strftimedate', 'langconfig')) . " a " . userdate($te, get_string('strftimedate', 'langconfig')); + } + $start_date = userdate($start_date, $fmt); + $end_date = userdate($end_date, $fmt); + } else { + $start_date = ''; + $end_date = ''; + } + $certificatedate = userdate($issue->timecreated); - echo '

' . get_string('certificate', 'block_verify_certificate') . ' ' . $issue->code . '

'; - echo '

' . get_string('to', 'block_verify_certificate') . ': ' . fullname($user) . '
'; - echo '

' . get_string('course', 'block_verify_certificate') . ': ' . $course->fullname . '
'; - echo '

' . get_string('date', 'block_verify_certificate') . ': ' . $certificatedate . '

'; + echo '

' . get_string('certificate', 'block_verify_certificate') . " {$issue->code}

"; + echo '

' . get_string('to', 'block_verify_certificate') . ': ' . fullname($user) . '

'; + echo '

' . get_string('course', 'block_verify_certificate') . ": {$course->fullname}

"; + echo '

' . get_string('date', 'block_verify_certificate') . ": $certificatedate

"; + echo '

' . get_string('enrol_period', 'block_verify_certificate') . ": $start_date - $end_date

"; + if ($certificate->printhours) { + echo '

' . get_string('printhours', 'block_verify_certificate') . ": {$certificate->printhours}

"; + } if ($certificate->customtext !== '') { - echo '

' . get_string('customtext', 'block_verify_certificate') . ':

'; + echo '

' . get_string('customtext', 'block_verify_certificate') . ':

'; echo $certificate->customtext; } } } + echo $OUTPUT->box_end(); echo $OUTPUT->footer(); diff --git a/lang/de/block_verify_certificate.php b/lang/de/block_verify_certificate.php index 67b6920..81dec6c 100644 --- a/lang/de/block_verify_certificate.php +++ b/lang/de/block_verify_certificate.php @@ -9,3 +9,5 @@ $string['course'] = 'Kurs'; $string['date'] = 'Am'; $string['grade'] = 'Bewertung'; $string['customtext'] = 'Kurs details'; +$string['enrol_period'] = 'Einschreiben Zeitraum'; +$string['printhours'] = 'Stunden'; diff --git a/lang/en/block_verify_certificate.php b/lang/en/block_verify_certificate.php index 4c91c98..1d055b5 100644 --- a/lang/en/block_verify_certificate.php +++ b/lang/en/block_verify_certificate.php @@ -9,3 +9,5 @@ $string['course'] = 'Course'; $string['date'] = 'On'; $string['grade'] = 'Grade'; $string['customtext'] = 'Course details'; +$string['enrol_period'] = 'Enroll period'; +$string['printhours'] = 'Hours'; diff --git a/lang/pt_br/block_verify_certificate.php b/lang/pt_br/block_verify_certificate.php index b562690..c3d80ac 100644 --- a/lang/pt_br/block_verify_certificate.php +++ b/lang/pt_br/block_verify_certificate.php @@ -9,3 +9,5 @@ $string['course'] = 'Curso'; $string['date'] = 'Data'; $string['grade'] = 'Nota'; $string['customtext'] = 'Programa do curso'; +$string['enrol_period'] = 'Período de realização'; +$string['printhours'] = 'Carga horária';