Path : /home/vishqocm/pcib.in/student/models/
File Upload :
Current File : /home/vishqocm/pcib.in/student/models/certificate.php

<?php
/**
 * Certificate Template
 * 
 * This file generates the HTML for a certificate based on the provided parameters
 * Parameters expected:
 * - $student_name: Full name of the student
 * - $course_title: Title of the completed course
 * - $certificate_number: Unique certificate identifier
 * - $issue_date: Date when the certificate was issued
 * - $institute_name: Name of the institute
 * - $institute_logo: Path to the institute logo
 * - $instructor_name: Name of the course instructor
 * - $instructor_signature: Path to instructor's signature image
 * - $director_name: Name of the institute director
 * - $director_signature: Path to director's signature image
 * - $certificate_border_color: Color of the certificate border
 * - $certificate_background: Background image for the certificate (optional)
 * - $certificate_watermark: Watermark image for the certificate (optional)
 */

// Get parameters from parent scope
$student_name = $enrollment_data['student_name'] ?? 'Student Name';
$course_title = $enrollment_data['course_title'] ?? 'Course Title';
$issue_date = date('F d, Y');
$instructor_name = $enrollment_data['instructor_name'] ?? 'Course Instructor';
$institute_website = $institute_settings['institute_website'] ?? 'www.example.com';

// Check if paths need adjustment for signatures
$institute_logo_path = (strpos($institute_logo, '../') === 0) ? substr($institute_logo, 3) : $institute_logo;
$instructor_signature_path = (strpos($instructor_signature, '../') === 0) ? substr($instructor_signature, 3) : $instructor_signature;
$director_signature_path = (strpos($director_signature, '../') === 0) ? substr($director_signature, 3) : $director_signature;

// Background style based on whether a background image is provided
$background_style = '';
if (!empty($certificate_background)) {
    $bg_path = (strpos($certificate_background, '../') === 0) ? substr($certificate_background, 3) : $certificate_background;
    $background_style = "background-image: url('../{$bg_path}'); background-size: cover; background-position: center;";
} else {
    $background_style = "background-color: #fff;";
}

// Watermark style
$watermark_style = '';
if (!empty($certificate_watermark)) {
    $watermark_path = (strpos($certificate_watermark, '../') === 0) ? substr($certificate_watermark, 3) : $certificate_watermark;
    $watermark_style = "
        .certificate-watermark {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            opacity: 0.1;
            z-index: 0;
            width: 70%;
            height: auto;
        }
    ";
}

// Sanitize color code
$certificate_border_color = htmlspecialchars($certificate_border_color);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Certificate of Completion - <?php echo htmlspecialchars($course_title); ?></title>
    <style>
        @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap");
        @import url("https://fonts.googleapis.com/css2?family=Great+Vibes&display=swap");
        
        body {
            font-family: "Poppins", sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f5f5f5;
            color: #333;
        }
        
        .certificate-container {
            width: 1000px;
            height: 700px;
            position: relative;
            margin: 0 auto;
            <?php echo $background_style; ?>
            border: 20px solid <?php echo $certificate_border_color; ?>;
            padding: 30px;
            box-sizing: border-box;
            box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }
        
        .certificate-header {
            text-align: center;
            margin-bottom: 20px;
            border-bottom: 2px solid #f0f0f0;
            padding-bottom: 20px;
            position: relative;
            z-index: 2;
        }
        
        .logo {
            max-width: 150px;
            margin-bottom: 10px;
        }
        
        .institute-name {
            font-size: 24px;
            font-weight: 700;
            margin: 10px 0;
            color: <?php echo $certificate_border_color; ?>;
        }
        
        .certificate-title {
            font-size: 36px;
            font-weight: 700;
            margin: 40px 0 20px;
            color: #333;
            text-transform: uppercase;
            letter-spacing: 5px;
            position: relative;
            z-index: 2;
        }
        
        .student-name {
            font-size: 40px;
            font-weight: 500;
            margin: 20px 0;
            color: #333;
            font-family: "Great Vibes", cursive;
            position: relative;
            z-index: 2;
        }
        
        .certificate-text {
            font-size: 18px;
            line-height: 1.6;
            margin: 20px 0;
            text-align: center;
            position: relative;
            z-index: 2;
        }
        
        .course-title {
            font-size: 24px;
            font-weight: 600;
            margin: 15px 0;
            color: <?php echo $certificate_border_color; ?>;
            position: relative;
            z-index: 2;
        }
        
        .certificate-footer {
            display: flex;
            justify-content: space-between;
            margin-top: 60px;
            padding-top: 30px;
            border-top: 2px solid #f0f0f0;
            position: relative;
            z-index: 2;
        }
        
        .signature {
            text-align: center;
            width: 200px;
        }
        
        .signature-img {
            max-width: 150px;
            max-height: 60px;
            margin-bottom: 10px;
        }
        
        .signature-line {
            width: 100%;
            height: 2px;
            background-color: #333;
            margin-bottom: 10px;
        }
        
        .signature-name {
            font-weight: 600;
            font-size: 16px;
        }
        
        .signature-title {
            font-size: 14px;
            color: #666;
        }
        
        .certificate-number {
            position: absolute;
            bottom: 20px;
            right: 30px;
            font-size: 12px;
            color: #666;
            z-index: 2;
        }
        
        .verification-text {
            position: absolute;
            bottom: 20px;
            left: 30px;
            font-size: 12px;
            color: #666;
            z-index: 2;
        }
        
        .certificate-seal {
            position: absolute;
            right: 100px;
            bottom: 100px;
            width: 120px;
            height: 120px;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Ccircle cx='60' cy='60' r='58' fill='none' stroke='<?php echo urlencode(str_replace('#', '%23', $certificate_border_color)); ?>' stroke-width='4'/%3E%3Ccircle cx='60' cy='60' r='52' fill='none' stroke='<?php echo urlencode(str_replace('#', '%23', $certificate_border_color)); ?>' stroke-width='2' stroke-dasharray='8,4'/%3E%3Ctext x='60' y='65' font-family='Arial' font-size='16' text-anchor='middle' fill='<?php echo urlencode(str_replace('#', '%23', $certificate_border_color)); ?>'%3EVERIFIED%3C/text%3E%3C/svg%3E");
            background-size: contain;
            opacity: 0.7;
            z-index: 2;
        }
        
        .date {
            margin-top: 20px;
            font-size: 16px;
            color: #666;
            text-align: center;
            position: relative;
            z-index: 2;
        }
        
        <?php echo $watermark_style; ?>
        
        @media print {
            body {
                background-color: #fff;
            }
            
            .certificate-container {
                border: none;
                box-shadow: none;
                padding: 0;
            }
            
            .print-button {
                display: none;
            }
        }
    </style>
</head>
<body>
    <div class="certificate-container">
        <?php if (!empty($certificate_watermark)): ?>
        <img src="../<?php echo $watermark_path; ?>" alt="Watermark" class="certificate-watermark">
        <?php endif; ?>
        
        <div class="certificate-header">
            <img src="../<?php echo $institute_logo_path; ?>" alt="<?php echo htmlspecialchars($institute_name); ?> Logo" class="logo">
            <div class="institute-name"><?php echo htmlspecialchars($institute_name); ?></div>
        </div>
        
        <h1 class="certificate-title">Certificate of Completion</h1>
        
        <p class="certificate-text">This is to certify that</p>
        
        <h2 class="student-name"><?php echo htmlspecialchars($student_name); ?></h2>
        
        <p class="certificate-text">has successfully completed the course</p>
        
        <h3 class="course-title"><?php echo htmlspecialchars($course_title); ?></h3>
        
        <p class="certificate-text">with all the requirements as prescribed by the institute.</p>
        
        <div class="date"><?php echo $issue_date; ?></div>
        
        <div class="certificate-footer">
            <div class="signature">
                <?php if (!empty($instructor_signature)): ?>
                <img src="../<?php echo $instructor_signature_path; ?>" alt="Instructor Signature" class="signature-img">
                <?php else: ?>
                <div class="signature-line"></div>
                <?php endif; ?>
                <div class="signature-name"><?php echo htmlspecialchars($instructor_name); ?></div>
                <div class="signature-title">Course Instructor</div>
            </div>
            
            <div class="signature">
                <?php if (!empty($director_signature)): ?>
                <img src="../<?php echo $director_signature_path; ?>" alt="Director Signature" class="signature-img">
                <?php else: ?>
                <div class="signature-line"></div>
                <?php endif; ?>
                <div class="signature-name"><?php echo htmlspecialchars($director_name); ?></div>
                <div class="signature-title">Director</div>
            </div>
        </div>
        
        <div class="certificate-seal"></div>
        
        <div class="certificate-number">Certificate No: <?php echo htmlspecialchars($certificate_number); ?></div>
        
        <div class="verification-text">Verify this certificate at: <?php echo htmlspecialchars($institute_website); ?>/verify.php</div>
    </div>
    
    <div class="print-button" style="text-align: center; margin: 20px;">
        <button onclick="window.print();" style="padding: 10px 20px; background-color: <?php echo $certificate_border_color; ?>; color: white; border: none; border-radius: 5px; cursor: pointer;">Print Certificate</button>
        <a href="certificates.php" style="display: inline-block; padding: 10px 20px; background-color: #6c757d; color: white; border: none; border-radius: 5px; text-decoration: none; margin-left: 10px;">Back to Certificates</a>
    </div>
</body>
</html>