<?php
require_once __DIR__ . '/../library/auth.php'; 
$school_id = $_SESSION['school_id'];
allow_roles(['admin']);
$page_title = 'Add Teacher';
require_once __DIR__ . '/../include/header.php';
require_once __DIR__ . '/../include/sidebar.php';
?>

<div class="content-wrapper">
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1>Add Staff Member</h1>
                </div>
            </div>
        </div>
    </section>

    <section class="content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-12">
                    <div class="card shadow-sm border-0">
                        <div class="card-header bg-primary text-white">
                            <h3 class="card-title">Teacher Details</h3>
                        </div>

                        <form action="<?php echo WEB_ROOT; ?>teacher/process.php" method="post" enctype="multipart/form-data">
						<input type="hidden" name="action" value="add" >
                            <div class="card-body">
                                <?php if (isset($_GET['msg'])): ?>
                                    <div class="alert alert-info alert-dismissible">
                                        <button type="button" class="close" data-dismiss="alert">&times;</button>
                                        <?php echo htmlspecialchars($_GET['msg']); ?>
                                    </div>
                                <?php endif; ?>

                                <div class="row">
                                    <!-- Personal Info -->
                                    <div class="col-md-6">
                                        <h6 class="font-weight-bold text-primary mb-3"><i class="fas fa-user"></i> Personal Information</h6>
                                        <div class="form-group">
                                            <label>Name <span class="text-danger">*</span></label>
                                            <input type="text" name="name" class="form-control form-control-lg" placeholder="Enter full name" required>
                                        </div>

                                        <div class="form-group">
                                            <label>Father's Name</label>
                                            <input type="text" name="father_name" class="form-control form-control-lg" placeholder="Enter father's name">
                                        </div>

                                        <div class="form-group">
                                            <label>Mother's Name</label>
                                            <input type="text" name="mother_name" class="form-control form-control-lg" placeholder="Enter mother's name">
                                        </div>

                                        <div class="form-group">
                                            <label>Date of Birth</label>
                                            <input type="date" name="date_of_birth" class="form-control form-control-lg">
                                        </div>

                                        <div class="form-group">
                                            <label>Marital Status</label>
                                            <div class="form-check form-check-inline">
                                                <input class="form-check-input" type="radio" name="marital_status" id="single" value="Single" checked>
                                                <label class="form-check-label" for="single">Single</label>
                                            </div>
                                            <div class="form-check form-check-inline">
                                                <input class="form-check-input" type="radio" name="marital_status" id="married" value="Married">
                                                <label class="form-check-label" for="married">Married</label>
                                            </div>
                                        </div>
                                    </div>

                                    <!-- Academic Qualifications -->
                                    <div class="col-md-6">
                                        <h6 class="font-weight-bold text-primary mb-3"><i class="fas fa-graduation-cap"></i> Academic Qualifications</h6>
                                        <div class="form-group">
                                            <label>Qualification</label>
                                            <input type="text" name="qualification" class="form-control form-control-lg" placeholder="e.g., B.Ed, M.Sc">
                                        </div>

                                        <div class="row">
                                            <div class="col-6 form-group">
                                                <label>10th Year</label>
                                                <input type="text" name="tenth_year" class="form-control form-control-lg" placeholder="YYYY" maxlength="4">
                                            </div>
                                            <div class="col-6 form-group">
                                                <label>10th %</label>
                                                <input type="text" name="tenth_percentage" class="form-control form-control-lg" placeholder="e.g., 85.5">
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-6 form-group">
                                                <label>12th Year</label>
                                                <input type="text" name="twelfth_year" class="form-control form-control-lg" placeholder="YYYY" maxlength="4">
                                            </div>
                                            <div class="col-6 form-group">
                                                <label>12th %</label>
                                                <input type="text" name="twelfth_percentage" class="form-control form-control-lg" placeholder="e.g., 88.2">
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-6 form-group">
                                                <label>Grad Year</label>
                                                <input type="text" name="grad_year" class="form-control form-control-lg" placeholder="YYYY" maxlength="4">
                                            </div>
                                            <div class="col-6 form-group">
                                                <label>Grad %</label>
                                                <input type="text" name="grad_percentage" class="form-control form-control-lg" placeholder="e.g., 72.5">
                                            </div>
                                        </div>

                                        <div class="row">
                                            <div class="col-6 form-group">
                                                <label>PG Year</label>
                                                <input type="text" name="pg_year" class="form-control form-control-lg" placeholder="YYYY" maxlength="4">
                                            </div>
                                            <div class="col-6 form-group">
                                                <label>PG %</label>
                                                <input type="text" name="pg_percentage" class="form-control form-control-lg" placeholder="e.g., 68.0">
                                            </div>
                                        </div>
                                    </div>

                                    <!-- Contact & Service Details -->
                                    <div class="col-md-6">
                                        <h6 class="font-weight-bold text-primary mb-3"><i class="fas fa-phone"></i> Contact Information</h6>
                                        <div class="form-group">
                                            <label>Mobile No.</label>
                                            <input type="text" name="mobile_no" class="form-control form-control-lg" placeholder="10 digit mobile" maxlength="10" pattern="[0-9]{10}" >
                                        </div>

                                        <div class="form-group">
                                            <label>Aadhar No.</label>
                                            <input type="text" name="adhar_no" class="form-control form-control-lg" placeholder="12 digit aadhar" maxlength="12">
                                        </div>

                                        <div class="form-group">
                                            <label>Address</label>
                                            <textarea name="address" class="form-control form-control-lg" rows="3" placeholder="Complete address"></textarea>
                                        </div>

                                        <div class="form-group">
                                            <label>Salary (₹)</label>
                                            <input type="text" name="salary" class="form-control form-control-lg" placeholder="e.g., 35000">
                                        </div>
                                    </div>

                                    <div class="col-md-6">
                                        <h6 class="font-weight-bold text-primary mb-3"><i class="fas fa-calendar-alt"></i> Service Details</h6>
                                        <div class="form-group">
                                            <label>Date of Joining</label>
                                            <input type="date" name="date_of_joining" class="form-control form-control-lg">
                                        </div>

                                        <div class="form-group">
                                            <label>Date of Leaving (Optional)</label>
                                            <input type="date" name="date_of_leaving" class="form-control form-control-lg">
                                        </div>

                                        <div class="form-group">
                                            <label>Photo</label>
                                            <input type="file" name="photo" class="form-control form-control-lg" accept="image/*">
                                            <small class="text-muted">JPG, PNG, WebP (Max 2MB)</small>
                                        </div>

                                        <div class="form-group">
                                            <label>Resume (PDF)</label>
                                            <input type="file" name="resume" class="form-control form-control-lg" accept="application/pdf">
                                            <small class="text-muted">PDF only</small>
                                        </div>
                                    </div>
                                </div>
                            </div>

                           <div class="card-footer text-right">

    <button
        type="submit"
        class="btn btn-primary btn-lg"
    >

        <i class="fas fa-save"></i>

        Save Teacher

    </button>

    <a

        href="<?php echo WEB_ROOT; ?>teacher/index.php"

        class="btn btn-secondary btn-lg"
    >

        <i class="fas fa-arrow-left"></i>

        Back

    </a>

</div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>

<?php
require_once __DIR__ . '/../include/footer.php';
?>