

<?php $__env->startSection('title', 'Case Search'); ?>

<?php $__env->startSection('content'); ?>

<div class="container-fluid">

    <!-- Page Header -->

    <div class="mb-4">

        <h3 class="fw-bold mb-1">
            <i class="bi bi-search"></i>
            Case Status Search
        </h3>

        <p class="text-muted mb-0">
            Search case records using different search criteria
        </p>

    </div>


    <!-- Search Card -->

    <div class="card border-0 shadow-sm mb-4">

        <!-- Card Header -->

        <div class="card-header bg-dark text-white py-3">

            <h5 class="mb-0">

                <i class="bi bi-search me-2"></i>

                Search Case

            </h5>

        </div>


        <div class="card-body">


            <!-- Search Tabs -->

            <ul class="nav nav-tabs mb-4" id="searchTabs">

                <li class="nav-item">

                    <button
                        type="button"
                        class="nav-link active"
                        data-type="case_number"
                    >

                        <i class="bi bi-file-earmark-text me-1"></i>

                        Case Number

                    </button>

                </li>


                <li class="nav-item">

                    <button
                        type="button"
                        class="nav-link"
                        data-type="party_name"
                    >

                        <i class="bi bi-person me-1"></i>

                        Party Name

                    </button>

                </li>


                <li class="nav-item">

                    <button
                        type="button"
                        class="nav-link"
                        data-type="lawyer_name"
                    >

                        <i class="bi bi-person-badge me-1"></i>

                        Lawyer Name

                    </button>

                </li>


                <li class="nav-item">

                    <button
                        type="button"
                        class="nav-link"
                        data-type="crime"
                    >

                        <i class="bi bi-shield-exclamation me-1"></i>

                        Crime No./Year

                    </button>

                </li>


                <li class="nav-item">

                    <button
                        type="button"
                        class="nav-link"
                        data-type="district"
                    >

                        <i class="bi bi-geo-alt me-1"></i>

                        District Court

                    </button>

                </li>

            </ul>


            <!-- Search Form -->

            <form
                method="GET"
                action="<?php echo e(route('cases.search')); ?>"
            >

                <input
                    type="hidden"
                    name="search_type"
                    id="search_type"
                    value="<?php echo e($searchType); ?>"
                >


                <!-- CASE NUMBER -->

                <div
                    id="case_number"
                    class="search-section"
                >

                    <div class="row g-3">

                        <!-- Case Type -->

                        <div class="col-md-4">

                            <label class="form-label fw-semibold">

                                Case Type

                            </label>

                            <select
                                name="case_type"
                                class="form-select"
                            >

                                <option value="">

                                    -- Select Case Type --

                                </option>

                                <?php $__currentLoopData = $caseTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                    <option
                                        value="<?php echo e($type->id); ?>"
                                        <?php echo e(request('case_type') == $type->id ? 'selected' : ''); ?>

                                    >

                                        <?php echo e(trim($type->casename)); ?>


                                    </option>

                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                            </select>

                        </div>


                        <!-- Case Number -->

                        <div class="col-md-4">

                            <label class="form-label fw-semibold">

                                Case Number

                            </label>

                            <input
                                type="number"
                                name="case_number"
                                class="form-control"
                                value="<?php echo e(request('case_number')); ?>"
                                placeholder="e.g. 4966"
                            >

                        </div>


                        <!-- Year -->

                        <div class="col-md-4">

                            <label class="form-label fw-semibold">

                                Year

                            </label>

                            <select
                                name="year"
                                class="form-select"
                            >

                                <option value="">

                                    -- Select Year --

                                </option>

                                <?php $__currentLoopData = $years; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $year): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                    <option
                                        value="<?php echo e($year); ?>"
                                        <?php echo e(request('year') == $year ? 'selected' : ''); ?>

                                    >

                                        <?php echo e($year); ?>


                                    </option>

                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                            </select>

                        </div>

                    </div>

                </div>


                <!-- PARTY NAME -->

                <div
                    id="party_name"
                    class="search-section d-none"
                >

                    <label class="form-label fw-semibold">

                        Party Name

                    </label>

                    <input
                        type="text"
                        name="party_name"
                        class="form-control"
                        value="<?php echo e(request('party_name')); ?>"
                        placeholder="Enter Petitioner or Respondent Name"
                    >

                    <small class="text-muted">

                        Search will check both Petitioner and Respondent.

                    </small>

                </div>


                <!-- LAWYER NAME -->

                <div
                    id="lawyer_name"
                    class="search-section d-none"
                >

                    <label class="form-label fw-semibold">

                        Lawyer Name

                    </label>

                    <input
                        type="text"
                        name="lawyer_name"
                        class="form-control"
                        value="<?php echo e(request('lawyer_name')); ?>"
                        placeholder="Enter Advocate Name"
                    >

                    <small class="text-muted">

                        Search will check both Petitioner and Respondent Advocate.

                    </small>

                </div>


                <!-- CRIME -->

                <div
                    id="crime"
                    class="search-section d-none"
                >

                    <div class="row g-3">

                        <div class="col-md-6">

                            <label class="form-label fw-semibold">

                                Crime Number

                            </label>

                            <input
                                type="number"
                                name="crime_number"
                                class="form-control"
                                value="<?php echo e(request('crime_number')); ?>"
                                placeholder="Enter Crime Number"
                            >

                        </div>


                        <div class="col-md-6">

                            <label class="form-label fw-semibold">

                                Year

                            </label>

                            <select
                                name="crime_year"
                                class="form-select"
                            >

                                <option value="">

                                    -- Select Year --

                                </option>

                                <?php $__currentLoopData = $years; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $year): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                    <option
                                        value="<?php echo e($year); ?>"
                                        <?php echo e(request('crime_year') == $year ? 'selected' : ''); ?>

                                    >

                                        <?php echo e($year); ?>


                                    </option>

                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                            </select>

                        </div>

                    </div>

                </div>


                <!-- DISTRICT -->

                <div
                    id="district"
                    class="search-section d-none"
                >

                    <label class="form-label fw-semibold">

                        District

                    </label>

                    <input
                        type="number"
                        name="district"
                        class="form-control"
                        value="<?php echo e(request('district')); ?>"
                        placeholder="Enter District ID"
                    >

                    <small class="text-muted">

                        District master 

                    </small>

                </div>


                <!-- Buttons -->

                <div class="mt-4 d-flex gap-2">

                    <button
                        type="submit"
                        class="btn btn-dark px-4"
                    >

                        <i class="bi bi-search me-1"></i>

                        Search

                    </button>


                    <a
                        href="<?php echo e(route('cases.search')); ?>"
                        class="btn btn-outline-secondary px-4"
                    >

                        <i class="bi bi-arrow-clockwise me-1"></i>

                        Reset

                    </a>

                </div>

            </form>

        </div>

    </div>


    <!-- SEARCH RESULT -->

   







<?php if(request()->hasAny([
    'case_type',
    'case_number',
    'year',
    'party_name',
    'lawyer_name',
    'crime_number',
    'crime_year',
    'district'
])): ?>

    <?php if($cases->count() > 0): ?>

        

        <div class="card border-0 shadow-sm mb-4">

            <div class="card-body p-4">

                

                <div class="result-header mb-3">

                    <div>

                        <h5 class="fw-bold mb-1">
                            Search Results
                        </h5>

                        <div class="text-muted small">

                            Showing
                            <strong><?php echo e($cases->firstItem()); ?></strong>

                            to

                            <strong><?php echo e($cases->lastItem()); ?></strong>

                            of

                            <strong><?php echo e($cases->total()); ?></strong>

                            entries

                        </div>

                    </div>

                    <div class="result-count">
                        <?php echo e($cases->total()); ?> Cases
                    </div>

                </div>


                

                <div class="row mb-3">

                    <div class="col-md-5 ms-auto">

                        <input
                            type="text"
                            id="resultSearch"
                            class="form-control"
                            placeholder="Search in results..."
                        >

                    </div>

                </div>


                

                <div class="table-responsive">

                    <table
                        class="table table-bordered case-result-table align-middle"
                        id="caseResultTable"
                    >

                        <thead>

                            <tr>

                                <th class="text-center">
                                    S.No.
                                </th>

                                <th>
                                    Case / Reg. Date
                                </th>

                                <th>
                                    Petitioner Name<br>
                                    Respondent Name
                                </th>

                                <th>
                                    Petitioner's Advocate<br>
                                    Respondent's Advocate
                                </th>

                                <th class="text-center">
                                    Status
                                </th>

                                <th class="text-center">
                                    Action
                                </th>

                            </tr>

                        </thead>


                        <tbody>

                            <?php $__currentLoopData = $cases; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $case): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                <tr class="case-row">

                                    

                                    <td class="text-center fw-semibold">

                                        <?php echo e($cases->firstItem() + $index); ?>


                                    </td>


                                    

                                    <td>

                                        <a
                                            href="javascript:void(0)"
                                            class="case-link"
                                            data-bs-toggle="modal"
                                            data-bs-target="#caseModal<?php echo e($case->cino); ?>"
                                        >

                                            <?php echo e(trim($case->caseType->skey ?? '')); ?>

                                            -
                                            <?php echo e($case->caseno); ?>

                                            -
                                            <?php echo e($case->caseyear); ?>


                                        </a>


                                        <div class="case-date">

                                            <?php if($case->fil_dt): ?>

                                                <?php echo e(\Carbon\Carbon::parse($case->fil_dt)->format('Y-m-d H:i:s')); ?>


                                            <?php else: ?>

                                                -

                                            <?php endif; ?>

                                        </div>

                                    </td>


                                    

                                    <td>

                                        <div class="party-result-name">
                                            <?php echo e($case->pet_name ?? '-'); ?>

                                        </div>

                                        <div class="vs-small">
                                            Vs
                                        </div>

                                        <div class="party-result-name">
                                            <?php echo e($case->res_name ?? '-'); ?>

                                        </div>

                                    </td>


                                    

                                    <td>

                                        <div>
                                            <?php echo e($case->pet_adv ?? '-'); ?>

                                        </div>

                                        <div class="vs-small">
                                            Vs
                                        </div>

                                        <div>
                                            <?php echo e($case->res_adv ?? '-'); ?>

                                        </div>

                                    </td>


                                    

                                    <td class="text-center">

                                        <?php if($case->c_status === 'P'): ?>

                                            <span class="case-status pending">
                                                Pending
                                            </span>

                                        <?php elseif($case->c_status === 'D'): ?>

                                            <span class="case-status disposed">
                                                Disposed
                                            </span>

                                        <?php else: ?>

                                            <span class="case-status other">
                                                <?php echo e($case->c_status ?? 'N/A'); ?>

                                            </span>

                                        <?php endif; ?>

                                    </td>


                                    

                                    <td class="text-center">

                                        <button
                                            type="button"
                                            class="btn btn-view-detail"
                                            data-bs-toggle="modal"
                                            data-bs-target="#caseModal<?php echo e($case->cino); ?>"
                                        >

                                            <i class="bi bi-eye me-1"></i>

                                            View Full Detail

                                        </button>

                                    </td>

                                </tr>


                                

                                <?php echo $__env->make(
                                    'cases.partials.case-detail-modal',
                                    ['case' => $case]
                                , array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                        </tbody>

                    </table>

                </div>


                

                <?php if($cases->hasPages()): ?>

                    <div class="mt-4 d-flex justify-content-center">

                        <?php echo e($cases->withQueryString()->links()); ?>


                    </div>

                <?php endif; ?>

            </div>

        </div>


    <?php else: ?>

        

        <div class="card border-0 shadow-sm">

            <div class="card-body text-center py-5">

                <i class="bi bi-search no-result-icon"></i>

                <h4 class="mt-3">
                    No Case Found
                </h4>

                <p class="text-muted mb-0">
                    No Matching Case Record Found             
                   </p>

            </div>

        </div>

    <?php endif; ?>

<?php endif; ?>







</div>





<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\abhay\erp-system\resources\views/cases/search.blade.php ENDPATH**/ ?>