<?php require_once './classes/Certificates.php'; $courseid = $_POST['courseid']; $userid = $_POST['userid']; $completion_date = $_POST['completion_date']; $certificate = new Certificates(); $list = $certificate->send_certificate($courseid, $userid, $completion_date); echo $list;
function print_certificate($courseid, $students) { $certs = array(); $students_arr = explode(",", $students); if (count($students_arr) > 0) { $now = time(); $cert = new Certificates(); foreach ($students_arr as $studentid) { //echo "Course id: ".$courseid."<br>"; //echo "Student id: ".$studentid."<br>"; $cert->send_certificate($courseid, $studentid, $now, false); //$pdf_file = $_SERVER['DOCUMENT_ROOT'] . "/lms/custom/certificates/$studentid/certificate.pdf"; $pdf_file = $_SERVER['DOCUMENT_ROOT'] . "/lms/custom/certificates/{$studentid}/{$courseid}/certificate.pdf"; $certs[] = $pdf_file; } //print_r($certs); $datadir = $_SERVER['DOCUMENT_ROOT'] . "/print/"; //$outputName = $datadir . "merged.pdf"; $outputName = $datadir . $now . "_merged.pdf"; $cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile={$outputName} "; foreach ($certs as $certificate) { $cmd .= $certificate . " "; } // end foreach shell_exec($cmd); /* $query = "select * from mdl_print_job"; $num = $this->db->numrows($query); if ($num > 0) { $query2 = "update mdl_print_job set students='$students'"; } // end if $num > 0 else { $query2 = "insert into mdl_print_job (students) values('$students')"; } // end else $this->db->query($query2); */ } else { echo "No students selected ..."; } return $now . "_merged.pdf"; }
function renew_certificate() { /* ************************************************************* * Certificate validation is one year. So whenever user clicks * Certificate could be prolonged at any time even it is not * expired. There are three options: * * - one year prolongation - $50 plus late fees applied (if any) * - two years prolongation - $100 * - three years prolongation - $150 * * Additional fee for expired certificates: * $25 if renew attempt 30 days after expiration * $50 if renew attempt 90 days after expiration * if renew attempt 95 days after expiration - new exam * * ************************************************************* */ $courseid = $this->get_user_course($this->user->id); $sum = $this->check_user_balance($courseid, $this->user->id); // user must be able to renew certificate at any time even it is not expired $sum = 0; if ($sum > 0) { $diff = 7776000; // 3 months in secs $now = time(); $cert = new Certificates(); if ($this->user->id == 12937) { $date = now(); } else { $date = $this->get_course_completion($courseid, $this->user->id); } // end else if ($date > 0) { $new_date = $date + 31536000; // one year later after course completion if ($new_date - $now >= $diff) { $code = ''; $renew = true; // We renew certificate only for one year (one year is added at Certificates module) $cert->send_certificate($courseid, $this->user->id, $date, true, $code, $renew); } else { $list .= "<div class='container-fluid'>"; $list .= "<span class='span9'>Please contact site manager to get your updated certificate info@medical2.com.</span>"; $list .= "</div>"; } // end else } else { $list .= "<div class='container-fluid'>"; $list .= "<span class='span9'>You did not complete the course. Certificate is not available</span>"; $list .= "</div>"; } // end else } else { $list .= "<div class='container-fluid'>"; $userid = $this->user->id; $renew_fee = $this->get_certificate_renew_fee($courseid, $userid); $list .= "<span class='span9'>Certificate renew is a paid service. Please select option: </span>"; $list .= "</div>"; $list .= "<div class='container-fluid'>"; $list .= "<span class='span9'>One year prolongation - <a href='https://" . $_SERVER['SERVER_NAME'] . "/index.php/payments/index/{$userid}/{$courseid}/0/{$renew_fee}/1' target='_blank'>\$50 (late fee could be applied)</a></span></span>"; $list .= "</div>"; $list .= "<div class='container-fluid'>"; $list .= "<span class='span9'>Two years prolongation - <a href='https://" . $_SERVER['SERVER_NAME'] . "/index.php/payments/index/{$userid}/{$courseid}/0/100/2' target='_blank'>\$100</a></span></span>"; $list .= "</div>"; $list .= "<div class='container-fluid'>"; $list .= "<span class='span9'>Three years prolongation - <a href='https://" . $_SERVER['SERVER_NAME'] . "/index.php/payments/index/{$userid}/{$courseid}/0/150/3' target='_blank'>\$150</a></span></span>"; $list .= "</div>"; return $list; } return $list; }