| Current Path : /home/emeraadmin/public_html/4d695/ |
| Current File : /home/emeraadmin/public_html/4d695/viewtasks.php.tar |
home/emeraadmin/public_html/pages/emeraadmin/viewtasks.php 0000644 00000025144 15167742256 0020057 0 ustar 00 <?php
include('head.php');
// Include database connection and TaskService class
require_once '../../Classes/Database.php';
require_once '../../Service/TaskService.php';
require_once '../../Classes/System.php';
$System = new System();
// Create TaskService instance
$taskService = new TaskService();
// Initialize filters array
$filters = [];
// Check for filter inputs and add to the filters array
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
if (!empty($_GET['service_name'])) {
$filters['service_name'] = filter_input(INPUT_GET, 'service_name', FILTER_SANITIZE_STRING);
}
if (!empty($_GET['region'])) {
$filters['region'] = filter_input(INPUT_GET, 'region', FILTER_SANITIZE_STRING);
}
if (!empty($_GET['frequency'])) {
$filters['frequency'] = filter_input(INPUT_GET, 'frequency', FILTER_SANITIZE_STRING);
}
if (isset($_GET['public']) && $_GET['public'] !== '') {
$filters['public'] = filter_input(INPUT_GET, 'public', FILTER_SANITIZE_NUMBER_INT);
}
if (isset($_GET['finished']) && $_GET['finished'] !== '') {
$filters['finished'] = filter_input(INPUT_GET, 'finished', FILTER_SANITIZE_NUMBER_INT);
}
if (isset($_GET['assigned']) && $_GET['assigned'] !== '') {
$filters['assigned'] = filter_input(INPUT_GET, 'assigned', FILTER_SANITIZE_NUMBER_INT);
}
}
// Fetch tasks from the database based on filters
$tasks = $taskService->getAllTasks($filters);
?>
<div class="main-content">
<div class="container-fluid">
<div class="page-header">
<div class="row align-items-end">
<div class="col-lg-8">
<div class="page-header-title">
<i class="ik ik-layers bg-blue"></i>
<div class="d-inline">
<h5>View Tasks</h5>
<span>View all tasks</span>
</div>
</div>
</div>
<div class="col-lg-4">
<nav class="breadcrumb-container" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="../../index.html"><i class="ik ik-home"></i></a>
</li>
<li class="breadcrumb-item">
<a href="#">Tasks</a>
</li>
<li class="breadcrumb-item active" aria-current="page">View Tasks</li>
</ol>
</nav>
</div>
</div>
</div>
<!-- Search Form -->
<div class="row mb-3">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h3>Search Tasks</h3>
</div>
<div class="card-body">
<form method="GET" action="">
<div class="form-row">
<div class="form-group col-md-2">
<label for="service_name">Service Name</label>
<input type="text" class="form-control" id="service_name" name="service_name" placeholder="Enter service name" value="<?php echo htmlspecialchars($_GET['service_name'] ?? ''); ?>">
</div>
<div class="form-group col-md-2">
<label for="region">Region</label>
<input type="text" class="form-control" id="region" name="region" placeholder="Enter region" value="<?php echo htmlspecialchars($_GET['region'] ?? ''); ?>">
</div>
<div class="form-group col-md-2">
<label for="frequency">Frequency</label>
<select class="form-control" id="frequency" name="frequency">
<option value="">Select</option>
<option value="daily" <?php echo (isset($_GET['frequency']) && $_GET['frequency'] === 'daily') ? 'selected' : ''; ?>>Daily</option>
<option value="3x/week" <?php echo (isset($_GET['frequency']) && $_GET['frequency'] === '3x/week') ? 'selected' : ''; ?>>3x/week</option>
</select>
</div>
<div class="form-group col-md-2">
<label for="public">Public</label>
<select class="form-control" id="public" name="public">
<option value="">Select</option>
<option value="1" <?php echo (isset($_GET['public']) && $_GET['public'] === '1') ? 'selected' : ''; ?>>Yes</option>
<option value="0" <?php echo (isset($_GET['public']) && $_GET['public'] === '0') ? 'selected' : ''; ?>>No</option>
</select>
</div>
<div class="form-group col-md-2">
<label for="finished">Finished</label>
<select class="form-control" id="finished" name="finished">
<option value="">Select</option>
<option value="1" <?php echo (isset($_GET['finished']) && $_GET['finished'] === '1') ? 'selected' : ''; ?>>Yes</option>
<option value="0" <?php echo (isset($_GET['finished']) && $_GET['finished'] === '0') ? 'selected' : ''; ?>>No</option>
</select>
</div>
<div class="form-group col-md-2">
<label for="assigned">Assigned</label>
<select class="form-control" id="assigned" name="assigned">
<option value="">Select</option>
<option value="1" <?php echo (isset($_GET['assigned']) && $_GET['assigned'] === '1') ? 'selected' : ''; ?>>Yes</option>
<option value="0" <?php echo (isset($_GET['assigned']) && $_GET['assigned'] === '0') ? 'selected' : ''; ?>>No</option>
</select>
</div>
</div>
<button type="submit" class="btn btn-primary">Apply Filters</button>
<a href="viewtasks.php" class="btn btn-secondary">Clear Filters</a>
</form>
</div>
</div>
</div>
</div>
<!-- End of Search Form -->
<!-- Task viewing section -->
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header"><h3>View Tasks</h3></div>
<div class="card-body">
<table id="advanced_table" class="table">
<thead>
<tr>
<th>#</th>
<th>Service Name</th>
<th>Region</th>
<th>Frequency</th>
<th>Created By</th>
<th>Created At</th>
<th>Finished</th>
<th>Assigned</th>
<th>Assigned To</th>
<th>Accepted</th>
<th>Public Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php if (!empty($tasks)): ?>
<?php foreach ($tasks as $task): ?>
<tr>
<td><?php echo 'TSK-000'.htmlspecialchars($task->id); ?></td>
<td><?php echo htmlspecialchars($task->service_name); ?></td>
<td><?php echo htmlspecialchars($task->region); ?></td>
<td><?php echo htmlspecialchars($task->frequency); ?></td>
<td><?php echo htmlspecialchars($task->added_by_name); ?></td>
<td><?php echo date('F j, Y, g:i a', strtotime($task->created_at)); ?></td>
<td><?php echo ($task->finished ? '<label class="badge badge-success">Finished</label>' : '<label class="badge badge-danger">Not Finished</label>'); ?></td>
<td><?php echo ($task->is_assigned ? '<label class="badge badge-success">Assigned</label>' : '<label class="badge badge-danger">Not Assigned</label>'); ?></td>
<td><?php echo htmlspecialchars($task->assigned_to_name); ?></td>
<th><?php echo ($task->accepted ? ' <label class="badge badge-success">Accepted</label>' : '<label class="badge badge-yellow">Not Accepted</label>'); ?></th>
<td><label class="badge badge-<?php echo $task->isPublic ? 'yellow' : 'green'; ?>"><?php echo $task->isPublic ? 'Public' : 'Not Public'; ?></label></td>
<td><a href="viewtask.php?id=<?php echo htmlspecialchars($System->encryptData($task->id)); ?>" class="btn btn-primary">View Details</a></td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="10">No tasks found.</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include('footer.php'); ?>