📂 FileMgr
📍
/home/u462965992/domains/afsarnext.com/public_html/app/Views/admin/teachers
✏️ Edit File: /home/u462965992/domains/afsarnext.com/public_html/app/Views/admin/teachers/index.php
⬅ Kembali
<?= $this->include('admin/layout/header') ?> <?= $this->include('admin/layout/sidebar') ?> <style> /* Hide CKEditor warning */ .cke_notification, .cke_notification_warning { display: none !important; } </style> <main class="dashboard-main"> <?= $this->include('admin/layout/headermain') ?> <div class="dashboard-main-body"> <!-- BREADCRUMB --> <div class="breadcrumb d-flex flex-wrap align-items-center justify-content-between gap-3 mb-24"> <div> <h1 class="fw-semibold mb-4 h6 text-primary-light">Teachers Management</h1> <div> <a href="<?= base_url('admin/dashboard') ?>" class="text-secondary-light hover-text-primary">Dashboard</a> <span class="text-secondary-light"> / Teachers</span> </div> </div> <button class="btn btn-primary-600 d-flex align-items-center gap-6" onclick="openTeacherModal()"> <i class="ri-add-large-line"></i> Add Teacher </button> </div> <!-- TABLE --> <div class="card h-100"> <div class="card-body p-0"> <table class="table bordered-table mb-0 data-table"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Designation</th> <th>Contact</th> <th>Email</th> <th>Status</th> <th width="120">Action</th> </tr> </thead> <tbody> <?php foreach ($teachers as $teacher): ?> <tr> <td><?= $teacher['id'] ?></td> <td><?= esc($teacher['name']) ?></td> <td><?= esc($teacher['designation']) ?></td> <td><?= esc($teacher['contactno']) ?></td> <td><?= esc($teacher['email']) ?></td> <td> <?= $teacher['status'] ? '<span class="bg-success-100 text-success-600 px-16 py-4 radius-4">Active</span>' : '<span class="bg-danger-100 text-danger-600 px-16 py-4 radius-4">Inactive</span>' ?> </td> <td> <div class="btn-group"> <button class="text-primary-light text-xl" data-bs-toggle="dropdown"> <i class="ri-more-2-fill"></i> </button> <ul class="dropdown-menu dropdown-menu-end p-12"> <li> <button class="dropdown-item" onclick="editTeacher(<?= $teacher['id'] ?>)"> <i class="ri-edit-2-line"></i> Edit </button> </li> <li> <button class="dropdown-item text-danger" onclick="deleteTeacher(<?= $teacher['id'] ?>)"> <i class="ri-delete-bin-6-line"></i> Delete </button> </li> </ul> </div> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> </div> </div> <!-- MODAL --> <div class="modal fade" id="teacherModal"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <form id="teacherForm" enctype="multipart/form-data"> <?= csrf_field() ?> <input type="hidden" id="teacher_id"> <div class="modal-header"> <h5 class="modal-title">Teacher</h5> <button class="btn-close" data-bs-dismiss="modal"></button> </div> <div class="modal-body row g-3"> <div class="col-md-6"> <label>Name</label> <input type="text" name="name" id="name" class="form-control" required> </div> <div class="col-md-6"> <label>Designation</label> <input type="text" name="designation" id="designation" class="form-control"> </div> <div class="col-md-6"> <label>Contact No</label> <input type="text" name="contactno" id="contactno" class="form-control"> </div> <div class="col-md-6"> <label>Email</label> <input type="email" name="email" id="email" class="form-control"> </div> <div class="col-md-12"> <label>Biography</label> <textarea name="biography" id="biography" class="form-control editor"></textarea> </div> <div class="col-md-6"> <label>Image</label> <input type="file" name="image" class="form-control"> </div> <div class="col-md-6"> <label>Status</label> <select name="status" id="status" class="form-control"> <option value="1">Active</option> <option value="0">Inactive</option> </select> </div> </div> <div class="modal-footer"> <button type="submit" class="btn btn-primary-600">Save</button> </div> </form> </div> </div> </div> <?= $this->include('admin/layout/footer') ?> <script src="https://cdn.ckeditor.com/4.22.1/full/ckeditor.js"></script> <script> let teacherEditor; let editBiography = ''; /* INIT CKEDITOR */ $('#teacherModal').on('shown.bs.modal', function () { if (!CKEDITOR.instances.biography) { teacherEditor = CKEDITOR.replace('biography', { height: 200, extraPlugins: 'justify', allowedContent: true }); teacherEditor.on('instanceReady', function () { if (editBiography) { teacherEditor.setData(editBiography); } }); } }); /* DESTROY ON CLOSE */ $('#teacherModal').on('hidden.bs.modal', function () { if (CKEDITOR.instances.biography) { CKEDITOR.instances.biography.destroy(true); } }); /* OPEN ADD */ function openTeacherModal() { $('#teacherForm')[0].reset(); $('#teacher_id').val(''); editBiography = ''; $('#teacherModal').modal('show'); } /* EDIT */ function editTeacher(id) { $.get("<?= base_url('admin/teachers/edit') ?>/" + id, function (res) { $('#teacher_id').val(res.id); $('#name').val(res.name); $('#designation').val(res.designation); $('#contactno').val(res.contactno); $('#email').val(res.email); $('#status').val(res.status); editBiography = res.biography; $('#teacherModal').modal('show'); }); } /* SAVE */ $('#teacherForm').submit(function (e) { e.preventDefault(); if (CKEDITOR.instances.biography) { CKEDITOR.instances.biography.updateElement(); } let id = $('#teacher_id').val(); let url = id ? "<?= base_url('admin/teachers/update') ?>/" + id : "<?= base_url('admin/teachers/store') ?>"; $.ajax({ url: url, type: "POST", data: new FormData(this), processData: false, contentType: false, success: function () { location.reload(); } }); }); /* DELETE */ function deleteTeacher(id) { if (confirm('Delete this teacher?')) { $.get("<?= base_url('admin/teachers/delete') ?>/" + id, function () { location.reload(); }); } } </script>
💾 Simpan File
Batal
⬅ Naik ke admin
1 item
Nama
Tipe
Ukuran
Diubah
Aksi
🐘
index.php
php
8.3 KB
2026-03-05 15:16
✏️ Edit
👁️ View
🗑 Hapus