Your IP : 216.73.216.86


Current Path : /home/emeraadmin/public_html/4d695/
Upload File :
Current File : /home/emeraadmin/public_html/4d695/report_subtaskswithnotes.php.tar

home/emeraadmin/public_html/pages/emeraadmin/report_subtaskswithnotes.php000064400000032760151677421770023242 0ustar00<?php
include('head.php');
require_once '../../Classes/Database.php';
require_once '../../Service/TaskService.php';
require_once '../../Classes/System.php';
require_once '../../Service/ServiceService.php';

// Initialize necessary services and objects
$serviceService = new ServiceService();
$taskService = new TaskService();
$System = new System();

// Fetch services for dropdown
$services = $serviceService->getAllServicesForDropdown();

// Fetch assigned user ID from session or request
$assignedUserId = $_SESSION['user_id'] ?? ($_GET['user_id'] ?? 1); // Default to 1 if not set

// Fetch all notes grouped by date
$startDate = $_GET['start_date'] ?? null;
$endDate = $_GET['end_date'] ?? null;
$subcontractorId = $_GET['subcontractor_id'] ?? null;
$serviceLocationId = $_GET['service_location_id'] ?? null;

if ($_GET['filter_today'] ?? false) {
    $startDate = date('Y-m-d');
    $endDate = date('Y-m-d');
}

$subtasks = $taskService->getAllSubtasksWithNotesGroupByDate($startDate, $endDate, $subcontractorId, $serviceLocationId);
?>

<!-- Include Bootstrap Datepicker CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" />

<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>Tasks</h5>
                            <span>Report Submitting Notes</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=""><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">All Subtasks</li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>

        <!-- Date Filter and Today Checkbox -->
        <div class="row mb-4">
            <div class="col-md-3">
                <div class="form-group">
                    <label for="startDate">Start Date</label>
                    <input type="text" id="startDate" class="form-control datepicker" placeholder="Select start date" value="<?= htmlspecialchars($startDate) ?>">
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="endDate">End Date</label>
                    <input type="text" id="endDate" class="form-control datepicker" placeholder="Select end date" value="<?= htmlspecialchars($endDate) ?>">
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="subcontractorId">Select a Subcontractor:</label>
                    <select id="subcontractorId" name="subcontractorId" class="form-control select2">
                        <!-- Default option -->
                        <option value="">All Subcontractors</option>
                        <?php
                        // Fetch company list from the database
                        $companies = $taskService->getAllCompanies();
                        if ($companies) {
                            foreach ($companies as $company) {
                                // Check if subcontractor_id is set in the URL
                                $selected = '';
                                if (isset($_GET['subcontractor_id']) && $_GET['subcontractor_id'] == $company->id) {
                                    $selected = 'selected';
                                }
                                echo '<option value="' . $company->id . '" ' . $selected . '>' . $company->first_name . ' ' . $company->last_name . '</option>';
                            }
                        } else {
                            echo '<option value="">No subcontractors available</option>';
                        }
                        ?>
                    </select>
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="serviceLocationId">Select a Service Location:</label>
                    <select id="serviceLocationId" name="serviceLocationId" class="form-control">
                        <option value="">All Locations</option>
                        <?php
                        // Collect unique regions
                        foreach ($services as $service) {
                            // Check if serviceLocationId is set in the URL
                            $selected = '';
                            if (isset($_GET['service_location_id']) && $_GET['service_location_id'] == $service->id) {
                                $selected = 'selected';
                            }
                            echo '<option value="' . htmlspecialchars($service->id) . '" ' . $selected . '>' . htmlspecialchars($service->name) . '</option>';
                        }
                        ?>
                    </select>
                </div>
            </div>
            <div class="col-md-3 d-flex align-items-center">
                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="checkbox" id="todayCheckbox" value="today" <?= ($startDate == date('Y-m-d') && $endDate == date('Y-m-d')) ? 'checked' : '' ?>>
                    <label class="form-check-label" for="todayCheckbox">Today</label>
                </div>
            </div>
            <div class="col-md-3 d-flex align-items-center">
                <button id="applyFilter" class="btn btn-primary">Apply Filter</button>
                &nbsp;
                &nbsp;
                <button type="button" id="reset_filters" class="btn btn-icon btn-outline-danger"><i class="ik ik-refresh-cw"></i></button>
            </div>
        </div>

        <!-- Display subtasks grouped by date -->
        <?php foreach ($subtasks as $date => $subtaskList) { ?>
            <?php
            // Check if all subtasks under this date have empty notes
            $allEmpty = true;
            foreach ($subtaskList as $subtask) {
                if (!empty($subtask['notes'])) {
                    $allEmpty = false;
                    break;
                }
            }

            // If all subtasks have empty notes, skip displaying this section
            if ($allEmpty) {
                continue;
            }
            ?>
            <div class="row subtask-row" data-date="<?php echo $date; ?>">
                <div class="col-md-12">
                    <div class="card">
                        <div class="card-header">
                            <h3>Subtasks for <?php
                                if ($date == date('Y-m-d')) {
                                    echo 'Today';
                                } else if ($date == date('Y-m-d', strtotime('tomorrow'))) {
                                    echo 'Tomorrow';
                                } else {
                                    echo date('l, F j, Y', strtotime($date));
                                }
                                ?></h3>
                        </div>
                        <div class="card-body">
                            <div class="dt-responsive">
                                <table class="table" id="advanced_table_<?php echo strtotime($date); ?>">
                                    <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>Service Name</th>
                                        <th>Subcontractor</th>
                                        <th>Date</th>
                                        <th>Time</th>
                                        <th>Notes</th>
                                        <th>Actions</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php foreach ($subtaskList as $subtask) { ?>
                                        <?php if (empty($subtask['notes'])) continue; // Skip rows with empty notes ?>
                                        <tr class="subtask-row">
                                            <td>ST-000<?= $subtask['id']; ?></td>
                                            <td><?= $subtask['service_name']; ?></td>
                                            <td><?= $subtask['assigned_user_first_name'].' '.$subtask['assigned_user_last_name']; ?></td>
                                            <td><?= $subtask['subtask_date']; ?></td>
                                            <td><?= $subtask['subtask_time'] ? date('h:i A', strtotime($subtask['subtask_time'])) : ''; ?></td>
                                            <td><?= $subtask['notes']; ?></td>
                                            <td>
                                                <a href="viewsubtask.php?id=<?= $System->encryptData($subtask['id']); ?>" class="btn btn-primary">View</a>
                                            </td>
                                        </tr>
                                    <?php } ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        <?php } ?>
    </div>
</div>

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


<!-- Include jQuery and Bootstrap Datepicker JS -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>

<script>
    $(document).ready(function() {
        // Initialize datepickers
        $('.datepicker').datepicker({
            format: 'yyyy-mm-dd',
            autoclose: true,
            todayHighlight: true
        });

        // Function to save filters to localStorage
        function saveFilters() {
            var filters = {
                startDate: $('#startDate').val(),
                endDate: $('#endDate').val(),
                subcontractorId: $('#subcontractorId').val(),
                serviceLocationId: $('#serviceLocationId').val(),
                todayCheckbox: $('#todayCheckbox').is(':checked')
            };
            localStorage.setItem('dateRangeFilters', JSON.stringify(filters));
        }

        // Function to apply saved filters
        function applyFilters() {
            var filters = JSON.parse(localStorage.getItem('dateRangeFilters'));
            if (filters) {
                $('#startDate').val(filters.startDate);
                $('#endDate').val(filters.endDate);
                $('#subcontractorId').val(filters.subcontractorId);
                $('#serviceLocationId').val(filters.serviceLocationId);
                $('#todayCheckbox').prop('checked', filters.todayCheckbox);
            }
        }

        // Function to reset filters
        function resetFilters() {
            $('#startDate').val('');
            $('#endDate').val('');
            $('#subcontractorId').val('');
            $('#serviceLocationId').val('');
            $('#todayCheckbox').prop('checked', false);
            localStorage.removeItem('dateRangeFilters');
            applyDateRangeFilter();
        }

        // Apply date range filter by modifying the URL
        function applyDateRangeFilter() {
            var startDate = $('#startDate').val();
            var endDate = $('#endDate').val();
            var subcontractorId = $('#subcontractorId').val();
            var serviceLocationId = $('#serviceLocationId').val();
            var url = window.location.href.split('?')[0] + '?start_date=' + startDate + '&end_date=' + endDate + '&subcontractor_id=' + subcontractorId + '&service_location_id=' + serviceLocationId;
            window.location.href = url;
        }

        // Event handler for applyFilter button
        $('#applyFilter').on('click', function() {
            saveFilters();
            applyDateRangeFilter();
        });

        // Event handler for todayCheckbox
        $('#todayCheckbox').on('change', function() {
            if ($(this).is(':checked')) {
                var today = '<?= date('Y-m-d') ?>';
                $('#startDate').val(today);
                $('#endDate').val(today);
            } else {
                $('#startDate').val('');
                $('#endDate').val('');
            }
            saveFilters();
            applyDateRangeFilter();
        });

        // Add reset filters button functionality
        $('#reset_filters').on('click', function() {
            resetFilters();
        });

        // Apply saved filters on initial load
        applyFilters();
    });
</script>
home/emeraadmin/public_html/pages/taskprovider/report_subtaskswithnotes.php000064400000017540151677422760023654 0ustar00<?php
include('head.php');
require_once '../../Classes/Database.php';
require_once '../../Service/TaskService.php';
require_once '../../Classes/System.php';

// Initialize necessary services and objects
$taskService = new TaskService();
$System = new System();

// Fetch filter parameters
$startDate = $_GET['start_date'] ?? null;
$endDate = $_GET['end_date'] ?? null;
$serviceLocationId = $_GET['service_location_id'] ?? null;

if ($_GET['filter_today'] ?? false) {
    $startDate = date('Y-m-d');
    $endDate = date('Y-m-d');
}

// Fetch all notes grouped by date without subcontractor filtering
$subtasks = $taskService->getAllSubtasksWithNotesGroupByDateForTeamKidsAdmin($startDate, $endDate, $serviceLocationId);
?>

<!-- Include Bootstrap Datepicker CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" />

