Sindbad~EG File Manager
# 🎖️ Officership Detail Pages - Implementation Guide
## Files to Create (Total: 10 files)
### **Detail Pages (6 files):**
1. `modules/officership/pastorate.php` - Filter: District, Title | Sort & Order ✅
2. `modules/officership/officers.php` - Filter: District, Assembly, Title | Sort & Order
3. `modules/officership/retiree-pastorate.php` - Filter: District, Title | Sort & Order
4. `modules/officership/retiree-officers.php` - Filter: District, Assembly, Title | Sort & Order
5. `modules/officership/pastorate-transfers.php` - Filter: District, Transfer Type, Title | Sort & Order
6. `modules/officership/officers-transfers.php` - Filter: District, Transfer Type, Title | Sort & Order
### **Individual Management (1 file):**
7. `modules/officership/view.php` - View/Edit with tabs for Member, Ordination, Retirement, Transfers
### **Export Handlers (3 files):**
8. `modules/officership/export-csv.php` - CSV export
9. `modules/officership/export-pdf.php` - PDF export (using TCPDF)
10. `modules/officership/export-excel.php` - Excel export (using PhpSpreadsheet)
---
## Common Features (All Pages)
### **Filters:**
- District dropdown
- Assembly dropdown (Retiree Officers, Officers)
- Title dropdown (all officer titles)
- Transfer Type (Transfer pages only)
- Search box
### **Sort Options:**
- Sort by: Title, Name, District, Date
- Order: Ascending / Descending
### **Actions:**
- View (eye icon) - Goes to view.php?id=X
- Edit (pencil icon) - Goes to view.php?id=X&edit=1
- Delete (trash icon) - Soft delete with confirmation
- Activate/Deactivate toggle
### **Export Buttons:**
- CSV export
- PDF export
- Excel export
- Print (browser print)
---
## Page Structure Template
```php
<?php
session_start();
require_once '../../config/config.php';
require_once '../../classes/Officership.php';
// Auth check
if (!isset($_SESSION['user_id'])) {
header('Location: ../../login.php');
exit();
}
$access_level = $_SESSION['access_level'] ?? '';
if (!in_array($access_level, ['superuser', 'admin'])) {
die('Access denied');
}
$pdo = Database::getInstance()->getConnection();
$officership = new Officership($pdo);
// Get filters
$district_id = $_GET['district'] ?? '';
$title = $_GET['title'] ?? '';
$sort = $_GET['sort'] ?? 'title';
$order = $_GET['order'] ?? 'asc';
// Get data
$filters = [
'district_id' => $district_id,
'title' => $title,
'sort' => $sort,
'order' => $order
];
$officers = $officership->getPastorateList($filters);
// Get districts for filter
$stmt = $pdo->query("SELECT * FROM districts ORDER BY district_name");
$districts = $stmt->fetchAll();
$page_title = "Pastorate Management";
include '../../includes/header.php';
?>
<!-- Page HTML -->
<div class="container mx-auto px-4 py-8">
<!-- Header -->
<!-- Filters -->
<!-- Data Table -->
<!-- Export Buttons -->
</div>
<?php include '../../includes/footer.php'; ?>
```
---
## Filter Methods Needed in Officership.php
Add these methods to `classes/Officership.php`:
```php
public function getPastorateList($filters = []) {
// SQL with filters for pastorate
}
public function getOfficersList($filters = []) {
// SQL with filters for officers
}
public function getRetireePastorateList($filters = []) {
// SQL with filters for retired pastorate
}
public function getRetireeOfficersList($filters = []) {
// SQL with filters for retired officers
}
public function getPastorateTransfersList($filters = []) {
// SQL with filters for pastorate transfers
}
public function getOfficersTransfersList($filters = []) {
// SQL with filters for officers transfers
}
```
---
## Export Handler Structure
### **CSV Export (export-csv.php):**
```php
// Set headers
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="pastorate_' . date('Y-m-d') . '.csv"');
// Output data
$output = fopen('php://output', 'w');
fputcsv($output, ['Title', 'Name', 'District', 'Card No', 'Date Ordained']);
foreach ($data as $row) {
fputcsv($output, [$row['title'], $row['full_name'], ...]);
}
```
### **PDF Export (export-pdf.php):**
```php
require_once('../../vendor/autoload.php'); // or TCPDF library
$pdf = new TCPDF();
$pdf->AddPage();
$pdf->SetFont('helvetica', '', 12);
// Build HTML table
$html = '<table>...</table>';
$pdf->writeHTML($html);
$pdf->Output('pastorate_' . date('Y-m-d') . '.pdf', 'D');
```
### **Excel Export (export-excel.php):**
```php
require_once '../../vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
// Headers
$sheet->setCellValue('A1', 'Title');
$sheet->setCellValue('B1', 'Name');
// ... data rows
$writer = new Xlsx($spreadsheet);
$writer->save('php://output');
```
---
## View/Edit Page Structure (view.php)
```php
// Get officer ID
$officer_id = $_GET['id'] ?? 0;
$edit_mode = isset($_GET['edit']);
// Get complete officer details
$officer_details = $officership->getOfficerDetails($officer_id);
// Tabs:
// 1. Member Information
// 2. Ordination Details
// 3. Retirement Details (if retired)
// 4. Transfer History
// Forms for editing each section
```
---
## Status: Ready to Implement
I'll now create the first complete example page (pastorate.php) with all features. Once you approve the structure, I can create the remaining pages following the same pattern.
**Next Step:** Create `pastorate.php` as the complete working example?
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists