<?php $__env->startSection('title','Update Case Hearing | '); ?>
<?php $__env->startSection('content'); ?>
<!-- Content Header (Page header) -->
<div class="content-header">
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-6">
                <h1 class="m-0">Update Case Hearing</h1>
            </div><!-- /.col -->
            <div class="col-sm-6">
                <ol class="breadcrumb float-sm-right">
                    <li class="breadcrumb-item"><a href="#">Home</a></li>
                    <li class="breadcrumb-item active">Case Management</li>
                </ol>
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
<!-- Main content -->
<section class="content">
    <div class="container-fluid">
        <div class="card card-default">
            <div class="card-header">
                <h3 class="card-title">Update Case Hearing</h3>
            </div>
            <!-- /.card-header -->
            <div class="card-body">
                <?php if(session('success')): ?>
                <div class="alert alert-success alert-dismissible fade show" role="alert">
                    <strong><?php echo e(session('success')); ?></strong>
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <?php endif; ?>
                <?php if(session('error')): ?>
                <div class="alert alert-danger alert-dismissible fade show" role="alert">
                    <strong><?php echo e(session('error')); ?></strong>
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <?php endif; ?>
                <?php if(session('warning')): ?>
                <div class="alert alert-warning alert-dismissible fade show" role="alert">
                    <strong><?php echo e(session('warning')); ?></strong>
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <?php endif; ?>
                <?php if(!empty($cases)): ?>
                <form action="<?php echo e(route('save.case.hearing')); ?>" method="post" autocomplete="off" enctype="multipart/form-data">
                    <?php echo csrf_field(); ?>
                    <input type="hidden" name="case_id" value="<?php echo e($cases->id); ?>">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="case_number">Case Number</label>
                                <input type="text" name="case_number"
                                    class="form-control   <?php if( $errors->has('case_number')): ?> is-invalid border-danger  <?php endif; ?>"
                                    value="<?php echo e($cases->case_number); ?>" id="case_number" placeholder="Case Number"
                                    readonly>
                                <small class="text-danger case_number_error"></small>
                                <?php if($errors->has('case_number')): ?>
                                <span id="case_number-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('case_number')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div>
                         <div class="col-md-3">
                            <div class="form-group">
                                <label for="next_hearing_date">Previous Hearing Date</label>                               
                                <?php if(empty($cases->next_hearing_date)): ?>
                                <span class="form-control" readonly><?php echo e($cases->hearing_date); ?></span>
                                <?php endif; ?>

                                <?php if(!empty($cases->next_hearing_date)): ?>
                                <span class="form-control" readonly><?php echo e($cases->next_hearing_date); ?></span>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                            <?php if(empty($cases->next_hearing_date)): ?>
                                <input type="hidden" value="<?php echo e($cases->hearing_date); ?>"  id="previous_hearing_date" name="previous_hearing_date">
                                <?php endif; ?>  
                                <?php if(!empty($cases->next_hearing_date)): ?>
                                <input type="hidden" value="<?php echo e($cases->next_hearing_date); ?>"  id="previous_hearing_date" name="previous_hearing_date">
                                <?php endif; ?>
                                <label for="next_hearing_date">Next Hearing Date</label>
                                <input type="date" name="next_hearing_date"
                                    class="form-control   <?php if( $errors->has('next_hearing_date')): ?> is-invalid border-danger  <?php endif; ?>"
                                    value="<?php echo e(old('next_hearing_date')); ?>" id="next_hearing_date" <?php if($cases->case_status == 3): ?> disabled  <?php endif; ?>>
                                <?php if($errors->has('next_hearing_date')): ?>
                                <span id="next_hearing_date-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('next_hearing_date')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="remark">Current Case Remark <small class="text-muted">(Hearing Remark)</small></label>
                                <textarea name="remark" id="" cols="30"
                                    class="form-control <?php if( $errors->has('remark')): ?> is-invalid border-danger  <?php endif; ?>"
                                    rows="4" placeholder="Current Remark" <?php if($cases->case_status == 3): ?> disabled <?php endif; ?>><?php echo e(old('remark')); ?></textarea>
                                <?php if($errors->has('remark')): ?>
                                <span id="remark-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('remark')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="case_status">Current Case Status</label>
                                <select name="case_status" id="case_status"
                                    class="form-control <?php if( $errors->has('case_status')): ?> is-invalid border-danger  <?php endif; ?>" <?php if($cases->case_status == 3): ?> disabled onclick="return false;" <?php endif; ?>>
                                    <option value="">Select Case Status</option>
                                    <option value="1" <?php echo e(($cases->case_status == 1) ? 'selected' : ''); ?>>Pending
                                    </option>
                                    <option value="2" <?php echo e(($cases->case_status == 2) ? 'selected' : ''); ?>>Processing
                                    </option>
                                    <option value="3" <?php echo e(($cases->case_status == 3) ? 'selected' : ''); ?>>Closed</option>
                                </select>
                                <?php if($errors->has('case_status')): ?>
                                <span id="case_status-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('case_status')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="case_document">Current Documents(Optional) </label>
                                <input type="file" name="case_document"
                                    class="form-control  <?php if( $errors->has('case_document')): ?> is-invalid border-danger  <?php endif; ?>"
                                    value="<?php echo e(old('case_document')); ?>" id="case_document" <?php if($cases->case_status == 3): ?> disabled  <?php endif; ?>>
                                <?php if($errors->has('case_document')): ?>
                                <span id="case_document-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('case_document')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <a href="<?php echo e(route('list.all.cases')); ?>" class="btn btn-secondary">Back</a>
                                <?php if($cases->case_status != 3): ?>
                                <input type="submit" name="update" value="Update" class="btn btn-primary">
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </form>
                <?php else: ?>
                    <div class="row">
                        <div class="col-md-12">
                            <h5 class="text-muted">No hearings found.</h5>
                        </div>
                    </div>
                <?php endif; ?>
            </div>
        </div>
        <!-- /.card -->
        <!-- Card for list all the hearings updated till now -->
        <div class="card">
            <div class="card-header">
                <h3 class="card-title">All Hearings</h3>
            </div>
            <div class="card-body">
                <table id="hearingListing" class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>Sr No.</th>
                            <th>Case Number</th>
                            <th>Previous Hearing Date</th>
                            <th>Next Hearing Date</th>
                            <th>Date Status</th>
                            <th>Remarks</th>
                            <th>Files</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php if(!empty($cases->case_hearings)): ?>
                        <?php if($cases->case_hearings->count() > 0): ?>
                        <?php
                        $count = 1;
                        $today = date('Y-m-d');
                        ?>
                        <?php $__currentLoopData = $cases->case_hearings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $data): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($count); ?></td>
                            <td><?php echo e($cases->case_number); ?></td>
                            <td>
                                <?php echo e((!empty($data->previous_hearing_date)) ? formatDate($data->previous_hearing_date) : ''); ?>

                            </td>
                            <td>
                                <?php echo e((!empty($data->next_hearing_date)) ? formatDate($data->next_hearing_date) : ''); ?>

                            </td>
                            <td>
                                <?php echo e(($today > $data->next_hearing_date) ? 'Date Passed' : 'Date Pending'); ?>

                            </td>
                            <td><?php echo e($data->current_remark); ?></td>
                            <td> 
                             <?php if(!empty($data->current_file_copy)): ?>
                            <a href='<?php echo e(url("public/assets/cases/$data->current_file_copy ")); ?>' class="btn btn-xs btn-primary pl-3 pr-3" download>Download</a>
                            <?php else: ?>

                            <?php endif; ?>
                            </td>
                        </tr>
                        <?php
                        $count++;
                        ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php endif; ?>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
        <!-- /.card -->
    </div>
    <!--/. container-fluid -->
</section>
<!-- /.content -->
<?php $__env->stopSection(); ?>
<?php $__env->startPush('js'); ?>
<script>

// for hearing Listing data table
$(function() {
    $('#hearingListing').DataTable({
        "paging": true,
        "lengthChange": true,
        "searching": true,
        "ordering": true,
        "info": true,
        "autoWidth": false,
        "responsive": true,
        // "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
        // "buttons": ["csv", "excel", "pdf"]
    });
    // .buttons().container().appendTo('#hearingListing_wrapper .col-md-6:eq(0)');
});
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/data/public_html/legal/resources/views/pages/cases/updateHearing.blade.php ENDPATH**/ ?>