<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>Tasks</h5>
                            <span>View and Submit Notes</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="#"><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">Subtasks</li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>

        <!-- Date Filter -->
        <div class="row mb-4">
            <div class="col-md-3">
                <div class="form-group">
                    <label for="startDate">Start Date</label>
                    <input type="text" id="startDate" class="form-control datepicker" placeholder="Select start date" value="<?= htmlspecialchars($startDate) ?>">
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="endDate">End Date</label>
                    <input type="text" id="endDate" class="form-control datepicker" placeholder="Select end date" value="<?= htmlspecialchars($endDate) ?>">
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="serviceLocationId">Select a Service Location:</label>
                    <select id="serviceLocationId" name="serviceLocationId" class="form-control">
                        <option value="">All Locations</option>
                        <?php
                        // Populate service locations
                        $services = $taskService->getAllServicesForDropdown();
                        foreach ($services as $service) {
                            $selected = ($serviceLocationId == $service->id) ? 'selected' : '';
                            echo '<option value="' . htmlspecialchars($service->id) . '" ' . $selected . '>' . htmlspecialchars($service->name) . '</option>';
                        }
                        ?>
                    </select>
                </div>
            </div>
            <div class="col-md-3 d-flex align-items-center">
                <button id="applyFilter" class="btn btn-primary">Apply Filter</button>
                &nbsp;
                <button type="button" id="reset_filters" class="btn btn-icon btn-outline-danger"><i class="ik ik-refresh-cw"></i></button>
            </div>
        </div>

        <!-- Display subtasks grouped by date -->
        <?php foreach ($subtasks as $date => $subtaskList) { ?>
            <?php
            // Skip if all notes are empty
            $allEmpty = true;
            foreach ($subtaskList as $subtask) {
                if (!empty($subtask['notes'])) {
                    $allEmpty = false;
                    break;
                }
            }
            if ($allEmpty) continue;
            ?>
            <div class="row subtask-row" data-date="<?php echo $date; ?>">
                <div class="col-md-12">
                    <div class="card">
                        <div class="card-header">
                            <h3>Subtasks for <?= date('l, F j, Y', strtotime($date)); ?></h3>
                        </div>
                        <div class="card-body">
                            <table class="table">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Service Name</th>
                                    <th>Date</th>
                                    <th>Time</th>
                                    <th>Notes</th>
                                    <th>Actions</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php foreach ($subtaskList as $subtask) { ?>
                                    <?php if (empty($subtask['notes'])) continue; ?>
                                    <tr>
                                        <td>ST-<?= htmlspecialchars($subtask['id']); ?></td>
                                        <td><?= htmlspecialchars($subtask['service_name']); ?></td>
                                        <td><?= htmlspecialchars($subtask['subtask_date']); ?></td>
                                        <td><?= htmlspecialchars($subtask['subtask_time'] ? date('h:i A', strtotime($subtask['subtask_time'])) : ''); ?></td>
                                        <td><?= htmlspecialchars($subtask['notes']); ?></td>
                                        <td>
                                            <a href="viewsubtask.php?id=<?= $System->encryptData($subtask['id']); ?>" class="btn btn-primary">View</a>
                                        </td>
                                    </tr>
                                <?php } ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        <?php } ?>
    </div>
</div>

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

<!-- Include Scripts -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
<script>
    $(document).ready(function () {
        // Datepicker initialization
        $('.datepicker').datepicker({format: 'yyyy-mm-dd', autoclose: true, todayHighlight: true});

        // Apply filter
        $('#applyFilter').on('click', function () {
            var startDate = $('#startDate').val();
            var endDate = $('#endDate').val();
            var serviceLocationId = $('#serviceLocationId').val();
            var url = window.location.href.split('?')[0] + '?start_date=' + startDate + '&end_date=' + endDate + '&service_location_id=' + serviceLocationId;
            window.location.href = url;
        });

        // Reset filters
        $('#reset_filters').on('click', function () {
            window.location.href = window.location.href.split('?')[0];
        });
    });
</script>
home/emeraadmin/public_html/pages/subcontractor/report_subtaskswithnotes.php000064400000017665151701476040024023 0ustar00<?php
include('head.php');
require_once '../../Classes/Database.php';
require_once '../../Service/TaskService.php';
require_once '../../Classes/System.php';

// Initialize necessary services and objects
$taskService = new TaskService();
$System = new System();

// Fetch current subcontractor ID from session
$currentSubcontractorId = $_SESSION['user_id'] ?? null;

// Fetch all notes grouped by date for the current subcontractor
$startDate = $_GET['start_date'] ?? null;
$endDate = $_GET['end_date'] ?? null;
$serviceLocationId = $_GET['service_location_id'] ?? null;

if ($_GET['filter_today'] ?? false) {
    $startDate = date('Y-m-d');
    $endDate = date('Y-m-d');
}

$subtasks = $taskService->getAllSubtasksWithNotesGroupByDateForSubContractors($startDate, $endDate, $currentSubcontractorId, $serviceLocationId);
?>

<!-- Include Bootstrap Datepicker CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" />

