🤩 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:services.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 Services</h4> <?php if($data['action'] !== 'add' && $data['action'] !== 'edit'): ?> <a href="<?php echo URLROOT; ?>/admin/services/add" class="btn btn-navy rounded-pill px-4"> <i class="fas fa-plus me-2"></i> Add New Service </a> <?php endif; ?> </div> <?php if($data['action'] == 'add' || ($data['action'] == 'edit' && $data['selected_service'])): ?> <!-- Add/Edit Form --> <?php $isEdit = $data['action'] == 'edit'; $service = $data['selected_service']; $formAction = $isEdit ? URLROOT . '/admin/services/edit/' . $service->id : URLROOT . '/admin/services/add'; $titleVal = $isEdit ? $service->title : ''; $descVal = $isEdit ? $service->description : ''; $iconVal = $isEdit ? $service->icon : 'fa-shield-alt'; $orderVal = $isEdit ? $service->order_index : 0; ?> <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 Service' : 'Add New Service'; ?></h5> </div> <div class="card-body p-4"> <form action="<?php echo $formAction; ?>" method="POST"> <div class="mb-3"> <label for="title" class="form-label font-inter fw-medium text-navy">Service Title</label> <input type="text" name="title" id="title" class="form-control rounded-3 <?php echo (!empty($data['title_err'])) ? 'is-invalid' : ''; ?>" value="<?php echo htmlspecialchars($titleVal); ?>"> <div class="invalid-feedback"><?php echo $data['title_err'] ?? ''; ?></div> </div> <div class="mb-3"> <label for="description" class="form-label font-inter fw-medium text-navy">Description</label> <textarea name="description" id="description" rows="4" class="form-control rounded-3 <?php echo (!empty($data['description_err'])) ? 'is-invalid' : ''; ?>"><?php echo htmlspecialchars($descVal); ?></textarea> <div class="invalid-feedback"><?php echo $data['description_err'] ?? ''; ?></div> </div> <div class="row"> <div class="col-md-6 mb-3"> <label for="icon" class="form-label font-inter fw-medium text-navy">FontAwesome Icon Class</label> <input type="text" name="icon" id="icon" class="form-control rounded-3" value="<?php echo htmlspecialchars($iconVal); ?>" placeholder="e.g. fa-shield-alt"> <small class="text-muted">Use classes from FontAwesome (e.g., fa-shield-alt, fa-video, fa-car).</small> </div> <div class="col-md-6 mb-3"> <label for="order_index" class="form-label font-inter fw-medium text-navy">Display Order</label> <input type="number" name="order_index" id="order_index" class="form-control rounded-3" value="<?php echo $orderVal; ?>"> </div> </div> <div class="d-flex justify-content-end mt-4 gap-2"> <a href="<?php echo URLROOT; ?>/admin/services" 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 Service' : 'Save Service'; ?></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">Icon</th> <th>Title</th> <th>Description</th> <th>Order</th> <th class="text-end pe-4">Actions</th> </tr> </thead> <tbody> <?php if(empty($data['services'])): ?> <tr> <td colspan="5" class="text-center py-5 text-muted"> <i class="fas fa-folder-open fs-2 mb-3 d-block"></i> No services found. Add some services to show them on the site. </td> </tr> <?php else: ?> <?php foreach($data['services'] as $service): ?> <tr> <td class="ps-4"> <span class="d-inline-flex align-items-center justify-content-center bg-light text-navy rounded-circle" style="width: 45px; height: 45px;"> <i class="fas <?php echo htmlspecialchars($service->icon); ?> fs-5"></i> </span> </td> <td class="fw-bold text-navy"><?php echo htmlspecialchars($service->title); ?></td> <td class="text-muted" style="max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"> <?php echo htmlspecialchars($service->description); ?> </td> <td><span class="badge bg-secondary rounded-pill"><?php echo $service->order_index; ?></span></td> <td class="text-end pe-4"> <a href="<?php echo URLROOT; ?>/admin/services/edit/<?php echo $service->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/services/delete/<?php echo $service->id; ?>" class="btn btn-sm btn-outline-danger rounded-pill px-3" onclick="return confirm('Are you sure you want to delete this service?');"> <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