

<?php $__env->startSection('content'); ?>
    <!--begin::App Content Header-->
    <div class="app-content-header"> <!--begin::Container-->
        <div class="container-fluid">
            <!--begin::Row-->
            <div class="row">
                <div class="col-sm-6">
                    <h3 class="mb-0">Task List</h3>
                </div>
                <?php if(session('success')): ?>
                    <div class="alert alert-success">
                        <?php echo e(session('success')); ?>

                    </div>
                <?php endif; ?>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-end">
                        <li class="breadcrumb-item"><a href="<?php echo e(route('admin.dashboard')); ?>">Home</a></li>
                        <li class="breadcrumb-item active" aria-current="page">
                            Task List
                        </li>
                    </ol>
                </div>
            </div>
            <!--end::Row-->
        </div> <!--end::Container-->

        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-header">
                        <div class="text-end ">
                            <?php if(Auth::user()->id_role != 3): ?>
                                <a href="<?php echo e(route('tasks.create')); ?>" class="btn btn-success mb-3">Create Task</a>
                            <?php endif; ?>
                        </div>
                    </div>
                    <div class="card-body">
                        <table class="table table-bordered table-striped">
                            <thead>
                                <tr class="text-center">
                                    <th>No</th>
                                    <th>Title</th>
                                    <th>Description</th>
                                    <th>Creator</th>
                                    <th>Assigned To</th>
                                    <th>Farm</th>
                                    <th>Section</th>
                                    <th>Created At</th>
                                    <th>Actions</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $tasks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $task): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td><?php echo e($loop->iteration); ?></td>
                                        <td><?php echo e($task->title); ?></td>
                                        <td><?php echo e(Str::limit($task->description, 50)); ?></td>
                                        <td><?php echo e($task->creator->fullname ?? 'N/A'); ?></td>
                                        <td><?php echo e($task->assignee->fullname ?? 'N/A'); ?></td>
                                        <td><?php echo e($task->farm->registration_no ?? 'N/A'); ?></td>
                                        <td><?php echo e($task->section->name ?? 'N/A'); ?></td>
                                        <td><?php echo e($task->created_at->format('Y-m-d H:i')); ?></td>
                                        <td>
                                            <div class="text-center" class="btn-group">
                                                <a href="<?php echo e(route('tasks.show', $task->id)); ?>"
                                                    class="btn btn-primary btn-sm">View</a>
                                                <?php if(Auth::user()->id_role != 3): ?>
                                                    <a href="<?php echo e(route('tasks.edit', $task->id)); ?>"
                                                        class="btn btn-warning btn-sm">Edit</a>
                                                    <form action="<?php echo e(route('tasks.destroy', $task->id)); ?>" method="POST"
                                                        style="display: inline-block;">
                                                        <?php echo csrf_field(); ?>
                                                        <?php echo method_field('DELETE'); ?>
                                                        <button type="submit" class="btn btn-danger btn-sm"
                                                            onclick="return confirm('Are you sure you want to delete this task?');">Delete</button>
                                                    </form>
                                                <?php endif; ?>
                                            </div>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="9" class="text-center">No tasks found.</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>

                        <div class="d-flex justify-content-center">
                            <?php echo e($tasks->links()); ?>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    <?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\laragon\www\FMIS_fypsystem\resources\views/tasks/tasks-index.blade.php ENDPATH**/ ?>