<?php $__env->startSection('title','Create New Case | '); ?>
<?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">New Case</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">Register New Case</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; ?>
                <form action="<?php echo e(route('store.new.case')); ?>" method="post" autocomplete="off">
                    <?php echo csrf_field(); ?>
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="case_register_for">Case register For</small></label>
                                <select name="case_register_for" id="case_register_for" class="custom-select  <?php if( $errors->has('case_register_for')): ?> is-invalid border-danger  <?php endif; ?>" >
                                    <option value="" <?php echo e(($type == '') ? 'selected' : ''); ?>>-- Select Case For --</option>
                                    <option value="1" <?php echo e(($type == '1') ? 'selected' : ''); ?>>Rejected Claim</option>
                                    <option value="2" <?php echo e(($type == '2') ? 'selected' : ''); ?>>Other</option>
                                </select>
                                <?php if($errors->has('case_register_for')): ?>
                                <span id="case_register_for-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('case_register_for')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div> 
                        <div class="col-md-6 hide_on_others">
                            <div class="form-group">
                                <label for="applied_claim">Claims</small></label>
                                <select name="applied_claim" id="applied_claim" class="custom-select select2 <?php if( $errors->has('applied_claim')): ?> is-invalid border-danger  <?php endif; ?>" >
                                    <option value="" <?php echo e((old('applied_claim') == '') ? 'selected' : ''); ?>>-- Select Claims --</option>
                                    <?php if(!empty($rejected_claims)): ?>
                                    <?php $__currentLoopData = $rejected_claims; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $claims): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($claims->id); ?>" <?php echo e((old('applied_claim') == $claims->id) ? 'selected' : (($claim_id == $claims->id) ? 'selected' : '')); ?>><?php echo e($claims->claim_master_id); ?>  [<?php echo e($claims->claim_category); ?>] <?php echo e($claims->emp_name); ?> (<?php echo e($claims->emp_id); ?>)</option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <?php endif; ?>
                                </select>
                                <small class="text-danger applied_claim_error"></small>
                                <?php if($errors->has('applied_claim')): ?>
                                <span id="applied_claim-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('applied_claim')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div> 
                        <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(old('case_number')); ?>" id="case_number" placeholder="Case Number">
                                <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-6">
                            <div class="form-group">
                                <label for="case_type">Case Type <small class="text-muted">(Death/Accident)</small></label>
                                <select name="case_type" id="case_type" class="custom-select  <?php if( $errors->has('case_type')): ?> is-invalid border-danger  <?php endif; ?>" >
                                    <option value="" <?php echo e((old('case_type') == '') ? 'selected' : ''); ?>>-- Select Case Type --</option>
                                    <option value="1" <?php echo e((old('case_type') == '1') ? 'selected' : ''); ?>>Death</option>
                                    <option value="2" <?php echo e((old('case_type') == '2') ? 'selected' : ''); ?>>Accident</option>
                                </select>

                                <?php if($errors->has('case_type')): ?>
                                <span id="case_type-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('case_type')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div> -->
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="case_reported_date">Case Reported Date</label>
                                <input type="date" name="case_reported_date"
                                    class="form-control   <?php if( $errors->has('case_reported_date')): ?> is-invalid border-danger  <?php endif; ?>"
                                    value="<?php echo e(old('case_reported_date')); ?>" id="case_reported_date">
                                <?php if($errors->has('case_reported_date')): ?>
                                <span id="case_reported_date-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('case_reported_date')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="case_file_date">Case File Date</label>
                                <input type="date" name="case_file_date"
                                    class="form-control  <?php if( $errors->has('case_file_date')): ?> is-invalid border-danger  <?php endif; ?>"
                                    value="<?php echo e(old('case_file_date')); ?>" id="case_file_date">
                                <?php if($errors->has('case_file_date')): ?>
                                <span id="case_file_date-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('case_file_date')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="plaintiff">Plaintiff <small class="text-muted">a person who starts a legal action against somebody in a court of law (case karne waala)</small></label>
                                <input type="text" name="plaintiff"
                                    class="form-control <?php if( $errors->has('plaintiff')): ?> is-invalid border-danger  <?php endif; ?>"
                                    id="plaintiff" value="<?php echo e(old('plaintiff')); ?>" placeholder="Plantiff">
                                <?php if($errors->has('plaintiff')): ?>
                                <span id="plaintiff-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('plaintiff')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="defendant">Defendant <small class="text-muted">The defendant in a trial is the person accused of a crime. (Jiske khilaf case kiya gaya)</small></label>
                                <input type="text" name="defendant"
                                    class="form-control <?php if( $errors->has('defendant')): ?> is-invalid border-danger  <?php endif; ?>"
                                    id="defendant" value="<?php echo e(old('defendant')); ?>" placeholder="Defendant">
                                <?php if($errors->has('defendant')): ?>
                                <span id="defendant-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('defendant')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="lawyer_name">Lawyer Name <small class="text-muted">Name of assigned Lawyer</small></label>
                                <input type="text" name="lawyer_name"
                                    class="form-control <?php if( $errors->has('lawyer_name')): ?> is-invalid border-danger  <?php endif; ?>"
                                    id="lawyer_name" value="<?php echo e(old('lawyer_name')); ?>" placeholder="Lawyer Name">
                                <?php if($errors->has('lawyer_name')): ?>
                                <span id="lawyer_name-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('lawyer_name')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="lawyer_mobile">Lawyer Mobile <small class="text-muted">Mobile Number of assigned Lawyer</small></label>
                                <input type="number" name="lawyer_mobile"
                                    class="form-control <?php if( $errors->has('lawyer_mobile')): ?> is-invalid border-danger  <?php endif; ?>"
                                    id="lawyer_mobile" value="<?php echo e(old('lawyer_mobile')); ?>" placeholder="Lawyer Mobile"  min="6000000001" max="9999999999">
                                <?php if($errors->has('lawyer_mobile')): ?>
                                <span id="lawyer_mobile-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('lawyer_mobile')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="lawyer_email">Lawyer Email(Optional) <small class="text-muted">Email of assigned Lawyer</small></label>
                                <input type="email" name="lawyer_email"
                                    class="form-control <?php if( $errors->has('lawyer_email')): ?> is-invalid border-danger  <?php endif; ?>"
                                    id="lawyer_email" value="<?php echo e(old('lawyer_email')); ?>" placeholder="Lawyer Email">
                                <?php if($errors->has('lawyer_email')): ?>
                                <span id="lawyer_email-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('lawyer_email')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div>
                       
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="hearing_date">Hearing Date</label>
                                <input type="date" name="hearing_date"
                                    class="form-control <?php if( $errors->has('hearing_date')): ?> is-invalid border-danger  <?php endif; ?>"
                                    id="hearing_date" value="<?php echo e(old('hearing_date')); ?>" 
                                    min="<?php echo e(date('Y-m-d')); ?>">
                                <?php if($errors->has('hearing_date')): ?>
                                <span id="hearing_date-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('hearing_date')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div>
                        
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="court_name">Court Name</label>
                                <input type="text" name="court_name"
                                    class="form-control <?php if( $errors->has('court_name')): ?> is-invalid border-danger  <?php endif; ?>"
                                    id="court_name" value="<?php echo e(old('court_name')); ?>" placeholder="Court Name">
                                <small class="text-danger court_name_error"></small>
                                <?php if($errors->has('court_name')): ?>
                                <span id="court_name-error"
                                    class="error text-danger invalid-feedback"><?php echo e($errors->first('court_name')); ?></span>
                                <small></small>
                                <?php endif; ?>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="court_address">Court Address</label>
                                <textarea name="court_address" id="court_address" class="form-control <?php if( $errors->has('court_address')): ?> is-invalid border-danger  <?php endif; ?>" rows="4" placeholder="Court Address"><?php echo e(old('court_address')); ?></textarea>
                                <?php if($errors->has('court_address')): ?>
                                <small class="text-danger court_address_error"><?php echo e($errors->first('court_address')); ?></small>
                                <?php endif; ?>
                            </div>
                        </div>
                        
                         <div class="col-md-6">
                            <div class="form-group">
                                <label for="case_remark">Case Remark</label>
                                <textarea name="case_remark" id="case_remark" class="form-control <?php if( $errors->has('case_remark')): ?> is-invalid border-danger  <?php endif; ?>" rows="4" placeholder="Case Remark"><?php echo e(old('case_remark')); ?></textarea>
                                <?php if($errors->has('case_remark')): ?>
                                <small class="text-danger case_remark_error"><?php echo e($errors->first('case_remark')); ?></small>
                                <?php endif; ?>
                            </div>
                        </div>
                        
                        <?php if(Auth::user()->user_role == 1 || Auth::user()->user_role == 2): ?>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label for="assign_to">Assign To</label>
                                <select name="assign_to" id="assign_to" class="custom-select  <?php if($errors->has('assign_to')): ?> is-invalid border-danger  <?php endif; ?>">
                                    <option value="" >-- Select User --</option>    
                                    <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($user->id); ?>" <?php echo e((old('assign_to') == $user->id) ? 'selected' : ''); ?>><?php echo e($user->full_name); ?> (<?php echo e(getUserType($user->user_role)); ?>)</option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                                <?php if($errors->has('assign_to')): ?>
                                <small class="text-danger "><?php echo e($errors->first('assign_to')); ?></small>
                                <?php endif; ?>
                            </div>
                        </div> 
                        <?php endif; ?>
                        <div class="col-md-12">
                            <div class="form-group">
                                <a href="<?php echo e(route('list.all.cases')); ?>" class="btn btn-secondary">Back</a>
                                <input type="submit" name="save" value="Save Case" class="btn btn-primary">
                            </div>
                            <small class="text-muted"><strong>Note: </strong>Verify the details entered by you before
                                saving and proceeding with the form</small><br>
                            <small class="text-muted"><strong>नोट: </strong>फॉर्म को सेव और आगे बढ़ाने से पहले आपके
                                द्वारा भरी गई डिटेल्स की पुष्टि कर ले</small>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <!-- /.card -->
    </div>
    <!--/. container-fluid -->
</section>
<!-- /.content -->
<?php $__env->stopSection(); ?>
<?php $__env->startPush('js'); ?>
<script>

    // show/hide applied claim column base on selected case register for
    $('#case_register_for').ready(function(){
        showHide();
    });
    $('#case_register_for').change(function(){
        showHide();
    });

    function showHide()
    {
        let case_register_for = $('#case_register_for').find('option:selected').val();
        let hide_on_others = $('.hide_on_others');
    
        if(case_register_for == 1)
        {
            hide_on_others.show();
        } else {
            hide_on_others.hide();
        }
    }

    // check case is registered or not
    $('#applied_claim').ready(function(){
        checkCase();
    });
    $('#applied_claim').change(function(){
        checkCase();
    });

    function checkCase() {
        let applied_claim_id = $('#applied_claim').find('option:selected').val();
        error_tag = $('.applied_claim_error');
        let url = "<?php echo e(route('check.cases')); ?>";
        $.ajax({
            url: url,
            type: "GET",
            data: {
              applied_claim_id: applied_claim_id
            },
            dataType: "json",
            success: function(response) {
                // console.log(response);
                if (response.status == 'success') {
                    error_tag.text(response.message);
                }
            }
        });

    }
</script>

<?php $__env->stopPush(); ?>

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