🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:testimonials.php
<?php require APPROOT . '/views/layouts/admin_header.php'; ?> <div class="d-flex justify-content-between align-items-center mb-4"> <h4 class="font-outfit fw-bold text-navy">Manage Testimonials</h4> <?php if($data['action'] !== 'add' && $data['action'] !== 'edit'): ?> <a href="<?php echo URLROOT; ?>/admin/testimonials/add" class="btn btn-navy rounded-pill px-4"> <i class="fas fa-plus me-2"></i> Add Testimonial </a> <?php endif; ?> </div> <?php if($data['action'] == 'add' || ($data['action'] == 'edit' && $data['selected_testimonial'])): ?> <!-- Add/Edit Form --> <?php $isEdit = $data['action'] == 'edit'; $testimonial = $data['selected_testimonial']; $formAction = $isEdit ? URLROOT . '/admin/testimonials/edit/' . $testimonial->id : URLROOT . '/admin/testimonials/add'; $clientNameVal = $isEdit ? $testimonial->client_name : ''; $contentVal = $isEdit ? $testimonial->content : ''; ?> <div class="card border-0 shadow-sm rounded-4 max-width-md mx-auto"> <div class="card-header bg-white border-bottom py-3"> <h5 class="mb-0 font-outfit fw-bold text-navy"><?php echo $isEdit ? 'Edit Testimonial' : 'Add Testimonial'; ?></h5> </div> <div class="card-body p-4"> <form action="<?php echo $formAction; ?>" method="POST"> <div class="mb-3"> <label for="client_name" class="form-label font-inter fw-medium text-navy">Client Name / Organization</label> <input type="text" name="client_name" id="client_name" class="form-control rounded-3 <?php echo (!empty($data['name_err'])) ? 'is-invalid' : ''; ?>" value="<?php echo htmlspecialchars($clientNameVal); ?>" placeholder="e.g. John Doe, CEO of Alpha Corp"> <div class="invalid-feedback"><?php echo $data['name_err'] ?? ''; ?></div> </div> <div class="mb-3"> <label for="content" class="form-label font-inter fw-medium text-navy">Testimonial Content</label> <textarea name="content" id="content" rows="5" class="form-control rounded-3 <?php echo (!empty($data['content_err'])) ? 'is-invalid' : ''; ?>" placeholder="Enter what the client said..."><?php echo htmlspecialchars($contentVal); ?></textarea> <div class="invalid-feedback"><?php echo $data['content_err'] ?? ''; ?></div> </div> <div class="d-flex justify-content-end mt-4 gap-2"> <a href="<?php echo URLROOT; ?>/admin/testimonials" class="btn btn-outline-secondary rounded-pill px-4">Cancel</a> <button type="submit" class="btn btn-navy rounded-pill px-4"><?php echo $isEdit ? 'Update Testimonial' : 'Save Testimonial'; ?></button> </div> </form> </div> </div> <?php else: ?> <!-- List View --> <div class="card border-0 shadow-sm rounded-4"> <div class="card-body p-0"> <div class="table-responsive"> <table class="table table-hover align-middle mb-0"> <thead class="table-light"> <tr> <th class="ps-4">Client Name</th> <th>Testimonial</th> <th>Created At</th> <th class="text-end pe-4">Actions</th> </tr> </thead> <tbody> <?php if(empty($data['testimonials'])): ?> <tr> <td colspan="4" class="text-center py-5 text-muted"> <i class="fas fa-quote-left fs-2 mb-3 d-block text-secondary"></i> No testimonials found. Add some client reviews to display them. </td> </tr> <?php else: ?> <?php foreach($data['testimonials'] as $testimonial): ?> <tr> <td class="ps-4 fw-bold text-navy"><?php echo htmlspecialchars($testimonial->client_name); ?></td> <td class="text-muted" style="max-width: 450px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"> "<?php echo htmlspecialchars($testimonial->content); ?>" </td> <td><?php echo date('Y-m-d H:i', strtotime($testimonial->created_at)); ?></td> <td class="text-end pe-4"> <a href="<?php echo URLROOT; ?>/admin/testimonials/edit/<?php echo $testimonial->id; ?>" class="btn btn-sm btn-outline-navy me-1 rounded-pill px-3"> <i class="fas fa-edit me-1"></i> Edit </a> <a href="<?php echo URLROOT; ?>/admin/testimonials/delete/<?php echo $testimonial->id; ?>" class="btn btn-sm btn-outline-danger rounded-pill px-3" onclick="return confirm('Are you sure you want to delete this testimonial?');"> <i class="fas fa-trash me-1"></i> Delete </a> </td> </tr> <?php endforeach; ?> <?php endif; ?> </tbody> </table> </div> </div> <!-- Pagination --> <?php if(isset($data['total_pages']) && $data['total_pages'] > 1): ?> <div class="card-footer bg-white border-top py-3 d-flex justify-content-between align-items-center" style="border-bottom-left-radius: 12px; border-bottom-right-radius: 12px;"> <div class="text-muted small"> Showing page <strong><?php echo $data['current_page']; ?></strong> of <strong><?php echo $data['total_pages']; ?></strong> </div> <nav aria-label="Page navigation"> <ul class="pagination pagination-sm mb-0"> <li class="page-item <?php echo ($data['current_page'] <= 1) ? 'disabled' : ''; ?>"> <a class="page-link border-light text-navy rounded-circle me-1" href="?page=<?php echo $data['current_page'] - 1; ?>" aria-label="Previous"> <span aria-hidden="true">«</span> </a> </li> <?php for($i = 1; $i <= $data['total_pages']; $i++): ?> <li class="page-item <?php echo ($data['current_page'] == $i) ? 'active' : ''; ?>"> <a class="page-link border-light rounded-circle me-1 <?php echo ($data['current_page'] == $i) ? 'bg-navy border-navy text-white' : 'text-navy'; ?>" href="?page=<?php echo $i; ?>"><?php echo $i; ?></a> </li> <?php endfor; ?> <li class="page-item <?php echo ($data['current_page'] >= $data['total_pages']) ? 'disabled' : ''; ?>"> <a class="page-link border-light text-navy rounded-circle" href="?page=<?php echo $data['current_page'] + 1; ?>" aria-label="Next"> <span aria-hidden="true">»</span> </a> </li> </ul> </nav> </div> <?php endif; ?> </div> <?php endif; ?> <?php require APPROOT . '/views/layouts/admin_footer.php'; ?>
Save Changes
Cancel
Create New File
Create New Folder