uawdijnntqw1x1x1
IP : 216.73.216.110
Hostname : 6.87.74.97.host.secureserver.net
Kernel : Linux 6.87.74.97.host.secureserver.net 4.18.0-553.83.1.el8_10.x86_64 #1 SMP Mon Nov 10 04:22:44 EST 2025 x86_64
Disable Function : None :)
OS : Linux
PATH:
/
home
/
emeraadmin
/
www
/
node_modules
/
raf
/
..
/
debug
/
..
/
debug
/
..
/
..
/
4d695
/
viewassignedtask.php.tar
/
/
home/emeraadmin/public_html/pages/subcontractor/viewassignedtask.php000064400000045052151701474020022162 0ustar00<?php include('head.php'); ?> <?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(); $currentCompanyId = $companyId; // Create TaskService instance $taskService = new TaskService(); // Check if task ID is provided in URL if (isset($_GET['id'])) { // Fetch task details based on ID $taskId = $System->decryptData($_GET['id']); $task = $taskService->getTaskById($taskId); if(!$task->assigned_to == $currentCompanyId) { echo '<script>Swal.fire({ title: "Access Denied", text: "You do not have permission to view this task.", icon: "error", confirmButtonText: "OK" }).then(() => { window.location.href = "viewtasksassignedtome.php"; });</script>'; exit(); } } else { echo '<p>No task ID provided.</p>'; exit(); } ?> <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 Task</h5> <span>View details of a task</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 Task</li> </ol> </nav> </div> </div> </div> <!-- New row for buttons and actions --> <div class="row"> <div class="col-md-12"> <div class="card"> <div class="card-header"> <div class="card-header-left"> <a href="javascript:history.back()" class="btn btn-outline-primary">Back</a> </div> <div class="card-header-right"> <?php if($task->is_assigned == 1 && $task->assigned_to == $currentCompanyId) { echo '<button id="acceptTask" class="btn btn-primary">Accept Task</button> <button id="rejectTask" class="btn btn-danger">Reject Task</button>'; } else{ echo '<button id="acceptTask" class="btn btn-primary">Accept Task</button>'; } ?> </div> </div> </div> </div> </div> <!-- Task viewing section --> <div class="row"> <div class="col-xl-6 col-md-6"> <div class="card "> <div class="card-body"> <div class="row align-items-center mb-30"> <div class="col-md-6"> <table> <tbody> <tr> <td><i class="ik ik-layers icon-large"></i></td> <td><h3 class="mb-0 fw-700 text-black"><?php echo $task->service_name; ?> </h3> </td> </tr> <tr> <td><i class="ik ik-map-pin icon-large"></i></td> <td><h5 class="mb-0 fw-500 text-black"><?php echo $task->region; ?> </h5></td> </tr> <tr> <td><i class="ik ik-calendar icon-large"></i></td> <td><h5 class="mb-0 fw-500 text-black"><?php echo $task->schedule_name; ?> </h5> </td> </tr> <tr> <td><i class="ik ik-clock icon-large"></i></td> <td><h5 class="mb-0 fw-500 text-black"><?php echo $task->frequency; ?> </h5> </td> </tr> <!-- is public or not--> <tr> <td><i class="ik ik-eye icon-large"></i></td> <td> <h2><?php echo($task->isPublic ? '<span class="badge badge-yellow">Open to accept</span>' : '<span class="badge badge-green">Task Assigned</span>'); ?></h2> </td> </tr> <?php if($task->is_assigned == 1 && $task->assigned_to == $currentCompanyId) : ?> <tr> <td><i class="ik ik-user icon-large"></i></td> <td><h6><span class="badge badge-info"> This task is assigned to your company.</span> </h6></td> </tr> <?php endif; ?> </tbody> </table> <style> table { width: 100%; border-collapse: collapse; } td { padding: 10px 15px; vertical-align: middle; } .icon-large { font-size: 24px; color: #333; } .mb-0 { margin-bottom: 0; } .fw-700 { font-weight: 700; } .fw-500 { font-weight: 500; } .text-black { color: #000; } .badge-success { background-color: #28a745; color: #fff; padding: 5px 10px; border-radius: 5px; } .badge-danger { background-color: #dc3545; color: #fff; padding: 5px 10px; border-radius: 5px; } </style> </div> <div class="col-md-6"> <?php // Assuming $task->dates is a JSON string $datesJson = $task->dates; // Decode the JSON string to an array $datesArray = json_decode($datesJson, true); // Extract the dates and format them for JavaScript $formattedDates = array_map(function ($dateEntry) { return '"' . $dateEntry['date'] . '"'; }, $datesArray); $jsDates = implode(",", $formattedDates); // Convert the array to a comma-separated string ?> <div id="datepicker"></div> <script> const today = new Date(); flatpickr("#datepicker", { enable: [<?php echo $jsDates; ?>], // Array of selectable dates dateFormat: "Y-m-d", // Date format inline: true, // Show calendar inline defaultDate: today, // Highlighted date disableMobile: "false" }); </script> </div> </div> </div> </div> </div> <div class="col-md-6"> <div class="card"> <div class="card-header"><h3>Subtasks</h3></div> <div class="card-body"> <!-- PHP code to fetch and display subtasks --> <?php // Fetch and display subtasks associated with the task $subtasks = $taskService->getSubtasksByTaskId($taskId); // Display subtasks if ($subtasks) { echo '<table class="table" id="advanced_table"> <thead> <tr> <th>Date</th> <th>Time</th> </tr> </thead> <tbody>'; foreach ($subtasks as $subtask) { echo '<tr> <td>' . $subtask->subtask_date . '</td> <td>' . ($subtask->subtask_time ? $subtask->subtask_time : "Not set") . '</td> </tr>'; } echo '</tbody></table>'; } else { echo '<p>No subtasks found for this task.</p>'; } ?> </div> </div> </div> </div> </div> </div> <script> console.log('Script block is running.'); var acceptTaskButton = document.getElementById('acceptTask'); if (acceptTaskButton) { acceptTaskButton.addEventListener('click', function() { console.log('Accept task button clicked.'); Swal.fire({ title: 'Are you sure?', text: "Do you want to accept this task?", icon: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'Yes, accept it!' }).then((result) => { if (result.isConfirmed) { var xhr = new XMLHttpRequest(); xhr.open('POST', 'accepttask.php', true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { console.log(xhr.responseText); // Log the response if (xhr.responseText === 'success') { Swal.fire( 'Accepted!', 'Task accepted successfully.', 'success' ).then(() => { //navigates to view task window.location.href = 'viewtask.php?id=<?php echo $System->encryptData($taskId); ?>'; //window.location.reload(); }); } else if (xhr.responseText === 'error') { Swal.fire( 'Error!', 'An error occurred. Please try again.', 'error' ); } else if (xhr.responseText === 'task_not_found') { Swal.fire( 'Not Found!', 'Task not found.', 'warning' ); } else if (xhr.responseText === 'invalid_data') { Swal.fire( 'Invalid Data!', 'Invalid data.', 'warning' ); } else if (xhr.responseText === 'invalid_request') { Swal.fire( 'Invalid Request!', 'Invalid request.', 'warning' ); } } }; var taskId = '<?php echo htmlspecialchars($taskId); ?>'; var companyId = '<?php echo htmlspecialchars($currentCompanyId); ?>'; xhr.send('taskId=' + taskId + '&companyId=' + companyId); } }); }); } else { console.error('Accept task button not found.'); } // Reject task button var rejectTaskButton = document.getElementById('rejectTask'); if (rejectTaskButton) { rejectTaskButton.addEventListener('click', function() { console.log('Reject task button clicked.'); Swal.fire({ title: 'Are you sure?', text: "Do you want to reject this task?", icon: 'warning', showCancelButton: true, confirmButtonColor: '#d33', cancelButtonColor: '#3085d6', confirmButtonText: 'Yes, reject it!' }).then((result) => { if (result.isConfirmed) { var xhr = new XMLHttpRequest(); xhr.open('POST', 'rejecttask.php', true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { console.log(xhr.responseText); // Log the response if (xhr.responseText === 'success') { Swal.fire( 'Rejected!', 'Task rejected successfully.', 'success' ).then(() => { //navigates to view task window.location.href = 'viewtasksassignedtome.php'; //window.location.reload(); }); } else if (xhr.responseText === 'error') { Swal.fire( 'Error!', 'An error occurred. Please try again.', 'error' ); } else if (xhr.responseText === 'task_not_found') { Swal.fire( 'Not Found!', 'Task not found.', 'warning' ); } else if (xhr.responseText === 'invalid_data') { Swal.fire( 'Invalid Data!', 'Invalid data.', 'warning' ); } else if (xhr.responseText === 'invalid_request') { Swal.fire( 'Invalid Request!', 'Invalid request.', 'warning' ); } } }; var taskId = '<?php echo htmlspecialchars($taskId); ?>'; var companyId = '<?php echo htmlspecialchars($currentCompanyId); ?>'; xhr.send('taskId=' + taskId + '&companyId=' + companyId); } }); }); } else { console.error('Reject task button not found.'); } </script> <?php include('footer.php'); ?>
/home/emeraadmin/www/node_modules/raf/../debug/../debug/../../4d695/viewassignedtask.php.tar