📂 FileMgr
📍
/home/u462965992/domains/afsarnext.com/public_html/app/Views/admin/free_trial_modals
✏️ Edit File: /home/u462965992/domains/afsarnext.com/public_html/app/Views/admin/free_trial_modals/index.php
⬅ Kembali
<?= $this->include('admin/layout/header') ?> <?= $this->include('admin/layout/sidebar') ?> <main class="dashboard-main"> <?= $this->include('admin/layout/headermain') ?> <div class="dashboard-main-body"> <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">Free Trial Modal Content</h1> <div> <a href="<?= base_url('admin/dashboard') ?>" class="text-secondary-light hover-text-primary">Dashboard</a> <span class="text-secondary-light"> / Free Trial Modals</span> </div> </div> </div> <!-- TABS --> <ul class="nav nav-tabs mb-4"> <li class="nav-item"> <a class="nav-link <?= $type === 'summary' ? 'active' : '' ?>" href="<?= base_url('admin/free-trial-modals/summary') ?>">Summary Notes</a> </li> <li class="nav-item"> <a class="nav-link <?= $type === 'mindmap' ? 'active' : '' ?>" href="<?= base_url('admin/free-trial-modals/mindmap') ?>">Mindmap</a> </li> <li class="nav-item"> <a class="nav-link <?= $type === 'qa' ? 'active' : '' ?>" href="<?= base_url('admin/free-trial-modals/qa') ?>">Q&A</a> </li> <li class="nav-item"> <a class="nav-link <?= $type === 'flashcard' ? 'active' : '' ?>" href="<?= base_url('admin/free-trial-modals/flashcard') ?>">Flashcards</a> </li> </ul> <div class="d-flex justify-content-between align-items-center mb-3"> <h5 class="mb-0"><?= esc($title) ?></h5> <button class="btn btn-primary-600" onclick="openModal()"> <i class="ri-add-large-line"></i> Add <?= esc($title) ?> </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>Resource ID</th> <?php if (in_array($type, ['summary', 'qa'])): ?> <th>Title</th> <?php endif; ?> <?php if ($type === 'mindmap'): ?> <th>Image</th> <?php endif; ?> <?php if (in_array($type, ['summary', 'qa'])): ?> <th>Order</th> <?php endif; ?> <th>Status</th> <th width="120">Action</th> </tr> </thead> <tbody> <?php foreach ($items as $row): ?> <tr> <td><?= $row['id'] ?></td> <td><?= esc($row['resource_id'] ?? '-') ?></td> <?php if (in_array($type, ['summary', 'qa'])): ?> <td><?= esc($row['title'] ?? '-') ?></td> <?php endif; ?> <?php if ($type === 'mindmap'): ?> <td> <?php if (!empty($row['image'])): ?> <img src="<?= base_url($row['image']) ?>" alt="" style="max-height:40px;"> <?php else: ?>-<?php endif; ?> </td> <?php endif; ?> <?php if (in_array($type, ['summary', 'qa'])): ?> <td><?= $row['sort_order'] ?? 0 ?></td> <?php endif; ?> <td> <?= ($row['status'] ?? 1) ? '<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="editItem(<?= $row['id'] ?>)"><i class="ri-edit-2-line"></i> Edit</button></li> <li><button class="dropdown-item text-danger" onclick="deleteItem(<?= $row['id'] ?>)"><i class="ri-delete-bin-6-line"></i> Delete</button></li> </ul> </div> </td> </tr> <?php endforeach; ?> <?php if (empty($items)): ?> <tr><td colspan="7" class="text-center py-4 text-muted">No records yet. Click "Add <?= esc($title) ?>" to create.</td></tr> <?php endif; ?> </tbody> </table> </div> </div> </div> <!-- MODAL --> <div class="modal fade" id="itemModal"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <form id="itemForm" enctype="multipart/form-data"> <?= csrf_field() ?> <input type="hidden" id="item_id"> <div class="modal-header"> <h5 class="modal-title"><?= esc($title) ?></h5> <button type="button" class="btn-close" data-bs-dismiss="modal"></button> </div> <div class="modal-body row g-3"> <div class="col-12"> <label>Resource ID</label> <input type="text" name="resource_id" id="resource_id" class="form-control" required list="resource_id_list" placeholder="e.g. gandhi, volcanism, continental"> <datalist id="resource_id_list"> <?php foreach ($resourceIds as $rid): ?> <option value="<?= esc($rid) ?>"> <?php endforeach; ?> </datalist> <small class="text-muted">Must match resource_id from Free Trial Videos</small> </div> <?php if (in_array($type, ['summary', 'qa'])): ?> <div class="col-12"> <label>Title</label> <input type="text" name="title" id="title" class="form-control" required placeholder="e.g. Mahatma Gandhi: Life Journey"> </div> <?php endif; ?> <?php if ($type === 'mindmap'): ?> <div class="col-12"> <label>Mindmap Image</label> <input type="file" name="image" id="image" class="form-control" accept="image/*"> </div> <?php endif; ?> <?php if ($type === 'summary'): ?> <div class="col-12"> <label>Content (JSON)</label> <textarea name="content" id="content" class="form-control font-monospace" rows="12" placeholder='[{"question":"Section title","items":[{"text":"Link text","url":"#"}]}]'></textarea> <small class="text-muted">Format: [{"question":"...","items":[{"text":"...","url":"..."}]}]</small> </div> <?php endif; ?> <?php if ($type === 'qa'): ?> <div class="col-12"> <label>Content (JSON)</label> <textarea name="content" id="content" class="form-control font-monospace" rows="12" placeholder='[{"question":"...","answer":"..."}]'></textarea> <small class="text-muted">Format: [{"question":"...","answer":"..."}]</small> </div> <?php endif; ?> <?php if ($type === 'flashcard'): ?> <div class="col-12"> <label>Cards (JSON)</label> <textarea name="cards" id="cards" class="form-control font-monospace" rows="12" placeholder='[{"title":"...","level":"Beginner","content":"..."}]'></textarea> <small class="text-muted">Format: [{"title":"...","level":"...","content":"..."}]</small> </div> <?php endif; ?> <?php if (in_array($type, ['summary', 'qa'])): ?> <div class="col-md-6"> <label>Sort Order</label> <input type="number" name="sort_order" id="sort_order" class="form-control" value="0"> </div> <?php endif; ?> <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> var type = '<?= $type ?>'; var baseUrl = '<?= base_url('admin/free-trial-modals') ?>'; function openModal() { $('#itemForm')[0].reset(); $('#item_id').val(''); $('#itemModal').modal('show'); } function editItem(id) { var url = baseUrl + '/' + type + '/edit/' + id; $.get(url, function(res) { $('#item_id').val(res.id); $('#resource_id').val(res.resource_id); $('#status').val(res.status); if (type === 'summary' || type === 'qa') { $('#title').val(res.title); $('#sort_order').val(res.sort_order || 0); $('#content').val(JSON.stringify(res.content || [], null, 2)); } if (type === 'mindmap') { // no prefill for file } if (type === 'flashcard') { $('#cards').val(JSON.stringify(res.cards || [], null, 2)); } $('#itemModal').modal('show'); }); } $('#itemForm').submit(function(e) { e.preventDefault(); var id = $('#item_id').val(); var url, data; if (type === 'summary') { url = id ? baseUrl + '/summary/update/' + id : baseUrl + '/summary/store'; data = new FormData(this); } else if (type === 'mindmap') { url = id ? baseUrl + '/mindmap/update/' + id : baseUrl + '/mindmap/store'; data = new FormData(this); } else if (type === 'qa') { url = id ? baseUrl + '/qa/update/' + id : baseUrl + '/qa/store'; data = new FormData(this); } else if (type === 'flashcard') { url = id ? baseUrl + '/flashcard/update/' + id : baseUrl + '/flashcard/store'; data = new FormData(this); } $.ajax({ url: url, type: 'POST', data: data, processData: false, contentType: false, success: function() { location.reload(); } }); }); function deleteItem(id) { if (!confirm('Delete this item?')) return; var url = baseUrl + '/' + type + '/delete/' + id; $.get(url, function() { location.reload(); }); } </script>
💾 Simpan File
Batal
⬅ Naik ke admin
1 item
Nama
Tipe
Ukuran
Diubah
Aksi
🐘
index.php
php
11.4 KB
2026-03-05 15:16
✏️ Edit
👁️ View
🗑 Hapus