<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>Tasks</h5>
                            <span>View and Submit Notes</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="#"><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">Subtasks</li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>

        <!-- Date Filter -->
        <div class="row mb-4">
            <div class="col-md-3">
                <div class="form-group">
                    <label for="startDate">Start Date</label>
                    <input type="text" id="startDate" class="form-control datepicker" placeholder="Select start date" value="<?= htmlspecialchars($startDate) ?>">
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="endDate">End Date</label>
                    <input type="text" id="endDate" class="form-control datepicker" placeholder="Select end date" value="<?= htmlspecialchars($endDate) ?>">
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label for="serviceLocationId">Select a Service Location:</label>
                    <select id="serviceLocationId" name="serviceLocationId" class="form-control">
                        <option value="">All Locations</option>
                        <?php
                        // Populate service locations
                        $services = $taskService->getAllServicesForDropdown();
                        foreach ($services as $service) {
                            $selected = ($serviceLocationId == $service->id) ? 'selected' : '';
                            echo '<option value="' . htmlspecialchars($service->id) . '" ' . $selected . '>' . htmlspecialchars($service->name) . '</option>';
                        }
                        ?>
                    </select>
                </div>
            </div>
            <div class="col-md-3 d-flex align-items-center">
                <button id="applyFilter" class="btn btn-primary">Apply Filter</button>
                &nbsp;
                <button type="button" id="reset_filters" class="btn btn-icon btn-outline-danger"><i class="ik ik-refresh-cw"></i></button>
            </div>
        </div>

        <!-- Display subtasks grouped by date -->
        <?php foreach ($subtasks as $date => $subtaskList) { ?>
            <?php
            // Skip if all notes are empty
            $allEmpty = true;
            foreach ($subtaskList as $subtask) {
                if (!empty($subtask['notes'])) {
                    $allEmpty = false;
                    break;
                }
            }
            if ($allEmpty) continue;
            ?>
            <div class="row subtask-row" data-date="<?php echo $date; ?>">
                <div class="col-md-12">
                    <div class="card">
                        <div class="card-header">
                            <h3>Subtasks for <?= date('l, F j, Y', strtotime($date)); ?></h3>
                        </div>
                        <div class="card-body">
                            <table class="table">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Service Name</th>
                                    <th>Date</th>
                                    <th>Time</th>
                                    <th>Notes</th>
                                    <th>Actions</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php foreach ($subtaskList as $subtask) { ?>
                                    <?php if (empty($subtask['notes'])) continue; ?>
                                    <tr>
                                        <td>ST-<?= $subtask['id']; ?></td>
                                        <td><?= htmlspecialchars($subtask['service_name']); ?></td>
                                        <td><?= htmlspecialchars($subtask['subtask_date']); ?></td>
                                        <td><?= htmlspecialchars($subtask['subtask_time'] ? date('h:i A', strtotime($subtask['subtask_time'])) : ''); ?></td>
                                        <td><?= htmlspecialchars($subtask['notes']); ?></td>
                                        <td>
                                            <a href="viewsubtask.php?id=<?= $System->encryptData($subtask['id']); ?>" class="btn btn-primary">View</a>
                                        </td>
                                    </tr>
                                <?php } ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        <?php } ?>
    </div>
</div>

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

<!-- Include Scripts -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
<script>
    $(document).ready(function () {
        // Datepicker initialization
        $('.datepicker').datepicker({format: 'yyyy-mm-dd', autoclose: true, todayHighlight: true});

        // Apply filter
        $('#applyFilter').on('click', function () {
            var startDate = $('#startDate').val();
            var endDate = $('#endDate').val();
            var serviceLocationId = $('#serviceLocationId').val();
            var url = window.location.href.split('?')[0] + '?start_date=' + startDate + '&end_date=' + endDate + '&service_location_id=' + serviceLocationId;
            window.location.href = url;
        });

        // Reset filters
        $('#reset_filters').on('click', function () {
            window.location.href = window.location.href.split('?')[0];
        });
    });
</script>