Your IP : 216.73.216.86


Current Path : /home/emeraadmin/public_html/pages/subcontractor/
Upload File :
Current File : /home/emeraadmin/public_html/pages/subcontractor/assigntasks.php

<?php
include('head.php');
require_once '../../Classes/Database.php';
require_once '../../Service/TaskService.php';
require_once '../../Classes/System.php';
require_once '../../Service/ServiceService.php';

$serviceService = new ServiceService();

$System = new System();

$services = $serviceService->getAllServicesForDropdown();


// Create TaskService instance
$taskService = new TaskService();



$tasks = $taskService->getTasksWithUnassignedSubtasks($companyId);

?>

<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 Assignable Tasks</h5>
                            <span>View details of tasks assigned to your company</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 Accepted Tasks</li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>

        <!-- 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">
                        <div class="form-group row">
                            <div class="col-sm-3">
                                <label for="filter_service" class="col-form-label">Filter Service Name:</label>
                                <input type="text" class="form-control" id="filter_service">
                            </div>
                            <div class="col-sm-3">
                                <label for="filter_region" class="col-form-label">Filter Region:</label>
                                <select class="form-control" id="filter_region">
                                    <option value="">All Regions</option>
                                    <?php
                                    // Collect unique regions
                                    $uniqueRegions = [];
                                    foreach ($services as $service) {
                                        if (!in_array($service->region, $uniqueRegions)) {
                                            $uniqueRegions[] = $service->region;
                                            ?>
                                            <option value="<?= htmlspecialchars($service->region) ?>"><?= htmlspecialchars($service->region) ?></option>
                                            <?php
                                        }
                                    }
                                    ?>
                                </select>
                            </div>

                        </div>
                        <table id="super_advanced_table" class="table">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>Service Name</th>
                                <th>Region</th>
                                <th>Frequency</th>
                                <th>Created At</th>
                                <th>Completed</th>
                                <th>Actions</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php foreach ($tasks as $task): ?>
                                <tr>
                                    <td><?php echo 'TSK-000'.$task->id; ?></td>
                                    <td><?php echo $task->service_name; ?></td>
                                    <td><?php echo $task->region; ?></td>
                                    <td><?php echo $task->frequency; ?></td>
                                    <td><?php echo date('F j, Y, g:i a', strtotime($task->created_at)); ?></td>
                                    <td>
                                        <label class="badge badge-<?php echo $task->finished ? 'success' : 'yellow'; ?>"><?php echo $task->finished ? 'Completed' : 'Not Completed'; ?></label>
                                    </td>
                                    <td>
                                        <a href="viewtask.php?id=<?php echo $System->encryptData($task->id); ?>" class="btn btn-primary">View Details</a>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                            </tbody>
                        </table>
                    </div>
                    <script>
                        $(document).ready(function () {
                            // Initialize DataTable
                            var table = $('#super_advanced_table').DataTable({
                                // Configure initial settings if needed
                            });

                            // Add custom filters
                            $('#filter_service').on('keyup', function () {
                                table.column(1).search(this.value).draw();
                            });

                            $('#filter_region').on('change', function () {
                                table.column(2).search($(this).val()).draw();
                            });


                        });
                    </script>
                </div>
            </div>
        </div>

    </div>
</div>

<?php include('footer.php'); ?>